babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.plane" {
  1937. import { DeepImmutable } from "babylonjs/types";
  1938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1939. /**
  1940. * Represens a plane by the equation ax + by + cz + d = 0
  1941. */
  1942. export class Plane {
  1943. private static _TmpMatrix;
  1944. /**
  1945. * Normal of the plane (a,b,c)
  1946. */
  1947. normal: Vector3;
  1948. /**
  1949. * d component of the plane
  1950. */
  1951. d: number;
  1952. /**
  1953. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1954. * @param a a component of the plane
  1955. * @param b b component of the plane
  1956. * @param c c component of the plane
  1957. * @param d d component of the plane
  1958. */
  1959. constructor(a: number, b: number, c: number, d: number);
  1960. /**
  1961. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1962. */
  1963. asArray(): number[];
  1964. /**
  1965. * @returns a new plane copied from the current Plane.
  1966. */
  1967. clone(): Plane;
  1968. /**
  1969. * @returns the string "Plane".
  1970. */
  1971. getClassName(): string;
  1972. /**
  1973. * @returns the Plane hash code.
  1974. */
  1975. getHashCode(): number;
  1976. /**
  1977. * Normalize the current Plane in place.
  1978. * @returns the updated Plane.
  1979. */
  1980. normalize(): Plane;
  1981. /**
  1982. * Applies a transformation the plane and returns the result
  1983. * @param transformation the transformation matrix to be applied to the plane
  1984. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1985. */
  1986. transform(transformation: DeepImmutable<Matrix>): Plane;
  1987. /**
  1988. * Compute the dot product between the point and the plane normal
  1989. * @param point point to calculate the dot product with
  1990. * @returns the dot product (float) of the point coordinates and the plane normal.
  1991. */
  1992. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1993. /**
  1994. * Updates the current Plane from the plane defined by the three given points.
  1995. * @param point1 one of the points used to contruct the plane
  1996. * @param point2 one of the points used to contruct the plane
  1997. * @param point3 one of the points used to contruct the plane
  1998. * @returns the updated Plane.
  1999. */
  2000. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2001. /**
  2002. * Checks if the plane is facing a given direction
  2003. * @param direction the direction to check if the plane is facing
  2004. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2005. * @returns True is the vector "direction" is the same side than the plane normal.
  2006. */
  2007. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2008. /**
  2009. * Calculates the distance to a point
  2010. * @param point point to calculate distance to
  2011. * @returns the signed distance (float) from the given point to the Plane.
  2012. */
  2013. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2014. /**
  2015. * Creates a plane from an array
  2016. * @param array the array to create a plane from
  2017. * @returns a new Plane from the given array.
  2018. */
  2019. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2020. /**
  2021. * Creates a plane from three points
  2022. * @param point1 point used to create the plane
  2023. * @param point2 point used to create the plane
  2024. * @param point3 point used to create the plane
  2025. * @returns a new Plane defined by the three given points.
  2026. */
  2027. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2028. /**
  2029. * Creates a plane from an origin point and a normal
  2030. * @param origin origin of the plane to be constructed
  2031. * @param normal normal of the plane to be constructed
  2032. * @returns a new Plane the normal vector to this plane at the given origin point.
  2033. * Note : the vector "normal" is updated because normalized.
  2034. */
  2035. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Calculates the distance from a plane and a point
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @param point point to calculate distance to
  2041. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2042. */
  2043. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2044. }
  2045. }
  2046. declare module "babylonjs/Maths/math.vector" {
  2047. import { Viewport } from "babylonjs/Maths/math.viewport";
  2048. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2049. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2050. import { Plane } from "babylonjs/Maths/math.plane";
  2051. /**
  2052. * Class representing a vector containing 2 coordinates
  2053. */
  2054. export class Vector2 {
  2055. /** defines the first coordinate */
  2056. x: number;
  2057. /** defines the second coordinate */
  2058. y: number;
  2059. /**
  2060. * Creates a new Vector2 from the given x and y coordinates
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. */
  2064. constructor(
  2065. /** defines the first coordinate */
  2066. x?: number,
  2067. /** defines the second coordinate */
  2068. y?: number);
  2069. /**
  2070. * Gets a string with the Vector2 coordinates
  2071. * @returns a string with the Vector2 coordinates
  2072. */
  2073. toString(): string;
  2074. /**
  2075. * Gets class name
  2076. * @returns the string "Vector2"
  2077. */
  2078. getClassName(): string;
  2079. /**
  2080. * Gets current vector hash code
  2081. * @returns the Vector2 hash code as a number
  2082. */
  2083. getHashCode(): number;
  2084. /**
  2085. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2086. * @param array defines the source array
  2087. * @param index defines the offset in source array
  2088. * @returns the current Vector2
  2089. */
  2090. toArray(array: FloatArray, index?: number): Vector2;
  2091. /**
  2092. * Copy the current vector to an array
  2093. * @returns a new array with 2 elements: the Vector2 coordinates.
  2094. */
  2095. asArray(): number[];
  2096. /**
  2097. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2098. * @param source defines the source Vector2
  2099. * @returns the current updated Vector2
  2100. */
  2101. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2102. /**
  2103. * Sets the Vector2 coordinates with the given floats
  2104. * @param x defines the first coordinate
  2105. * @param y defines the second coordinate
  2106. * @returns the current updated Vector2
  2107. */
  2108. copyFromFloats(x: number, y: number): Vector2;
  2109. /**
  2110. * Sets the Vector2 coordinates with the given floats
  2111. * @param x defines the first coordinate
  2112. * @param y defines the second coordinate
  2113. * @returns the current updated Vector2
  2114. */
  2115. set(x: number, y: number): Vector2;
  2116. /**
  2117. * Add another vector with the current one
  2118. * @param otherVector defines the other vector
  2119. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2120. */
  2121. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2122. /**
  2123. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2124. * @param otherVector defines the other vector
  2125. * @param result defines the target vector
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2129. /**
  2130. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2131. * @param otherVector defines the other vector
  2132. * @returns the current updated Vector2
  2133. */
  2134. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2135. /**
  2136. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2137. * @param otherVector defines the other vector
  2138. * @returns a new Vector2
  2139. */
  2140. addVector3(otherVector: Vector3): Vector2;
  2141. /**
  2142. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2
  2145. */
  2146. subtract(otherVector: Vector2): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Multiplies in place the current Vector2 coordinates by the given ones
  2162. * @param otherVector defines the other vector
  2163. * @returns the current updated Vector2
  2164. */
  2165. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2166. /**
  2167. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns a new Vector2
  2184. */
  2185. multiplyByFloats(x: number, y: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2
  2190. */
  2191. divide(otherVector: Vector2): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Divides the current Vector2 coordinates by the given ones
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 with current Vector2 negated coordinates
  2207. * @returns a new Vector2
  2208. */
  2209. negate(): Vector2;
  2210. /**
  2211. * Negate this vector in place
  2212. * @returns this
  2213. */
  2214. negateInPlace(): Vector2;
  2215. /**
  2216. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2217. * @param result defines the Vector3 object where to store the result
  2218. * @returns the current Vector2
  2219. */
  2220. negateToRef(result: Vector2): Vector2;
  2221. /**
  2222. * Multiply the Vector2 coordinates by scale
  2223. * @param scale defines the scaling factor
  2224. * @returns the current updated Vector2
  2225. */
  2226. scaleInPlace(scale: number): Vector2;
  2227. /**
  2228. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2229. * @param scale defines the scaling factor
  2230. * @returns a new Vector2
  2231. */
  2232. scale(scale: number): Vector2;
  2233. /**
  2234. * Scale the current Vector2 values by a factor to a given Vector2
  2235. * @param scale defines the scale factor
  2236. * @param result defines the Vector2 object where to store the result
  2237. * @returns the unmodified current Vector2
  2238. */
  2239. scaleToRef(scale: number, result: Vector2): Vector2;
  2240. /**
  2241. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2242. * @param scale defines the scale factor
  2243. * @param result defines the Vector2 object where to store the result
  2244. * @returns the unmodified current Vector2
  2245. */
  2246. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2247. /**
  2248. * Gets a boolean if two vectors are equals
  2249. * @param otherVector defines the other vector
  2250. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2251. */
  2252. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets a boolean if two vectors are equals (using an epsilon value)
  2255. * @param otherVector defines the other vector
  2256. * @param epsilon defines the minimal distance to consider equality
  2257. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2258. */
  2259. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2260. /**
  2261. * Gets a new Vector2 from current Vector2 floored values
  2262. * @returns a new Vector2
  2263. */
  2264. floor(): Vector2;
  2265. /**
  2266. * Gets a new Vector2 from current Vector2 floored values
  2267. * @returns a new Vector2
  2268. */
  2269. fract(): Vector2;
  2270. /**
  2271. * Gets the length of the vector
  2272. * @returns the vector length (float)
  2273. */
  2274. length(): number;
  2275. /**
  2276. * Gets the vector squared length
  2277. * @returns the vector squared length (float)
  2278. */
  2279. lengthSquared(): number;
  2280. /**
  2281. * Normalize the vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. normalize(): Vector2;
  2285. /**
  2286. * Gets a new Vector2 copied from the Vector2
  2287. * @returns a new Vector2
  2288. */
  2289. clone(): Vector2;
  2290. /**
  2291. * Gets a new Vector2(0, 0)
  2292. * @returns a new Vector2
  2293. */
  2294. static Zero(): Vector2;
  2295. /**
  2296. * Gets a new Vector2(1, 1)
  2297. * @returns a new Vector2
  2298. */
  2299. static One(): Vector2;
  2300. /**
  2301. * Gets a new Vector2 set from the given index element of the given array
  2302. * @param array defines the data source
  2303. * @param offset defines the offset in the data source
  2304. * @returns a new Vector2
  2305. */
  2306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2307. /**
  2308. * Sets "result" from the given index element of the given array
  2309. * @param array defines the data source
  2310. * @param offset defines the offset in the data source
  2311. * @param result defines the target vector
  2312. */
  2313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2314. /**
  2315. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2316. * @param value1 defines 1st point of control
  2317. * @param value2 defines 2nd point of control
  2318. * @param value3 defines 3rd point of control
  2319. * @param value4 defines 4th point of control
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * 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".
  2326. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2327. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2328. * @param value defines the value to clamp
  2329. * @param min defines the lower limit
  2330. * @param max defines the upper limit
  2331. * @returns a new Vector2
  2332. */
  2333. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2334. /**
  2335. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2336. * @param value1 defines the 1st control point
  2337. * @param tangent1 defines the outgoing tangent
  2338. * @param value2 defines the 2nd control point
  2339. * @param tangent2 defines the incoming tangent
  2340. * @param amount defines the interpolation factor
  2341. * @returns a new Vector2
  2342. */
  2343. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2344. /**
  2345. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2346. * @param start defines the start vector
  2347. * @param end defines the end vector
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Gets the dot product of the vector "left" and the vector "right"
  2354. * @param left defines first vector
  2355. * @param right defines second vector
  2356. * @returns the dot product (float)
  2357. */
  2358. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2359. /**
  2360. * Returns a new Vector2 equal to the normalized given vector
  2361. * @param vector defines the vector to normalize
  2362. * @returns a new Vector2
  2363. */
  2364. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2365. /**
  2366. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2367. * @param left defines 1st vector
  2368. * @param right defines 2nd vector
  2369. * @returns a new Vector2
  2370. */
  2371. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2372. /**
  2373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2374. * @param left defines 1st vector
  2375. * @param right defines 2nd vector
  2376. * @returns a new Vector2
  2377. */
  2378. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2379. /**
  2380. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2381. * @param vector defines the vector to transform
  2382. * @param transformation defines the matrix to apply
  2383. * @returns a new Vector2
  2384. */
  2385. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2386. /**
  2387. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2388. * @param vector defines the vector to transform
  2389. * @param transformation defines the matrix to apply
  2390. * @param result defines the target vector
  2391. */
  2392. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2393. /**
  2394. * Determines if a given vector is included in a triangle
  2395. * @param p defines the vector to test
  2396. * @param p0 defines 1st triangle point
  2397. * @param p1 defines 2nd triangle point
  2398. * @param p2 defines 3rd triangle point
  2399. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2400. */
  2401. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2402. /**
  2403. * Gets the distance between the vectors "value1" and "value2"
  2404. * @param value1 defines first vector
  2405. * @param value2 defines second vector
  2406. * @returns the distance between vectors
  2407. */
  2408. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2409. /**
  2410. * Returns the squared distance between the vectors "value1" and "value2"
  2411. * @param value1 defines first vector
  2412. * @param value2 defines second vector
  2413. * @returns the squared distance between vectors
  2414. */
  2415. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2416. /**
  2417. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2418. * @param value1 defines first vector
  2419. * @param value2 defines second vector
  2420. * @returns a new Vector2
  2421. */
  2422. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2423. /**
  2424. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2425. * @param p defines the middle point
  2426. * @param segA defines one point of the segment
  2427. * @param segB defines the other point of the segment
  2428. * @returns the shortest distance
  2429. */
  2430. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2431. }
  2432. /**
  2433. * Class used to store (x,y,z) vector representation
  2434. * A Vector3 is the main object used in 3D geometry
  2435. * It can represent etiher the coordinates of a point the space, either a direction
  2436. * Reminder: js uses a left handed forward facing system
  2437. */
  2438. export class Vector3 {
  2439. /**
  2440. * Defines the first coordinates (on X axis)
  2441. */
  2442. x: number;
  2443. /**
  2444. * Defines the second coordinates (on Y axis)
  2445. */
  2446. y: number;
  2447. /**
  2448. * Defines the third coordinates (on Z axis)
  2449. */
  2450. z: number;
  2451. private static _UpReadOnly;
  2452. private static _ZeroReadOnly;
  2453. /**
  2454. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2455. * @param x defines the first coordinates (on X axis)
  2456. * @param y defines the second coordinates (on Y axis)
  2457. * @param z defines the third coordinates (on Z axis)
  2458. */
  2459. constructor(
  2460. /**
  2461. * Defines the first coordinates (on X axis)
  2462. */
  2463. x?: number,
  2464. /**
  2465. * Defines the second coordinates (on Y axis)
  2466. */
  2467. y?: number,
  2468. /**
  2469. * Defines the third coordinates (on Z axis)
  2470. */
  2471. z?: number);
  2472. /**
  2473. * Creates a string representation of the Vector3
  2474. * @returns a string with the Vector3 coordinates.
  2475. */
  2476. toString(): string;
  2477. /**
  2478. * Gets the class name
  2479. * @returns the string "Vector3"
  2480. */
  2481. getClassName(): string;
  2482. /**
  2483. * Creates the Vector3 hash code
  2484. * @returns a number which tends to be unique between Vector3 instances
  2485. */
  2486. getHashCode(): number;
  2487. /**
  2488. * Creates an array containing three elements : the coordinates of the Vector3
  2489. * @returns a new array of numbers
  2490. */
  2491. asArray(): number[];
  2492. /**
  2493. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2494. * @param array defines the destination array
  2495. * @param index defines the offset in the destination array
  2496. * @returns the current Vector3
  2497. */
  2498. toArray(array: FloatArray, index?: number): Vector3;
  2499. /**
  2500. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2501. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2502. */
  2503. toQuaternion(): Quaternion;
  2504. /**
  2505. * Adds the given vector to the current Vector3
  2506. * @param otherVector defines the second operand
  2507. * @returns the current updated Vector3
  2508. */
  2509. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Adds the given coordinates to the current Vector3
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Subtract the given vector from the current Vector3
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the resulting Vector3
  2541. */
  2542. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2567. /**
  2568. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2569. * @returns a new Vector3
  2570. */
  2571. negate(): Vector3;
  2572. /**
  2573. * Negate this vector in place
  2574. * @returns this
  2575. */
  2576. negateInPlace(): Vector3;
  2577. /**
  2578. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. negateToRef(result: Vector3): Vector3;
  2583. /**
  2584. * Multiplies the Vector3 coordinates by the float "scale"
  2585. * @param scale defines the multiplier factor
  2586. * @returns the current updated Vector3
  2587. */
  2588. scaleInPlace(scale: number): Vector3;
  2589. /**
  2590. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2591. * @param scale defines the multiplier factor
  2592. * @returns a new Vector3
  2593. */
  2594. scale(scale: number): Vector3;
  2595. /**
  2596. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2597. * @param scale defines the multiplier factor
  2598. * @param result defines the Vector3 object where to store the result
  2599. * @returns the current Vector3
  2600. */
  2601. scaleToRef(scale: number, result: Vector3): Vector3;
  2602. /**
  2603. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2604. * @param scale defines the scale factor
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the unmodified current Vector3
  2607. */
  2608. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2609. /**
  2610. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2611. * @param origin defines the origin of the projection ray
  2612. * @param plane defines the plane to project to
  2613. * @returns the projected vector3
  2614. */
  2615. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2616. /**
  2617. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2618. * @param origin defines the origin of the projection ray
  2619. * @param plane defines the plane to project to
  2620. * @param result defines the Vector3 where to store the result
  2621. */
  2622. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2623. /**
  2624. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2625. * @param otherVector defines the second operand
  2626. * @returns true if both vectors are equals
  2627. */
  2628. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2629. /**
  2630. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2631. * @param otherVector defines the second operand
  2632. * @param epsilon defines the minimal distance to define values as equals
  2633. * @returns true if both vectors are distant less than epsilon
  2634. */
  2635. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2636. /**
  2637. * Returns true if the current Vector3 coordinates equals the given floats
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @returns true if both vectors are equals
  2642. */
  2643. equalsToFloats(x: number, y: number, z: number): boolean;
  2644. /**
  2645. * Multiplies the current Vector3 coordinates by the given ones
  2646. * @param otherVector defines the second operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2650. /**
  2651. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2652. * @param otherVector defines the second operand
  2653. * @returns the new Vector3
  2654. */
  2655. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2658. * @param otherVector defines the second operand
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the new Vector3
  2669. */
  2670. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2673. * @param otherVector defines the second operand
  2674. * @returns the new Vector3
  2675. */
  2676. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2677. /**
  2678. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2679. * @param otherVector defines the second operand
  2680. * @param result defines the Vector3 object where to store the result
  2681. * @returns the current Vector3
  2682. */
  2683. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2684. /**
  2685. * Divides the current Vector3 coordinates by the given ones.
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. divideInPlace(otherVector: Vector3): Vector3;
  2690. /**
  2691. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2692. * @param other defines the second operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2698. * @param other defines the second operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2702. /**
  2703. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2720. * Check if is non uniform within a certain amount of decimal places to account for this
  2721. * @param epsilon the amount the values can differ
  2722. * @returns if the the vector is non uniform to a certain number of decimal places
  2723. */
  2724. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2725. /**
  2726. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2727. */
  2728. get isNonUniform(): boolean;
  2729. /**
  2730. * Gets a new Vector3 from current Vector3 floored values
  2731. * @returns a new Vector3
  2732. */
  2733. floor(): Vector3;
  2734. /**
  2735. * Gets a new Vector3 from current Vector3 floored values
  2736. * @returns a new Vector3
  2737. */
  2738. fract(): Vector3;
  2739. /**
  2740. * Gets the length of the Vector3
  2741. * @returns the length of the Vector3
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Gets the squared length of the Vector3
  2746. * @returns squared length of the Vector3
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalize the current Vector3.
  2751. * Please note that this is an in place operation.
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalize(): Vector3;
  2755. /**
  2756. * Reorders the x y z properties of the vector in place
  2757. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2758. * @returns the current updated vector
  2759. */
  2760. reorderInPlace(order: string): this;
  2761. /**
  2762. * Rotates the vector around 0,0,0 by a quaternion
  2763. * @param quaternion the rotation quaternion
  2764. * @param result vector to store the result
  2765. * @returns the resulting vector
  2766. */
  2767. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2768. /**
  2769. * Rotates a vector around a given point
  2770. * @param quaternion the rotation quaternion
  2771. * @param point the point to rotate around
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2776. /**
  2777. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2778. * The cross product is then orthogonal to both current and "other"
  2779. * @param other defines the right operand
  2780. * @returns the cross product
  2781. */
  2782. cross(other: Vector3): Vector3;
  2783. /**
  2784. * Normalize the current Vector3 with the given input length.
  2785. * Please note that this is an in place operation.
  2786. * @param len the length of the vector
  2787. * @returns the current updated Vector3
  2788. */
  2789. normalizeFromLength(len: number): Vector3;
  2790. /**
  2791. * Normalize the current Vector3 to a new vector
  2792. * @returns the new Vector3
  2793. */
  2794. normalizeToNew(): Vector3;
  2795. /**
  2796. * Normalize the current Vector3 to the reference
  2797. * @param reference define the Vector3 to update
  2798. * @returns the updated Vector3
  2799. */
  2800. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2801. /**
  2802. * Creates a new Vector3 copied from the current Vector3
  2803. * @returns the new Vector3
  2804. */
  2805. clone(): Vector3;
  2806. /**
  2807. * Copies the given vector coordinates to the current Vector3 ones
  2808. * @param source defines the source Vector3
  2809. * @returns the current updated Vector3
  2810. */
  2811. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2812. /**
  2813. * Copies the given floats to the current Vector3 coordinates
  2814. * @param x defines the x coordinate of the operand
  2815. * @param y defines the y coordinate of the operand
  2816. * @param z defines the z coordinate of the operand
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFromFloats(x: number, y: number, z: number): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. set(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given float to the current Vector3 coordinates
  2830. * @param v defines the x, y and z coordinates of the operand
  2831. * @returns the current updated Vector3
  2832. */
  2833. setAll(v: number): Vector3;
  2834. /**
  2835. * Get the clip factor between two vectors
  2836. * @param vector0 defines the first operand
  2837. * @param vector1 defines the second operand
  2838. * @param axis defines the axis to use
  2839. * @param size defines the size along the axis
  2840. * @returns the clip factor
  2841. */
  2842. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2843. /**
  2844. * Get angle between two vectors
  2845. * @param vector0 angle between vector0 and vector1
  2846. * @param vector1 angle between vector0 and vector1
  2847. * @param normal direction of the normal
  2848. * @return the angle between vector0 and vector1
  2849. */
  2850. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2851. /**
  2852. * Returns a new Vector3 set from the index "offset" of the given array
  2853. * @param array defines the source array
  2854. * @param offset defines the offset in the source array
  2855. * @returns the new Vector3
  2856. */
  2857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2860. * @param array defines the source array
  2861. * @param offset defines the offset in the source array
  2862. * @returns the new Vector3
  2863. * @deprecated Please use FromArray instead.
  2864. */
  2865. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2873. /**
  2874. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2875. * @param array defines the source array
  2876. * @param offset defines the offset in the source array
  2877. * @param result defines the Vector3 where to store the result
  2878. * @deprecated Please use FromArrayToRef instead.
  2879. */
  2880. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the given floats.
  2883. * @param x defines the x coordinate of the source
  2884. * @param y defines the y coordinate of the source
  2885. * @param z defines the z coordinate of the source
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2891. * @returns a new empty Vector3
  2892. */
  2893. static Zero(): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2896. * @returns a new unit Vector3
  2897. */
  2898. static One(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2901. * @returns a new up Vector3
  2902. */
  2903. static Up(): Vector3;
  2904. /**
  2905. * Gets a up Vector3 that must not be updated
  2906. */
  2907. static get UpReadOnly(): DeepImmutable<Vector3>;
  2908. /**
  2909. * Gets a zero Vector3 that must not be updated
  2910. */
  2911. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2912. /**
  2913. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2914. * @returns a new down Vector3
  2915. */
  2916. static Down(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2919. * @param rightHandedSystem is the scene right-handed (negative z)
  2920. * @returns a new forward Vector3
  2921. */
  2922. static Forward(rightHandedSystem?: boolean): Vector3;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2925. * @param rightHandedSystem is the scene right-handed (negative-z)
  2926. * @returns a new forward Vector3
  2927. */
  2928. static Backward(rightHandedSystem?: boolean): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2931. * @returns a new right Vector3
  2932. */
  2933. static Right(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2936. * @returns a new left Vector3
  2937. */
  2938. static Left(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2941. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @returns the transformed Vector3
  2945. */
  2946. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2957. * This method computes tranformed coordinates only, not transformed direction vectors
  2958. * @param x define the x coordinate of the source vector
  2959. * @param y define the y coordinate of the source vector
  2960. * @param z define the z coordinate of the source vector
  2961. * @param transformation defines the transformation matrix
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2967. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @returns the new Vector3
  2971. */
  2972. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2973. /**
  2974. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param x define the x coordinate of the source vector
  2985. * @param y define the y coordinate of the source vector
  2986. * @param z define the z coordinate of the source vector
  2987. * @param transformation defines the transformation matrix
  2988. * @param result defines the Vector3 where to store the result
  2989. */
  2990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2991. /**
  2992. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2993. * @param value1 defines the first control point
  2994. * @param value2 defines the second control point
  2995. * @param value3 defines the third control point
  2996. * @param value4 defines the fourth control point
  2997. * @param amount defines the amount on the spline to use
  2998. * @returns the new Vector3
  2999. */
  3000. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3001. /**
  3002. * 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"
  3003. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3004. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3005. * @param value defines the current value
  3006. * @param min defines the lower range value
  3007. * @param max defines the upper range value
  3008. * @returns the new Vector3
  3009. */
  3010. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * 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"
  3013. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3014. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3015. * @param value defines the current value
  3016. * @param min defines the lower range value
  3017. * @param max defines the upper range value
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3021. /**
  3022. * Checks if a given vector is inside a specific range
  3023. * @param v defines the vector to test
  3024. * @param min defines the minimum range
  3025. * @param max defines the maximum range
  3026. */
  3027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3028. /**
  3029. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3030. * @param value1 defines the first control point
  3031. * @param tangent1 defines the first tangent vector
  3032. * @param value2 defines the second control point
  3033. * @param tangent2 defines the second tangent vector
  3034. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3035. * @returns the new Vector3
  3036. */
  3037. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3040. * @param start defines the start value
  3041. * @param end defines the end value
  3042. * @param amount max defines amount between both (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3054. /**
  3055. * Returns the dot product (float) between the vectors "left" and "right"
  3056. * @param left defines the left operand
  3057. * @param right defines the right operand
  3058. * @returns the dot product
  3059. */
  3060. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3061. /**
  3062. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3063. * The cross product is then orthogonal to both "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the cross product
  3067. */
  3068. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3069. /**
  3070. * Sets the given vector "result" with the cross product of "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @param result defines the Vector3 where to store the result
  3075. */
  3076. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3077. /**
  3078. * Returns a new Vector3 as the normalization of the given vector
  3079. * @param vector defines the Vector3 to normalize
  3080. * @returns the new Vector3
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3083. /**
  3084. * Sets the given vector "result" with the normalization of the given first vector
  3085. * @param vector defines the Vector3 to normalize
  3086. * @param result defines the Vector3 where to store the result
  3087. */
  3088. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3089. /**
  3090. * Project a Vector3 onto screen space
  3091. * @param vector defines the Vector3 to project
  3092. * @param world defines the world matrix to use
  3093. * @param transform defines the transform (view x projection) matrix to use
  3094. * @param viewport defines the screen viewport to use
  3095. * @returns the new Vector3
  3096. */
  3097. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3098. /** @hidden */
  3099. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3100. /**
  3101. * Unproject from screen space to object space
  3102. * @param source defines the screen space Vector3 to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param transform defines the transform (view x projection) matrix to use
  3107. * @returns the new Vector3
  3108. */
  3109. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3110. /**
  3111. * Unproject from screen space to object space
  3112. * @param source defines the screen space Vector3 to use
  3113. * @param viewportWidth defines the current width of the viewport
  3114. * @param viewportHeight defines the current height of the viewport
  3115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3116. * @param view defines the view matrix to use
  3117. * @param projection defines the projection matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param sourceX defines the screen space x coordinate to use
  3135. * @param sourceY defines the screen space y coordinate to use
  3136. * @param sourceZ defines the screen space z coordinate to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param view defines the view matrix to use
  3141. * @param projection defines the projection matrix to use
  3142. * @param result defines the Vector3 where to store the result
  3143. */
  3144. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3145. /**
  3146. * Gets the minimal coordinate values between two Vector3
  3147. * @param left defines the first operand
  3148. * @param right defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Gets the maximal coordinate values between two Vector3
  3154. * @param left defines the first operand
  3155. * @param right defines the second operand
  3156. * @returns the new Vector3
  3157. */
  3158. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Returns the distance between the vectors "value1" and "value2"
  3161. * @param value1 defines the first operand
  3162. * @param value2 defines the second operand
  3163. * @returns the distance
  3164. */
  3165. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3166. /**
  3167. * Returns the squared distance between the vectors "value1" and "value2"
  3168. * @param value1 defines the first operand
  3169. * @param value2 defines the second operand
  3170. * @returns the squared distance
  3171. */
  3172. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3173. /**
  3174. * Returns a new Vector3 located at the center between "value1" and "value2"
  3175. * @param value1 defines the first operand
  3176. * @param value2 defines the second operand
  3177. * @returns the new Vector3
  3178. */
  3179. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3180. /**
  3181. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3182. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3183. * to something in order to rotate it from its local system to the given target system
  3184. * Note: axis1, axis2 and axis3 are normalized during this operation
  3185. * @param axis1 defines the first axis
  3186. * @param axis2 defines the second axis
  3187. * @param axis3 defines the third axis
  3188. * @returns a new Vector3
  3189. */
  3190. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @param ref defines the Vector3 where to store the result
  3197. */
  3198. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3199. }
  3200. /**
  3201. * Vector4 class created for EulerAngle class conversion to Quaternion
  3202. */
  3203. export class Vector4 {
  3204. /** x value of the vector */
  3205. x: number;
  3206. /** y value of the vector */
  3207. y: number;
  3208. /** z value of the vector */
  3209. z: number;
  3210. /** w value of the vector */
  3211. w: number;
  3212. /**
  3213. * Creates a Vector4 object from the given floats.
  3214. * @param x x value of the vector
  3215. * @param y y value of the vector
  3216. * @param z z value of the vector
  3217. * @param w w value of the vector
  3218. */
  3219. constructor(
  3220. /** x value of the vector */
  3221. x: number,
  3222. /** y value of the vector */
  3223. y: number,
  3224. /** z value of the vector */
  3225. z: number,
  3226. /** w value of the vector */
  3227. w: number);
  3228. /**
  3229. * Returns the string with the Vector4 coordinates.
  3230. * @returns a string containing all the vector values
  3231. */
  3232. toString(): string;
  3233. /**
  3234. * Returns the string "Vector4".
  3235. * @returns "Vector4"
  3236. */
  3237. getClassName(): string;
  3238. /**
  3239. * Returns the Vector4 hash code.
  3240. * @returns a unique hash code
  3241. */
  3242. getHashCode(): number;
  3243. /**
  3244. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3245. * @returns the resulting array
  3246. */
  3247. asArray(): number[];
  3248. /**
  3249. * Populates the given array from the given index with the Vector4 coordinates.
  3250. * @param array array to populate
  3251. * @param index index of the array to start at (default: 0)
  3252. * @returns the Vector4.
  3253. */
  3254. toArray(array: FloatArray, index?: number): Vector4;
  3255. /**
  3256. * Adds the given vector to the current Vector4.
  3257. * @param otherVector the vector to add
  3258. * @returns the updated Vector4.
  3259. */
  3260. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3263. * @param otherVector the vector to add
  3264. * @returns the resulting vector
  3265. */
  3266. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3269. * @param otherVector the vector to add
  3270. * @param result the vector to store the result
  3271. * @returns the current Vector4.
  3272. */
  3273. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3274. /**
  3275. * Subtract in place the given vector from the current Vector4.
  3276. * @param otherVector the vector to subtract
  3277. * @returns the updated Vector4.
  3278. */
  3279. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3282. * @param otherVector the vector to add
  3283. * @returns the new vector with the result
  3284. */
  3285. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3288. * @param otherVector the vector to subtract
  3289. * @param result the vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. */
  3296. /**
  3297. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3298. * @param x value to subtract
  3299. * @param y value to subtract
  3300. * @param z value to subtract
  3301. * @param w value to subtract
  3302. * @returns new vector containing the result
  3303. */
  3304. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3305. /**
  3306. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3307. * @param x value to subtract
  3308. * @param y value to subtract
  3309. * @param z value to subtract
  3310. * @param w value to subtract
  3311. * @param result the vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3315. /**
  3316. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3317. * @returns a new vector with the negated values
  3318. */
  3319. negate(): Vector4;
  3320. /**
  3321. * Negate this vector in place
  3322. * @returns this
  3323. */
  3324. negateInPlace(): Vector4;
  3325. /**
  3326. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3327. * @param result defines the Vector3 object where to store the result
  3328. * @returns the current Vector4
  3329. */
  3330. negateToRef(result: Vector4): Vector4;
  3331. /**
  3332. * Multiplies the current Vector4 coordinates by scale (float).
  3333. * @param scale the number to scale with
  3334. * @returns the updated Vector4.
  3335. */
  3336. scaleInPlace(scale: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3339. * @param scale the number to scale with
  3340. * @returns a new vector with the result
  3341. */
  3342. scale(scale: number): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3345. * @param scale the number to scale with
  3346. * @param result a vector to store the result in
  3347. * @returns the current Vector4.
  3348. */
  3349. scaleToRef(scale: number, result: Vector4): Vector4;
  3350. /**
  3351. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3352. * @param scale defines the scale factor
  3353. * @param result defines the Vector4 object where to store the result
  3354. * @returns the unmodified current Vector4
  3355. */
  3356. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3357. /**
  3358. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3359. * @param otherVector the vector to compare against
  3360. * @returns true if they are equal
  3361. */
  3362. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3363. /**
  3364. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3365. * @param otherVector vector to compare against
  3366. * @param epsilon (Default: very small number)
  3367. * @returns true if they are equal
  3368. */
  3369. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3370. /**
  3371. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3372. * @param x x value to compare against
  3373. * @param y y value to compare against
  3374. * @param z z value to compare against
  3375. * @param w w value to compare against
  3376. * @returns true if equal
  3377. */
  3378. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3379. /**
  3380. * Multiplies in place the current Vector4 by the given one.
  3381. * @param otherVector vector to multiple with
  3382. * @returns the updated Vector4.
  3383. */
  3384. multiplyInPlace(otherVector: Vector4): Vector4;
  3385. /**
  3386. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3387. * @param otherVector vector to multiple with
  3388. * @returns resulting new vector
  3389. */
  3390. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3393. * @param otherVector vector to multiple with
  3394. * @param result vector to store the result
  3395. * @returns the current Vector4.
  3396. */
  3397. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3400. * @param x x value multiply with
  3401. * @param y y value multiply with
  3402. * @param z z value multiply with
  3403. * @param w w value multiply with
  3404. * @returns resulting new vector
  3405. */
  3406. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3407. /**
  3408. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3409. * @param otherVector vector to devide with
  3410. * @returns resulting new vector
  3411. */
  3412. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3415. * @param otherVector vector to devide with
  3416. * @param result vector to store the result
  3417. * @returns the current Vector4.
  3418. */
  3419. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3420. /**
  3421. * Divides the current Vector3 coordinates by the given ones.
  3422. * @param otherVector vector to devide with
  3423. * @returns the updated Vector3.
  3424. */
  3425. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3428. * @param other defines the second operand
  3429. * @returns the current updated Vector4
  3430. */
  3431. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3434. * @param other defines the second operand
  3435. * @returns the current updated Vector4
  3436. */
  3437. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Gets a new Vector4 from current Vector4 floored values
  3440. * @returns a new Vector4
  3441. */
  3442. floor(): Vector4;
  3443. /**
  3444. * Gets a new Vector4 from current Vector3 floored values
  3445. * @returns a new Vector4
  3446. */
  3447. fract(): Vector4;
  3448. /**
  3449. * Returns the Vector4 length (float).
  3450. * @returns the length
  3451. */
  3452. length(): number;
  3453. /**
  3454. * Returns the Vector4 squared length (float).
  3455. * @returns the length squared
  3456. */
  3457. lengthSquared(): number;
  3458. /**
  3459. * Normalizes in place the Vector4.
  3460. * @returns the updated Vector4.
  3461. */
  3462. normalize(): Vector4;
  3463. /**
  3464. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3465. * @returns this converted to a new vector3
  3466. */
  3467. toVector3(): Vector3;
  3468. /**
  3469. * Returns a new Vector4 copied from the current one.
  3470. * @returns the new cloned vector
  3471. */
  3472. clone(): Vector4;
  3473. /**
  3474. * Updates the current Vector4 with the given one coordinates.
  3475. * @param source the source vector to copy from
  3476. * @returns the updated Vector4.
  3477. */
  3478. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the current Vector4 coordinates with the given floats.
  3481. * @param x float to copy from
  3482. * @param y float to copy from
  3483. * @param z float to copy from
  3484. * @param w float to copy from
  3485. * @returns the updated Vector4.
  3486. */
  3487. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3488. /**
  3489. * Updates the current Vector4 coordinates with the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @returns the updated Vector4.
  3495. */
  3496. set(x: number, y: number, z: number, w: number): Vector4;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y, z and w coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set from the starting index of the given array.
  3505. * @param array the array to pull values from
  3506. * @param offset the offset into the array to start at
  3507. * @returns the new vector
  3508. */
  3509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3510. /**
  3511. * Updates the given vector "result" from the starting index of the given array.
  3512. * @param array the array to pull values from
  3513. * @param offset the offset into the array to start at
  3514. * @param result the vector to store the result in
  3515. */
  3516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3517. /**
  3518. * Updates the given vector "result" from the starting index of the given Float32Array.
  3519. * @param array the array to pull values from
  3520. * @param offset the offset into the array to start at
  3521. * @param result the vector to store the result in
  3522. */
  3523. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3524. /**
  3525. * Updates the given vector "result" coordinates from the given floats.
  3526. * @param x float to set from
  3527. * @param y float to set from
  3528. * @param z float to set from
  3529. * @param w float to set from
  3530. * @param result the vector to the floats in
  3531. */
  3532. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3533. /**
  3534. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3535. * @returns the new vector
  3536. */
  3537. static Zero(): Vector4;
  3538. /**
  3539. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3540. * @returns the new vector
  3541. */
  3542. static One(): Vector4;
  3543. /**
  3544. * Returns a new normalized Vector4 from the given one.
  3545. * @param vector the vector to normalize
  3546. * @returns the vector
  3547. */
  3548. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3549. /**
  3550. * Updates the given vector "result" from the normalization of the given one.
  3551. * @param vector the vector to normalize
  3552. * @param result the vector to store the result in
  3553. */
  3554. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3555. /**
  3556. * Returns a vector with the minimum values from the left and right vectors
  3557. * @param left left vector to minimize
  3558. * @param right right vector to minimize
  3559. * @returns a new vector with the minimum of the left and right vector values
  3560. */
  3561. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a vector with the maximum values from the left and right vectors
  3564. * @param left left vector to maximize
  3565. * @param right right vector to maximize
  3566. * @returns a new vector with the maximum of the left and right vector values
  3567. */
  3568. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3569. /**
  3570. * Returns the distance (float) between the vectors "value1" and "value2".
  3571. * @param value1 value to calulate the distance between
  3572. * @param value2 value to calulate the distance between
  3573. * @return the distance between the two vectors
  3574. */
  3575. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3576. /**
  3577. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3578. * @param value1 value to calulate the distance between
  3579. * @param value2 value to calulate the distance between
  3580. * @return the distance between the two vectors squared
  3581. */
  3582. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3583. /**
  3584. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3585. * @param value1 value to calulate the center between
  3586. * @param value2 value to calulate the center between
  3587. * @return the center between the two vectors
  3588. */
  3589. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3592. * This methods computes transformed normalized direction vectors only.
  3593. * @param vector the vector to transform
  3594. * @param transformation the transformation matrix to apply
  3595. * @returns the new vector
  3596. */
  3597. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3598. /**
  3599. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @param result the vector to store the result in
  3604. */
  3605. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param x value to transform
  3610. * @param y value to transform
  3611. * @param z value to transform
  3612. * @param w value to transform
  3613. * @param transformation the transformation matrix to apply
  3614. * @param result the vector to store the results in
  3615. */
  3616. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3617. /**
  3618. * Creates a new Vector4 from a Vector3
  3619. * @param source defines the source data
  3620. * @param w defines the 4th component (default is 0)
  3621. * @returns a new Vector4
  3622. */
  3623. static FromVector3(source: Vector3, w?: number): Vector4;
  3624. }
  3625. /**
  3626. * Class used to store quaternion data
  3627. * @see https://en.wikipedia.org/wiki/Quaternion
  3628. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3629. */
  3630. export class Quaternion {
  3631. /** defines the first component (0 by default) */
  3632. x: number;
  3633. /** defines the second component (0 by default) */
  3634. y: number;
  3635. /** defines the third component (0 by default) */
  3636. z: number;
  3637. /** defines the fourth component (1.0 by default) */
  3638. w: number;
  3639. /**
  3640. * Creates a new Quaternion from the given floats
  3641. * @param x defines the first component (0 by default)
  3642. * @param y defines the second component (0 by default)
  3643. * @param z defines the third component (0 by default)
  3644. * @param w defines the fourth component (1.0 by default)
  3645. */
  3646. constructor(
  3647. /** defines the first component (0 by default) */
  3648. x?: number,
  3649. /** defines the second component (0 by default) */
  3650. y?: number,
  3651. /** defines the third component (0 by default) */
  3652. z?: number,
  3653. /** defines the fourth component (1.0 by default) */
  3654. w?: number);
  3655. /**
  3656. * Gets a string representation for the current quaternion
  3657. * @returns a string with the Quaternion coordinates
  3658. */
  3659. toString(): string;
  3660. /**
  3661. * Gets the class name of the quaternion
  3662. * @returns the string "Quaternion"
  3663. */
  3664. getClassName(): string;
  3665. /**
  3666. * Gets a hash code for this quaternion
  3667. * @returns the quaternion hash code
  3668. */
  3669. getHashCode(): number;
  3670. /**
  3671. * Copy the quaternion to an array
  3672. * @returns a new array populated with 4 elements from the quaternion coordinates
  3673. */
  3674. asArray(): number[];
  3675. /**
  3676. * Check if two quaternions are equals
  3677. * @param otherQuaternion defines the second operand
  3678. * @return true if the current quaternion and the given one coordinates are strictly equals
  3679. */
  3680. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3683. * @param otherQuaternion defines the other quaternion
  3684. * @param epsilon defines the minimal distance to consider equality
  3685. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3686. */
  3687. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3688. /**
  3689. * Clone the current quaternion
  3690. * @returns a new quaternion copied from the current one
  3691. */
  3692. clone(): Quaternion;
  3693. /**
  3694. * Copy a quaternion to the current one
  3695. * @param other defines the other quaternion
  3696. * @returns the updated current quaternion
  3697. */
  3698. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Updates the current quaternion with the given float coordinates
  3701. * @param x defines the x coordinate
  3702. * @param y defines the y coordinate
  3703. * @param z defines the z coordinate
  3704. * @param w defines the w coordinate
  3705. * @returns the updated current quaternion
  3706. */
  3707. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given float coordinates
  3710. * @param x defines the x coordinate
  3711. * @param y defines the y coordinate
  3712. * @param z defines the z coordinate
  3713. * @param w defines the w coordinate
  3714. * @returns the updated current quaternion
  3715. */
  3716. set(x: number, y: number, z: number, w: number): Quaternion;
  3717. /**
  3718. * Adds two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3721. */
  3722. add(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Add a quaternion to the current one
  3725. * @param other defines the quaternion to add
  3726. * @returns the current quaternion
  3727. */
  3728. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3729. /**
  3730. * Subtract two quaternions
  3731. * @param other defines the second operand
  3732. * @returns a new quaternion as the subtraction result of the given one from the current one
  3733. */
  3734. subtract(other: Quaternion): Quaternion;
  3735. /**
  3736. * Multiplies the current quaternion by a scale factor
  3737. * @param value defines the scale factor
  3738. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3739. */
  3740. scale(value: number): Quaternion;
  3741. /**
  3742. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3743. * @param scale defines the scale factor
  3744. * @param result defines the Quaternion object where to store the result
  3745. * @returns the unmodified current quaternion
  3746. */
  3747. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3748. /**
  3749. * Multiplies in place the current quaternion by a scale factor
  3750. * @param value defines the scale factor
  3751. * @returns the current modified quaternion
  3752. */
  3753. scaleInPlace(value: number): Quaternion;
  3754. /**
  3755. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3756. * @param scale defines the scale factor
  3757. * @param result defines the Quaternion object where to store the result
  3758. * @returns the unmodified current quaternion
  3759. */
  3760. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3761. /**
  3762. * Multiplies two quaternions
  3763. * @param q1 defines the second operand
  3764. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3765. */
  3766. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3767. /**
  3768. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3769. * @param q1 defines the second operand
  3770. * @param result defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3774. /**
  3775. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @returns the currentupdated quaternion
  3778. */
  3779. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3780. /**
  3781. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3782. * @param ref defines the target quaternion
  3783. * @returns the current quaternion
  3784. */
  3785. conjugateToRef(ref: Quaternion): Quaternion;
  3786. /**
  3787. * Conjugates in place (1-q) the current quaternion
  3788. * @returns the current updated quaternion
  3789. */
  3790. conjugateInPlace(): Quaternion;
  3791. /**
  3792. * Conjugates in place (1-q) the current quaternion
  3793. * @returns a new quaternion
  3794. */
  3795. conjugate(): Quaternion;
  3796. /**
  3797. * Gets length of current quaternion
  3798. * @returns the quaternion length (float)
  3799. */
  3800. length(): number;
  3801. /**
  3802. * Normalize in place the current quaternion
  3803. * @returns the current updated quaternion
  3804. */
  3805. normalize(): Quaternion;
  3806. /**
  3807. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3808. * @param order is a reserved parameter and is ignore for now
  3809. * @returns a new Vector3 containing the Euler angles
  3810. */
  3811. toEulerAngles(order?: string): Vector3;
  3812. /**
  3813. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3814. * @param result defines the vector which will be filled with the Euler angles
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns the current unchanged quaternion
  3817. */
  3818. toEulerAnglesToRef(result: Vector3): Quaternion;
  3819. /**
  3820. * Updates the given rotation matrix with the current quaternion values
  3821. * @param result defines the target matrix
  3822. * @returns the current unchanged quaternion
  3823. */
  3824. toRotationMatrix(result: Matrix): Quaternion;
  3825. /**
  3826. * Updates the current quaternion from the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @returns the current updated quaternion
  3829. */
  3830. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3831. /**
  3832. * Creates a new quaternion from a rotation matrix
  3833. * @param matrix defines the source matrix
  3834. * @returns a new quaternion created from the given rotation matrix values
  3835. */
  3836. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3837. /**
  3838. * Updates the given quaternion with the given rotation matrix values
  3839. * @param matrix defines the source matrix
  3840. * @param result defines the target quaternion
  3841. */
  3842. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3843. /**
  3844. * Returns the dot product (float) between the quaternions "left" and "right"
  3845. * @param left defines the left operand
  3846. * @param right defines the right operand
  3847. * @returns the dot product
  3848. */
  3849. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3850. /**
  3851. * Checks if the two quaternions are close to each other
  3852. * @param quat0 defines the first quaternion to check
  3853. * @param quat1 defines the second quaternion to check
  3854. * @returns true if the two quaternions are close to each other
  3855. */
  3856. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates an empty quaternion
  3859. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3860. */
  3861. static Zero(): Quaternion;
  3862. /**
  3863. * Inverse a given quaternion
  3864. * @param q defines the source quaternion
  3865. * @returns a new quaternion as the inverted current quaternion
  3866. */
  3867. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Inverse a given quaternion
  3870. * @param q defines the source quaternion
  3871. * @param result the quaternion the result will be stored in
  3872. * @returns the result quaternion
  3873. */
  3874. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3875. /**
  3876. * Creates an identity quaternion
  3877. * @returns the identity quaternion
  3878. */
  3879. static Identity(): Quaternion;
  3880. /**
  3881. * Gets a boolean indicating if the given quaternion is identity
  3882. * @param quaternion defines the quaternion to check
  3883. * @returns true if the quaternion is identity
  3884. */
  3885. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3886. /**
  3887. * Creates a quaternion from a rotation around an axis
  3888. * @param axis defines the axis to use
  3889. * @param angle defines the angle to use
  3890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3891. */
  3892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3893. /**
  3894. * Creates a rotation around an axis and stores it into the given quaternion
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @param result defines the target quaternion
  3898. * @returns the target quaternion
  3899. */
  3900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3901. /**
  3902. * Creates a new quaternion from data stored into an array
  3903. * @param array defines the data source
  3904. * @param offset defines the offset in the source array where the data starts
  3905. * @returns a new quaternion
  3906. */
  3907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3908. /**
  3909. * Updates the given quaternion "result" from the starting index of the given array.
  3910. * @param array the array to pull values from
  3911. * @param offset the offset into the array to start at
  3912. * @param result the quaternion to store the result in
  3913. */
  3914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3915. /**
  3916. * Create a quaternion from Euler rotation angles
  3917. * @param x Pitch
  3918. * @param y Yaw
  3919. * @param z Roll
  3920. * @returns the new Quaternion
  3921. */
  3922. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3923. /**
  3924. * Updates a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @param result the quaternion to store the result
  3929. * @returns the updated quaternion
  3930. */
  3931. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3932. /**
  3933. * Create a quaternion from Euler rotation vector
  3934. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3935. * @returns the new Quaternion
  3936. */
  3937. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3938. /**
  3939. * Updates a quaternion from Euler rotation vector
  3940. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3941. * @param result the quaternion to store the result
  3942. * @returns the updated quaternion
  3943. */
  3944. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3945. /**
  3946. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3947. * @param yaw defines the rotation around Y axis
  3948. * @param pitch defines the rotation around X axis
  3949. * @param roll defines the rotation around Z axis
  3950. * @returns the new quaternion
  3951. */
  3952. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3953. /**
  3954. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @param result defines the target quaternion
  3959. */
  3960. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3961. /**
  3962. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3963. * @param alpha defines the rotation around first axis
  3964. * @param beta defines the rotation around second axis
  3965. * @param gamma defines the rotation around third axis
  3966. * @returns the new quaternion
  3967. */
  3968. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @param result defines the target quaternion
  3975. */
  3976. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3977. /**
  3978. * 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)
  3979. * @param axis1 defines the first axis
  3980. * @param axis2 defines the second axis
  3981. * @param axis3 defines the third axis
  3982. * @returns the new quaternion
  3983. */
  3984. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3985. /**
  3986. * 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
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @param ref defines the target quaternion
  3991. */
  3992. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3993. /**
  3994. * Interpolates between two quaternions
  3995. * @param left defines first quaternion
  3996. * @param right defines second quaternion
  3997. * @param amount defines the gradient to use
  3998. * @returns the new interpolated quaternion
  3999. */
  4000. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4001. /**
  4002. * Interpolates between two quaternions and stores it into a target quaternion
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @param result defines the target quaternion
  4007. */
  4008. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4009. /**
  4010. * Interpolate between two quaternions using Hermite interpolation
  4011. * @param value1 defines first quaternion
  4012. * @param tangent1 defines the incoming tangent
  4013. * @param value2 defines second quaternion
  4014. * @param tangent2 defines the outgoing tangent
  4015. * @param amount defines the target quaternion
  4016. * @returns the new interpolated quaternion
  4017. */
  4018. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4019. }
  4020. /**
  4021. * Class used to store matrix data (4x4)
  4022. */
  4023. export class Matrix {
  4024. private static _updateFlagSeed;
  4025. private static _identityReadOnly;
  4026. private _isIdentity;
  4027. private _isIdentityDirty;
  4028. private _isIdentity3x2;
  4029. private _isIdentity3x2Dirty;
  4030. /**
  4031. * Gets the update flag of the matrix which is an unique number for the matrix.
  4032. * It will be incremented every time the matrix data change.
  4033. * You can use it to speed the comparison between two versions of the same matrix.
  4034. */
  4035. updateFlag: number;
  4036. private readonly _m;
  4037. /**
  4038. * Gets the internal data of the matrix
  4039. */
  4040. get m(): DeepImmutable<Float32Array>;
  4041. /** @hidden */
  4042. _markAsUpdated(): void;
  4043. /** @hidden */
  4044. private _updateIdentityStatus;
  4045. /**
  4046. * Creates an empty matrix (filled with zeros)
  4047. */
  4048. constructor();
  4049. /**
  4050. * Check if the current matrix is identity
  4051. * @returns true is the matrix is the identity matrix
  4052. */
  4053. isIdentity(): boolean;
  4054. /**
  4055. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4056. * @returns true is the matrix is the identity matrix
  4057. */
  4058. isIdentityAs3x2(): boolean;
  4059. /**
  4060. * Gets the determinant of the matrix
  4061. * @returns the matrix determinant
  4062. */
  4063. determinant(): number;
  4064. /**
  4065. * Returns the matrix as a Float32Array
  4066. * @returns the matrix underlying array
  4067. */
  4068. toArray(): DeepImmutable<Float32Array>;
  4069. /**
  4070. * Returns the matrix as a Float32Array
  4071. * @returns the matrix underlying array.
  4072. */
  4073. asArray(): DeepImmutable<Float32Array>;
  4074. /**
  4075. * Inverts the current matrix in place
  4076. * @returns the current inverted matrix
  4077. */
  4078. invert(): Matrix;
  4079. /**
  4080. * Sets all the matrix elements to zero
  4081. * @returns the current matrix
  4082. */
  4083. reset(): Matrix;
  4084. /**
  4085. * Adds the current matrix with a second one
  4086. * @param other defines the matrix to add
  4087. * @returns a new matrix as the addition of the current matrix and the given one
  4088. */
  4089. add(other: DeepImmutable<Matrix>): Matrix;
  4090. /**
  4091. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4092. * @param other defines the matrix to add
  4093. * @param result defines the target matrix
  4094. * @returns the current matrix
  4095. */
  4096. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4097. /**
  4098. * Adds in place the given matrix to the current matrix
  4099. * @param other defines the second operand
  4100. * @returns the current updated matrix
  4101. */
  4102. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4103. /**
  4104. * Sets the given matrix to the current inverted Matrix
  4105. * @param other defines the target matrix
  4106. * @returns the unmodified current matrix
  4107. */
  4108. invertToRef(other: Matrix): Matrix;
  4109. /**
  4110. * add a value at the specified position in the current Matrix
  4111. * @param index the index of the value within the matrix. between 0 and 15.
  4112. * @param value the value to be added
  4113. * @returns the current updated matrix
  4114. */
  4115. addAtIndex(index: number, value: number): Matrix;
  4116. /**
  4117. * mutiply the specified position in the current Matrix by a value
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. multiplyAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * Inserts the translation vector (using 3 floats) in the current matrix
  4125. * @param x defines the 1st component of the translation
  4126. * @param y defines the 2nd component of the translation
  4127. * @param z defines the 3rd component of the translation
  4128. * @returns the current updated matrix
  4129. */
  4130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4131. /**
  4132. * Adds the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Inserts the translation vector in the current matrix
  4141. * @param vector3 defines the translation to insert
  4142. * @returns the current updated matrix
  4143. */
  4144. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4145. /**
  4146. * Gets the translation value of the current matrix
  4147. * @returns a new Vector3 as the extracted translation from the matrix
  4148. */
  4149. getTranslation(): Vector3;
  4150. /**
  4151. * Fill a Vector3 with the extracted translation from the matrix
  4152. * @param result defines the Vector3 where to store the translation
  4153. * @returns the current matrix
  4154. */
  4155. getTranslationToRef(result: Vector3): Matrix;
  4156. /**
  4157. * Remove rotation and scaling part from the matrix
  4158. * @returns the updated matrix
  4159. */
  4160. removeRotationAndScaling(): Matrix;
  4161. /**
  4162. * Multiply two matrices
  4163. * @param other defines the second operand
  4164. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4165. */
  4166. multiply(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Copy the current matrix from the given one
  4169. * @param other defines the source matrix
  4170. * @returns the current updated matrix
  4171. */
  4172. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Populates the given array from the starting index with the current matrix values
  4175. * @param array defines the target array
  4176. * @param offset defines the offset in the target array where to start storing values
  4177. * @returns the current matrix
  4178. */
  4179. copyToArray(array: Float32Array, offset?: number): Matrix;
  4180. /**
  4181. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4182. * @param other defines the second operand
  4183. * @param result defines the matrix where to store the multiplication
  4184. * @returns the current matrix
  4185. */
  4186. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4187. /**
  4188. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the array where to store the multiplication
  4191. * @param offset defines the offset in the target array where to start storing values
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4195. /**
  4196. * Check equality between this matrix and a second one
  4197. * @param value defines the second matrix to compare
  4198. * @returns true is the current matrix and the given one values are strictly equal
  4199. */
  4200. equals(value: DeepImmutable<Matrix>): boolean;
  4201. /**
  4202. * Clone the current matrix
  4203. * @returns a new matrix from the current matrix
  4204. */
  4205. clone(): Matrix;
  4206. /**
  4207. * Returns the name of the current matrix class
  4208. * @returns the string "Matrix"
  4209. */
  4210. getClassName(): string;
  4211. /**
  4212. * Gets the hash code of the current matrix
  4213. * @returns the hash code
  4214. */
  4215. getHashCode(): number;
  4216. /**
  4217. * Decomposes the current Matrix into a translation, rotation and scaling components
  4218. * @param scale defines the scale vector3 given as a reference to update
  4219. * @param rotation defines the rotation quaternion given as a reference to update
  4220. * @param translation defines the translation vector3 given as a reference to update
  4221. * @returns true if operation was successful
  4222. */
  4223. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4224. /**
  4225. * Gets specific row of the matrix
  4226. * @param index defines the number of the row to get
  4227. * @returns the index-th row of the current matrix as a new Vector4
  4228. */
  4229. getRow(index: number): Nullable<Vector4>;
  4230. /**
  4231. * Sets the index-th row of the current matrix to the vector4 values
  4232. * @param index defines the number of the row to set
  4233. * @param row defines the target vector4
  4234. * @returns the updated current matrix
  4235. */
  4236. setRow(index: number, row: Vector4): Matrix;
  4237. /**
  4238. * Compute the transpose of the matrix
  4239. * @returns the new transposed matrix
  4240. */
  4241. transpose(): Matrix;
  4242. /**
  4243. * Compute the transpose of the matrix and store it in a given matrix
  4244. * @param result defines the target matrix
  4245. * @returns the current matrix
  4246. */
  4247. transposeToRef(result: Matrix): Matrix;
  4248. /**
  4249. * Sets the index-th row of the current matrix with the given 4 x float values
  4250. * @param index defines the row index
  4251. * @param x defines the x component to set
  4252. * @param y defines the y component to set
  4253. * @param z defines the z component to set
  4254. * @param w defines the w component to set
  4255. * @returns the updated current matrix
  4256. */
  4257. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4258. /**
  4259. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4260. * @param scale defines the scale factor
  4261. * @returns a new matrix
  4262. */
  4263. scale(scale: number): Matrix;
  4264. /**
  4265. * Scale the current matrix values by a factor to a given result matrix
  4266. * @param scale defines the scale factor
  4267. * @param result defines the matrix to store the result
  4268. * @returns the current matrix
  4269. */
  4270. scaleToRef(scale: number, result: Matrix): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor and add the result to a given matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the Matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4280. * @param ref matrix to store the result
  4281. */
  4282. toNormalMatrix(ref: Matrix): void;
  4283. /**
  4284. * Gets only rotation part of the current matrix
  4285. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4286. */
  4287. getRotationMatrix(): Matrix;
  4288. /**
  4289. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4290. * @param result defines the target matrix to store data to
  4291. * @returns the current matrix
  4292. */
  4293. getRotationMatrixToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Toggles model matrix from being right handed to left handed in place and vice versa
  4296. */
  4297. toggleModelMatrixHandInPlace(): void;
  4298. /**
  4299. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4300. */
  4301. toggleProjectionMatrixHandInPlace(): void;
  4302. /**
  4303. * Creates a matrix from an array
  4304. * @param array defines the source array
  4305. * @param offset defines an offset in the source array
  4306. * @returns a new Matrix set from the starting index of the given array
  4307. */
  4308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4309. /**
  4310. * Copy the content of an array into a given matrix
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @param result defines the target matrix
  4314. */
  4315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4316. /**
  4317. * Stores an array into a matrix after having multiplied each component by a given factor
  4318. * @param array defines the source array
  4319. * @param offset defines the offset in the source array
  4320. * @param scale defines the scaling factor
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4324. /**
  4325. * Gets an identity matrix that must not be updated
  4326. */
  4327. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4328. /**
  4329. * Stores a list of values (16) inside a given matrix
  4330. * @param initialM11 defines 1st value of 1st row
  4331. * @param initialM12 defines 2nd value of 1st row
  4332. * @param initialM13 defines 3rd value of 1st row
  4333. * @param initialM14 defines 4th value of 1st row
  4334. * @param initialM21 defines 1st value of 2nd row
  4335. * @param initialM22 defines 2nd value of 2nd row
  4336. * @param initialM23 defines 3rd value of 2nd row
  4337. * @param initialM24 defines 4th value of 2nd row
  4338. * @param initialM31 defines 1st value of 3rd row
  4339. * @param initialM32 defines 2nd value of 3rd row
  4340. * @param initialM33 defines 3rd value of 3rd row
  4341. * @param initialM34 defines 4th value of 3rd row
  4342. * @param initialM41 defines 1st value of 4th row
  4343. * @param initialM42 defines 2nd value of 4th row
  4344. * @param initialM43 defines 3rd value of 4th row
  4345. * @param initialM44 defines 4th value of 4th row
  4346. * @param result defines the target matrix
  4347. */
  4348. 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;
  4349. /**
  4350. * Creates new matrix from a list of values (16)
  4351. * @param initialM11 defines 1st value of 1st row
  4352. * @param initialM12 defines 2nd value of 1st row
  4353. * @param initialM13 defines 3rd value of 1st row
  4354. * @param initialM14 defines 4th value of 1st row
  4355. * @param initialM21 defines 1st value of 2nd row
  4356. * @param initialM22 defines 2nd value of 2nd row
  4357. * @param initialM23 defines 3rd value of 2nd row
  4358. * @param initialM24 defines 4th value of 2nd row
  4359. * @param initialM31 defines 1st value of 3rd row
  4360. * @param initialM32 defines 2nd value of 3rd row
  4361. * @param initialM33 defines 3rd value of 3rd row
  4362. * @param initialM34 defines 4th value of 3rd row
  4363. * @param initialM41 defines 1st value of 4th row
  4364. * @param initialM42 defines 2nd value of 4th row
  4365. * @param initialM43 defines 3rd value of 4th row
  4366. * @param initialM44 defines 4th value of 4th row
  4367. * @returns the new matrix
  4368. */
  4369. 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;
  4370. /**
  4371. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4372. * @param scale defines the scale vector3
  4373. * @param rotation defines the rotation quaternion
  4374. * @param translation defines the translation vector3
  4375. * @returns a new matrix
  4376. */
  4377. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @param result defines the target matrix
  4384. */
  4385. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * Creates a new identity matrix
  4388. * @returns a new identity matrix
  4389. */
  4390. static Identity(): Matrix;
  4391. /**
  4392. * Creates a new identity matrix and stores the result in a given matrix
  4393. * @param result defines the target matrix
  4394. */
  4395. static IdentityToRef(result: Matrix): void;
  4396. /**
  4397. * Creates a new zero matrix
  4398. * @returns a new zero matrix
  4399. */
  4400. static Zero(): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis
  4403. * @param angle defines the angle (in radians) to use
  4404. * @return the new matrix
  4405. */
  4406. static RotationX(angle: number): Matrix;
  4407. /**
  4408. * Creates a new matrix as the invert of a given matrix
  4409. * @param source defines the source matrix
  4410. * @returns the new matrix
  4411. */
  4412. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationXToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Y axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationY(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationYToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the Z axis
  4433. * @param angle defines the angle (in radians) to use
  4434. * @return the new matrix
  4435. */
  4436. static RotationZ(angle: number): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationZToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the given axis
  4445. * @param axis defines the axis to use
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @param result defines the target matrix
  4455. */
  4456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4457. /**
  4458. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4459. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4460. * @param from defines the vector to align
  4461. * @param to defines the vector to align to
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4465. /**
  4466. * Creates a rotation matrix
  4467. * @param yaw defines the yaw angle in radians (Y axis)
  4468. * @param pitch defines the pitch angle in radians (X axis)
  4469. * @param roll defines the roll angle in radians (X axis)
  4470. * @returns the new rotation matrix
  4471. */
  4472. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4473. /**
  4474. * Creates a rotation matrix and stores it in a given matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4481. /**
  4482. * Creates a scaling matrix
  4483. * @param x defines the scale factor on X axis
  4484. * @param y defines the scale factor on Y axis
  4485. * @param z defines the scale factor on Z axis
  4486. * @returns the new matrix
  4487. */
  4488. static Scaling(x: number, y: number, z: number): Matrix;
  4489. /**
  4490. * Creates a scaling matrix and stores it in a given matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @param result defines the target matrix
  4495. */
  4496. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4497. /**
  4498. * Creates a translation matrix
  4499. * @param x defines the translation on X axis
  4500. * @param y defines the translation on Y axis
  4501. * @param z defines the translationon Z axis
  4502. * @returns the new matrix
  4503. */
  4504. static Translation(x: number, y: number, z: number): Matrix;
  4505. /**
  4506. * Creates a translation matrix and stores it in a given matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @param result defines the target matrix
  4511. */
  4512. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4513. /**
  4514. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4515. * @param startValue defines the start value
  4516. * @param endValue defines the end value
  4517. * @param gradient defines the gradient factor
  4518. * @returns the new matrix
  4519. */
  4520. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4521. /**
  4522. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @param result defines the Matrix object where to store data
  4527. */
  4528. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4529. /**
  4530. * Builds a new matrix whose values are computed by:
  4531. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4532. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4533. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4534. * @param startValue defines the first matrix
  4535. * @param endValue defines the second matrix
  4536. * @param gradient defines the gradient between the two matrices
  4537. * @returns the new matrix
  4538. */
  4539. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4540. /**
  4541. * Update a matrix to values which are computed by:
  4542. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4543. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4544. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4545. * @param startValue defines the first matrix
  4546. * @param endValue defines the second matrix
  4547. * @param gradient defines the gradient between the two matrices
  4548. * @param result defines the target matrix
  4549. */
  4550. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4551. /**
  4552. * 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"
  4553. * This function works in left handed mode
  4554. * @param eye defines the final position of the entity
  4555. * @param target defines where the entity should look at
  4556. * @param up defines the up vector for the entity
  4557. * @returns the new matrix
  4558. */
  4559. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4560. /**
  4561. * 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".
  4562. * This function works in left handed mode
  4563. * @param eye defines the final position of the entity
  4564. * @param target defines where the entity should look at
  4565. * @param up defines the up vector for the entity
  4566. * @param result defines the target matrix
  4567. */
  4568. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * 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"
  4571. * This function works in right handed mode
  4572. * @param eye defines the final position of the entity
  4573. * @param target defines where the entity should look at
  4574. * @param up defines the up vector for the entity
  4575. * @returns the new matrix
  4576. */
  4577. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * 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".
  4580. * This function works in right handed mode
  4581. * @param eye defines the final position of the entity
  4582. * @param target defines where the entity should look at
  4583. * @param up defines the up vector for the entity
  4584. * @param result defines the target matrix
  4585. */
  4586. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Create a left-handed orthographic projection matrix
  4589. * @param width defines the viewport width
  4590. * @param height defines the viewport height
  4591. * @param znear defines the near clip plane
  4592. * @param zfar defines the far clip plane
  4593. * @returns a new matrix as a left-handed orthographic projection matrix
  4594. */
  4595. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4596. /**
  4597. * Store a left-handed orthographic projection to a given matrix
  4598. * @param width defines the viewport width
  4599. * @param height defines the viewport height
  4600. * @param znear defines the near clip plane
  4601. * @param zfar defines the far clip plane
  4602. * @param result defines the target matrix
  4603. */
  4604. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4605. /**
  4606. * Create a left-handed orthographic projection matrix
  4607. * @param left defines the viewport left coordinate
  4608. * @param right defines the viewport right coordinate
  4609. * @param bottom defines the viewport bottom coordinate
  4610. * @param top defines the viewport top coordinate
  4611. * @param znear defines the near clip plane
  4612. * @param zfar defines the far clip plane
  4613. * @returns a new matrix as a left-handed orthographic projection matrix
  4614. */
  4615. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4616. /**
  4617. * Stores a left-handed orthographic projection into a given matrix
  4618. * @param left defines the viewport left coordinate
  4619. * @param right defines the viewport right coordinate
  4620. * @param bottom defines the viewport bottom coordinate
  4621. * @param top defines the viewport top coordinate
  4622. * @param znear defines the near clip plane
  4623. * @param zfar defines the far clip plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4627. /**
  4628. * Creates a right-handed orthographic projection matrix
  4629. * @param left defines the viewport left coordinate
  4630. * @param right defines the viewport right coordinate
  4631. * @param bottom defines the viewport bottom coordinate
  4632. * @param top defines the viewport top coordinate
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a right-handed orthographic projection matrix
  4636. */
  4637. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a right-handed orthographic projection into a given matrix
  4640. * @param left defines the viewport left coordinate
  4641. * @param right defines the viewport right coordinate
  4642. * @param bottom defines the viewport bottom coordinate
  4643. * @param top defines the viewport top coordinate
  4644. * @param znear defines the near clip plane
  4645. * @param zfar defines the far clip plane
  4646. * @param result defines the target matrix
  4647. */
  4648. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4649. /**
  4650. * Creates a left-handed perspective projection matrix
  4651. * @param width defines the viewport width
  4652. * @param height defines the viewport height
  4653. * @param znear defines the near clip plane
  4654. * @param zfar defines the far clip plane
  4655. * @returns a new matrix as a left-handed perspective projection matrix
  4656. */
  4657. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4658. /**
  4659. * Creates a left-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a left-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a left-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Creates a right-handed perspective projection matrix
  4689. * @param fov defines the horizontal field of view
  4690. * @param aspect defines the aspect ratio
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @returns a new matrix as a right-handed perspective projection matrix
  4694. */
  4695. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4696. /**
  4697. * Stores a right-handed perspective projection into a given matrix
  4698. * @param fov defines the horizontal field of view
  4699. * @param aspect defines the aspect ratio
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4704. */
  4705. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4706. /**
  4707. * Stores a right-handed perspective projection into a given matrix
  4708. * @param fov defines the horizontal field of view
  4709. * @param aspect defines the aspect ratio
  4710. * @param znear defines the near clip plane
  4711. * @param zfar not used as infinity is used as far clip
  4712. * @param result defines the target matrix
  4713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4714. */
  4715. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4716. /**
  4717. * Stores a perspective projection for WebVR info a given matrix
  4718. * @param fov defines the field of view
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @param result defines the target matrix
  4722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4723. */
  4724. static PerspectiveFovWebVRToRef(fov: {
  4725. upDegrees: number;
  4726. downDegrees: number;
  4727. leftDegrees: number;
  4728. rightDegrees: number;
  4729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4730. /**
  4731. * Computes a complete transformation matrix
  4732. * @param viewport defines the viewport to use
  4733. * @param world defines the world matrix
  4734. * @param view defines the view matrix
  4735. * @param projection defines the projection matrix
  4736. * @param zmin defines the near clip plane
  4737. * @param zmax defines the far clip plane
  4738. * @returns the transformation matrix
  4739. */
  4740. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4741. /**
  4742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4743. * @param matrix defines the matrix to use
  4744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4745. */
  4746. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4747. /**
  4748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4749. * @param matrix defines the matrix to use
  4750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4751. */
  4752. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4753. /**
  4754. * Compute the transpose of a given matrix
  4755. * @param matrix defines the matrix to transpose
  4756. * @returns the new matrix
  4757. */
  4758. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4759. /**
  4760. * Compute the transpose of a matrix and store it in a target matrix
  4761. * @param matrix defines the matrix to transpose
  4762. * @param result defines the target matrix
  4763. */
  4764. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4765. /**
  4766. * Computes a reflection matrix from a plane
  4767. * @param plane defines the reflection plane
  4768. * @returns a new matrix
  4769. */
  4770. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4771. /**
  4772. * Computes a reflection matrix from a plane
  4773. * @param plane defines the reflection plane
  4774. * @param result defines the target matrix
  4775. */
  4776. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4777. /**
  4778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4779. * @param xaxis defines the value of the 1st axis
  4780. * @param yaxis defines the value of the 2nd axis
  4781. * @param zaxis defines the value of the 3rd axis
  4782. * @param result defines the target matrix
  4783. */
  4784. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4785. /**
  4786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4787. * @param quat defines the quaternion to use
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4791. }
  4792. /**
  4793. * @hidden
  4794. */
  4795. export class TmpVectors {
  4796. static Vector2: Vector2[];
  4797. static Vector3: Vector3[];
  4798. static Vector4: Vector4[];
  4799. static Quaternion: Quaternion[];
  4800. static Matrix: Matrix[];
  4801. }
  4802. }
  4803. declare module "babylonjs/Maths/math.path" {
  4804. import { DeepImmutable, Nullable } from "babylonjs/types";
  4805. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4806. /**
  4807. * Defines potential orientation for back face culling
  4808. */
  4809. export enum Orientation {
  4810. /**
  4811. * Clockwise
  4812. */
  4813. CW = 0,
  4814. /** Counter clockwise */
  4815. CCW = 1
  4816. }
  4817. /** Class used to represent a Bezier curve */
  4818. export class BezierCurve {
  4819. /**
  4820. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4821. * @param t defines the time
  4822. * @param x1 defines the left coordinate on X axis
  4823. * @param y1 defines the left coordinate on Y axis
  4824. * @param x2 defines the right coordinate on X axis
  4825. * @param y2 defines the right coordinate on Y axis
  4826. * @returns the interpolated value
  4827. */
  4828. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4829. }
  4830. /**
  4831. * Defines angle representation
  4832. */
  4833. export class Angle {
  4834. private _radians;
  4835. /**
  4836. * Creates an Angle object of "radians" radians (float).
  4837. * @param radians the angle in radians
  4838. */
  4839. constructor(radians: number);
  4840. /**
  4841. * Get value in degrees
  4842. * @returns the Angle value in degrees (float)
  4843. */
  4844. degrees(): number;
  4845. /**
  4846. * Get value in radians
  4847. * @returns the Angle value in radians (float)
  4848. */
  4849. radians(): number;
  4850. /**
  4851. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4852. * @param a defines first vector
  4853. * @param b defines second vector
  4854. * @returns a new Angle
  4855. */
  4856. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4857. /**
  4858. * Gets a new Angle object from the given float in radians
  4859. * @param radians defines the angle value in radians
  4860. * @returns a new Angle
  4861. */
  4862. static FromRadians(radians: number): Angle;
  4863. /**
  4864. * Gets a new Angle object from the given float in degrees
  4865. * @param degrees defines the angle value in degrees
  4866. * @returns a new Angle
  4867. */
  4868. static FromDegrees(degrees: number): Angle;
  4869. }
  4870. /**
  4871. * This represents an arc in a 2d space.
  4872. */
  4873. export class Arc2 {
  4874. /** Defines the start point of the arc */
  4875. startPoint: Vector2;
  4876. /** Defines the mid point of the arc */
  4877. midPoint: Vector2;
  4878. /** Defines the end point of the arc */
  4879. endPoint: Vector2;
  4880. /**
  4881. * Defines the center point of the arc.
  4882. */
  4883. centerPoint: Vector2;
  4884. /**
  4885. * Defines the radius of the arc.
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Defines the angle of the arc (from mid point to end point).
  4890. */
  4891. angle: Angle;
  4892. /**
  4893. * Defines the start angle of the arc (from start point to middle point).
  4894. */
  4895. startAngle: Angle;
  4896. /**
  4897. * Defines the orientation of the arc (clock wise/counter clock wise).
  4898. */
  4899. orientation: Orientation;
  4900. /**
  4901. * Creates an Arc object from the three given points : start, middle and end.
  4902. * @param startPoint Defines the start point of the arc
  4903. * @param midPoint Defines the midlle point of the arc
  4904. * @param endPoint Defines the end point of the arc
  4905. */
  4906. constructor(
  4907. /** Defines the start point of the arc */
  4908. startPoint: Vector2,
  4909. /** Defines the mid point of the arc */
  4910. midPoint: Vector2,
  4911. /** Defines the end point of the arc */
  4912. endPoint: Vector2);
  4913. }
  4914. /**
  4915. * Represents a 2D path made up of multiple 2D points
  4916. */
  4917. export class Path2 {
  4918. private _points;
  4919. private _length;
  4920. /**
  4921. * If the path start and end point are the same
  4922. */
  4923. closed: boolean;
  4924. /**
  4925. * Creates a Path2 object from the starting 2D coordinates x and y.
  4926. * @param x the starting points x value
  4927. * @param y the starting points y value
  4928. */
  4929. constructor(x: number, y: number);
  4930. /**
  4931. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4932. * @param x the added points x value
  4933. * @param y the added points y value
  4934. * @returns the updated Path2.
  4935. */
  4936. addLineTo(x: number, y: number): Path2;
  4937. /**
  4938. * 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.
  4939. * @param midX middle point x value
  4940. * @param midY middle point y value
  4941. * @param endX end point x value
  4942. * @param endY end point y value
  4943. * @param numberOfSegments (default: 36)
  4944. * @returns the updated Path2.
  4945. */
  4946. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4947. /**
  4948. * Closes the Path2.
  4949. * @returns the Path2.
  4950. */
  4951. close(): Path2;
  4952. /**
  4953. * Gets the sum of the distance between each sequential point in the path
  4954. * @returns the Path2 total length (float).
  4955. */
  4956. length(): number;
  4957. /**
  4958. * Gets the points which construct the path
  4959. * @returns the Path2 internal array of points.
  4960. */
  4961. getPoints(): Vector2[];
  4962. /**
  4963. * Retreives the point at the distance aways from the starting point
  4964. * @param normalizedLengthPosition the length along the path to retreive the point from
  4965. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4966. */
  4967. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4968. /**
  4969. * Creates a new path starting from an x and y position
  4970. * @param x starting x value
  4971. * @param y starting y value
  4972. * @returns a new Path2 starting at the coordinates (x, y).
  4973. */
  4974. static StartingAt(x: number, y: number): Path2;
  4975. }
  4976. /**
  4977. * Represents a 3D path made up of multiple 3D points
  4978. */
  4979. export class Path3D {
  4980. /**
  4981. * an array of Vector3, the curve axis of the Path3D
  4982. */
  4983. path: Vector3[];
  4984. private _curve;
  4985. private _distances;
  4986. private _tangents;
  4987. private _normals;
  4988. private _binormals;
  4989. private _raw;
  4990. private _alignTangentsWithPath;
  4991. private readonly _pointAtData;
  4992. /**
  4993. * new Path3D(path, normal, raw)
  4994. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4995. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4996. * @param path an array of Vector3, the curve axis of the Path3D
  4997. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4998. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4999. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5000. */
  5001. constructor(
  5002. /**
  5003. * an array of Vector3, the curve axis of the Path3D
  5004. */
  5005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5006. /**
  5007. * Returns the Path3D array of successive Vector3 designing its curve.
  5008. * @returns the Path3D array of successive Vector3 designing its curve.
  5009. */
  5010. getCurve(): Vector3[];
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getPoints(): Vector3[];
  5016. /**
  5017. * @returns the computed length (float) of the path.
  5018. */
  5019. length(): number;
  5020. /**
  5021. * Returns an array populated with tangent vectors on each Path3D curve point.
  5022. * @returns an array populated with tangent vectors on each Path3D curve point.
  5023. */
  5024. getTangents(): Vector3[];
  5025. /**
  5026. * Returns an array populated with normal vectors on each Path3D curve point.
  5027. * @returns an array populated with normal vectors on each Path3D curve point.
  5028. */
  5029. getNormals(): Vector3[];
  5030. /**
  5031. * Returns an array populated with binormal vectors on each Path3D curve point.
  5032. * @returns an array populated with binormal vectors on each Path3D curve point.
  5033. */
  5034. getBinormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5037. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5038. */
  5039. getDistances(): number[];
  5040. /**
  5041. * Returns an interpolated point along this path
  5042. * @param position the position of the point along this path, from 0.0 to 1.0
  5043. * @returns a new Vector3 as the point
  5044. */
  5045. getPointAt(position: number): Vector3;
  5046. /**
  5047. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5050. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5051. */
  5052. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5057. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5058. */
  5059. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5064. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5065. */
  5066. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5071. */
  5072. getDistanceAt(position: number): number;
  5073. /**
  5074. * Returns the array index of the previous point of an interpolated point along this path
  5075. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5076. * @returns the array index
  5077. */
  5078. getPreviousPointIndexAt(position: number): number;
  5079. /**
  5080. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5082. * @returns the sub position
  5083. */
  5084. getSubPositionAt(position: number): number;
  5085. /**
  5086. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5087. * @param target the vector of which to get the closest position to
  5088. * @returns the position of the closest virtual point on this path to the target vector
  5089. */
  5090. getClosestPositionTo(target: Vector3): number;
  5091. /**
  5092. * Returns a sub path (slice) of this path
  5093. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5094. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5095. * @returns a sub path (slice) of this path
  5096. */
  5097. slice(start?: number, end?: number): Path3D;
  5098. /**
  5099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5100. * @param path path which all values are copied into the curves points
  5101. * @param firstNormal which should be projected onto the curve
  5102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5103. * @returns the same object updated.
  5104. */
  5105. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5106. private _compute;
  5107. private _getFirstNonNullVector;
  5108. private _getLastNonNullVector;
  5109. private _normalVector;
  5110. /**
  5111. * Updates the point at data for an interpolated point along this curve
  5112. * @param position the position of the point along this curve, from 0.0 to 1.0
  5113. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5114. * @returns the (updated) point at data
  5115. */
  5116. private _updatePointAtData;
  5117. /**
  5118. * Updates the point at data from the specified parameters
  5119. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5120. * @param point the interpolated point
  5121. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5122. */
  5123. private _setPointAtData;
  5124. /**
  5125. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5126. */
  5127. private _updateInterpolationMatrix;
  5128. }
  5129. /**
  5130. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5131. * A Curve3 is designed from a series of successive Vector3.
  5132. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5133. */
  5134. export class Curve3 {
  5135. private _points;
  5136. private _length;
  5137. /**
  5138. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5139. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5140. * @param v1 (Vector3) the control point
  5141. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5142. * @param nbPoints (integer) the wanted number of points in the curve
  5143. * @returns the created Curve3
  5144. */
  5145. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5146. /**
  5147. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5148. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5149. * @param v1 (Vector3) the first control point
  5150. * @param v2 (Vector3) the second control point
  5151. * @param v3 (Vector3) the end point of the Cubic Bezier
  5152. * @param nbPoints (integer) the wanted number of points in the curve
  5153. * @returns the created Curve3
  5154. */
  5155. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5156. /**
  5157. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5158. * @param p1 (Vector3) the origin point of the Hermite Spline
  5159. * @param t1 (Vector3) the tangent vector at the origin point
  5160. * @param p2 (Vector3) the end point of the Hermite Spline
  5161. * @param t2 (Vector3) the tangent vector at the end point
  5162. * @param nbPoints (integer) the wanted number of points in the curve
  5163. * @returns the created Curve3
  5164. */
  5165. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5166. /**
  5167. * Returns a Curve3 object along a CatmullRom Spline curve :
  5168. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5169. * @param nbPoints (integer) the wanted number of points between each curve control points
  5170. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5178. * @param points points which make up the curve
  5179. */
  5180. constructor(points: Vector3[]);
  5181. /**
  5182. * @returns the Curve3 stored array of successive Vector3
  5183. */
  5184. getPoints(): Vector3[];
  5185. /**
  5186. * @returns the computed length (float) of the curve.
  5187. */
  5188. length(): number;
  5189. /**
  5190. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5191. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5192. * curveA and curveB keep unchanged.
  5193. * @param curve the curve to continue from this curve
  5194. * @returns the newly constructed curve
  5195. */
  5196. continue(curve: DeepImmutable<Curve3>): Curve3;
  5197. private _computeLength;
  5198. }
  5199. }
  5200. declare module "babylonjs/Animations/easing" {
  5201. /**
  5202. * This represents the main contract an easing function should follow.
  5203. * Easing functions are used throughout the animation system.
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export interface IEasingFunction {
  5207. /**
  5208. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5209. * of the easing function.
  5210. * The link below provides some of the most common examples of easing functions.
  5211. * @see https://easings.net/
  5212. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5213. * @returns the corresponding value on the curve defined by the easing function
  5214. */
  5215. ease(gradient: number): number;
  5216. }
  5217. /**
  5218. * Base class used for every default easing function.
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class EasingFunction implements IEasingFunction {
  5222. /**
  5223. * Interpolation follows the mathematical formula associated with the easing function.
  5224. */
  5225. static readonly EASINGMODE_EASEIN: number;
  5226. /**
  5227. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5228. */
  5229. static readonly EASINGMODE_EASEOUT: number;
  5230. /**
  5231. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5232. */
  5233. static readonly EASINGMODE_EASEINOUT: number;
  5234. private _easingMode;
  5235. /**
  5236. * Sets the easing mode of the current function.
  5237. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5238. */
  5239. setEasingMode(easingMode: number): void;
  5240. /**
  5241. * Gets the current easing mode.
  5242. * @returns the easing mode
  5243. */
  5244. getEasingMode(): number;
  5245. /**
  5246. * @hidden
  5247. */
  5248. easeInCore(gradient: number): number;
  5249. /**
  5250. * Given an input gradient between 0 and 1, this returns the corresponding value
  5251. * of the easing function.
  5252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5253. * @returns the corresponding value on the curve defined by the easing function
  5254. */
  5255. ease(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a circle shape (see link below).
  5259. * @see https://easings.net/#easeInCirc
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class CircleEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a ease back shape (see link below).
  5268. * @see https://easings.net/#easeInBack
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BackEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the amplitude of the function */
  5273. amplitude: number;
  5274. /**
  5275. * Instantiates a back ease easing
  5276. * @see https://easings.net/#easeInBack
  5277. * @param amplitude Defines the amplitude of the function
  5278. */
  5279. constructor(
  5280. /** Defines the amplitude of the function */
  5281. amplitude?: number);
  5282. /** @hidden */
  5283. easeInCore(gradient: number): number;
  5284. }
  5285. /**
  5286. * Easing function with a bouncing shape (see link below).
  5287. * @see https://easings.net/#easeInBounce
  5288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5289. */
  5290. export class BounceEase extends EasingFunction implements IEasingFunction {
  5291. /** Defines the number of bounces */
  5292. bounces: number;
  5293. /** Defines the amplitude of the bounce */
  5294. bounciness: number;
  5295. /**
  5296. * Instantiates a bounce easing
  5297. * @see https://easings.net/#easeInBounce
  5298. * @param bounces Defines the number of bounces
  5299. * @param bounciness Defines the amplitude of the bounce
  5300. */
  5301. constructor(
  5302. /** Defines the number of bounces */
  5303. bounces?: number,
  5304. /** Defines the amplitude of the bounce */
  5305. bounciness?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a power of 3 shape (see link below).
  5311. * @see https://easings.net/#easeInCubic
  5312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class CubicEase extends EasingFunction implements IEasingFunction {
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. /**
  5319. * Easing function with an elastic shape (see link below).
  5320. * @see https://easings.net/#easeInElastic
  5321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5324. /** Defines the number of oscillations*/
  5325. oscillations: number;
  5326. /** Defines the amplitude of the oscillations*/
  5327. springiness: number;
  5328. /**
  5329. * Instantiates an elastic easing function
  5330. * @see https://easings.net/#easeInElastic
  5331. * @param oscillations Defines the number of oscillations
  5332. * @param springiness Defines the amplitude of the oscillations
  5333. */
  5334. constructor(
  5335. /** Defines the number of oscillations*/
  5336. oscillations?: number,
  5337. /** Defines the amplitude of the oscillations*/
  5338. springiness?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an exponential shape (see link below).
  5344. * @see https://easings.net/#easeInExpo
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the exponent of the function */
  5349. exponent: number;
  5350. /**
  5351. * Instantiates an exponential easing function
  5352. * @see https://easings.net/#easeInExpo
  5353. * @param exponent Defines the exponent of the function
  5354. */
  5355. constructor(
  5356. /** Defines the exponent of the function */
  5357. exponent?: number);
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a power shape (see link below).
  5363. * @see https://easings.net/#easeInQuad
  5364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class PowerEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the power of the function */
  5368. power: number;
  5369. /**
  5370. * Instantiates an power base easing function
  5371. * @see https://easings.net/#easeInQuad
  5372. * @param power Defines the power of the function
  5373. */
  5374. constructor(
  5375. /** Defines the power of the function */
  5376. power?: number);
  5377. /** @hidden */
  5378. easeInCore(gradient: number): number;
  5379. }
  5380. /**
  5381. * Easing function with a power of 2 shape (see link below).
  5382. * @see https://easings.net/#easeInQuad
  5383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5384. */
  5385. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a power of 4 shape (see link below).
  5391. * @see https://easings.net/#easeInQuart
  5392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5395. /** @hidden */
  5396. easeInCore(gradient: number): number;
  5397. }
  5398. /**
  5399. * Easing function with a power of 5 shape (see link below).
  5400. * @see https://easings.net/#easeInQuint
  5401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5402. */
  5403. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5404. /** @hidden */
  5405. easeInCore(gradient: number): number;
  5406. }
  5407. /**
  5408. * Easing function with a sin shape (see link below).
  5409. * @see https://easings.net/#easeInSine
  5410. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5411. */
  5412. export class SineEase extends EasingFunction implements IEasingFunction {
  5413. /** @hidden */
  5414. easeInCore(gradient: number): number;
  5415. }
  5416. /**
  5417. * Easing function with a bezier shape (see link below).
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5420. */
  5421. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5422. /** Defines the x component of the start tangent in the bezier curve */
  5423. x1: number;
  5424. /** Defines the y component of the start tangent in the bezier curve */
  5425. y1: number;
  5426. /** Defines the x component of the end tangent in the bezier curve */
  5427. x2: number;
  5428. /** Defines the y component of the end tangent in the bezier curve */
  5429. y2: number;
  5430. /**
  5431. * Instantiates a bezier function
  5432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5433. * @param x1 Defines the x component of the start tangent in the bezier curve
  5434. * @param y1 Defines the y component of the start tangent in the bezier curve
  5435. * @param x2 Defines the x component of the end tangent in the bezier curve
  5436. * @param y2 Defines the y component of the end tangent in the bezier curve
  5437. */
  5438. constructor(
  5439. /** Defines the x component of the start tangent in the bezier curve */
  5440. x1?: number,
  5441. /** Defines the y component of the start tangent in the bezier curve */
  5442. y1?: number,
  5443. /** Defines the x component of the end tangent in the bezier curve */
  5444. x2?: number,
  5445. /** Defines the y component of the end tangent in the bezier curve */
  5446. y2?: number);
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/math.color" {
  5452. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to hold a RBG color
  5455. */
  5456. export class Color3 {
  5457. /**
  5458. * Defines the red component (between 0 and 1, default is 0)
  5459. */
  5460. r: number;
  5461. /**
  5462. * Defines the green component (between 0 and 1, default is 0)
  5463. */
  5464. g: number;
  5465. /**
  5466. * Defines the blue component (between 0 and 1, default is 0)
  5467. */
  5468. b: number;
  5469. /**
  5470. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5471. * @param r defines the red component (between 0 and 1, default is 0)
  5472. * @param g defines the green component (between 0 and 1, default is 0)
  5473. * @param b defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number);
  5488. /**
  5489. * Creates a string with the Color3 current values
  5490. * @returns the string representation of the Color3 object
  5491. */
  5492. toString(): string;
  5493. /**
  5494. * Returns the string "Color3"
  5495. * @returns "Color3"
  5496. */
  5497. getClassName(): string;
  5498. /**
  5499. * Compute the Color3 hash code
  5500. * @returns an unique number that can be used to hash Color3 objects
  5501. */
  5502. getHashCode(): number;
  5503. /**
  5504. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color3 object
  5508. */
  5509. toArray(array: FloatArray, index?: number): Color3;
  5510. /**
  5511. * Returns a new Color4 object from the current Color3 and the given alpha
  5512. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5513. * @returns a new Color4 object
  5514. */
  5515. toColor4(alpha?: number): Color4;
  5516. /**
  5517. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5518. * @returns the new array
  5519. */
  5520. asArray(): number[];
  5521. /**
  5522. * Returns the luminance value
  5523. * @returns a float value
  5524. */
  5525. toLuminance(): number;
  5526. /**
  5527. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5528. * @param otherColor defines the second operand
  5529. * @returns the new Color3 object
  5530. */
  5531. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5532. /**
  5533. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5534. * @param otherColor defines the second operand
  5535. * @param result defines the Color3 object where to store the result
  5536. * @returns the current Color3
  5537. */
  5538. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5539. /**
  5540. * Determines equality between Color3 objects
  5541. * @param otherColor defines the second operand
  5542. * @returns true if the rgb values are equal to the given ones
  5543. */
  5544. equals(otherColor: DeepImmutable<Color3>): boolean;
  5545. /**
  5546. * Determines equality between the current Color3 object and a set of r,b,g values
  5547. * @param r defines the red component to check
  5548. * @param g defines the green component to check
  5549. * @param b defines the blue component to check
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equalsFloats(r: number, g: number, b: number): boolean;
  5553. /**
  5554. * Multiplies in place each rgb value by scale
  5555. * @param scale defines the scaling factor
  5556. * @returns the updated Color3
  5557. */
  5558. scale(scale: number): Color3;
  5559. /**
  5560. * Multiplies the rgb values by scale and stores the result into "result"
  5561. * @param scale defines the scaling factor
  5562. * @param result defines the Color3 object where to store the result
  5563. * @returns the unmodified current Color3
  5564. */
  5565. scaleToRef(scale: number, result: Color3): Color3;
  5566. /**
  5567. * Scale the current Color3 values by a factor and add the result to a given Color3
  5568. * @param scale defines the scale factor
  5569. * @param result defines color to store the result into
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Clamps the rgb values by the min and max values and stores the result into "result"
  5575. * @param min defines minimum clamping value (default is 0)
  5576. * @param max defines maximum clamping value (default is 1)
  5577. * @param result defines color to store the result into
  5578. * @returns the original Color3
  5579. */
  5580. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5581. /**
  5582. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5583. * @param otherColor defines the second operand
  5584. * @returns the new Color3
  5585. */
  5586. add(otherColor: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5589. * @param otherColor defines the second operand
  5590. * @param result defines Color3 object to store the result into
  5591. * @returns the unmodified current Color3
  5592. */
  5593. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5594. /**
  5595. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5596. * @param otherColor defines the second operand
  5597. * @returns the new Color3
  5598. */
  5599. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5600. /**
  5601. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5602. * @param otherColor defines the second operand
  5603. * @param result defines Color3 object to store the result into
  5604. * @returns the unmodified current Color3
  5605. */
  5606. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5607. /**
  5608. * Copy the current object
  5609. * @returns a new Color3 copied the current one
  5610. */
  5611. clone(): Color3;
  5612. /**
  5613. * Copies the rgb values from the source in the current Color3
  5614. * @param source defines the source Color3 object
  5615. * @returns the updated Color3 object
  5616. */
  5617. copyFrom(source: DeepImmutable<Color3>): Color3;
  5618. /**
  5619. * Updates the Color3 rgb values from the given floats
  5620. * @param r defines the red component to read from
  5621. * @param g defines the green component to read from
  5622. * @param b defines the blue component to read from
  5623. * @returns the current Color3 object
  5624. */
  5625. copyFromFloats(r: number, g: number, b: number): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. set(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Compute the Color3 hexadecimal code as a string
  5636. * @returns a string containing the hexadecimal representation of the Color3 object
  5637. */
  5638. toHexString(): string;
  5639. /**
  5640. * Computes a new Color3 converted from the current one to linear space
  5641. * @returns a new Color3 object
  5642. */
  5643. toLinearSpace(): Color3;
  5644. /**
  5645. * Converts current color in rgb space to HSV values
  5646. * @returns a new color3 representing the HSV values
  5647. */
  5648. toHSV(): Color3;
  5649. /**
  5650. * Converts current color in rgb space to HSV values
  5651. * @param result defines the Color3 where to store the HSV values
  5652. */
  5653. toHSVToRef(result: Color3): void;
  5654. /**
  5655. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5656. * @param convertedColor defines the Color3 object where to store the linear space version
  5657. * @returns the unmodified Color3
  5658. */
  5659. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5660. /**
  5661. * Computes a new Color3 converted from the current one to gamma space
  5662. * @returns a new Color3 object
  5663. */
  5664. toGammaSpace(): Color3;
  5665. /**
  5666. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5667. * @param convertedColor defines the Color3 object where to store the gamma space version
  5668. * @returns the unmodified Color3
  5669. */
  5670. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5671. private static _BlackReadOnly;
  5672. /**
  5673. * Convert Hue, saturation and value to a Color3 (RGB)
  5674. * @param hue defines the hue
  5675. * @param saturation defines the saturation
  5676. * @param value defines the value
  5677. * @param result defines the Color3 where to store the RGB values
  5678. */
  5679. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5680. /**
  5681. * Creates a new Color3 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromHexString(hex: string): Color3;
  5686. /**
  5687. * Creates a new Color3 from the starting index of the given array
  5688. * @param array defines the source array
  5689. * @param offset defines an offset in the source array
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5693. /**
  5694. * Creates a new Color3 from integer values (< 256)
  5695. * @param r defines the red component to read from (value between 0 and 255)
  5696. * @param g defines the green component to read from (value between 0 and 255)
  5697. * @param b defines the blue component to read from (value between 0 and 255)
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromInts(r: number, g: number, b: number): Color3;
  5701. /**
  5702. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5703. * @param start defines the start Color3 value
  5704. * @param end defines the end Color3 value
  5705. * @param amount defines the gradient value between start and end
  5706. * @returns a new Color3 object
  5707. */
  5708. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param left defines the start value
  5712. * @param right defines the end value
  5713. * @param amount defines the gradient factor
  5714. * @param result defines the Color3 object where to store the result
  5715. */
  5716. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5717. /**
  5718. * Returns a Color3 value containing a red color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Red(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a green color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Green(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a blue color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Blue(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a black color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Black(): Color3;
  5737. /**
  5738. * Gets a Color3 value containing a black color that must not be updated
  5739. */
  5740. static get BlackReadOnly(): DeepImmutable<Color3>;
  5741. /**
  5742. * Returns a Color3 value containing a white color
  5743. * @returns a new Color3 object
  5744. */
  5745. static White(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a purple color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Purple(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a magenta color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Magenta(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a yellow color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Yellow(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a gray color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Gray(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a teal color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Teal(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a random color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Random(): Color3;
  5776. }
  5777. /**
  5778. * Class used to hold a RBGA color
  5779. */
  5780. export class Color4 {
  5781. /**
  5782. * Defines the red component (between 0 and 1, default is 0)
  5783. */
  5784. r: number;
  5785. /**
  5786. * Defines the green component (between 0 and 1, default is 0)
  5787. */
  5788. g: number;
  5789. /**
  5790. * Defines the blue component (between 0 and 1, default is 0)
  5791. */
  5792. b: number;
  5793. /**
  5794. * Defines the alpha component (between 0 and 1, default is 1)
  5795. */
  5796. a: number;
  5797. /**
  5798. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5799. * @param r defines the red component (between 0 and 1, default is 0)
  5800. * @param g defines the green component (between 0 and 1, default is 0)
  5801. * @param b defines the blue component (between 0 and 1, default is 0)
  5802. * @param a defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. constructor(
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r?: number,
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g?: number,
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b?: number,
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a?: number);
  5821. /**
  5822. * Adds in place the given Color4 values to the current Color4 object
  5823. * @param right defines the second operand
  5824. * @returns the current updated Color4 object
  5825. */
  5826. addInPlace(right: DeepImmutable<Color4>): Color4;
  5827. /**
  5828. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5829. * @returns the new array
  5830. */
  5831. asArray(): number[];
  5832. /**
  5833. * Stores from the starting index in the given array the Color4 successive values
  5834. * @param array defines the array where to store the r,g,b components
  5835. * @param index defines an optional index in the target array to define where to start storing values
  5836. * @returns the current Color4 object
  5837. */
  5838. toArray(array: number[], index?: number): Color4;
  5839. /**
  5840. * Determines equality between Color4 objects
  5841. * @param otherColor defines the second operand
  5842. * @returns true if the rgba values are equal to the given ones
  5843. */
  5844. equals(otherColor: DeepImmutable<Color4>): boolean;
  5845. /**
  5846. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5847. * @param right defines the second operand
  5848. * @returns a new Color4 object
  5849. */
  5850. add(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5853. * @param right defines the second operand
  5854. * @returns a new Color4 object
  5855. */
  5856. subtract(right: DeepImmutable<Color4>): Color4;
  5857. /**
  5858. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5859. * @param right defines the second operand
  5860. * @param result defines the Color4 object where to store the result
  5861. * @returns the current Color4 object
  5862. */
  5863. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5864. /**
  5865. * Creates a new Color4 with the current Color4 values multiplied by scale
  5866. * @param scale defines the scaling factor to apply
  5867. * @returns a new Color4 object
  5868. */
  5869. scale(scale: number): Color4;
  5870. /**
  5871. * Multiplies the current Color4 values by scale and stores the result in "result"
  5872. * @param scale defines the scaling factor to apply
  5873. * @param result defines the Color4 object where to store the result
  5874. * @returns the current unmodified Color4
  5875. */
  5876. scaleToRef(scale: number, result: Color4): Color4;
  5877. /**
  5878. * Scale the current Color4 values by a factor and add the result to a given Color4
  5879. * @param scale defines the scale factor
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the unmodified current Color4
  5882. */
  5883. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Clamps the rgb values by the min and max values and stores the result into "result"
  5886. * @param min defines minimum clamping value (default is 0)
  5887. * @param max defines maximum clamping value (default is 1)
  5888. * @param result defines color to store the result into.
  5889. * @returns the cuurent Color4
  5890. */
  5891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5892. /**
  5893. * Multipy an Color4 value by another and return a new Color4 object
  5894. * @param color defines the Color4 value to multiply by
  5895. * @returns a new Color4 object
  5896. */
  5897. multiply(color: Color4): Color4;
  5898. /**
  5899. * Multipy a Color4 value by another and push the result in a reference value
  5900. * @param color defines the Color4 value to multiply by
  5901. * @param result defines the Color4 to fill the result in
  5902. * @returns the result Color4
  5903. */
  5904. multiplyToRef(color: Color4, result: Color4): Color4;
  5905. /**
  5906. * Creates a string with the Color4 current values
  5907. * @returns the string representation of the Color4 object
  5908. */
  5909. toString(): string;
  5910. /**
  5911. * Returns the string "Color4"
  5912. * @returns "Color4"
  5913. */
  5914. getClassName(): string;
  5915. /**
  5916. * Compute the Color4 hash code
  5917. * @returns an unique number that can be used to hash Color4 objects
  5918. */
  5919. getHashCode(): number;
  5920. /**
  5921. * Creates a new Color4 copied from the current one
  5922. * @returns a new Color4 object
  5923. */
  5924. clone(): Color4;
  5925. /**
  5926. * Copies the given Color4 values into the current one
  5927. * @param source defines the source Color4 object
  5928. * @returns the current updated Color4 object
  5929. */
  5930. copyFrom(source: Color4): Color4;
  5931. /**
  5932. * Copies the given float values into the current one
  5933. * @param r defines the red component to read from
  5934. * @param g defines the green component to read from
  5935. * @param b defines the blue component to read from
  5936. * @param a defines the alpha component to read from
  5937. * @returns the current updated Color4 object
  5938. */
  5939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5940. /**
  5941. * Copies the given float values into the current one
  5942. * @param r defines the red component to read from
  5943. * @param g defines the green component to read from
  5944. * @param b defines the blue component to read from
  5945. * @param a defines the alpha component to read from
  5946. * @returns the current updated Color4 object
  5947. */
  5948. set(r: number, g: number, b: number, a: number): Color4;
  5949. /**
  5950. * Compute the Color4 hexadecimal code as a string
  5951. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5952. * @returns a string containing the hexadecimal representation of the Color4 object
  5953. */
  5954. toHexString(returnAsColor3?: boolean): string;
  5955. /**
  5956. * Computes a new Color4 converted from the current one to linear space
  5957. * @returns a new Color4 object
  5958. */
  5959. toLinearSpace(): Color4;
  5960. /**
  5961. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5962. * @param convertedColor defines the Color4 object where to store the linear space version
  5963. * @returns the unmodified Color4
  5964. */
  5965. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5966. /**
  5967. * Computes a new Color4 converted from the current one to gamma space
  5968. * @returns a new Color4 object
  5969. */
  5970. toGammaSpace(): Color4;
  5971. /**
  5972. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5973. * @param convertedColor defines the Color4 object where to store the gamma space version
  5974. * @returns the unmodified Color4
  5975. */
  5976. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 from the string containing valid hexadecimal values
  5979. * @param hex defines a string containing valid hexadecimal values
  5980. * @returns a new Color4 object
  5981. */
  5982. static FromHexString(hex: string): Color4;
  5983. /**
  5984. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5985. * @param left defines the start value
  5986. * @param right defines the end value
  5987. * @param amount defines the gradient factor
  5988. * @returns a new Color4 object
  5989. */
  5990. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5991. /**
  5992. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @param result defines the Color4 object where to store data
  5997. */
  5998. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5999. /**
  6000. * Creates a new Color4 from a Color3 and an alpha value
  6001. * @param color3 defines the source Color3 to read from
  6002. * @param alpha defines the alpha component (1.0 by default)
  6003. * @returns a new Color4 object
  6004. */
  6005. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6006. /**
  6007. * Creates a new Color4 from the starting index element of the given array
  6008. * @param array defines the source array to read from
  6009. * @param offset defines the offset in the source array
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6013. /**
  6014. * Creates a new Color3 from integer values (< 256)
  6015. * @param r defines the red component to read from (value between 0 and 255)
  6016. * @param g defines the green component to read from (value between 0 and 255)
  6017. * @param b defines the blue component to read from (value between 0 and 255)
  6018. * @param a defines the alpha component to read from (value between 0 and 255)
  6019. * @returns a new Color3 object
  6020. */
  6021. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6022. /**
  6023. * Check the content of a given array and convert it to an array containing RGBA data
  6024. * If the original array was already containing count * 4 values then it is returned directly
  6025. * @param colors defines the array to check
  6026. * @param count defines the number of RGBA data to expect
  6027. * @returns an array containing count * 4 values (RGBA)
  6028. */
  6029. static CheckColors4(colors: number[], count: number): number[];
  6030. }
  6031. /**
  6032. * @hidden
  6033. */
  6034. export class TmpColors {
  6035. static Color3: Color3[];
  6036. static Color4: Color4[];
  6037. }
  6038. }
  6039. declare module "babylonjs/Animations/animationKey" {
  6040. /**
  6041. * Defines an interface which represents an animation key frame
  6042. */
  6043. export interface IAnimationKey {
  6044. /**
  6045. * Frame of the key frame
  6046. */
  6047. frame: number;
  6048. /**
  6049. * Value at the specifies key frame
  6050. */
  6051. value: any;
  6052. /**
  6053. * The input tangent for the cubic hermite spline
  6054. */
  6055. inTangent?: any;
  6056. /**
  6057. * The output tangent for the cubic hermite spline
  6058. */
  6059. outTangent?: any;
  6060. /**
  6061. * The animation interpolation type
  6062. */
  6063. interpolation?: AnimationKeyInterpolation;
  6064. }
  6065. /**
  6066. * Enum for the animation key frame interpolation type
  6067. */
  6068. export enum AnimationKeyInterpolation {
  6069. /**
  6070. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6071. */
  6072. STEP = 1
  6073. }
  6074. }
  6075. declare module "babylonjs/Animations/animationRange" {
  6076. /**
  6077. * Represents the range of an animation
  6078. */
  6079. export class AnimationRange {
  6080. /**The name of the animation range**/
  6081. name: string;
  6082. /**The starting frame of the animation */
  6083. from: number;
  6084. /**The ending frame of the animation*/
  6085. to: number;
  6086. /**
  6087. * Initializes the range of an animation
  6088. * @param name The name of the animation range
  6089. * @param from The starting frame of the animation
  6090. * @param to The ending frame of the animation
  6091. */
  6092. constructor(
  6093. /**The name of the animation range**/
  6094. name: string,
  6095. /**The starting frame of the animation */
  6096. from: number,
  6097. /**The ending frame of the animation*/
  6098. to: number);
  6099. /**
  6100. * Makes a copy of the animation range
  6101. * @returns A copy of the animation range
  6102. */
  6103. clone(): AnimationRange;
  6104. }
  6105. }
  6106. declare module "babylonjs/Animations/animationEvent" {
  6107. /**
  6108. * Composed of a frame, and an action function
  6109. */
  6110. export class AnimationEvent {
  6111. /** The frame for which the event is triggered **/
  6112. frame: number;
  6113. /** The event to perform when triggered **/
  6114. action: (currentFrame: number) => void;
  6115. /** Specifies if the event should be triggered only once**/
  6116. onlyOnce?: boolean | undefined;
  6117. /**
  6118. * Specifies if the animation event is done
  6119. */
  6120. isDone: boolean;
  6121. /**
  6122. * Initializes the animation event
  6123. * @param frame The frame for which the event is triggered
  6124. * @param action The event to perform when triggered
  6125. * @param onlyOnce Specifies if the event should be triggered only once
  6126. */
  6127. constructor(
  6128. /** The frame for which the event is triggered **/
  6129. frame: number,
  6130. /** The event to perform when triggered **/
  6131. action: (currentFrame: number) => void,
  6132. /** Specifies if the event should be triggered only once**/
  6133. onlyOnce?: boolean | undefined);
  6134. /** @hidden */
  6135. _clone(): AnimationEvent;
  6136. }
  6137. }
  6138. declare module "babylonjs/Behaviors/behavior" {
  6139. import { Nullable } from "babylonjs/types";
  6140. /**
  6141. * Interface used to define a behavior
  6142. */
  6143. export interface Behavior<T> {
  6144. /** gets or sets behavior's name */
  6145. name: string;
  6146. /**
  6147. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6148. */
  6149. init(): void;
  6150. /**
  6151. * Called when the behavior is attached to a target
  6152. * @param target defines the target where the behavior is attached to
  6153. */
  6154. attach(target: T): void;
  6155. /**
  6156. * Called when the behavior is detached from its target
  6157. */
  6158. detach(): void;
  6159. }
  6160. /**
  6161. * Interface implemented by classes supporting behaviors
  6162. */
  6163. export interface IBehaviorAware<T> {
  6164. /**
  6165. * Attach a behavior
  6166. * @param behavior defines the behavior to attach
  6167. * @returns the current host
  6168. */
  6169. addBehavior(behavior: Behavior<T>): T;
  6170. /**
  6171. * Remove a behavior from the current object
  6172. * @param behavior defines the behavior to detach
  6173. * @returns the current host
  6174. */
  6175. removeBehavior(behavior: Behavior<T>): T;
  6176. /**
  6177. * Gets a behavior using its name to search
  6178. * @param name defines the name to search
  6179. * @returns the behavior or null if not found
  6180. */
  6181. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6182. }
  6183. }
  6184. declare module "babylonjs/Misc/smartArray" {
  6185. /**
  6186. * Defines an array and its length.
  6187. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6188. */
  6189. export interface ISmartArrayLike<T> {
  6190. /**
  6191. * The data of the array.
  6192. */
  6193. data: Array<T>;
  6194. /**
  6195. * The active length of the array.
  6196. */
  6197. length: number;
  6198. }
  6199. /**
  6200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6201. */
  6202. export class SmartArray<T> implements ISmartArrayLike<T> {
  6203. /**
  6204. * The full set of data from the array.
  6205. */
  6206. data: Array<T>;
  6207. /**
  6208. * The active length of the array.
  6209. */
  6210. length: number;
  6211. protected _id: number;
  6212. /**
  6213. * Instantiates a Smart Array.
  6214. * @param capacity defines the default capacity of the array.
  6215. */
  6216. constructor(capacity: number);
  6217. /**
  6218. * Pushes a value at the end of the active data.
  6219. * @param value defines the object to push in the array.
  6220. */
  6221. push(value: T): void;
  6222. /**
  6223. * Iterates over the active data and apply the lambda to them.
  6224. * @param func defines the action to apply on each value.
  6225. */
  6226. forEach(func: (content: T) => void): void;
  6227. /**
  6228. * Sorts the full sets of data.
  6229. * @param compareFn defines the comparison function to apply.
  6230. */
  6231. sort(compareFn: (a: T, b: T) => number): void;
  6232. /**
  6233. * Resets the active data to an empty array.
  6234. */
  6235. reset(): void;
  6236. /**
  6237. * Releases all the data from the array as well as the array.
  6238. */
  6239. dispose(): void;
  6240. /**
  6241. * Concats the active data with a given array.
  6242. * @param array defines the data to concatenate with.
  6243. */
  6244. concat(array: any): void;
  6245. /**
  6246. * Returns the position of a value in the active data.
  6247. * @param value defines the value to find the index for
  6248. * @returns the index if found in the active data otherwise -1
  6249. */
  6250. indexOf(value: T): number;
  6251. /**
  6252. * Returns whether an element is part of the active data.
  6253. * @param value defines the value to look for
  6254. * @returns true if found in the active data otherwise false
  6255. */
  6256. contains(value: T): boolean;
  6257. private static _GlobalId;
  6258. }
  6259. /**
  6260. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6261. * The data in this array can only be present once
  6262. */
  6263. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6264. private _duplicateId;
  6265. /**
  6266. * Pushes a value at the end of the active data.
  6267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6268. * @param value defines the object to push in the array.
  6269. */
  6270. push(value: T): void;
  6271. /**
  6272. * Pushes a value at the end of the active data.
  6273. * If the data is already present, it won t be added again
  6274. * @param value defines the object to push in the array.
  6275. * @returns true if added false if it was already present
  6276. */
  6277. pushNoDuplicate(value: T): boolean;
  6278. /**
  6279. * Resets the active data to an empty array.
  6280. */
  6281. reset(): void;
  6282. /**
  6283. * Concats the active data with a given array.
  6284. * This ensures no dupplicate will be present in the result.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concatWithNoDuplicate(array: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Cameras/cameraInputsManager" {
  6291. import { Nullable } from "babylonjs/types";
  6292. import { Camera } from "babylonjs/Cameras/camera";
  6293. /**
  6294. * @ignore
  6295. * This is a list of all the different input types that are available in the application.
  6296. * Fo instance: ArcRotateCameraGamepadInput...
  6297. */
  6298. export var CameraInputTypes: {};
  6299. /**
  6300. * This is the contract to implement in order to create a new input class.
  6301. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6302. */
  6303. export interface ICameraInput<TCamera extends Camera> {
  6304. /**
  6305. * Defines the camera the input is attached to.
  6306. */
  6307. camera: Nullable<TCamera>;
  6308. /**
  6309. * Gets the class name of the current intput.
  6310. * @returns the class name
  6311. */
  6312. getClassName(): string;
  6313. /**
  6314. * Get the friendly name associated with the input class.
  6315. * @returns the input friendly name
  6316. */
  6317. getSimpleName(): string;
  6318. /**
  6319. * Attach the input controls to a specific dom element to get the input from.
  6320. * @param element Defines the element the controls should be listened from
  6321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6322. */
  6323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6324. /**
  6325. * Detach the current controls from the specified dom element.
  6326. * @param element Defines the element to stop listening the inputs from
  6327. */
  6328. detachControl(element: Nullable<HTMLElement>): void;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs?: () => void;
  6334. }
  6335. /**
  6336. * Represents a map of input types to input instance or input index to input instance.
  6337. */
  6338. export interface CameraInputsMap<TCamera extends Camera> {
  6339. /**
  6340. * Accessor to the input by input type.
  6341. */
  6342. [name: string]: ICameraInput<TCamera>;
  6343. /**
  6344. * Accessor to the input by input index.
  6345. */
  6346. [idx: number]: ICameraInput<TCamera>;
  6347. }
  6348. /**
  6349. * This represents the input manager used within a camera.
  6350. * It helps dealing with all the different kind of input attached to a camera.
  6351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6352. */
  6353. export class CameraInputsManager<TCamera extends Camera> {
  6354. /**
  6355. * Defines the list of inputs attahed to the camera.
  6356. */
  6357. attached: CameraInputsMap<TCamera>;
  6358. /**
  6359. * Defines the dom element the camera is collecting inputs from.
  6360. * This is null if the controls have not been attached.
  6361. */
  6362. attachedElement: Nullable<HTMLElement>;
  6363. /**
  6364. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. noPreventDefault: boolean;
  6367. /**
  6368. * Defined the camera the input manager belongs to.
  6369. */
  6370. camera: TCamera;
  6371. /**
  6372. * Update the current camera state depending on the inputs that have been used this frame.
  6373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6374. */
  6375. checkInputs: () => void;
  6376. /**
  6377. * Instantiate a new Camera Input Manager.
  6378. * @param camera Defines the camera the input manager blongs to
  6379. */
  6380. constructor(camera: TCamera);
  6381. /**
  6382. * Add an input method to a camera
  6383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6384. * @param input camera input method
  6385. */
  6386. add(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Remove a specific input method from a camera
  6389. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6390. * @param inputToRemove camera input method
  6391. */
  6392. remove(inputToRemove: ICameraInput<TCamera>): void;
  6393. /**
  6394. * Remove a specific input type from a camera
  6395. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6396. * @param inputType the type of the input to remove
  6397. */
  6398. removeByType(inputType: string): void;
  6399. private _addCheckInputs;
  6400. /**
  6401. * Attach the input controls to the currently attached dom element to listen the events from.
  6402. * @param input Defines the input to attach
  6403. */
  6404. attachInput(input: ICameraInput<TCamera>): void;
  6405. /**
  6406. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6407. * @param element Defines the dom element to collect the events from
  6408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6409. */
  6410. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6411. /**
  6412. * Detach the current manager inputs controls from a specific dom element.
  6413. * @param element Defines the dom element to collect the events from
  6414. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6415. */
  6416. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6417. /**
  6418. * Rebuild the dynamic inputCheck function from the current list of
  6419. * defined inputs in the manager.
  6420. */
  6421. rebuildInputCheck(): void;
  6422. /**
  6423. * Remove all attached input methods from a camera
  6424. */
  6425. clear(): void;
  6426. /**
  6427. * Serialize the current input manager attached to a camera.
  6428. * This ensures than once parsed,
  6429. * the input associated to the camera will be identical to the current ones
  6430. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6431. */
  6432. serialize(serializedCamera: any): void;
  6433. /**
  6434. * Parses an input manager serialized JSON to restore the previous list of inputs
  6435. * and states associated to a camera.
  6436. * @param parsedCamera Defines the JSON to parse
  6437. */
  6438. parse(parsedCamera: any): void;
  6439. }
  6440. }
  6441. declare module "babylonjs/Meshes/buffer" {
  6442. import { Nullable, DataArray } from "babylonjs/types";
  6443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6444. /**
  6445. * Class used to store data that will be store in GPU memory
  6446. */
  6447. export class Buffer {
  6448. private _engine;
  6449. private _buffer;
  6450. /** @hidden */
  6451. _data: Nullable<DataArray>;
  6452. private _updatable;
  6453. private _instanced;
  6454. private _divisor;
  6455. /**
  6456. * Gets the byte stride.
  6457. */
  6458. readonly byteStride: number;
  6459. /**
  6460. * Constructor
  6461. * @param engine the engine
  6462. * @param data the data to use for this buffer
  6463. * @param updatable whether the data is updatable
  6464. * @param stride the stride (optional)
  6465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param useBytes set to true if the stride in in bytes (optional)
  6468. * @param divisor sets an optional divisor for instances (1 by default)
  6469. */
  6470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6471. /**
  6472. * Create a new VertexBuffer based on the current buffer
  6473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6474. * @param offset defines offset in the buffer (0 by default)
  6475. * @param size defines the size in floats of attributes (position is 3 for instance)
  6476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6477. * @param instanced defines if the vertex buffer contains indexed data
  6478. * @param useBytes defines if the offset and stride are in bytes *
  6479. * @param divisor sets an optional divisor for instances (1 by default)
  6480. * @returns the new vertex buffer
  6481. */
  6482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6483. /**
  6484. * Gets a boolean indicating if the Buffer is updatable?
  6485. * @returns true if the buffer is updatable
  6486. */
  6487. isUpdatable(): boolean;
  6488. /**
  6489. * Gets current buffer's data
  6490. * @returns a DataArray or null
  6491. */
  6492. getData(): Nullable<DataArray>;
  6493. /**
  6494. * Gets underlying native buffer
  6495. * @returns underlying native buffer
  6496. */
  6497. getBuffer(): Nullable<DataBuffer>;
  6498. /**
  6499. * Gets the stride in float32 units (i.e. byte stride / 4).
  6500. * May not be an integer if the byte stride is not divisible by 4.
  6501. * @returns the stride in float32 units
  6502. * @deprecated Please use byteStride instead.
  6503. */
  6504. getStrideSize(): number;
  6505. /**
  6506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6507. * @param data defines the data to store
  6508. */
  6509. create(data?: Nullable<DataArray>): void;
  6510. /** @hidden */
  6511. _rebuild(): void;
  6512. /**
  6513. * Update current buffer data
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates the data directly.
  6519. * @param data the new data
  6520. * @param offset the new offset
  6521. * @param vertexCount the vertex count (optional)
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6525. /**
  6526. * Release all resources
  6527. */
  6528. dispose(): void;
  6529. }
  6530. /**
  6531. * Specialized buffer used to store vertex data
  6532. */
  6533. export class VertexBuffer {
  6534. /** @hidden */
  6535. _buffer: Buffer;
  6536. private _kind;
  6537. private _size;
  6538. private _ownsBuffer;
  6539. private _instanced;
  6540. private _instanceDivisor;
  6541. /**
  6542. * The byte type.
  6543. */
  6544. static readonly BYTE: number;
  6545. /**
  6546. * The unsigned byte type.
  6547. */
  6548. static readonly UNSIGNED_BYTE: number;
  6549. /**
  6550. * The short type.
  6551. */
  6552. static readonly SHORT: number;
  6553. /**
  6554. * The unsigned short type.
  6555. */
  6556. static readonly UNSIGNED_SHORT: number;
  6557. /**
  6558. * The integer type.
  6559. */
  6560. static readonly INT: number;
  6561. /**
  6562. * The unsigned integer type.
  6563. */
  6564. static readonly UNSIGNED_INT: number;
  6565. /**
  6566. * The float type.
  6567. */
  6568. static readonly FLOAT: number;
  6569. /**
  6570. * Gets or sets the instance divisor when in instanced mode
  6571. */
  6572. get instanceDivisor(): number;
  6573. set instanceDivisor(value: number);
  6574. /**
  6575. * Gets the byte stride.
  6576. */
  6577. readonly byteStride: number;
  6578. /**
  6579. * Gets the byte offset.
  6580. */
  6581. readonly byteOffset: number;
  6582. /**
  6583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6584. */
  6585. readonly normalized: boolean;
  6586. /**
  6587. * Gets the data type of each component in the array.
  6588. */
  6589. readonly type: number;
  6590. /**
  6591. * Constructor
  6592. * @param engine the engine
  6593. * @param data the data to use for this vertex buffer
  6594. * @param kind the vertex buffer kind
  6595. * @param updatable whether the data is updatable
  6596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6597. * @param stride the stride (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param offset the offset of the data (optional)
  6600. * @param size the number of components (optional)
  6601. * @param type the type of the component (optional)
  6602. * @param normalized whether the data contains normalized data (optional)
  6603. * @param useBytes set to true if stride and offset are in bytes (optional)
  6604. * @param divisor defines the instance divisor to use (1 by default)
  6605. */
  6606. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6607. /** @hidden */
  6608. _rebuild(): void;
  6609. /**
  6610. * Returns the kind of the VertexBuffer (string)
  6611. * @returns a string
  6612. */
  6613. getKind(): string;
  6614. /**
  6615. * Gets a boolean indicating if the VertexBuffer is updatable?
  6616. * @returns true if the buffer is updatable
  6617. */
  6618. isUpdatable(): boolean;
  6619. /**
  6620. * Gets current buffer's data
  6621. * @returns a DataArray or null
  6622. */
  6623. getData(): Nullable<DataArray>;
  6624. /**
  6625. * Gets underlying native buffer
  6626. * @returns underlying native buffer
  6627. */
  6628. getBuffer(): Nullable<DataBuffer>;
  6629. /**
  6630. * Gets the stride in float32 units (i.e. byte stride / 4).
  6631. * May not be an integer if the byte stride is not divisible by 4.
  6632. * @returns the stride in float32 units
  6633. * @deprecated Please use byteStride instead.
  6634. */
  6635. getStrideSize(): number;
  6636. /**
  6637. * Returns the offset as a multiple of the type byte length.
  6638. * @returns the offset in bytes
  6639. * @deprecated Please use byteOffset instead.
  6640. */
  6641. getOffset(): number;
  6642. /**
  6643. * Returns the number of components per vertex attribute (integer)
  6644. * @returns the size in float
  6645. */
  6646. getSize(): number;
  6647. /**
  6648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6649. * @returns true if this buffer is instanced
  6650. */
  6651. getIsInstanced(): boolean;
  6652. /**
  6653. * Returns the instancing divisor, zero for non-instanced (integer).
  6654. * @returns a number
  6655. */
  6656. getInstanceDivisor(): number;
  6657. /**
  6658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6659. * @param data defines the data to store
  6660. */
  6661. create(data?: DataArray): void;
  6662. /**
  6663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6664. * This function will create a new buffer if the current one is not updatable
  6665. * @param data defines the data to store
  6666. */
  6667. update(data: DataArray): void;
  6668. /**
  6669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6670. * Returns the directly updated WebGLBuffer.
  6671. * @param data the new data
  6672. * @param offset the new offset
  6673. * @param useBytes set to true if the offset is in bytes
  6674. */
  6675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6676. /**
  6677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6678. */
  6679. dispose(): void;
  6680. /**
  6681. * Enumerates each value of this vertex buffer as numbers.
  6682. * @param count the number of values to enumerate
  6683. * @param callback the callback function called for each value
  6684. */
  6685. forEach(count: number, callback: (value: number, index: number) => void): void;
  6686. /**
  6687. * Positions
  6688. */
  6689. static readonly PositionKind: string;
  6690. /**
  6691. * Normals
  6692. */
  6693. static readonly NormalKind: string;
  6694. /**
  6695. * Tangents
  6696. */
  6697. static readonly TangentKind: string;
  6698. /**
  6699. * Texture coordinates
  6700. */
  6701. static readonly UVKind: string;
  6702. /**
  6703. * Texture coordinates 2
  6704. */
  6705. static readonly UV2Kind: string;
  6706. /**
  6707. * Texture coordinates 3
  6708. */
  6709. static readonly UV3Kind: string;
  6710. /**
  6711. * Texture coordinates 4
  6712. */
  6713. static readonly UV4Kind: string;
  6714. /**
  6715. * Texture coordinates 5
  6716. */
  6717. static readonly UV5Kind: string;
  6718. /**
  6719. * Texture coordinates 6
  6720. */
  6721. static readonly UV6Kind: string;
  6722. /**
  6723. * Colors
  6724. */
  6725. static readonly ColorKind: string;
  6726. /**
  6727. * Matrix indices (for bones)
  6728. */
  6729. static readonly MatricesIndicesKind: string;
  6730. /**
  6731. * Matrix weights (for bones)
  6732. */
  6733. static readonly MatricesWeightsKind: string;
  6734. /**
  6735. * Additional matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesExtraKind: string;
  6738. /**
  6739. * Additional matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsExtraKind: string;
  6742. /**
  6743. * Deduces the stride given a kind.
  6744. * @param kind The kind string to deduce
  6745. * @returns The deduced stride
  6746. */
  6747. static DeduceStride(kind: string): number;
  6748. /**
  6749. * Gets the byte length of the given type.
  6750. * @param type the type
  6751. * @returns the number of bytes
  6752. */
  6753. static GetTypeByteLength(type: number): number;
  6754. /**
  6755. * Enumerates each value of the given parameters as numbers.
  6756. * @param data the data to enumerate
  6757. * @param byteOffset the byte offset of the data
  6758. * @param byteStride the byte stride of the data
  6759. * @param componentCount the number of components per element
  6760. * @param componentType the type of the component
  6761. * @param count the number of values to enumerate
  6762. * @param normalized whether the data is normalized
  6763. * @param callback the callback function called for each value
  6764. */
  6765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6766. private static _GetFloatValue;
  6767. }
  6768. }
  6769. declare module "babylonjs/Collisions/intersectionInfo" {
  6770. import { Nullable } from "babylonjs/types";
  6771. /**
  6772. * @hidden
  6773. */
  6774. export class IntersectionInfo {
  6775. bu: Nullable<number>;
  6776. bv: Nullable<number>;
  6777. distance: number;
  6778. faceId: number;
  6779. subMeshId: number;
  6780. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6781. }
  6782. }
  6783. declare module "babylonjs/Culling/boundingSphere" {
  6784. import { DeepImmutable } from "babylonjs/types";
  6785. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6786. import { Plane } from "babylonjs/Maths/math.plane";
  6787. /**
  6788. * Class used to store bounding sphere information
  6789. */
  6790. export class BoundingSphere {
  6791. /**
  6792. * Gets the center of the bounding sphere in local space
  6793. */
  6794. readonly center: Vector3;
  6795. /**
  6796. * Radius of the bounding sphere in local space
  6797. */
  6798. radius: number;
  6799. /**
  6800. * Gets the center of the bounding sphere in world space
  6801. */
  6802. readonly centerWorld: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in world space
  6805. */
  6806. radiusWorld: number;
  6807. /**
  6808. * Gets the minimum vector in local space
  6809. */
  6810. readonly minimum: Vector3;
  6811. /**
  6812. * Gets the maximum vector in local space
  6813. */
  6814. readonly maximum: Vector3;
  6815. private _worldMatrix;
  6816. private static readonly TmpVector3;
  6817. /**
  6818. * Creates a new bounding sphere
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6824. /**
  6825. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6826. * @param min defines the new minimum vector (in local space)
  6827. * @param max defines the new maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Scale the current bounding sphere by applying a scale factor
  6833. * @param factor defines the scale factor to apply
  6834. * @returns the current bounding box
  6835. */
  6836. scale(factor: number): BoundingSphere;
  6837. /**
  6838. * Gets the world matrix of the bounding box
  6839. * @returns a matrix
  6840. */
  6841. getWorldMatrix(): DeepImmutable<Matrix>;
  6842. /** @hidden */
  6843. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Tests if the bounding sphere is intersecting the frustum planes
  6846. * @param frustumPlanes defines the frustum planes to test
  6847. * @returns true if there is an intersection
  6848. */
  6849. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6850. /**
  6851. * Tests if the bounding sphere center is in between the frustum planes.
  6852. * Used for optimistic fast inclusion.
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if the sphere center is in between the frustum planes
  6855. */
  6856. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if a point is inside the bounding sphere
  6859. * @param point defines the point to test
  6860. * @returns true if the point is inside the bounding sphere
  6861. */
  6862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Checks if two sphere intersct
  6865. * @param sphere0 sphere 0
  6866. * @param sphere1 sphere 1
  6867. * @returns true if the speres intersect
  6868. */
  6869. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingBox" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6876. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6877. import { Plane } from "babylonjs/Maths/math.plane";
  6878. /**
  6879. * Class used to store bounding box information
  6880. */
  6881. export class BoundingBox implements ICullable {
  6882. /**
  6883. * Gets the 8 vectors representing the bounding box in local space
  6884. */
  6885. readonly vectors: Vector3[];
  6886. /**
  6887. * Gets the center of the bounding box in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Gets the center of the bounding box in world space
  6892. */
  6893. readonly centerWorld: Vector3;
  6894. /**
  6895. * Gets the extend size in local space
  6896. */
  6897. readonly extendSize: Vector3;
  6898. /**
  6899. * Gets the extend size in world space
  6900. */
  6901. readonly extendSizeWorld: Vector3;
  6902. /**
  6903. * Gets the OBB (object bounding box) directions
  6904. */
  6905. readonly directions: Vector3[];
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in world space
  6908. */
  6909. readonly vectorsWorld: Vector3[];
  6910. /**
  6911. * Gets the minimum vector in world space
  6912. */
  6913. readonly minimumWorld: Vector3;
  6914. /**
  6915. * Gets the maximum vector in world space
  6916. */
  6917. readonly maximumWorld: Vector3;
  6918. /**
  6919. * Gets the minimum vector in local space
  6920. */
  6921. readonly minimum: Vector3;
  6922. /**
  6923. * Gets the maximum vector in local space
  6924. */
  6925. readonly maximum: Vector3;
  6926. private _worldMatrix;
  6927. private static readonly TmpVector3;
  6928. /**
  6929. * @hidden
  6930. */
  6931. _tag: number;
  6932. /**
  6933. * Creates a new bounding box
  6934. * @param min defines the minimum vector (in local space)
  6935. * @param max defines the maximum vector (in local space)
  6936. * @param worldMatrix defines the new world matrix
  6937. */
  6938. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6939. /**
  6940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6941. * @param min defines the new minimum vector (in local space)
  6942. * @param max defines the new maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Scale the current bounding box by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding box
  6950. */
  6951. scale(factor: number): BoundingBox;
  6952. /**
  6953. * Gets the world matrix of the bounding box
  6954. * @returns a matrix
  6955. */
  6956. getWorldMatrix(): DeepImmutable<Matrix>;
  6957. /** @hidden */
  6958. _update(world: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Tests if the bounding box is intersecting the frustum planes
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @returns true if there is an intersection
  6963. */
  6964. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. /**
  6966. * Tests if the bounding box is entirely inside the frustum planes
  6967. * @param frustumPlanes defines the frustum planes to test
  6968. * @returns true if there is an inclusion
  6969. */
  6970. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6971. /**
  6972. * Tests if a point is inside the bounding box
  6973. * @param point defines the point to test
  6974. * @returns true if the point is inside the bounding box
  6975. */
  6976. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6977. /**
  6978. * Tests if the bounding box intersects with a bounding sphere
  6979. * @param sphere defines the sphere to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6983. /**
  6984. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6985. * @param min defines the min vector to use
  6986. * @param max defines the max vector to use
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if two bounding boxes are intersections
  6992. * @param box0 defines the first box to test
  6993. * @param box1 defines the second box to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6997. /**
  6998. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6999. * @param minPoint defines the minimum vector of the bounding box
  7000. * @param maxPoint defines the maximum vector of the bounding box
  7001. * @param sphereCenter defines the sphere center
  7002. * @param sphereRadius defines the sphere radius
  7003. * @returns true if there is an intersection
  7004. */
  7005. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7006. /**
  7007. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @return true if there is an inclusion
  7011. */
  7012. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an intersection
  7018. */
  7019. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. }
  7021. }
  7022. declare module "babylonjs/Collisions/collider" {
  7023. import { Nullable, IndicesArray } from "babylonjs/types";
  7024. import { Vector3 } from "babylonjs/Maths/math.vector";
  7025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7026. import { Plane } from "babylonjs/Maths/math.plane";
  7027. /** @hidden */
  7028. export class Collider {
  7029. /** Define if a collision was found */
  7030. collisionFound: boolean;
  7031. /**
  7032. * Define last intersection point in local space
  7033. */
  7034. intersectionPoint: Vector3;
  7035. /**
  7036. * Define last collided mesh
  7037. */
  7038. collidedMesh: Nullable<AbstractMesh>;
  7039. private _collisionPoint;
  7040. private _planeIntersectionPoint;
  7041. private _tempVector;
  7042. private _tempVector2;
  7043. private _tempVector3;
  7044. private _tempVector4;
  7045. private _edge;
  7046. private _baseToVertex;
  7047. private _destinationPoint;
  7048. private _slidePlaneNormal;
  7049. private _displacementVector;
  7050. /** @hidden */
  7051. _radius: Vector3;
  7052. /** @hidden */
  7053. _retry: number;
  7054. private _velocity;
  7055. private _basePoint;
  7056. private _epsilon;
  7057. /** @hidden */
  7058. _velocityWorldLength: number;
  7059. /** @hidden */
  7060. _basePointWorld: Vector3;
  7061. private _velocityWorld;
  7062. private _normalizedVelocity;
  7063. /** @hidden */
  7064. _initialVelocity: Vector3;
  7065. /** @hidden */
  7066. _initialPosition: Vector3;
  7067. private _nearestDistance;
  7068. private _collisionMask;
  7069. get collisionMask(): number;
  7070. set collisionMask(mask: number);
  7071. /**
  7072. * Gets the plane normal used to compute the sliding response (in local space)
  7073. */
  7074. get slidePlaneNormal(): Vector3;
  7075. /** @hidden */
  7076. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7077. /** @hidden */
  7078. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */
  7080. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7081. /** @hidden */
  7082. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7083. /** @hidden */
  7084. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7085. /** @hidden */
  7086. _getResponse(pos: Vector3, vel: Vector3): void;
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingInfo" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7092. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7093. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7094. import { Plane } from "babylonjs/Maths/math.plane";
  7095. import { Collider } from "babylonjs/Collisions/collider";
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. get minimum(): Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. get maximum(): Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. get isLocked(): boolean;
  7155. set isLocked(value: boolean);
  7156. /**
  7157. * Updates the bounding sphere and box
  7158. * @param world world matrix to be used to update
  7159. */
  7160. update(world: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7163. * @param center New center of the bounding info
  7164. * @param extend New extend of the bounding info
  7165. * @returns the current bounding info
  7166. */
  7167. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7168. /**
  7169. * Scale the current bounding info by applying a scale factor
  7170. * @param factor defines the scale factor to apply
  7171. * @returns the current bounding info
  7172. */
  7173. scale(factor: number): BoundingInfo;
  7174. /**
  7175. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7176. * @param frustumPlanes defines the frustum to test
  7177. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7178. * @returns true if the bounding info is in the frustum planes
  7179. */
  7180. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7181. /**
  7182. * Gets the world distance between the min and max points of the bounding box
  7183. */
  7184. get diagonalLength(): number;
  7185. /**
  7186. * Checks if a cullable object (mesh...) is in the camera frustum
  7187. * Unlike isInFrustum this cheks the full bounding box
  7188. * @param frustumPlanes Camera near/planes
  7189. * @returns true if the object is in frustum otherwise false
  7190. */
  7191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /** @hidden */
  7193. _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module "babylonjs/Maths/math.functions" {
  7212. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7214. /**
  7215. * Extracts minimum and maximum values from a list of indexed positions
  7216. * @param positions defines the positions to use
  7217. * @param indices defines the indices to the positions
  7218. * @param indexStart defines the start index
  7219. * @param indexCount defines the end index
  7220. * @param bias defines bias value to add to the result
  7221. * @return minimum and maximum values
  7222. */
  7223. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7224. minimum: Vector3;
  7225. maximum: Vector3;
  7226. };
  7227. /**
  7228. * Extracts minimum and maximum values from a list of positions
  7229. * @param positions defines the positions to use
  7230. * @param start defines the start index in the positions array
  7231. * @param count defines the number of positions to handle
  7232. * @param bias defines bias value to add to the result
  7233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7234. * @return minimum and maximum values
  7235. */
  7236. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7237. minimum: Vector3;
  7238. maximum: Vector3;
  7239. };
  7240. }
  7241. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7243. /** @hidden */
  7244. export class WebGLDataBuffer extends DataBuffer {
  7245. private _buffer;
  7246. constructor(resource: WebGLBuffer);
  7247. get underlyingResource(): any;
  7248. }
  7249. }
  7250. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. import { Nullable } from "babylonjs/types";
  7253. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7254. /** @hidden */
  7255. export class WebGLPipelineContext implements IPipelineContext {
  7256. engine: ThinEngine;
  7257. program: Nullable<WebGLProgram>;
  7258. context?: WebGLRenderingContext;
  7259. vertexShader?: WebGLShader;
  7260. fragmentShader?: WebGLShader;
  7261. isParallelCompiled: boolean;
  7262. onCompiled?: () => void;
  7263. transformFeedback?: WebGLTransformFeedback | null;
  7264. vertexCompilationError: Nullable<string>;
  7265. fragmentCompilationError: Nullable<string>;
  7266. programLinkError: Nullable<string>;
  7267. programValidationError: Nullable<string>;
  7268. get isAsync(): boolean;
  7269. get isReady(): boolean;
  7270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7271. _getVertexShaderCode(): string | null;
  7272. _getFragmentShaderCode(): string | null;
  7273. }
  7274. }
  7275. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7276. import { FloatArray, Nullable } from "babylonjs/types";
  7277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7279. module "babylonjs/Engines/thinEngine" {
  7280. interface ThinEngine {
  7281. /**
  7282. * Create an uniform buffer
  7283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7284. * @param elements defines the content of the uniform buffer
  7285. * @returns the webGL uniform buffer
  7286. */
  7287. createUniformBuffer(elements: FloatArray): DataBuffer;
  7288. /**
  7289. * Create a dynamic uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Update an existing uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param uniformBuffer defines the target uniform buffer
  7299. * @param elements defines the content to update
  7300. * @param offset defines the offset in the uniform buffer where update should start
  7301. * @param count defines the size of the data to update
  7302. */
  7303. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7304. /**
  7305. * Bind an uniform buffer to the current webGL context
  7306. * @param buffer defines the buffer to bind
  7307. */
  7308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7309. /**
  7310. * Bind a buffer to the current webGL context at a given location
  7311. * @param buffer defines the buffer to bind
  7312. * @param location defines the index where to bind the buffer
  7313. */
  7314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7315. /**
  7316. * Bind a specific block at a given index in a specific shader program
  7317. * @param pipelineContext defines the pipeline context to use
  7318. * @param blockName defines the block name
  7319. * @param index defines the index where to bind the block
  7320. */
  7321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7322. }
  7323. }
  7324. }
  7325. declare module "babylonjs/Materials/uniformBuffer" {
  7326. import { Nullable, FloatArray } from "babylonjs/types";
  7327. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7328. import { Engine } from "babylonjs/Engines/engine";
  7329. import { Effect } from "babylonjs/Materials/effect";
  7330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7332. import { Color3 } from "babylonjs/Maths/math.color";
  7333. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7334. /**
  7335. * Uniform buffer objects.
  7336. *
  7337. * Handles blocks of uniform on the GPU.
  7338. *
  7339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7340. *
  7341. * For more information, please refer to :
  7342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7343. */
  7344. export class UniformBuffer {
  7345. private _engine;
  7346. private _buffer;
  7347. private _data;
  7348. private _bufferData;
  7349. private _dynamic?;
  7350. private _uniformLocations;
  7351. private _uniformSizes;
  7352. private _uniformLocationPointer;
  7353. private _needSync;
  7354. private _noUBO;
  7355. private _currentEffect;
  7356. /** @hidden */
  7357. _alreadyBound: boolean;
  7358. private static _MAX_UNIFORM_SIZE;
  7359. private static _tempBuffer;
  7360. /**
  7361. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7362. * This is dynamic to allow compat with webgl 1 and 2.
  7363. * You will need to pass the name of the uniform as well as the value.
  7364. */
  7365. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7366. /**
  7367. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7368. * This is dynamic to allow compat with webgl 1 and 2.
  7369. * You will need to pass the name of the uniform as well as the value.
  7370. */
  7371. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7372. /**
  7373. * Lambda to Update a single float in a uniform buffer.
  7374. * This is dynamic to allow compat with webgl 1 and 2.
  7375. * You will need to pass the name of the uniform as well as the value.
  7376. */
  7377. updateFloat: (name: string, x: number) => void;
  7378. /**
  7379. * Lambda to Update a vec2 of float in a uniform buffer.
  7380. * This is dynamic to allow compat with webgl 1 and 2.
  7381. * You will need to pass the name of the uniform as well as the value.
  7382. */
  7383. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7384. /**
  7385. * Lambda to Update a vec3 of float in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7390. /**
  7391. * Lambda to Update a vec4 of float in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7396. /**
  7397. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateMatrix: (name: string, mat: Matrix) => void;
  7402. /**
  7403. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateVector3: (name: string, vector: Vector3) => void;
  7408. /**
  7409. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateVector4: (name: string, vector: Vector4) => void;
  7414. /**
  7415. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7426. /**
  7427. * Instantiates a new Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. * @param engine Define the engine the buffer is associated with
  7436. * @param data Define the data contained in the buffer
  7437. * @param dynamic Define if the buffer is updatable
  7438. */
  7439. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7440. /**
  7441. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7442. * or just falling back on setUniformXXX calls.
  7443. */
  7444. get useUbo(): boolean;
  7445. /**
  7446. * Indicates if the WebGL underlying uniform buffer is in sync
  7447. * with the javascript cache data.
  7448. */
  7449. get isSync(): boolean;
  7450. /**
  7451. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7452. * Also, a dynamic UniformBuffer will disable cache verification and always
  7453. * update the underlying WebGL uniform buffer to the GPU.
  7454. * @returns if Dynamic, otherwise false
  7455. */
  7456. isDynamic(): boolean;
  7457. /**
  7458. * The data cache on JS side.
  7459. * @returns the underlying data as a float array
  7460. */
  7461. getData(): Float32Array;
  7462. /**
  7463. * The underlying WebGL Uniform buffer.
  7464. * @returns the webgl buffer
  7465. */
  7466. getBuffer(): Nullable<DataBuffer>;
  7467. /**
  7468. * std140 layout specifies how to align data within an UBO structure.
  7469. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7470. * for specs.
  7471. */
  7472. private _fillAlignment;
  7473. /**
  7474. * Adds an uniform in the buffer.
  7475. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7476. * for the layout to be correct !
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param size Data size, or data directly.
  7479. */
  7480. addUniform(name: string, size: number | number[]): void;
  7481. /**
  7482. * Adds a Matrix 4x4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param mat A 4x4 matrix.
  7485. */
  7486. addMatrix(name: string, mat: Matrix): void;
  7487. /**
  7488. * Adds a vec2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param x Define the x component value of the vec2
  7491. * @param y Define the y component value of the vec2
  7492. */
  7493. addFloat2(name: string, x: number, y: number): void;
  7494. /**
  7495. * Adds a vec3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec3
  7498. * @param y Define the y component value of the vec3
  7499. * @param z Define the z component value of the vec3
  7500. */
  7501. addFloat3(name: string, x: number, y: number, z: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param color Define the vec3 from a Color
  7506. */
  7507. addColor3(name: string, color: Color3): void;
  7508. /**
  7509. * Adds a vec4 to the uniform buffer.
  7510. * @param name Name of the uniform, as used in the uniform block in the shader.
  7511. * @param color Define the rgb components from a Color
  7512. * @param alpha Define the a component of the vec4
  7513. */
  7514. addColor4(name: string, color: Color3, alpha: number): void;
  7515. /**
  7516. * Adds a vec3 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param vector Define the vec3 components from a Vector
  7519. */
  7520. addVector3(name: string, vector: Vector3): void;
  7521. /**
  7522. * Adds a Matrix 3x3 to the uniform buffer.
  7523. * @param name Name of the uniform, as used in the uniform block in the shader.
  7524. */
  7525. addMatrix3x3(name: string): void;
  7526. /**
  7527. * Adds a Matrix 2x2 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. */
  7530. addMatrix2x2(name: string): void;
  7531. /**
  7532. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7533. */
  7534. create(): void;
  7535. /** @hidden */
  7536. _rebuild(): void;
  7537. /**
  7538. * Updates the WebGL Uniform Buffer on the GPU.
  7539. * If the `dynamic` flag is set to true, no cache comparison is done.
  7540. * Otherwise, the buffer will be updated only if the cache differs.
  7541. */
  7542. update(): void;
  7543. /**
  7544. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7546. * @param data Define the flattened data
  7547. * @param size Define the size of the data.
  7548. */
  7549. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7550. private _valueCache;
  7551. private _cacheMatrix;
  7552. private _updateMatrix3x3ForUniform;
  7553. private _updateMatrix3x3ForEffect;
  7554. private _updateMatrix2x2ForEffect;
  7555. private _updateMatrix2x2ForUniform;
  7556. private _updateFloatForEffect;
  7557. private _updateFloatForUniform;
  7558. private _updateFloat2ForEffect;
  7559. private _updateFloat2ForUniform;
  7560. private _updateFloat3ForEffect;
  7561. private _updateFloat3ForUniform;
  7562. private _updateFloat4ForEffect;
  7563. private _updateFloat4ForUniform;
  7564. private _updateMatrixForEffect;
  7565. private _updateMatrixForUniform;
  7566. private _updateVector3ForEffect;
  7567. private _updateVector3ForUniform;
  7568. private _updateVector4ForEffect;
  7569. private _updateVector4ForUniform;
  7570. private _updateColor3ForEffect;
  7571. private _updateColor3ForUniform;
  7572. private _updateColor4ForEffect;
  7573. private _updateColor4ForUniform;
  7574. /**
  7575. * Sets a sampler uniform on the effect.
  7576. * @param name Define the name of the sampler.
  7577. * @param texture Define the texture to set in the sampler
  7578. */
  7579. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7580. /**
  7581. * Directly updates the value of the uniform in the cache AND on the GPU.
  7582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7583. * @param data Define the flattened data
  7584. */
  7585. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7586. /**
  7587. * Binds this uniform buffer to an effect.
  7588. * @param effect Define the effect to bind the buffer to
  7589. * @param name Name of the uniform block in the shader.
  7590. */
  7591. bindToEffect(effect: Effect, name: string): void;
  7592. /**
  7593. * Disposes the uniform buffer.
  7594. */
  7595. dispose(): void;
  7596. }
  7597. }
  7598. declare module "babylonjs/Misc/iInspectable" {
  7599. /**
  7600. * Enum that determines the text-wrapping mode to use.
  7601. */
  7602. export enum InspectableType {
  7603. /**
  7604. * Checkbox for booleans
  7605. */
  7606. Checkbox = 0,
  7607. /**
  7608. * Sliders for numbers
  7609. */
  7610. Slider = 1,
  7611. /**
  7612. * Vector3
  7613. */
  7614. Vector3 = 2,
  7615. /**
  7616. * Quaternions
  7617. */
  7618. Quaternion = 3,
  7619. /**
  7620. * Color3
  7621. */
  7622. Color3 = 4,
  7623. /**
  7624. * String
  7625. */
  7626. String = 5
  7627. }
  7628. /**
  7629. * Interface used to define custom inspectable properties.
  7630. * This interface is used by the inspector to display custom property grids
  7631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7632. */
  7633. export interface IInspectable {
  7634. /**
  7635. * Gets the label to display
  7636. */
  7637. label: string;
  7638. /**
  7639. * Gets the name of the property to edit
  7640. */
  7641. propertyName: string;
  7642. /**
  7643. * Gets the type of the editor to use
  7644. */
  7645. type: InspectableType;
  7646. /**
  7647. * Gets the minimum value of the property when using in "slider" mode
  7648. */
  7649. min?: number;
  7650. /**
  7651. * Gets the maximum value of the property when using in "slider" mode
  7652. */
  7653. max?: number;
  7654. /**
  7655. * Gets the setp to use when using in "slider" mode
  7656. */
  7657. step?: number;
  7658. }
  7659. }
  7660. declare module "babylonjs/Misc/timingTools" {
  7661. /**
  7662. * Class used to provide helper for timing
  7663. */
  7664. export class TimingTools {
  7665. /**
  7666. * Polyfill for setImmediate
  7667. * @param action defines the action to execute after the current execution block
  7668. */
  7669. static SetImmediate(action: () => void): void;
  7670. }
  7671. }
  7672. declare module "babylonjs/Misc/instantiationTools" {
  7673. /**
  7674. * Class used to enable instatition of objects by class name
  7675. */
  7676. export class InstantiationTools {
  7677. /**
  7678. * Use this object to register external classes like custom textures or material
  7679. * to allow the laoders to instantiate them
  7680. */
  7681. static RegisteredExternalClasses: {
  7682. [key: string]: Object;
  7683. };
  7684. /**
  7685. * Tries to instantiate a new object from a given class name
  7686. * @param className defines the class name to instantiate
  7687. * @returns the new object or null if the system was not able to do the instantiation
  7688. */
  7689. static Instantiate(className: string): any;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7693. /**
  7694. * Define options used to create a depth texture
  7695. */
  7696. export class DepthTextureCreationOptions {
  7697. /** Specifies whether or not a stencil should be allocated in the texture */
  7698. generateStencil?: boolean;
  7699. /** Specifies whether or not bilinear filtering is enable on the texture */
  7700. bilinearFiltering?: boolean;
  7701. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7702. comparisonFunction?: number;
  7703. /** Specifies if the created texture is a cube texture */
  7704. isCube?: boolean;
  7705. }
  7706. }
  7707. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7709. import { Nullable } from "babylonjs/types";
  7710. import { Scene } from "babylonjs/scene";
  7711. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7712. module "babylonjs/Engines/thinEngine" {
  7713. interface ThinEngine {
  7714. /**
  7715. * Creates a depth stencil cube texture.
  7716. * This is only available in WebGL 2.
  7717. * @param size The size of face edge in the cube texture.
  7718. * @param options The options defining the cube texture.
  7719. * @returns The cube texture
  7720. */
  7721. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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>): InternalTexture;
  7739. /**
  7740. * Creates a cube texture
  7741. * @param rootUrl defines the url where the files to load is located
  7742. * @param scene defines the current scene
  7743. * @param files defines the list of files to load (1 per face)
  7744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7745. * @param onLoad defines an optional callback raised when the texture is loaded
  7746. * @param onError defines an optional callback raised if there is an issue to load the texture
  7747. * @param format defines the format of the data
  7748. * @param forcedExtension defines the extension to use to pick the right loader
  7749. * @returns the cube texture as an InternalTexture
  7750. */
  7751. 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;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @returns the cube texture as an InternalTexture
  7766. */
  7767. 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;
  7768. /** @hidden */
  7769. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7770. /** @hidden */
  7771. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7772. /** @hidden */
  7773. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7774. /** @hidden */
  7775. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7776. /**
  7777. * @hidden
  7778. */
  7779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7780. }
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7784. import { Nullable } from "babylonjs/types";
  7785. import { Scene } from "babylonjs/scene";
  7786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7788. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7789. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7790. import { Observable } from "babylonjs/Misc/observable";
  7791. /**
  7792. * Class for creating a cube texture
  7793. */
  7794. export class CubeTexture extends BaseTexture {
  7795. private _delayedOnLoad;
  7796. /**
  7797. * Observable triggered once the texture has been loaded.
  7798. */
  7799. onLoadObservable: Observable<CubeTexture>;
  7800. /**
  7801. * The url of the texture
  7802. */
  7803. url: string;
  7804. /**
  7805. * Gets or sets the center of the bounding box associated with the cube texture.
  7806. * It must define where the camera used to render the texture was set
  7807. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7808. */
  7809. boundingBoxPosition: Vector3;
  7810. private _boundingBoxSize;
  7811. /**
  7812. * Gets or sets the size of the bounding box associated with the cube texture
  7813. * When defined, the cubemap will switch to local mode
  7814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7815. * @example https://www.babylonjs-playground.com/#RNASML
  7816. */
  7817. set boundingBoxSize(value: Vector3);
  7818. /**
  7819. * Returns the bounding box size
  7820. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7821. */
  7822. get boundingBoxSize(): Vector3;
  7823. protected _rotationY: number;
  7824. /**
  7825. * Sets texture matrix rotation angle around Y axis in radians.
  7826. */
  7827. set rotationY(value: number);
  7828. /**
  7829. * Gets texture matrix rotation angle around Y axis radians.
  7830. */
  7831. get rotationY(): number;
  7832. /**
  7833. * Are mip maps generated for this texture or not.
  7834. */
  7835. get noMipmap(): boolean;
  7836. private _noMipmap;
  7837. private _files;
  7838. protected _forcedExtension: Nullable<string>;
  7839. private _extensions;
  7840. private _textureMatrix;
  7841. private _format;
  7842. private _createPolynomials;
  7843. /** @hidden */
  7844. _prefiltered: boolean;
  7845. /**
  7846. * Creates a cube texture from an array of image urls
  7847. * @param files defines an array of image urls
  7848. * @param scene defines the hosting scene
  7849. * @param noMipmap specifies if mip maps are not used
  7850. * @returns a cube texture
  7851. */
  7852. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7853. /**
  7854. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7855. * @param url defines the url of the prefiltered texture
  7856. * @param scene defines the scene the texture is attached to
  7857. * @param forcedExtension defines the extension of the file if different from the url
  7858. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7859. * @return the prefiltered texture
  7860. */
  7861. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7862. /**
  7863. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7864. * as prefiltered data.
  7865. * @param rootUrl defines the url of the texture or the root name of the six images
  7866. * @param null defines the scene or engine the texture is attached to
  7867. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7868. * @param noMipmap defines if mipmaps should be created or not
  7869. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7870. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7871. * @param onError defines a callback triggered in case of error during load
  7872. * @param format defines the internal format to use for the texture once loaded
  7873. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7874. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7875. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7876. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7877. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7878. * @return the cube texture
  7879. */
  7880. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7881. /**
  7882. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7883. */
  7884. get isPrefiltered(): boolean;
  7885. /**
  7886. * Get the current class name of the texture useful for serialization or dynamic coding.
  7887. * @returns "CubeTexture"
  7888. */
  7889. getClassName(): string;
  7890. /**
  7891. * Update the url (and optional buffer) of this texture if url was null during construction.
  7892. * @param url the url of the texture
  7893. * @param forcedExtension defines the extension to use
  7894. * @param onLoad callback called when the texture is loaded (defaults to null)
  7895. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7896. */
  7897. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7898. /**
  7899. * Delays loading of the cube texture
  7900. * @param forcedExtension defines the extension to use
  7901. */
  7902. delayLoad(forcedExtension?: string): void;
  7903. /**
  7904. * Returns the reflection texture matrix
  7905. * @returns the reflection texture matrix
  7906. */
  7907. getReflectionTextureMatrix(): Matrix;
  7908. /**
  7909. * Sets the reflection texture matrix
  7910. * @param value Reflection texture matrix
  7911. */
  7912. setReflectionTextureMatrix(value: Matrix): void;
  7913. /**
  7914. * Parses text to create a cube texture
  7915. * @param parsedTexture define the serialized text to read from
  7916. * @param scene defines the hosting scene
  7917. * @param rootUrl defines the root url of the cube texture
  7918. * @returns a cube texture
  7919. */
  7920. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7921. /**
  7922. * Makes a clone, or deep copy, of the cube texture
  7923. * @returns a new cube texture
  7924. */
  7925. clone(): CubeTexture;
  7926. }
  7927. }
  7928. declare module "babylonjs/Materials/materialDefines" {
  7929. /**
  7930. * Manages the defines for the Material
  7931. */
  7932. export class MaterialDefines {
  7933. /** @hidden */
  7934. protected _keys: string[];
  7935. private _isDirty;
  7936. /** @hidden */
  7937. _renderId: number;
  7938. /** @hidden */
  7939. _areLightsDirty: boolean;
  7940. /** @hidden */
  7941. _areLightsDisposed: boolean;
  7942. /** @hidden */
  7943. _areAttributesDirty: boolean;
  7944. /** @hidden */
  7945. _areTexturesDirty: boolean;
  7946. /** @hidden */
  7947. _areFresnelDirty: boolean;
  7948. /** @hidden */
  7949. _areMiscDirty: boolean;
  7950. /** @hidden */
  7951. _areImageProcessingDirty: boolean;
  7952. /** @hidden */
  7953. _normals: boolean;
  7954. /** @hidden */
  7955. _uvs: boolean;
  7956. /** @hidden */
  7957. _needNormals: boolean;
  7958. /** @hidden */
  7959. _needUVs: boolean;
  7960. [id: string]: any;
  7961. /**
  7962. * Specifies if the material needs to be re-calculated
  7963. */
  7964. get isDirty(): boolean;
  7965. /**
  7966. * Marks the material to indicate that it has been re-calculated
  7967. */
  7968. markAsProcessed(): void;
  7969. /**
  7970. * Marks the material to indicate that it needs to be re-calculated
  7971. */
  7972. markAsUnprocessed(): void;
  7973. /**
  7974. * Marks the material to indicate all of its defines need to be re-calculated
  7975. */
  7976. markAllAsDirty(): void;
  7977. /**
  7978. * Marks the material to indicate that image processing needs to be re-calculated
  7979. */
  7980. markAsImageProcessingDirty(): void;
  7981. /**
  7982. * Marks the material to indicate the lights need to be re-calculated
  7983. * @param disposed Defines whether the light is dirty due to dispose or not
  7984. */
  7985. markAsLightDirty(disposed?: boolean): void;
  7986. /**
  7987. * Marks the attribute state as changed
  7988. */
  7989. markAsAttributesDirty(): void;
  7990. /**
  7991. * Marks the texture state as changed
  7992. */
  7993. markAsTexturesDirty(): void;
  7994. /**
  7995. * Marks the fresnel state as changed
  7996. */
  7997. markAsFresnelDirty(): void;
  7998. /**
  7999. * Marks the misc state as changed
  8000. */
  8001. markAsMiscDirty(): void;
  8002. /**
  8003. * Rebuilds the material defines
  8004. */
  8005. rebuild(): void;
  8006. /**
  8007. * Specifies if two material defines are equal
  8008. * @param other - A material define instance to compare to
  8009. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8010. */
  8011. isEqual(other: MaterialDefines): boolean;
  8012. /**
  8013. * Clones this instance's defines to another instance
  8014. * @param other - material defines to clone values to
  8015. */
  8016. cloneTo(other: MaterialDefines): void;
  8017. /**
  8018. * Resets the material define values
  8019. */
  8020. reset(): void;
  8021. /**
  8022. * Converts the material define values to a string
  8023. * @returns - String of material define information
  8024. */
  8025. toString(): string;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/colorCurves" {
  8029. import { Effect } from "babylonjs/Materials/effect";
  8030. /**
  8031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8033. * 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;
  8034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8035. */
  8036. export class ColorCurves {
  8037. private _dirty;
  8038. private _tempColor;
  8039. private _globalCurve;
  8040. private _highlightsCurve;
  8041. private _midtonesCurve;
  8042. private _shadowsCurve;
  8043. private _positiveCurve;
  8044. private _negativeCurve;
  8045. private _globalHue;
  8046. private _globalDensity;
  8047. private _globalSaturation;
  8048. private _globalExposure;
  8049. /**
  8050. * Gets the global Hue value.
  8051. * 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).
  8052. */
  8053. get globalHue(): number;
  8054. /**
  8055. * Sets the global Hue value.
  8056. * 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).
  8057. */
  8058. set globalHue(value: number);
  8059. /**
  8060. * Gets the global Density value.
  8061. * 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.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. get globalDensity(): number;
  8065. /**
  8066. * Sets the global Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. set globalDensity(value: number);
  8071. /**
  8072. * Gets the global Saturation value.
  8073. * 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.
  8074. */
  8075. get globalSaturation(): number;
  8076. /**
  8077. * Sets the global Saturation value.
  8078. * 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.
  8079. */
  8080. set globalSaturation(value: number);
  8081. /**
  8082. * Gets the global Exposure value.
  8083. * 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.
  8084. */
  8085. get globalExposure(): number;
  8086. /**
  8087. * Sets the global Exposure value.
  8088. * 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.
  8089. */
  8090. set globalExposure(value: number);
  8091. private _highlightsHue;
  8092. private _highlightsDensity;
  8093. private _highlightsSaturation;
  8094. private _highlightsExposure;
  8095. /**
  8096. * Gets the highlights Hue value.
  8097. * 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).
  8098. */
  8099. get highlightsHue(): number;
  8100. /**
  8101. * Sets the highlights Hue value.
  8102. * 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).
  8103. */
  8104. set highlightsHue(value: number);
  8105. /**
  8106. * Gets the highlights Density value.
  8107. * 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.
  8108. * Values less than zero provide a filter of opposite hue.
  8109. */
  8110. get highlightsDensity(): number;
  8111. /**
  8112. * Sets the highlights Density value.
  8113. * 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.
  8114. * Values less than zero provide a filter of opposite hue.
  8115. */
  8116. set highlightsDensity(value: number);
  8117. /**
  8118. * Gets the highlights Saturation value.
  8119. * 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.
  8120. */
  8121. get highlightsSaturation(): number;
  8122. /**
  8123. * Sets the highlights Saturation value.
  8124. * 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.
  8125. */
  8126. set highlightsSaturation(value: number);
  8127. /**
  8128. * Gets the highlights Exposure value.
  8129. * 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.
  8130. */
  8131. get highlightsExposure(): number;
  8132. /**
  8133. * Sets the highlights Exposure value.
  8134. * 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.
  8135. */
  8136. set highlightsExposure(value: number);
  8137. private _midtonesHue;
  8138. private _midtonesDensity;
  8139. private _midtonesSaturation;
  8140. private _midtonesExposure;
  8141. /**
  8142. * Gets the midtones Hue value.
  8143. * 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).
  8144. */
  8145. get midtonesHue(): number;
  8146. /**
  8147. * Sets the midtones Hue value.
  8148. * 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).
  8149. */
  8150. set midtonesHue(value: number);
  8151. /**
  8152. * Gets the midtones Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get midtonesDensity(): number;
  8157. /**
  8158. * Sets the midtones Density value.
  8159. * 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.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set midtonesDensity(value: number);
  8163. /**
  8164. * Gets the midtones Saturation value.
  8165. * 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.
  8166. */
  8167. get midtonesSaturation(): number;
  8168. /**
  8169. * Sets the midtones Saturation value.
  8170. * 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.
  8171. */
  8172. set midtonesSaturation(value: number);
  8173. /**
  8174. * Gets the midtones Exposure value.
  8175. * 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.
  8176. */
  8177. get midtonesExposure(): number;
  8178. /**
  8179. * Sets the midtones Exposure value.
  8180. * 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.
  8181. */
  8182. set midtonesExposure(value: number);
  8183. private _shadowsHue;
  8184. private _shadowsDensity;
  8185. private _shadowsSaturation;
  8186. private _shadowsExposure;
  8187. /**
  8188. * Gets the shadows Hue value.
  8189. * 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).
  8190. */
  8191. get shadowsHue(): number;
  8192. /**
  8193. * Sets the shadows Hue value.
  8194. * 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).
  8195. */
  8196. set shadowsHue(value: number);
  8197. /**
  8198. * Gets the shadows Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get shadowsDensity(): number;
  8203. /**
  8204. * Sets the shadows Density value.
  8205. * 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.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set shadowsDensity(value: number);
  8209. /**
  8210. * Gets the shadows Saturation value.
  8211. * 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.
  8212. */
  8213. get shadowsSaturation(): number;
  8214. /**
  8215. * Sets the shadows Saturation value.
  8216. * 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.
  8217. */
  8218. set shadowsSaturation(value: number);
  8219. /**
  8220. * Gets the shadows Exposure value.
  8221. * 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.
  8222. */
  8223. get shadowsExposure(): number;
  8224. /**
  8225. * Sets the shadows Exposure value.
  8226. * 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.
  8227. */
  8228. set shadowsExposure(value: number);
  8229. /**
  8230. * Returns the class name
  8231. * @returns The class name
  8232. */
  8233. getClassName(): string;
  8234. /**
  8235. * Binds the color curves to the shader.
  8236. * @param colorCurves The color curve to bind
  8237. * @param effect The effect to bind to
  8238. * @param positiveUniform The positive uniform shader parameter
  8239. * @param neutralUniform The neutral uniform shader parameter
  8240. * @param negativeUniform The negative uniform shader parameter
  8241. */
  8242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8243. /**
  8244. * Prepare the list of uniforms associated with the ColorCurves effects.
  8245. * @param uniformsList The list of uniforms used in the effect
  8246. */
  8247. static PrepareUniforms(uniformsList: string[]): void;
  8248. /**
  8249. * Returns color grading data based on a hue, density, saturation and exposure value.
  8250. * @param filterHue The hue of the color filter.
  8251. * @param filterDensity The density of the color filter.
  8252. * @param saturation The saturation.
  8253. * @param exposure The exposure.
  8254. * @param result The result data container.
  8255. */
  8256. private getColorGradingDataToRef;
  8257. /**
  8258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8259. * @param value The input slider value in range [-100,100].
  8260. * @returns Adjusted value.
  8261. */
  8262. private static applyColorGradingSliderNonlinear;
  8263. /**
  8264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8265. * @param hue The hue (H) input.
  8266. * @param saturation The saturation (S) input.
  8267. * @param brightness The brightness (B) input.
  8268. * @result An RGBA color represented as Vector4.
  8269. */
  8270. private static fromHSBToRef;
  8271. /**
  8272. * Returns a value clamped between min and max
  8273. * @param value The value to clamp
  8274. * @param min The minimum of value
  8275. * @param max The maximum of value
  8276. * @returns The clamped value.
  8277. */
  8278. private static clamp;
  8279. /**
  8280. * Clones the current color curve instance.
  8281. * @return The cloned curves
  8282. */
  8283. clone(): ColorCurves;
  8284. /**
  8285. * Serializes the current color curve instance to a json representation.
  8286. * @return a JSON representation
  8287. */
  8288. serialize(): any;
  8289. /**
  8290. * Parses the color curve from a json representation.
  8291. * @param source the JSON source to parse
  8292. * @return The parsed curves
  8293. */
  8294. static Parse(source: any): ColorCurves;
  8295. }
  8296. }
  8297. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8298. import { Observable } from "babylonjs/Misc/observable";
  8299. import { Nullable } from "babylonjs/types";
  8300. import { Color4 } from "babylonjs/Maths/math.color";
  8301. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8302. import { Effect } from "babylonjs/Materials/effect";
  8303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8304. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8305. /**
  8306. * Interface to follow in your material defines to integrate easily the
  8307. * Image proccessing functions.
  8308. * @hidden
  8309. */
  8310. export interface IImageProcessingConfigurationDefines {
  8311. IMAGEPROCESSING: boolean;
  8312. VIGNETTE: boolean;
  8313. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8314. VIGNETTEBLENDMODEOPAQUE: boolean;
  8315. TONEMAPPING: boolean;
  8316. TONEMAPPING_ACES: boolean;
  8317. CONTRAST: boolean;
  8318. EXPOSURE: boolean;
  8319. COLORCURVES: boolean;
  8320. COLORGRADING: boolean;
  8321. COLORGRADING3D: boolean;
  8322. SAMPLER3DGREENDEPTH: boolean;
  8323. SAMPLER3DBGRMAP: boolean;
  8324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8325. }
  8326. /**
  8327. * @hidden
  8328. */
  8329. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8330. IMAGEPROCESSING: boolean;
  8331. VIGNETTE: boolean;
  8332. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8333. VIGNETTEBLENDMODEOPAQUE: boolean;
  8334. TONEMAPPING: boolean;
  8335. TONEMAPPING_ACES: boolean;
  8336. CONTRAST: boolean;
  8337. COLORCURVES: boolean;
  8338. COLORGRADING: boolean;
  8339. COLORGRADING3D: boolean;
  8340. SAMPLER3DGREENDEPTH: boolean;
  8341. SAMPLER3DBGRMAP: boolean;
  8342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8343. EXPOSURE: boolean;
  8344. constructor();
  8345. }
  8346. /**
  8347. * This groups together the common properties used for image processing either in direct forward pass
  8348. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8349. * or not.
  8350. */
  8351. export class ImageProcessingConfiguration {
  8352. /**
  8353. * Default tone mapping applied in BabylonJS.
  8354. */
  8355. static readonly TONEMAPPING_STANDARD: number;
  8356. /**
  8357. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8358. * to other engines rendering to increase portability.
  8359. */
  8360. static readonly TONEMAPPING_ACES: number;
  8361. /**
  8362. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8363. */
  8364. colorCurves: Nullable<ColorCurves>;
  8365. private _colorCurvesEnabled;
  8366. /**
  8367. * Gets wether the color curves effect is enabled.
  8368. */
  8369. get colorCurvesEnabled(): boolean;
  8370. /**
  8371. * Sets wether the color curves effect is enabled.
  8372. */
  8373. set colorCurvesEnabled(value: boolean);
  8374. private _colorGradingTexture;
  8375. /**
  8376. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8377. */
  8378. get colorGradingTexture(): Nullable<BaseTexture>;
  8379. /**
  8380. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8381. */
  8382. set colorGradingTexture(value: Nullable<BaseTexture>);
  8383. private _colorGradingEnabled;
  8384. /**
  8385. * Gets wether the color grading effect is enabled.
  8386. */
  8387. get colorGradingEnabled(): boolean;
  8388. /**
  8389. * Sets wether the color grading effect is enabled.
  8390. */
  8391. set colorGradingEnabled(value: boolean);
  8392. private _colorGradingWithGreenDepth;
  8393. /**
  8394. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8395. */
  8396. get colorGradingWithGreenDepth(): boolean;
  8397. /**
  8398. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8399. */
  8400. set colorGradingWithGreenDepth(value: boolean);
  8401. private _colorGradingBGR;
  8402. /**
  8403. * Gets wether the color grading texture contains BGR values.
  8404. */
  8405. get colorGradingBGR(): boolean;
  8406. /**
  8407. * Sets wether the color grading texture contains BGR values.
  8408. */
  8409. set colorGradingBGR(value: boolean);
  8410. /** @hidden */
  8411. _exposure: number;
  8412. /**
  8413. * Gets the Exposure used in the effect.
  8414. */
  8415. get exposure(): number;
  8416. /**
  8417. * Sets the Exposure used in the effect.
  8418. */
  8419. set exposure(value: number);
  8420. private _toneMappingEnabled;
  8421. /**
  8422. * Gets wether the tone mapping effect is enabled.
  8423. */
  8424. get toneMappingEnabled(): boolean;
  8425. /**
  8426. * Sets wether the tone mapping effect is enabled.
  8427. */
  8428. set toneMappingEnabled(value: boolean);
  8429. private _toneMappingType;
  8430. /**
  8431. * Gets the type of tone mapping effect.
  8432. */
  8433. get toneMappingType(): number;
  8434. /**
  8435. * Sets the type of tone mapping effect used in BabylonJS.
  8436. */
  8437. set toneMappingType(value: number);
  8438. protected _contrast: number;
  8439. /**
  8440. * Gets the contrast used in the effect.
  8441. */
  8442. get contrast(): number;
  8443. /**
  8444. * Sets the contrast used in the effect.
  8445. */
  8446. set contrast(value: number);
  8447. /**
  8448. * Vignette stretch size.
  8449. */
  8450. vignetteStretch: number;
  8451. /**
  8452. * Vignette centre X Offset.
  8453. */
  8454. vignetteCentreX: number;
  8455. /**
  8456. * Vignette centre Y Offset.
  8457. */
  8458. vignetteCentreY: number;
  8459. /**
  8460. * Vignette weight or intensity of the vignette effect.
  8461. */
  8462. vignetteWeight: number;
  8463. /**
  8464. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8465. * if vignetteEnabled is set to true.
  8466. */
  8467. vignetteColor: Color4;
  8468. /**
  8469. * Camera field of view used by the Vignette effect.
  8470. */
  8471. vignetteCameraFov: number;
  8472. private _vignetteBlendMode;
  8473. /**
  8474. * Gets the vignette blend mode allowing different kind of effect.
  8475. */
  8476. get vignetteBlendMode(): number;
  8477. /**
  8478. * Sets the vignette blend mode allowing different kind of effect.
  8479. */
  8480. set vignetteBlendMode(value: number);
  8481. private _vignetteEnabled;
  8482. /**
  8483. * Gets wether the vignette effect is enabled.
  8484. */
  8485. get vignetteEnabled(): boolean;
  8486. /**
  8487. * Sets wether the vignette effect is enabled.
  8488. */
  8489. set vignetteEnabled(value: boolean);
  8490. private _applyByPostProcess;
  8491. /**
  8492. * Gets wether the image processing is applied through a post process or not.
  8493. */
  8494. get applyByPostProcess(): boolean;
  8495. /**
  8496. * Sets wether the image processing is applied through a post process or not.
  8497. */
  8498. set applyByPostProcess(value: boolean);
  8499. private _isEnabled;
  8500. /**
  8501. * Gets wether the image processing is enabled or not.
  8502. */
  8503. get isEnabled(): boolean;
  8504. /**
  8505. * Sets wether the image processing is enabled or not.
  8506. */
  8507. set isEnabled(value: boolean);
  8508. /**
  8509. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8510. */
  8511. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8512. /**
  8513. * Method called each time the image processing information changes requires to recompile the effect.
  8514. */
  8515. protected _updateParameters(): void;
  8516. /**
  8517. * Gets the current class name.
  8518. * @return "ImageProcessingConfiguration"
  8519. */
  8520. getClassName(): string;
  8521. /**
  8522. * Prepare the list of uniforms associated with the Image Processing effects.
  8523. * @param uniforms The list of uniforms used in the effect
  8524. * @param defines the list of defines currently in use
  8525. */
  8526. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8527. /**
  8528. * Prepare the list of samplers associated with the Image Processing effects.
  8529. * @param samplersList The list of uniforms used in the effect
  8530. * @param defines the list of defines currently in use
  8531. */
  8532. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8533. /**
  8534. * Prepare the list of defines associated to the shader.
  8535. * @param defines the list of defines to complete
  8536. * @param forPostProcess Define if we are currently in post process mode or not
  8537. */
  8538. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8539. /**
  8540. * Returns true if all the image processing information are ready.
  8541. * @returns True if ready, otherwise, false
  8542. */
  8543. isReady(): boolean;
  8544. /**
  8545. * Binds the image processing to the shader.
  8546. * @param effect The effect to bind to
  8547. * @param overrideAspectRatio Override the aspect ratio of the effect
  8548. */
  8549. bind(effect: Effect, overrideAspectRatio?: number): void;
  8550. /**
  8551. * Clones the current image processing instance.
  8552. * @return The cloned image processing
  8553. */
  8554. clone(): ImageProcessingConfiguration;
  8555. /**
  8556. * Serializes the current image processing instance to a json representation.
  8557. * @return a JSON representation
  8558. */
  8559. serialize(): any;
  8560. /**
  8561. * Parses the image processing from a json representation.
  8562. * @param source the JSON source to parse
  8563. * @return The parsed image processing
  8564. */
  8565. static Parse(source: any): ImageProcessingConfiguration;
  8566. private static _VIGNETTEMODE_MULTIPLY;
  8567. private static _VIGNETTEMODE_OPAQUE;
  8568. /**
  8569. * Used to apply the vignette as a mix with the pixel color.
  8570. */
  8571. static get VIGNETTEMODE_MULTIPLY(): number;
  8572. /**
  8573. * Used to apply the vignette as a replacement of the pixel color.
  8574. */
  8575. static get VIGNETTEMODE_OPAQUE(): number;
  8576. }
  8577. }
  8578. declare module "babylonjs/Shaders/postprocess.vertex" {
  8579. /** @hidden */
  8580. export var postprocessVertexShader: {
  8581. name: string;
  8582. shader: string;
  8583. };
  8584. }
  8585. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8587. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8588. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8589. module "babylonjs/Engines/thinEngine" {
  8590. interface ThinEngine {
  8591. /**
  8592. * Creates a new render target texture
  8593. * @param size defines the size of the texture
  8594. * @param options defines the options used to create the texture
  8595. * @returns a new render target texture stored in an InternalTexture
  8596. */
  8597. createRenderTargetTexture(size: number | {
  8598. width: number;
  8599. height: number;
  8600. layers?: number;
  8601. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8602. /**
  8603. * Creates a depth stencil texture.
  8604. * This is only available in WebGL 2 or with the depth texture extension available.
  8605. * @param size The size of face edge in the texture.
  8606. * @param options The options defining the texture.
  8607. * @returns The texture
  8608. */
  8609. createDepthStencilTexture(size: number | {
  8610. width: number;
  8611. height: number;
  8612. layers?: number;
  8613. }, options: DepthTextureCreationOptions): InternalTexture;
  8614. /** @hidden */
  8615. _createDepthStencilTexture(size: number | {
  8616. width: number;
  8617. height: number;
  8618. layers?: number;
  8619. }, options: DepthTextureCreationOptions): InternalTexture;
  8620. }
  8621. }
  8622. }
  8623. declare module "babylonjs/Maths/math.axis" {
  8624. import { Vector3 } from "babylonjs/Maths/math.vector";
  8625. /** Defines supported spaces */
  8626. export enum Space {
  8627. /** Local (object) space */
  8628. LOCAL = 0,
  8629. /** World space */
  8630. WORLD = 1,
  8631. /** Bone space */
  8632. BONE = 2
  8633. }
  8634. /** Defines the 3 main axes */
  8635. export class Axis {
  8636. /** X axis */
  8637. static X: Vector3;
  8638. /** Y axis */
  8639. static Y: Vector3;
  8640. /** Z axis */
  8641. static Z: Vector3;
  8642. }
  8643. }
  8644. declare module "babylonjs/Cameras/targetCamera" {
  8645. import { Nullable } from "babylonjs/types";
  8646. import { Camera } from "babylonjs/Cameras/camera";
  8647. import { Scene } from "babylonjs/scene";
  8648. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8649. /**
  8650. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8651. * This is the base of the follow, arc rotate cameras and Free camera
  8652. * @see http://doc.babylonjs.com/features/cameras
  8653. */
  8654. export class TargetCamera extends Camera {
  8655. private static _RigCamTransformMatrix;
  8656. private static _TargetTransformMatrix;
  8657. private static _TargetFocalPoint;
  8658. /**
  8659. * Define the current direction the camera is moving to
  8660. */
  8661. cameraDirection: Vector3;
  8662. /**
  8663. * Define the current rotation the camera is rotating to
  8664. */
  8665. cameraRotation: Vector2;
  8666. /**
  8667. * When set, the up vector of the camera will be updated by the rotation of the camera
  8668. */
  8669. updateUpVectorFromRotation: boolean;
  8670. private _tmpQuaternion;
  8671. /**
  8672. * Define the current rotation of the camera
  8673. */
  8674. rotation: Vector3;
  8675. /**
  8676. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8677. */
  8678. rotationQuaternion: Quaternion;
  8679. /**
  8680. * Define the current speed of the camera
  8681. */
  8682. speed: number;
  8683. /**
  8684. * Add constraint to the camera to prevent it to move freely in all directions and
  8685. * around all axis.
  8686. */
  8687. noRotationConstraint: boolean;
  8688. /**
  8689. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8690. * panning
  8691. */
  8692. invertRotation: boolean;
  8693. /**
  8694. * Speed multiplier for inverse camera panning
  8695. */
  8696. inverseRotationSpeed: number;
  8697. /**
  8698. * Define the current target of the camera as an object or a position.
  8699. */
  8700. lockedTarget: any;
  8701. /** @hidden */
  8702. _currentTarget: Vector3;
  8703. /** @hidden */
  8704. _initialFocalDistance: number;
  8705. /** @hidden */
  8706. _viewMatrix: Matrix;
  8707. /** @hidden */
  8708. _camMatrix: Matrix;
  8709. /** @hidden */
  8710. _cameraTransformMatrix: Matrix;
  8711. /** @hidden */
  8712. _cameraRotationMatrix: Matrix;
  8713. /** @hidden */
  8714. _referencePoint: Vector3;
  8715. /** @hidden */
  8716. _transformedReferencePoint: Vector3;
  8717. protected _globalCurrentTarget: Vector3;
  8718. protected _globalCurrentUpVector: Vector3;
  8719. /** @hidden */
  8720. _reset: () => void;
  8721. private _defaultUp;
  8722. /**
  8723. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8724. * This is the base of the follow, arc rotate cameras and Free camera
  8725. * @see http://doc.babylonjs.com/features/cameras
  8726. * @param name Defines the name of the camera in the scene
  8727. * @param position Defines the start position of the camera in the scene
  8728. * @param scene Defines the scene the camera belongs to
  8729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8730. */
  8731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8732. /**
  8733. * Gets the position in front of the camera at a given distance.
  8734. * @param distance The distance from the camera we want the position to be
  8735. * @returns the position
  8736. */
  8737. getFrontPosition(distance: number): Vector3;
  8738. /** @hidden */
  8739. _getLockedTargetPosition(): Nullable<Vector3>;
  8740. private _storedPosition;
  8741. private _storedRotation;
  8742. private _storedRotationQuaternion;
  8743. /**
  8744. * Store current camera state of the camera (fov, position, rotation, etc..)
  8745. * @returns the camera
  8746. */
  8747. storeState(): Camera;
  8748. /**
  8749. * Restored camera state. You must call storeState() first
  8750. * @returns whether it was successful or not
  8751. * @hidden
  8752. */
  8753. _restoreStateValues(): boolean;
  8754. /** @hidden */
  8755. _initCache(): void;
  8756. /** @hidden */
  8757. _updateCache(ignoreParentClass?: boolean): void;
  8758. /** @hidden */
  8759. _isSynchronizedViewMatrix(): boolean;
  8760. /** @hidden */
  8761. _computeLocalCameraSpeed(): number;
  8762. /**
  8763. * Defines the target the camera should look at.
  8764. * @param target Defines the new target as a Vector or a mesh
  8765. */
  8766. setTarget(target: Vector3): void;
  8767. /**
  8768. * Return the current target position of the camera. This value is expressed in local space.
  8769. * @returns the target position
  8770. */
  8771. getTarget(): Vector3;
  8772. /** @hidden */
  8773. _decideIfNeedsToMove(): boolean;
  8774. /** @hidden */
  8775. _updatePosition(): void;
  8776. /** @hidden */
  8777. _checkInputs(): void;
  8778. protected _updateCameraRotationMatrix(): void;
  8779. /**
  8780. * 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)
  8781. * @returns the current camera
  8782. */
  8783. private _rotateUpVectorWithCameraRotationMatrix;
  8784. private _cachedRotationZ;
  8785. private _cachedQuaternionRotationZ;
  8786. /** @hidden */
  8787. _getViewMatrix(): Matrix;
  8788. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8789. /**
  8790. * @hidden
  8791. */
  8792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8793. /**
  8794. * @hidden
  8795. */
  8796. _updateRigCameras(): void;
  8797. private _getRigCamPositionAndTarget;
  8798. /**
  8799. * Gets the current object class name.
  8800. * @return the class name
  8801. */
  8802. getClassName(): string;
  8803. }
  8804. }
  8805. declare module "babylonjs/Events/keyboardEvents" {
  8806. /**
  8807. * Gather the list of keyboard event types as constants.
  8808. */
  8809. export class KeyboardEventTypes {
  8810. /**
  8811. * The keydown event is fired when a key becomes active (pressed).
  8812. */
  8813. static readonly KEYDOWN: number;
  8814. /**
  8815. * The keyup event is fired when a key has been released.
  8816. */
  8817. static readonly KEYUP: number;
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8821. */
  8822. export class KeyboardInfo {
  8823. /**
  8824. * Defines the type of event (KeyboardEventTypes)
  8825. */
  8826. type: number;
  8827. /**
  8828. * Defines the related dom event
  8829. */
  8830. event: KeyboardEvent;
  8831. /**
  8832. * Instantiates a new keyboard info.
  8833. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8834. * @param type Defines the type of event (KeyboardEventTypes)
  8835. * @param event Defines the related dom event
  8836. */
  8837. constructor(
  8838. /**
  8839. * Defines the type of event (KeyboardEventTypes)
  8840. */
  8841. type: number,
  8842. /**
  8843. * Defines the related dom event
  8844. */
  8845. event: KeyboardEvent);
  8846. }
  8847. /**
  8848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8850. */
  8851. export class KeyboardInfoPre extends KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8862. */
  8863. skipOnPointerObservable: boolean;
  8864. /**
  8865. * Instantiates a new keyboard pre info.
  8866. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8867. * @param type Defines the type of event (KeyboardEventTypes)
  8868. * @param event Defines the related dom event
  8869. */
  8870. constructor(
  8871. /**
  8872. * Defines the type of event (KeyboardEventTypes)
  8873. */
  8874. type: number,
  8875. /**
  8876. * Defines the related dom event
  8877. */
  8878. event: KeyboardEvent);
  8879. }
  8880. }
  8881. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8882. import { Nullable } from "babylonjs/types";
  8883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8885. /**
  8886. * Manage the keyboard inputs to control the movement of a free camera.
  8887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8888. */
  8889. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8890. /**
  8891. * Defines the camera the input is attached to.
  8892. */
  8893. camera: FreeCamera;
  8894. /**
  8895. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8896. */
  8897. keysUp: number[];
  8898. /**
  8899. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8900. */
  8901. keysUpward: number[];
  8902. /**
  8903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8904. */
  8905. keysDown: number[];
  8906. /**
  8907. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8908. */
  8909. keysDownward: number[];
  8910. /**
  8911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8912. */
  8913. keysLeft: number[];
  8914. /**
  8915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8916. */
  8917. keysRight: number[];
  8918. private _keys;
  8919. private _onCanvasBlurObserver;
  8920. private _onKeyboardObserver;
  8921. private _engine;
  8922. private _scene;
  8923. /**
  8924. * Attach the input controls to a specific dom element to get the input from.
  8925. * @param element Defines the element the controls should be listened from
  8926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8927. */
  8928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8929. /**
  8930. * Detach the current controls from the specified dom element.
  8931. * @param element Defines the element to stop listening the inputs from
  8932. */
  8933. detachControl(element: Nullable<HTMLElement>): void;
  8934. /**
  8935. * Update the current camera state depending on the inputs that have been used this frame.
  8936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8937. */
  8938. checkInputs(): void;
  8939. /**
  8940. * Gets the class name of the current intput.
  8941. * @returns the class name
  8942. */
  8943. getClassName(): string;
  8944. /** @hidden */
  8945. _onLostFocus(): void;
  8946. /**
  8947. * Get the friendly name associated with the input class.
  8948. * @returns the input friendly name
  8949. */
  8950. getSimpleName(): string;
  8951. }
  8952. }
  8953. declare module "babylonjs/Lights/shadowLight" {
  8954. import { Camera } from "babylonjs/Cameras/camera";
  8955. import { Scene } from "babylonjs/scene";
  8956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8958. import { Light } from "babylonjs/Lights/light";
  8959. /**
  8960. * Interface describing all the common properties and methods a shadow light needs to implement.
  8961. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8962. * as well as binding the different shadow properties to the effects.
  8963. */
  8964. export interface IShadowLight extends Light {
  8965. /**
  8966. * The light id in the scene (used in scene.findLighById for instance)
  8967. */
  8968. id: string;
  8969. /**
  8970. * The position the shdow will be casted from.
  8971. */
  8972. position: Vector3;
  8973. /**
  8974. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8975. */
  8976. direction: Vector3;
  8977. /**
  8978. * The transformed position. Position of the light in world space taking parenting in account.
  8979. */
  8980. transformedPosition: Vector3;
  8981. /**
  8982. * The transformed direction. Direction of the light in world space taking parenting in account.
  8983. */
  8984. transformedDirection: Vector3;
  8985. /**
  8986. * The friendly name of the light in the scene.
  8987. */
  8988. name: string;
  8989. /**
  8990. * Defines the shadow projection clipping minimum z value.
  8991. */
  8992. shadowMinZ: number;
  8993. /**
  8994. * Defines the shadow projection clipping maximum z value.
  8995. */
  8996. shadowMaxZ: number;
  8997. /**
  8998. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8999. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9000. */
  9001. computeTransformedInformation(): boolean;
  9002. /**
  9003. * Gets the scene the light belongs to.
  9004. * @returns The scene
  9005. */
  9006. getScene(): Scene;
  9007. /**
  9008. * Callback defining a custom Projection Matrix Builder.
  9009. * This can be used to override the default projection matrix computation.
  9010. */
  9011. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9012. /**
  9013. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9014. * @param matrix The materix to updated with the projection information
  9015. * @param viewMatrix The transform matrix of the light
  9016. * @param renderList The list of mesh to render in the map
  9017. * @returns The current light
  9018. */
  9019. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9020. /**
  9021. * Gets the current depth scale used in ESM.
  9022. * @returns The scale
  9023. */
  9024. getDepthScale(): number;
  9025. /**
  9026. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9027. * @returns true if a cube texture needs to be use
  9028. */
  9029. needCube(): boolean;
  9030. /**
  9031. * Detects if the projection matrix requires to be recomputed this frame.
  9032. * @returns true if it requires to be recomputed otherwise, false.
  9033. */
  9034. needProjectionMatrixCompute(): boolean;
  9035. /**
  9036. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9037. */
  9038. forceProjectionMatrixCompute(): void;
  9039. /**
  9040. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9041. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9042. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9043. */
  9044. getShadowDirection(faceIndex?: number): Vector3;
  9045. /**
  9046. * Gets the minZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the min for
  9048. * @returns the depth min z
  9049. */
  9050. getDepthMinZ(activeCamera: Camera): number;
  9051. /**
  9052. * Gets the maxZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the max for
  9054. * @returns the depth max z
  9055. */
  9056. getDepthMaxZ(activeCamera: Camera): number;
  9057. }
  9058. /**
  9059. * Base implementation IShadowLight
  9060. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9061. */
  9062. export abstract class ShadowLight extends Light implements IShadowLight {
  9063. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9064. protected _position: Vector3;
  9065. protected _setPosition(value: Vector3): void;
  9066. /**
  9067. * Sets the position the shadow will be casted from. Also use as the light position for both
  9068. * point and spot lights.
  9069. */
  9070. get position(): Vector3;
  9071. /**
  9072. * Sets the position the shadow will be casted from. Also use as the light position for both
  9073. * point and spot lights.
  9074. */
  9075. set position(value: Vector3);
  9076. protected _direction: Vector3;
  9077. protected _setDirection(value: Vector3): void;
  9078. /**
  9079. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9080. * Also use as the light direction on spot and directional lights.
  9081. */
  9082. get direction(): Vector3;
  9083. /**
  9084. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9085. * Also use as the light direction on spot and directional lights.
  9086. */
  9087. set direction(value: Vector3);
  9088. protected _shadowMinZ: number;
  9089. /**
  9090. * Gets the shadow projection clipping minimum z value.
  9091. */
  9092. get shadowMinZ(): number;
  9093. /**
  9094. * Sets the shadow projection clipping minimum z value.
  9095. */
  9096. set shadowMinZ(value: number);
  9097. protected _shadowMaxZ: number;
  9098. /**
  9099. * Sets the shadow projection clipping maximum z value.
  9100. */
  9101. get shadowMaxZ(): number;
  9102. /**
  9103. * Gets the shadow projection clipping maximum z value.
  9104. */
  9105. set shadowMaxZ(value: number);
  9106. /**
  9107. * Callback defining a custom Projection Matrix Builder.
  9108. * This can be used to override the default projection matrix computation.
  9109. */
  9110. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9111. /**
  9112. * The transformed position. Position of the light in world space taking parenting in account.
  9113. */
  9114. transformedPosition: Vector3;
  9115. /**
  9116. * The transformed direction. Direction of the light in world space taking parenting in account.
  9117. */
  9118. transformedDirection: Vector3;
  9119. private _needProjectionMatrixCompute;
  9120. /**
  9121. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9122. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9123. */
  9124. computeTransformedInformation(): boolean;
  9125. /**
  9126. * Return the depth scale used for the shadow map.
  9127. * @returns the depth scale.
  9128. */
  9129. getDepthScale(): number;
  9130. /**
  9131. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9132. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9133. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9134. */
  9135. getShadowDirection(faceIndex?: number): Vector3;
  9136. /**
  9137. * Returns the ShadowLight absolute position in the World.
  9138. * @returns the position vector in world space
  9139. */
  9140. getAbsolutePosition(): Vector3;
  9141. /**
  9142. * Sets the ShadowLight direction toward the passed target.
  9143. * @param target The point to target in local space
  9144. * @returns the updated ShadowLight direction
  9145. */
  9146. setDirectionToTarget(target: Vector3): Vector3;
  9147. /**
  9148. * Returns the light rotation in euler definition.
  9149. * @returns the x y z rotation in local space.
  9150. */
  9151. getRotation(): Vector3;
  9152. /**
  9153. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9154. * @returns true if a cube texture needs to be use
  9155. */
  9156. needCube(): boolean;
  9157. /**
  9158. * Detects if the projection matrix requires to be recomputed this frame.
  9159. * @returns true if it requires to be recomputed otherwise, false.
  9160. */
  9161. needProjectionMatrixCompute(): boolean;
  9162. /**
  9163. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9164. */
  9165. forceProjectionMatrixCompute(): void;
  9166. /** @hidden */
  9167. _initCache(): void;
  9168. /** @hidden */
  9169. _isSynchronized(): boolean;
  9170. /**
  9171. * Computes the world matrix of the node
  9172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9173. * @returns the world matrix
  9174. */
  9175. computeWorldMatrix(force?: boolean): Matrix;
  9176. /**
  9177. * Gets the minZ used for shadow according to both the scene and the light.
  9178. * @param activeCamera The camera we are returning the min for
  9179. * @returns the depth min z
  9180. */
  9181. getDepthMinZ(activeCamera: Camera): number;
  9182. /**
  9183. * Gets the maxZ used for shadow according to both the scene and the light.
  9184. * @param activeCamera The camera we are returning the max for
  9185. * @returns the depth max z
  9186. */
  9187. getDepthMaxZ(activeCamera: Camera): number;
  9188. /**
  9189. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9190. * @param matrix The materix to updated with the projection information
  9191. * @param viewMatrix The transform matrix of the light
  9192. * @param renderList The list of mesh to render in the map
  9193. * @returns The current light
  9194. */
  9195. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9196. }
  9197. }
  9198. declare module "babylonjs/Materials/effectFallbacks" {
  9199. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9200. import { Effect } from "babylonjs/Materials/effect";
  9201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9202. /**
  9203. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9204. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9205. */
  9206. export class EffectFallbacks implements IEffectFallbacks {
  9207. private _defines;
  9208. private _currentRank;
  9209. private _maxRank;
  9210. private _mesh;
  9211. /**
  9212. * Removes the fallback from the bound mesh.
  9213. */
  9214. unBindMesh(): void;
  9215. /**
  9216. * Adds a fallback on the specified property.
  9217. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9218. * @param define The name of the define in the shader
  9219. */
  9220. addFallback(rank: number, define: string): void;
  9221. /**
  9222. * Sets the mesh to use CPU skinning when needing to fallback.
  9223. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9224. * @param mesh The mesh to use the fallbacks.
  9225. */
  9226. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9227. /**
  9228. * Checks to see if more fallbacks are still availible.
  9229. */
  9230. get hasMoreFallbacks(): boolean;
  9231. /**
  9232. * Removes the defines that should be removed when falling back.
  9233. * @param currentDefines defines the current define statements for the shader.
  9234. * @param effect defines the current effect we try to compile
  9235. * @returns The resulting defines with defines of the current rank removed.
  9236. */
  9237. reduce(currentDefines: string, effect: Effect): string;
  9238. }
  9239. }
  9240. declare module "babylonjs/Materials/materialHelper" {
  9241. import { Nullable } from "babylonjs/types";
  9242. import { Scene } from "babylonjs/scene";
  9243. import { Engine } from "babylonjs/Engines/engine";
  9244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9245. import { Light } from "babylonjs/Lights/light";
  9246. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9247. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9249. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9250. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9251. /**
  9252. * "Static Class" containing the most commonly used helper while dealing with material for
  9253. * rendering purpose.
  9254. *
  9255. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9256. *
  9257. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9258. */
  9259. export class MaterialHelper {
  9260. /**
  9261. * Bind the current view position to an effect.
  9262. * @param effect The effect to be bound
  9263. * @param scene The scene the eyes position is used from
  9264. * @param variableName name of the shader variable that will hold the eye position
  9265. */
  9266. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9267. /**
  9268. * Helps preparing the defines values about the UVs in used in the effect.
  9269. * UVs are shared as much as we can accross channels in the shaders.
  9270. * @param texture The texture we are preparing the UVs for
  9271. * @param defines The defines to update
  9272. * @param key The channel key "diffuse", "specular"... used in the shader
  9273. */
  9274. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9275. /**
  9276. * Binds a texture matrix value to its corrsponding uniform
  9277. * @param texture The texture to bind the matrix for
  9278. * @param uniformBuffer The uniform buffer receivin the data
  9279. * @param key The channel key "diffuse", "specular"... used in the shader
  9280. */
  9281. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9282. /**
  9283. * Gets the current status of the fog (should it be enabled?)
  9284. * @param mesh defines the mesh to evaluate for fog support
  9285. * @param scene defines the hosting scene
  9286. * @returns true if fog must be enabled
  9287. */
  9288. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9289. /**
  9290. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9291. * @param mesh defines the current mesh
  9292. * @param scene defines the current scene
  9293. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9294. * @param pointsCloud defines if point cloud rendering has to be turned on
  9295. * @param fogEnabled defines if fog has to be turned on
  9296. * @param alphaTest defines if alpha testing has to be turned on
  9297. * @param defines defines the current list of defines
  9298. */
  9299. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9300. /**
  9301. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9302. * @param scene defines the current scene
  9303. * @param engine defines the current engine
  9304. * @param defines specifies the list of active defines
  9305. * @param useInstances defines if instances have to be turned on
  9306. * @param useClipPlane defines if clip plane have to be turned on
  9307. */
  9308. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9309. /**
  9310. * Prepares the defines for bones
  9311. * @param mesh The mesh containing the geometry data we will draw
  9312. * @param defines The defines to update
  9313. */
  9314. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9315. /**
  9316. * Prepares the defines for morph targets
  9317. * @param mesh The mesh containing the geometry data we will draw
  9318. * @param defines The defines to update
  9319. */
  9320. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9321. /**
  9322. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9323. * @param mesh The mesh containing the geometry data we will draw
  9324. * @param defines The defines to update
  9325. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9326. * @param useBones Precise whether bones should be used or not (override mesh info)
  9327. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9328. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9329. * @returns false if defines are considered not dirty and have not been checked
  9330. */
  9331. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9332. /**
  9333. * Prepares the defines related to multiview
  9334. * @param scene The scene we are intending to draw
  9335. * @param defines The defines to update
  9336. */
  9337. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9338. /**
  9339. * Prepares the defines related to the light information passed in parameter
  9340. * @param scene The scene we are intending to draw
  9341. * @param mesh The mesh the effect is compiling for
  9342. * @param light The light the effect is compiling for
  9343. * @param lightIndex The index of the light
  9344. * @param defines The defines to update
  9345. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9346. * @param state Defines the current state regarding what is needed (normals, etc...)
  9347. */
  9348. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9349. needNormals: boolean;
  9350. needRebuild: boolean;
  9351. shadowEnabled: boolean;
  9352. specularEnabled: boolean;
  9353. lightmapMode: boolean;
  9354. }): void;
  9355. /**
  9356. * Prepares the defines related to the light information passed in parameter
  9357. * @param scene The scene we are intending to draw
  9358. * @param mesh The mesh the effect is compiling for
  9359. * @param defines The defines to update
  9360. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9361. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9362. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9363. * @returns true if normals will be required for the rest of the effect
  9364. */
  9365. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9366. /**
  9367. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9368. * @param lightIndex defines the light index
  9369. * @param uniformsList The uniform list
  9370. * @param samplersList The sampler list
  9371. * @param projectedLightTexture defines if projected texture must be used
  9372. * @param uniformBuffersList defines an optional list of uniform buffers
  9373. */
  9374. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9375. /**
  9376. * Prepares the uniforms and samplers list to be used in the effect
  9377. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9378. * @param samplersList The sampler list
  9379. * @param defines The defines helping in the list generation
  9380. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9381. */
  9382. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9383. /**
  9384. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9385. * @param defines The defines to update while falling back
  9386. * @param fallbacks The authorized effect fallbacks
  9387. * @param maxSimultaneousLights The maximum number of lights allowed
  9388. * @param rank the current rank of the Effect
  9389. * @returns The newly affected rank
  9390. */
  9391. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9392. private static _TmpMorphInfluencers;
  9393. /**
  9394. * Prepares the list of attributes required for morph targets according to the effect defines.
  9395. * @param attribs The current list of supported attribs
  9396. * @param mesh The mesh to prepare the morph targets attributes for
  9397. * @param influencers The number of influencers
  9398. */
  9399. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9400. /**
  9401. * Prepares the list of attributes required for morph targets according to the effect defines.
  9402. * @param attribs The current list of supported attribs
  9403. * @param mesh The mesh to prepare the morph targets attributes for
  9404. * @param defines The current Defines of the effect
  9405. */
  9406. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9407. /**
  9408. * Prepares the list of attributes required for bones according to the effect defines.
  9409. * @param attribs The current list of supported attribs
  9410. * @param mesh The mesh to prepare the bones attributes for
  9411. * @param defines The current Defines of the effect
  9412. * @param fallbacks The current efffect fallback strategy
  9413. */
  9414. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9415. /**
  9416. * Check and prepare the list of attributes required for instances according to the effect defines.
  9417. * @param attribs The current list of supported attribs
  9418. * @param defines The current MaterialDefines of the effect
  9419. */
  9420. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9421. /**
  9422. * Add the list of attributes required for instances to the attribs array.
  9423. * @param attribs The current list of supported attribs
  9424. */
  9425. static PushAttributesForInstances(attribs: string[]): void;
  9426. /**
  9427. * Binds the light information to the effect.
  9428. * @param light The light containing the generator
  9429. * @param effect The effect we are binding the data to
  9430. * @param lightIndex The light index in the effect used to render
  9431. */
  9432. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9433. /**
  9434. * Binds the lights information from the scene to the effect for the given mesh.
  9435. * @param light Light to bind
  9436. * @param lightIndex Light index
  9437. * @param scene The scene where the light belongs to
  9438. * @param effect The effect we are binding the data to
  9439. * @param useSpecular Defines if specular is supported
  9440. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9441. */
  9442. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9443. /**
  9444. * Binds the lights information from the scene to the effect for the given mesh.
  9445. * @param scene The scene the lights belongs to
  9446. * @param mesh The mesh we are binding the information to render
  9447. * @param effect The effect we are binding the data to
  9448. * @param defines The generated defines for the effect
  9449. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9450. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9451. */
  9452. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9453. private static _tempFogColor;
  9454. /**
  9455. * Binds the fog information from the scene to the effect for the given mesh.
  9456. * @param scene The scene the lights belongs to
  9457. * @param mesh The mesh we are binding the information to render
  9458. * @param effect The effect we are binding the data to
  9459. * @param linearSpace Defines if the fog effect is applied in linear space
  9460. */
  9461. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9462. /**
  9463. * Binds the bones information from the mesh to the effect.
  9464. * @param mesh The mesh we are binding the information to render
  9465. * @param effect The effect we are binding the data to
  9466. */
  9467. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9468. /**
  9469. * Binds the morph targets information from the mesh to the effect.
  9470. * @param abstractMesh The mesh we are binding the information to render
  9471. * @param effect The effect we are binding the data to
  9472. */
  9473. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9474. /**
  9475. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9476. * @param defines The generated defines used in the effect
  9477. * @param effect The effect we are binding the data to
  9478. * @param scene The scene we are willing to render with logarithmic scale for
  9479. */
  9480. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9481. /**
  9482. * Binds the clip plane information from the scene to the effect.
  9483. * @param scene The scene the clip plane information are extracted from
  9484. * @param effect The effect we are binding the data to
  9485. */
  9486. static BindClipPlane(effect: Effect, scene: Scene): void;
  9487. }
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9490. /** @hidden */
  9491. export var packingFunctions: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9497. /** @hidden */
  9498. export var bayerDitherFunctions: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9504. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9505. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9506. /** @hidden */
  9507. export var shadowMapFragmentDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9513. /** @hidden */
  9514. export var clipPlaneFragmentDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9520. /** @hidden */
  9521. export var clipPlaneFragment: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9527. /** @hidden */
  9528. export var shadowMapFragment: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9535. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9537. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9538. /** @hidden */
  9539. export var shadowMapPixelShader: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9545. /** @hidden */
  9546. export var bonesDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9552. /** @hidden */
  9553. export var morphTargetsVertexGlobalDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9559. /** @hidden */
  9560. export var morphTargetsVertexDeclaration: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9566. /** @hidden */
  9567. export var instancesDeclaration: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9573. /** @hidden */
  9574. export var helperFunctions: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9580. /** @hidden */
  9581. export var shadowMapVertexDeclaration: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9587. /** @hidden */
  9588. export var clipPlaneVertexDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9594. /** @hidden */
  9595. export var morphTargetsVertex: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9601. /** @hidden */
  9602. export var instancesVertex: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9608. /** @hidden */
  9609. export var bonesVertex: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9615. /** @hidden */
  9616. export var shadowMapVertexNormalBias: {
  9617. name: string;
  9618. shader: string;
  9619. };
  9620. }
  9621. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9622. /** @hidden */
  9623. export var shadowMapVertexMetric: {
  9624. name: string;
  9625. shader: string;
  9626. };
  9627. }
  9628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9629. /** @hidden */
  9630. export var clipPlaneVertex: {
  9631. name: string;
  9632. shader: string;
  9633. };
  9634. }
  9635. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9636. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9637. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9641. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9643. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9644. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9645. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9646. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9647. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9649. /** @hidden */
  9650. export var shadowMapVertexShader: {
  9651. name: string;
  9652. shader: string;
  9653. };
  9654. }
  9655. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9656. /** @hidden */
  9657. export var depthBoxBlurPixelShader: {
  9658. name: string;
  9659. shader: string;
  9660. };
  9661. }
  9662. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9663. /** @hidden */
  9664. export var shadowMapFragmentSoftTransparentShadow: {
  9665. name: string;
  9666. shader: string;
  9667. };
  9668. }
  9669. declare module "babylonjs/Culling/ray" {
  9670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9677. import { Plane } from "babylonjs/Maths/math.plane";
  9678. /**
  9679. * Class representing a ray with position and direction
  9680. */
  9681. export class Ray {
  9682. /** origin point */
  9683. origin: Vector3;
  9684. /** direction */
  9685. direction: Vector3;
  9686. /** length of the ray */
  9687. length: number;
  9688. private static readonly TmpVector3;
  9689. private _tmpRay;
  9690. /**
  9691. * Creates a new ray
  9692. * @param origin origin point
  9693. * @param direction direction
  9694. * @param length length of the ray
  9695. */
  9696. constructor(
  9697. /** origin point */
  9698. origin: Vector3,
  9699. /** direction */
  9700. direction: Vector3,
  9701. /** length of the ray */
  9702. length?: number);
  9703. /**
  9704. * Checks if the ray intersects a box
  9705. * This does not account for the ray lenght by design to improve perfs.
  9706. * @param minimum bound of the box
  9707. * @param maximum bound of the box
  9708. * @param intersectionTreshold extra extend to be added to the box in all direction
  9709. * @returns if the box was hit
  9710. */
  9711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9712. /**
  9713. * Checks if the ray intersects a box
  9714. * This does not account for the ray lenght by design to improve perfs.
  9715. * @param box the bounding box to check
  9716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9717. * @returns if the box was hit
  9718. */
  9719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9720. /**
  9721. * If the ray hits a sphere
  9722. * @param sphere the bounding sphere to check
  9723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9724. * @returns true if it hits the sphere
  9725. */
  9726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9727. /**
  9728. * If the ray hits a triange
  9729. * @param vertex0 triangle vertex
  9730. * @param vertex1 triangle vertex
  9731. * @param vertex2 triangle vertex
  9732. * @returns intersection information if hit
  9733. */
  9734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9735. /**
  9736. * Checks if ray intersects a plane
  9737. * @param plane the plane to check
  9738. * @returns the distance away it was hit
  9739. */
  9740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9741. /**
  9742. * Calculate the intercept of a ray on a given axis
  9743. * @param axis to check 'x' | 'y' | 'z'
  9744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9746. */
  9747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9748. /**
  9749. * Checks if ray intersects a mesh
  9750. * @param mesh the mesh to check
  9751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9752. * @returns picking info of the intersecton
  9753. */
  9754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9755. /**
  9756. * Checks if ray intersects a mesh
  9757. * @param meshes the meshes to check
  9758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9759. * @param results array to store result in
  9760. * @returns Array of picking infos
  9761. */
  9762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9763. private _comparePickingInfo;
  9764. private static smallnum;
  9765. private static rayl;
  9766. /**
  9767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9768. * @param sega the first point of the segment to test the intersection against
  9769. * @param segb the second point of the segment to test the intersection against
  9770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9772. */
  9773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9774. /**
  9775. * Update the ray from viewport position
  9776. * @param x position
  9777. * @param y y position
  9778. * @param viewportWidth viewport width
  9779. * @param viewportHeight viewport height
  9780. * @param world world matrix
  9781. * @param view view matrix
  9782. * @param projection projection matrix
  9783. * @returns this ray updated
  9784. */
  9785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9786. /**
  9787. * Creates a ray with origin and direction of 0,0,0
  9788. * @returns the new ray
  9789. */
  9790. static Zero(): Ray;
  9791. /**
  9792. * Creates a new ray from screen space and viewport
  9793. * @param x position
  9794. * @param y y position
  9795. * @param viewportWidth viewport width
  9796. * @param viewportHeight viewport height
  9797. * @param world world matrix
  9798. * @param view view matrix
  9799. * @param projection projection matrix
  9800. * @returns new ray
  9801. */
  9802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9803. /**
  9804. * 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
  9805. * transformed to the given world matrix.
  9806. * @param origin The origin point
  9807. * @param end The end point
  9808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9809. * @returns the new ray
  9810. */
  9811. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9812. /**
  9813. * Transforms a ray by a matrix
  9814. * @param ray ray to transform
  9815. * @param matrix matrix to apply
  9816. * @returns the resulting new ray
  9817. */
  9818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9819. /**
  9820. * Transforms a ray by a matrix
  9821. * @param ray ray to transform
  9822. * @param matrix matrix to apply
  9823. * @param result ray to store result in
  9824. */
  9825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9826. /**
  9827. * Unproject a ray from screen space to object space
  9828. * @param sourceX defines the screen space x coordinate to use
  9829. * @param sourceY defines the screen space y coordinate to use
  9830. * @param viewportWidth defines the current width of the viewport
  9831. * @param viewportHeight defines the current height of the viewport
  9832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9833. * @param view defines the view matrix to use
  9834. * @param projection defines the projection matrix to use
  9835. */
  9836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9837. }
  9838. /**
  9839. * Type used to define predicate used to select faces when a mesh intersection is detected
  9840. */
  9841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9842. module "babylonjs/scene" {
  9843. interface Scene {
  9844. /** @hidden */
  9845. _tempPickingRay: Nullable<Ray>;
  9846. /** @hidden */
  9847. _cachedRayForTransform: Ray;
  9848. /** @hidden */
  9849. _pickWithRayInverseMatrix: Matrix;
  9850. /** @hidden */
  9851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9852. /** @hidden */
  9853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9854. }
  9855. }
  9856. }
  9857. declare module "babylonjs/sceneComponent" {
  9858. import { Scene } from "babylonjs/scene";
  9859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9861. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9862. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9863. import { Nullable } from "babylonjs/types";
  9864. import { Camera } from "babylonjs/Cameras/camera";
  9865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9866. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9867. import { AbstractScene } from "babylonjs/abstractScene";
  9868. import { Mesh } from "babylonjs/Meshes/mesh";
  9869. /**
  9870. * Groups all the scene component constants in one place to ease maintenance.
  9871. * @hidden
  9872. */
  9873. export class SceneComponentConstants {
  9874. static readonly NAME_EFFECTLAYER: string;
  9875. static readonly NAME_LAYER: string;
  9876. static readonly NAME_LENSFLARESYSTEM: string;
  9877. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9878. static readonly NAME_PARTICLESYSTEM: string;
  9879. static readonly NAME_GAMEPAD: string;
  9880. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9881. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9882. static readonly NAME_DEPTHRENDERER: string;
  9883. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9884. static readonly NAME_SPRITE: string;
  9885. static readonly NAME_OUTLINERENDERER: string;
  9886. static readonly NAME_PROCEDURALTEXTURE: string;
  9887. static readonly NAME_SHADOWGENERATOR: string;
  9888. static readonly NAME_OCTREE: string;
  9889. static readonly NAME_PHYSICSENGINE: string;
  9890. static readonly NAME_AUDIO: string;
  9891. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9892. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9893. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9894. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9895. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9896. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9897. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9898. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9899. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9900. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9901. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9902. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9903. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9904. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9905. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9906. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9907. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9908. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9909. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9910. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9911. static readonly STEP_AFTERRENDER_AUDIO: number;
  9912. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9913. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9914. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9915. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9916. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9917. static readonly STEP_POINTERMOVE_SPRITE: number;
  9918. static readonly STEP_POINTERDOWN_SPRITE: number;
  9919. static readonly STEP_POINTERUP_SPRITE: number;
  9920. }
  9921. /**
  9922. * This represents a scene component.
  9923. *
  9924. * This is used to decouple the dependency the scene is having on the different workloads like
  9925. * layers, post processes...
  9926. */
  9927. export interface ISceneComponent {
  9928. /**
  9929. * The name of the component. Each component must have a unique name.
  9930. */
  9931. name: string;
  9932. /**
  9933. * The scene the component belongs to.
  9934. */
  9935. scene: Scene;
  9936. /**
  9937. * Register the component to one instance of a scene.
  9938. */
  9939. register(): void;
  9940. /**
  9941. * Rebuilds the elements related to this component in case of
  9942. * context lost for instance.
  9943. */
  9944. rebuild(): void;
  9945. /**
  9946. * Disposes the component and the associated ressources.
  9947. */
  9948. dispose(): void;
  9949. }
  9950. /**
  9951. * This represents a SERIALIZABLE scene component.
  9952. *
  9953. * This extends Scene Component to add Serialization methods on top.
  9954. */
  9955. export interface ISceneSerializableComponent extends ISceneComponent {
  9956. /**
  9957. * Adds all the elements from the container to the scene
  9958. * @param container the container holding the elements
  9959. */
  9960. addFromContainer(container: AbstractScene): void;
  9961. /**
  9962. * Removes all the elements in the container from the scene
  9963. * @param container contains the elements to remove
  9964. * @param dispose if the removed element should be disposed (default: false)
  9965. */
  9966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9967. /**
  9968. * Serializes the component data to the specified json object
  9969. * @param serializationObject The object to serialize to
  9970. */
  9971. serialize(serializationObject: any): void;
  9972. }
  9973. /**
  9974. * Strong typing of a Mesh related stage step action
  9975. */
  9976. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9977. /**
  9978. * Strong typing of a Evaluate Sub Mesh related stage step action
  9979. */
  9980. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9981. /**
  9982. * Strong typing of a Active Mesh related stage step action
  9983. */
  9984. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9985. /**
  9986. * Strong typing of a Camera related stage step action
  9987. */
  9988. export type CameraStageAction = (camera: Camera) => void;
  9989. /**
  9990. * Strong typing of a Camera Frame buffer related stage step action
  9991. */
  9992. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9993. /**
  9994. * Strong typing of a Render Target related stage step action
  9995. */
  9996. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9997. /**
  9998. * Strong typing of a RenderingGroup related stage step action
  9999. */
  10000. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10001. /**
  10002. * Strong typing of a Mesh Render related stage step action
  10003. */
  10004. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10005. /**
  10006. * Strong typing of a simple stage step action
  10007. */
  10008. export type SimpleStageAction = () => void;
  10009. /**
  10010. * Strong typing of a render target action.
  10011. */
  10012. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10013. /**
  10014. * Strong typing of a pointer move action.
  10015. */
  10016. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10017. /**
  10018. * Strong typing of a pointer up/down action.
  10019. */
  10020. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10021. /**
  10022. * Representation of a stage in the scene (Basically a list of ordered steps)
  10023. * @hidden
  10024. */
  10025. export class Stage<T extends Function> extends Array<{
  10026. index: number;
  10027. component: ISceneComponent;
  10028. action: T;
  10029. }> {
  10030. /**
  10031. * Hide ctor from the rest of the world.
  10032. * @param items The items to add.
  10033. */
  10034. private constructor();
  10035. /**
  10036. * Creates a new Stage.
  10037. * @returns A new instance of a Stage
  10038. */
  10039. static Create<T extends Function>(): Stage<T>;
  10040. /**
  10041. * Registers a step in an ordered way in the targeted stage.
  10042. * @param index Defines the position to register the step in
  10043. * @param component Defines the component attached to the step
  10044. * @param action Defines the action to launch during the step
  10045. */
  10046. registerStep(index: number, component: ISceneComponent, action: T): void;
  10047. /**
  10048. * Clears all the steps from the stage.
  10049. */
  10050. clear(): void;
  10051. }
  10052. }
  10053. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10054. import { Nullable } from "babylonjs/types";
  10055. import { Observable } from "babylonjs/Misc/observable";
  10056. import { Scene } from "babylonjs/scene";
  10057. import { Sprite } from "babylonjs/Sprites/sprite";
  10058. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10059. import { Ray } from "babylonjs/Culling/ray";
  10060. import { Camera } from "babylonjs/Cameras/camera";
  10061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10062. import { ISceneComponent } from "babylonjs/sceneComponent";
  10063. module "babylonjs/scene" {
  10064. interface Scene {
  10065. /** @hidden */
  10066. _pointerOverSprite: Nullable<Sprite>;
  10067. /** @hidden */
  10068. _pickedDownSprite: Nullable<Sprite>;
  10069. /** @hidden */
  10070. _tempSpritePickingRay: Nullable<Ray>;
  10071. /**
  10072. * All of the sprite managers added to this scene
  10073. * @see http://doc.babylonjs.com/babylon101/sprites
  10074. */
  10075. spriteManagers: Array<ISpriteManager>;
  10076. /**
  10077. * An event triggered when sprites rendering is about to start
  10078. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10079. */
  10080. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10081. /**
  10082. * An event triggered when sprites rendering is done
  10083. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10084. */
  10085. onAfterSpritesRenderingObservable: Observable<Scene>;
  10086. /** @hidden */
  10087. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10088. /** Launch a ray to try to pick a sprite in the scene
  10089. * @param x position on screen
  10090. * @param y position on screen
  10091. * @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
  10092. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10094. * @returns a PickingInfo
  10095. */
  10096. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10097. /** Use the given ray to pick a sprite in the scene
  10098. * @param ray The ray (in world space) to use to pick meshes
  10099. * @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
  10100. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10101. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10102. * @returns a PickingInfo
  10103. */
  10104. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10105. /** @hidden */
  10106. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10107. /** Launch a ray to try to pick sprites in the scene
  10108. * @param x position on screen
  10109. * @param y position on screen
  10110. * @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
  10111. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10112. * @returns a PickingInfo array
  10113. */
  10114. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10115. /** Use the given ray to pick sprites in the scene
  10116. * @param ray The ray (in world space) to use to pick meshes
  10117. * @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
  10118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10119. * @returns a PickingInfo array
  10120. */
  10121. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10122. /**
  10123. * Force the sprite under the pointer
  10124. * @param sprite defines the sprite to use
  10125. */
  10126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10127. /**
  10128. * Gets the sprite under the pointer
  10129. * @returns a Sprite or null if no sprite is under the pointer
  10130. */
  10131. getPointerOverSprite(): Nullable<Sprite>;
  10132. }
  10133. }
  10134. /**
  10135. * Defines the sprite scene component responsible to manage sprites
  10136. * in a given scene.
  10137. */
  10138. export class SpriteSceneComponent implements ISceneComponent {
  10139. /**
  10140. * The component name helpfull to identify the component in the list of scene components.
  10141. */
  10142. readonly name: string;
  10143. /**
  10144. * The scene the component belongs to.
  10145. */
  10146. scene: Scene;
  10147. /** @hidden */
  10148. private _spritePredicate;
  10149. /**
  10150. * Creates a new instance of the component for the given scene
  10151. * @param scene Defines the scene to register the component in
  10152. */
  10153. constructor(scene: Scene);
  10154. /**
  10155. * Registers the component in a given scene
  10156. */
  10157. register(): void;
  10158. /**
  10159. * Rebuilds the elements related to this component in case of
  10160. * context lost for instance.
  10161. */
  10162. rebuild(): void;
  10163. /**
  10164. * Disposes the component and the associated ressources.
  10165. */
  10166. dispose(): void;
  10167. private _pickSpriteButKeepRay;
  10168. private _pointerMove;
  10169. private _pointerDown;
  10170. private _pointerUp;
  10171. }
  10172. }
  10173. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10174. /** @hidden */
  10175. export var fogFragmentDeclaration: {
  10176. name: string;
  10177. shader: string;
  10178. };
  10179. }
  10180. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10181. /** @hidden */
  10182. export var fogFragment: {
  10183. name: string;
  10184. shader: string;
  10185. };
  10186. }
  10187. declare module "babylonjs/Shaders/sprites.fragment" {
  10188. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10189. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10190. /** @hidden */
  10191. export var spritesPixelShader: {
  10192. name: string;
  10193. shader: string;
  10194. };
  10195. }
  10196. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10197. /** @hidden */
  10198. export var fogVertexDeclaration: {
  10199. name: string;
  10200. shader: string;
  10201. };
  10202. }
  10203. declare module "babylonjs/Shaders/sprites.vertex" {
  10204. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10205. /** @hidden */
  10206. export var spritesVertexShader: {
  10207. name: string;
  10208. shader: string;
  10209. };
  10210. }
  10211. declare module "babylonjs/Sprites/spriteManager" {
  10212. import { IDisposable, Scene } from "babylonjs/scene";
  10213. import { Nullable } from "babylonjs/types";
  10214. import { Observable } from "babylonjs/Misc/observable";
  10215. import { Sprite } from "babylonjs/Sprites/sprite";
  10216. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10217. import { Camera } from "babylonjs/Cameras/camera";
  10218. import { Texture } from "babylonjs/Materials/Textures/texture";
  10219. import "babylonjs/Shaders/sprites.fragment";
  10220. import "babylonjs/Shaders/sprites.vertex";
  10221. import { Ray } from "babylonjs/Culling/ray";
  10222. /**
  10223. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10224. */
  10225. export interface ISpriteManager extends IDisposable {
  10226. /**
  10227. * Restricts the camera to viewing objects with the same layerMask.
  10228. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10229. */
  10230. layerMask: number;
  10231. /**
  10232. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10233. */
  10234. isPickable: boolean;
  10235. /**
  10236. * Specifies the rendering group id for this mesh (0 by default)
  10237. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10238. */
  10239. renderingGroupId: number;
  10240. /**
  10241. * Defines the list of sprites managed by the manager.
  10242. */
  10243. sprites: Array<Sprite>;
  10244. /**
  10245. * Tests the intersection of a sprite with a specific ray.
  10246. * @param ray The ray we are sending to test the collision
  10247. * @param camera The camera space we are sending rays in
  10248. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10249. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10250. * @returns picking info or null.
  10251. */
  10252. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10253. /**
  10254. * Intersects the sprites with a ray
  10255. * @param ray defines the ray to intersect with
  10256. * @param camera defines the current active camera
  10257. * @param predicate defines a predicate used to select candidate sprites
  10258. * @returns null if no hit or a PickingInfo array
  10259. */
  10260. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10261. /**
  10262. * Renders the list of sprites on screen.
  10263. */
  10264. render(): void;
  10265. }
  10266. /**
  10267. * Class used to manage multiple sprites on the same spritesheet
  10268. * @see http://doc.babylonjs.com/babylon101/sprites
  10269. */
  10270. export class SpriteManager implements ISpriteManager {
  10271. /** defines the manager's name */
  10272. name: string;
  10273. /** Gets the list of sprites */
  10274. sprites: Sprite[];
  10275. /** Gets or sets the rendering group id (0 by default) */
  10276. renderingGroupId: number;
  10277. /** Gets or sets camera layer mask */
  10278. layerMask: number;
  10279. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10280. fogEnabled: boolean;
  10281. /** Gets or sets a boolean indicating if the sprites are pickable */
  10282. isPickable: boolean;
  10283. /** Defines the default width of a cell in the spritesheet */
  10284. cellWidth: number;
  10285. /** Defines the default height of a cell in the spritesheet */
  10286. cellHeight: number;
  10287. /** Associative array from JSON sprite data file */
  10288. private _cellData;
  10289. /** Array of sprite names from JSON sprite data file */
  10290. private _spriteMap;
  10291. /** True when packed cell data from JSON file is ready*/
  10292. private _packedAndReady;
  10293. private _textureContent;
  10294. /**
  10295. * An event triggered when the manager is disposed.
  10296. */
  10297. onDisposeObservable: Observable<SpriteManager>;
  10298. private _onDisposeObserver;
  10299. /**
  10300. * Callback called when the manager is disposed
  10301. */
  10302. set onDispose(callback: () => void);
  10303. private _capacity;
  10304. private _fromPacked;
  10305. private _spriteTexture;
  10306. private _epsilon;
  10307. private _scene;
  10308. private _vertexData;
  10309. private _buffer;
  10310. private _vertexBuffers;
  10311. private _indexBuffer;
  10312. private _effectBase;
  10313. private _effectFog;
  10314. /**
  10315. * Gets or sets the spritesheet texture
  10316. */
  10317. get texture(): Texture;
  10318. set texture(value: Texture);
  10319. private _blendMode;
  10320. /**
  10321. * Blend mode use to render the particle, it can be any of
  10322. * the static Constants.ALPHA_x properties provided in this class.
  10323. * Default value is Constants.ALPHA_COMBINE
  10324. */
  10325. get blendMode(): number;
  10326. set blendMode(blendMode: number);
  10327. /** Disables writing to the depth buffer when rendering the sprites.
  10328. * It can be handy to disable depth writing when using textures without alpha channel
  10329. * and setting some specific blend modes.
  10330. */
  10331. disableDepthWrite: boolean;
  10332. /**
  10333. * Creates a new sprite manager
  10334. * @param name defines the manager's name
  10335. * @param imgUrl defines the sprite sheet url
  10336. * @param capacity defines the maximum allowed number of sprites
  10337. * @param cellSize defines the size of a sprite cell
  10338. * @param scene defines the hosting scene
  10339. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10340. * @param samplingMode defines the smapling mode to use with spritesheet
  10341. * @param fromPacked set to false; do not alter
  10342. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10343. */
  10344. constructor(
  10345. /** defines the manager's name */
  10346. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10347. private _makePacked;
  10348. private _appendSpriteVertex;
  10349. private _checkTextureAlpha;
  10350. /**
  10351. * Intersects the sprites with a ray
  10352. * @param ray defines the ray to intersect with
  10353. * @param camera defines the current active camera
  10354. * @param predicate defines a predicate used to select candidate sprites
  10355. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10356. * @returns null if no hit or a PickingInfo
  10357. */
  10358. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10359. /**
  10360. * Intersects the sprites with a ray
  10361. * @param ray defines the ray to intersect with
  10362. * @param camera defines the current active camera
  10363. * @param predicate defines a predicate used to select candidate sprites
  10364. * @returns null if no hit or a PickingInfo array
  10365. */
  10366. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10367. /**
  10368. * Render all child sprites
  10369. */
  10370. render(): void;
  10371. /**
  10372. * Release associated resources
  10373. */
  10374. dispose(): void;
  10375. }
  10376. }
  10377. declare module "babylonjs/Misc/gradients" {
  10378. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10379. /** Interface used by value gradients (color, factor, ...) */
  10380. export interface IValueGradient {
  10381. /**
  10382. * Gets or sets the gradient value (between 0 and 1)
  10383. */
  10384. gradient: number;
  10385. }
  10386. /** Class used to store color4 gradient */
  10387. export class ColorGradient implements IValueGradient {
  10388. /**
  10389. * Gets or sets the gradient value (between 0 and 1)
  10390. */
  10391. gradient: number;
  10392. /**
  10393. * Gets or sets first associated color
  10394. */
  10395. color1: Color4;
  10396. /**
  10397. * Gets or sets second associated color
  10398. */
  10399. color2?: Color4 | undefined;
  10400. /**
  10401. * Creates a new color4 gradient
  10402. * @param gradient gets or sets the gradient value (between 0 and 1)
  10403. * @param color1 gets or sets first associated color
  10404. * @param color2 gets or sets first second color
  10405. */
  10406. constructor(
  10407. /**
  10408. * Gets or sets the gradient value (between 0 and 1)
  10409. */
  10410. gradient: number,
  10411. /**
  10412. * Gets or sets first associated color
  10413. */
  10414. color1: Color4,
  10415. /**
  10416. * Gets or sets second associated color
  10417. */
  10418. color2?: Color4 | undefined);
  10419. /**
  10420. * Will get a color picked randomly between color1 and color2.
  10421. * If color2 is undefined then color1 will be used
  10422. * @param result defines the target Color4 to store the result in
  10423. */
  10424. getColorToRef(result: Color4): void;
  10425. }
  10426. /** Class used to store color 3 gradient */
  10427. export class Color3Gradient implements IValueGradient {
  10428. /**
  10429. * Gets or sets the gradient value (between 0 and 1)
  10430. */
  10431. gradient: number;
  10432. /**
  10433. * Gets or sets the associated color
  10434. */
  10435. color: Color3;
  10436. /**
  10437. * Creates a new color3 gradient
  10438. * @param gradient gets or sets the gradient value (between 0 and 1)
  10439. * @param color gets or sets associated color
  10440. */
  10441. constructor(
  10442. /**
  10443. * Gets or sets the gradient value (between 0 and 1)
  10444. */
  10445. gradient: number,
  10446. /**
  10447. * Gets or sets the associated color
  10448. */
  10449. color: Color3);
  10450. }
  10451. /** Class used to store factor gradient */
  10452. export class FactorGradient implements IValueGradient {
  10453. /**
  10454. * Gets or sets the gradient value (between 0 and 1)
  10455. */
  10456. gradient: number;
  10457. /**
  10458. * Gets or sets first associated factor
  10459. */
  10460. factor1: number;
  10461. /**
  10462. * Gets or sets second associated factor
  10463. */
  10464. factor2?: number | undefined;
  10465. /**
  10466. * Creates a new factor gradient
  10467. * @param gradient gets or sets the gradient value (between 0 and 1)
  10468. * @param factor1 gets or sets first associated factor
  10469. * @param factor2 gets or sets second associated factor
  10470. */
  10471. constructor(
  10472. /**
  10473. * Gets or sets the gradient value (between 0 and 1)
  10474. */
  10475. gradient: number,
  10476. /**
  10477. * Gets or sets first associated factor
  10478. */
  10479. factor1: number,
  10480. /**
  10481. * Gets or sets second associated factor
  10482. */
  10483. factor2?: number | undefined);
  10484. /**
  10485. * Will get a number picked randomly between factor1 and factor2.
  10486. * If factor2 is undefined then factor1 will be used
  10487. * @returns the picked number
  10488. */
  10489. getFactor(): number;
  10490. }
  10491. /**
  10492. * Helper used to simplify some generic gradient tasks
  10493. */
  10494. export class GradientHelper {
  10495. /**
  10496. * Gets the current gradient from an array of IValueGradient
  10497. * @param ratio defines the current ratio to get
  10498. * @param gradients defines the array of IValueGradient
  10499. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10500. */
  10501. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10502. }
  10503. }
  10504. declare module "babylonjs/Maths/math.size" {
  10505. /**
  10506. * Interface for the size containing width and height
  10507. */
  10508. export interface ISize {
  10509. /**
  10510. * Width
  10511. */
  10512. width: number;
  10513. /**
  10514. * Heighht
  10515. */
  10516. height: number;
  10517. }
  10518. /**
  10519. * Size containing widht and height
  10520. */
  10521. export class Size implements ISize {
  10522. /**
  10523. * Width
  10524. */
  10525. width: number;
  10526. /**
  10527. * Height
  10528. */
  10529. height: number;
  10530. /**
  10531. * Creates a Size object from the given width and height (floats).
  10532. * @param width width of the new size
  10533. * @param height height of the new size
  10534. */
  10535. constructor(width: number, height: number);
  10536. /**
  10537. * Returns a string with the Size width and height
  10538. * @returns a string with the Size width and height
  10539. */
  10540. toString(): string;
  10541. /**
  10542. * "Size"
  10543. * @returns the string "Size"
  10544. */
  10545. getClassName(): string;
  10546. /**
  10547. * Returns the Size hash code.
  10548. * @returns a hash code for a unique width and height
  10549. */
  10550. getHashCode(): number;
  10551. /**
  10552. * Updates the current size from the given one.
  10553. * @param src the given size
  10554. */
  10555. copyFrom(src: Size): void;
  10556. /**
  10557. * Updates in place the current Size from the given floats.
  10558. * @param width width of the new size
  10559. * @param height height of the new size
  10560. * @returns the updated Size.
  10561. */
  10562. copyFromFloats(width: number, height: number): Size;
  10563. /**
  10564. * Updates in place the current Size from the given floats.
  10565. * @param width width to set
  10566. * @param height height to set
  10567. * @returns the updated Size.
  10568. */
  10569. set(width: number, height: number): Size;
  10570. /**
  10571. * Multiplies the width and height by numbers
  10572. * @param w factor to multiple the width by
  10573. * @param h factor to multiple the height by
  10574. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10575. */
  10576. multiplyByFloats(w: number, h: number): Size;
  10577. /**
  10578. * Clones the size
  10579. * @returns a new Size copied from the given one.
  10580. */
  10581. clone(): Size;
  10582. /**
  10583. * True if the current Size and the given one width and height are strictly equal.
  10584. * @param other the other size to compare against
  10585. * @returns True if the current Size and the given one width and height are strictly equal.
  10586. */
  10587. equals(other: Size): boolean;
  10588. /**
  10589. * The surface of the Size : width * height (float).
  10590. */
  10591. get surface(): number;
  10592. /**
  10593. * Create a new size of zero
  10594. * @returns a new Size set to (0.0, 0.0)
  10595. */
  10596. static Zero(): Size;
  10597. /**
  10598. * Sums the width and height of two sizes
  10599. * @param otherSize size to add to this size
  10600. * @returns a new Size set as the addition result of the current Size and the given one.
  10601. */
  10602. add(otherSize: Size): Size;
  10603. /**
  10604. * Subtracts the width and height of two
  10605. * @param otherSize size to subtract to this size
  10606. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10607. */
  10608. subtract(otherSize: Size): Size;
  10609. /**
  10610. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10611. * @param start starting size to lerp between
  10612. * @param end end size to lerp between
  10613. * @param amount amount to lerp between the start and end values
  10614. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10615. */
  10616. static Lerp(start: Size, end: Size, amount: number): Size;
  10617. }
  10618. }
  10619. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10621. import { Nullable } from "babylonjs/types";
  10622. module "babylonjs/Engines/thinEngine" {
  10623. interface ThinEngine {
  10624. /**
  10625. * Creates a dynamic texture
  10626. * @param width defines the width of the texture
  10627. * @param height defines the height of the texture
  10628. * @param generateMipMaps defines if the engine should generate the mip levels
  10629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10630. * @returns the dynamic texture inside an InternalTexture
  10631. */
  10632. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10633. /**
  10634. * Update the content of a dynamic texture
  10635. * @param texture defines the texture to update
  10636. * @param canvas defines the canvas containing the source
  10637. * @param invertY defines if data must be stored with Y axis inverted
  10638. * @param premulAlpha defines if alpha is stored as premultiplied
  10639. * @param format defines the format of the data
  10640. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10641. */
  10642. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10643. }
  10644. }
  10645. }
  10646. declare module "babylonjs/Misc/canvasGenerator" {
  10647. /**
  10648. * Helper class used to generate a canvas to manipulate images
  10649. */
  10650. export class CanvasGenerator {
  10651. /**
  10652. * Create a new canvas (or offscreen canvas depending on the context)
  10653. * @param width defines the expected width
  10654. * @param height defines the expected height
  10655. * @return a new canvas or offscreen canvas
  10656. */
  10657. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10658. }
  10659. }
  10660. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10661. import { Scene } from "babylonjs/scene";
  10662. import { Texture } from "babylonjs/Materials/Textures/texture";
  10663. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10664. /**
  10665. * A class extending Texture allowing drawing on a texture
  10666. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10667. */
  10668. export class DynamicTexture extends Texture {
  10669. private _generateMipMaps;
  10670. private _canvas;
  10671. private _context;
  10672. /**
  10673. * Creates a DynamicTexture
  10674. * @param name defines the name of the texture
  10675. * @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
  10676. * @param scene defines the scene where you want the texture
  10677. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10678. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10679. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10680. */
  10681. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10682. /**
  10683. * Get the current class name of the texture useful for serialization or dynamic coding.
  10684. * @returns "DynamicTexture"
  10685. */
  10686. getClassName(): string;
  10687. /**
  10688. * Gets the current state of canRescale
  10689. */
  10690. get canRescale(): boolean;
  10691. private _recreate;
  10692. /**
  10693. * Scales the texture
  10694. * @param ratio the scale factor to apply to both width and height
  10695. */
  10696. scale(ratio: number): void;
  10697. /**
  10698. * Resizes the texture
  10699. * @param width the new width
  10700. * @param height the new height
  10701. */
  10702. scaleTo(width: number, height: number): void;
  10703. /**
  10704. * Gets the context of the canvas used by the texture
  10705. * @returns the canvas context of the dynamic texture
  10706. */
  10707. getContext(): CanvasRenderingContext2D;
  10708. /**
  10709. * Clears the texture
  10710. */
  10711. clear(): void;
  10712. /**
  10713. * Updates the texture
  10714. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10715. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10716. */
  10717. update(invertY?: boolean, premulAlpha?: boolean): void;
  10718. /**
  10719. * Draws text onto the texture
  10720. * @param text defines the text to be drawn
  10721. * @param x defines the placement of the text from the left
  10722. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10723. * @param font defines the font to be used with font-style, font-size, font-name
  10724. * @param color defines the color used for the text
  10725. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10726. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10727. * @param update defines whether texture is immediately update (default is true)
  10728. */
  10729. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10730. /**
  10731. * Clones the texture
  10732. * @returns the clone of the texture.
  10733. */
  10734. clone(): DynamicTexture;
  10735. /**
  10736. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10737. * @returns a serialized dynamic texture object
  10738. */
  10739. serialize(): any;
  10740. /** @hidden */
  10741. _rebuild(): void;
  10742. }
  10743. }
  10744. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10745. import { Nullable } from "babylonjs/types";
  10746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10747. import { Scene } from "babylonjs/scene";
  10748. module "babylonjs/Engines/thinEngine" {
  10749. interface ThinEngine {
  10750. /**
  10751. * Creates a raw texture
  10752. * @param data defines the data to store in the texture
  10753. * @param width defines the width of the texture
  10754. * @param height defines the height of the texture
  10755. * @param format defines the format of the data
  10756. * @param generateMipMaps defines if the engine should generate the mip levels
  10757. * @param invertY defines if data must be stored with Y axis inverted
  10758. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10759. * @param compression defines the compression used (null by default)
  10760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10761. * @returns the raw texture inside an InternalTexture
  10762. */
  10763. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10764. /**
  10765. * Update a raw texture
  10766. * @param texture defines the texture to update
  10767. * @param data defines the data to store in the texture
  10768. * @param format defines the format of the data
  10769. * @param invertY defines if data must be stored with Y axis inverted
  10770. */
  10771. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10772. /**
  10773. * Update a raw texture
  10774. * @param texture defines the texture to update
  10775. * @param data defines the data to store in the texture
  10776. * @param format defines the format of the data
  10777. * @param invertY defines if data must be stored with Y axis inverted
  10778. * @param compression defines the compression used (null by default)
  10779. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10780. */
  10781. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10782. /**
  10783. * Creates a new raw cube texture
  10784. * @param data defines the array of data to use to create each face
  10785. * @param size defines the size of the textures
  10786. * @param format defines the format of the data
  10787. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10788. * @param generateMipMaps defines if the engine should generate the mip levels
  10789. * @param invertY defines if data must be stored with Y axis inverted
  10790. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10791. * @param compression defines the compression used (null by default)
  10792. * @returns the cube texture as an InternalTexture
  10793. */
  10794. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10795. /**
  10796. * Update a raw cube texture
  10797. * @param texture defines the texture to udpdate
  10798. * @param data defines the data to store
  10799. * @param format defines the data format
  10800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10801. * @param invertY defines if data must be stored with Y axis inverted
  10802. */
  10803. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10804. /**
  10805. * Update a raw cube texture
  10806. * @param texture defines the texture to udpdate
  10807. * @param data defines the data to store
  10808. * @param format defines the data format
  10809. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10810. * @param invertY defines if data must be stored with Y axis inverted
  10811. * @param compression defines the compression used (null by default)
  10812. */
  10813. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10814. /**
  10815. * Update a raw cube texture
  10816. * @param texture defines the texture to udpdate
  10817. * @param data defines the data to store
  10818. * @param format defines the data format
  10819. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10820. * @param invertY defines if data must be stored with Y axis inverted
  10821. * @param compression defines the compression used (null by default)
  10822. * @param level defines which level of the texture to update
  10823. */
  10824. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10825. /**
  10826. * Creates a new raw cube texture from a specified url
  10827. * @param url defines the url where the data is located
  10828. * @param scene defines the current scene
  10829. * @param size defines the size of the textures
  10830. * @param format defines the format of the data
  10831. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10832. * @param noMipmap defines if the engine should avoid generating the mip levels
  10833. * @param callback defines a callback used to extract texture data from loaded data
  10834. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10835. * @param onLoad defines a callback called when texture is loaded
  10836. * @param onError defines a callback called if there is an error
  10837. * @returns the cube texture as an InternalTexture
  10838. */
  10839. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10840. /**
  10841. * Creates a new raw cube texture from a specified url
  10842. * @param url defines the url where the data is located
  10843. * @param scene defines the current scene
  10844. * @param size defines the size of the textures
  10845. * @param format defines the format of the data
  10846. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10847. * @param noMipmap defines if the engine should avoid generating the mip levels
  10848. * @param callback defines a callback used to extract texture data from loaded data
  10849. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10850. * @param onLoad defines a callback called when texture is loaded
  10851. * @param onError defines a callback called if there is an error
  10852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10853. * @param invertY defines if data must be stored with Y axis inverted
  10854. * @returns the cube texture as an InternalTexture
  10855. */
  10856. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10857. /**
  10858. * Creates a new raw 3D texture
  10859. * @param data defines the data used to create the texture
  10860. * @param width defines the width of the texture
  10861. * @param height defines the height of the texture
  10862. * @param depth defines the depth of the texture
  10863. * @param format defines the format of the texture
  10864. * @param generateMipMaps defines if the engine must generate mip levels
  10865. * @param invertY defines if data must be stored with Y axis inverted
  10866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10867. * @param compression defines the compressed used (can be null)
  10868. * @param textureType defines the compressed used (can be null)
  10869. * @returns a new raw 3D texture (stored in an InternalTexture)
  10870. */
  10871. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10872. /**
  10873. * Update a raw 3D texture
  10874. * @param texture defines the texture to update
  10875. * @param data defines the data to store
  10876. * @param format defines the data format
  10877. * @param invertY defines if data must be stored with Y axis inverted
  10878. */
  10879. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10880. /**
  10881. * Update a raw 3D texture
  10882. * @param texture defines the texture to update
  10883. * @param data defines the data to store
  10884. * @param format defines the data format
  10885. * @param invertY defines if data must be stored with Y axis inverted
  10886. * @param compression defines the used compression (can be null)
  10887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10888. */
  10889. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10890. /**
  10891. * Creates a new raw 2D array texture
  10892. * @param data defines the data used to create the texture
  10893. * @param width defines the width of the texture
  10894. * @param height defines the height of the texture
  10895. * @param depth defines the number of layers of the texture
  10896. * @param format defines the format of the texture
  10897. * @param generateMipMaps defines if the engine must generate mip levels
  10898. * @param invertY defines if data must be stored with Y axis inverted
  10899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10900. * @param compression defines the compressed used (can be null)
  10901. * @param textureType defines the compressed used (can be null)
  10902. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10903. */
  10904. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10905. /**
  10906. * Update a raw 2D array texture
  10907. * @param texture defines the texture to update
  10908. * @param data defines the data to store
  10909. * @param format defines the data format
  10910. * @param invertY defines if data must be stored with Y axis inverted
  10911. */
  10912. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10913. /**
  10914. * Update a raw 2D array texture
  10915. * @param texture defines the texture to update
  10916. * @param data defines the data to store
  10917. * @param format defines the data format
  10918. * @param invertY defines if data must be stored with Y axis inverted
  10919. * @param compression defines the used compression (can be null)
  10920. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10921. */
  10922. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10923. }
  10924. }
  10925. }
  10926. declare module "babylonjs/Materials/Textures/rawTexture" {
  10927. import { Scene } from "babylonjs/scene";
  10928. import { Texture } from "babylonjs/Materials/Textures/texture";
  10929. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10930. /**
  10931. * Raw texture can help creating a texture directly from an array of data.
  10932. * This can be super useful if you either get the data from an uncompressed source or
  10933. * if you wish to create your texture pixel by pixel.
  10934. */
  10935. export class RawTexture extends Texture {
  10936. /**
  10937. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10938. */
  10939. format: number;
  10940. /**
  10941. * Instantiates a new RawTexture.
  10942. * Raw texture can help creating a texture directly from an array of data.
  10943. * This can be super useful if you either get the data from an uncompressed source or
  10944. * if you wish to create your texture pixel by pixel.
  10945. * @param data define the array of data to use to create the texture
  10946. * @param width define the width of the texture
  10947. * @param height define the height of the texture
  10948. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10949. * @param scene define the scene the texture belongs to
  10950. * @param generateMipMaps define whether mip maps should be generated or not
  10951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10954. */
  10955. constructor(data: ArrayBufferView, width: number, height: number,
  10956. /**
  10957. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10958. */
  10959. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10960. /**
  10961. * Updates the texture underlying data.
  10962. * @param data Define the new data of the texture
  10963. */
  10964. update(data: ArrayBufferView): void;
  10965. /**
  10966. * Creates a luminance texture from some data.
  10967. * @param data Define the texture data
  10968. * @param width Define the width of the texture
  10969. * @param height Define the height of the texture
  10970. * @param scene Define the scene the texture belongs to
  10971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10974. * @returns the luminance texture
  10975. */
  10976. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10977. /**
  10978. * Creates a luminance alpha texture from some data.
  10979. * @param data Define the texture data
  10980. * @param width Define the width of the texture
  10981. * @param height Define the height of the texture
  10982. * @param scene Define the scene the texture belongs to
  10983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10986. * @returns the luminance alpha texture
  10987. */
  10988. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10989. /**
  10990. * Creates an alpha texture from some data.
  10991. * @param data Define the texture data
  10992. * @param width Define the width of the texture
  10993. * @param height Define the height of the texture
  10994. * @param scene Define the scene the texture belongs to
  10995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10998. * @returns the alpha texture
  10999. */
  11000. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11001. /**
  11002. * Creates a RGB texture from some data.
  11003. * @param data Define the texture data
  11004. * @param width Define the width of the texture
  11005. * @param height Define the height of the texture
  11006. * @param scene Define the scene the texture belongs to
  11007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11011. * @returns the RGB alpha texture
  11012. */
  11013. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11014. /**
  11015. * Creates a RGBA texture from some data.
  11016. * @param data Define the texture data
  11017. * @param width Define the width of the texture
  11018. * @param height Define the height of the texture
  11019. * @param scene Define the scene the texture belongs to
  11020. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11021. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11022. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11023. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11024. * @returns the RGBA texture
  11025. */
  11026. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11027. /**
  11028. * Creates a R texture from some data.
  11029. * @param data Define the texture data
  11030. * @param width Define the width of the texture
  11031. * @param height Define the height of the texture
  11032. * @param scene Define the scene the texture belongs to
  11033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11036. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11037. * @returns the R texture
  11038. */
  11039. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11040. }
  11041. }
  11042. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11043. import { Scene } from "babylonjs/scene";
  11044. import { ISceneComponent } from "babylonjs/sceneComponent";
  11045. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11046. module "babylonjs/abstractScene" {
  11047. interface AbstractScene {
  11048. /**
  11049. * The list of procedural textures added to the scene
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11051. */
  11052. proceduralTextures: Array<ProceduralTexture>;
  11053. }
  11054. }
  11055. /**
  11056. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11057. * in a given scene.
  11058. */
  11059. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11060. /**
  11061. * The component name helpfull to identify the component in the list of scene components.
  11062. */
  11063. readonly name: string;
  11064. /**
  11065. * The scene the component belongs to.
  11066. */
  11067. scene: Scene;
  11068. /**
  11069. * Creates a new instance of the component for the given scene
  11070. * @param scene Defines the scene to register the component in
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Registers the component in a given scene
  11075. */
  11076. register(): void;
  11077. /**
  11078. * Rebuilds the elements related to this component in case of
  11079. * context lost for instance.
  11080. */
  11081. rebuild(): void;
  11082. /**
  11083. * Disposes the component and the associated ressources.
  11084. */
  11085. dispose(): void;
  11086. private _beforeClear;
  11087. }
  11088. }
  11089. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11091. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11092. module "babylonjs/Engines/thinEngine" {
  11093. interface ThinEngine {
  11094. /**
  11095. * Creates a new render target cube texture
  11096. * @param size defines the size of the texture
  11097. * @param options defines the options used to create the texture
  11098. * @returns a new render target cube texture stored in an InternalTexture
  11099. */
  11100. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11101. }
  11102. }
  11103. }
  11104. declare module "babylonjs/Shaders/procedural.vertex" {
  11105. /** @hidden */
  11106. export var proceduralVertexShader: {
  11107. name: string;
  11108. shader: string;
  11109. };
  11110. }
  11111. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11112. import { Observable } from "babylonjs/Misc/observable";
  11113. import { Nullable } from "babylonjs/types";
  11114. import { Scene } from "babylonjs/scene";
  11115. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11116. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11117. import { Effect } from "babylonjs/Materials/effect";
  11118. import { Texture } from "babylonjs/Materials/Textures/texture";
  11119. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11120. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11121. import "babylonjs/Shaders/procedural.vertex";
  11122. /**
  11123. * 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.
  11124. * This is the base class of any Procedural texture and contains most of the shareable code.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11126. */
  11127. export class ProceduralTexture extends Texture {
  11128. isCube: boolean;
  11129. /**
  11130. * Define if the texture is enabled or not (disabled texture will not render)
  11131. */
  11132. isEnabled: boolean;
  11133. /**
  11134. * Define if the texture must be cleared before rendering (default is true)
  11135. */
  11136. autoClear: boolean;
  11137. /**
  11138. * Callback called when the texture is generated
  11139. */
  11140. onGenerated: () => void;
  11141. /**
  11142. * Event raised when the texture is generated
  11143. */
  11144. onGeneratedObservable: Observable<ProceduralTexture>;
  11145. /** @hidden */
  11146. _generateMipMaps: boolean;
  11147. /** @hidden **/
  11148. _effect: Effect;
  11149. /** @hidden */
  11150. _textures: {
  11151. [key: string]: Texture;
  11152. };
  11153. /** @hidden */
  11154. protected _fallbackTexture: Nullable<Texture>;
  11155. private _size;
  11156. private _currentRefreshId;
  11157. private _frameId;
  11158. private _refreshRate;
  11159. private _vertexBuffers;
  11160. private _indexBuffer;
  11161. private _uniforms;
  11162. private _samplers;
  11163. private _fragment;
  11164. private _floats;
  11165. private _ints;
  11166. private _floatsArrays;
  11167. private _colors3;
  11168. private _colors4;
  11169. private _vectors2;
  11170. private _vectors3;
  11171. private _matrices;
  11172. private _fallbackTextureUsed;
  11173. private _fullEngine;
  11174. private _cachedDefines;
  11175. private _contentUpdateId;
  11176. private _contentData;
  11177. /**
  11178. * Instantiates a new procedural texture.
  11179. * 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.
  11180. * This is the base class of any Procedural texture and contains most of the shareable code.
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11182. * @param name Define the name of the texture
  11183. * @param size Define the size of the texture to create
  11184. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11185. * @param scene Define the scene the texture belongs to
  11186. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11187. * @param generateMipMaps Define if the texture should creates mip maps or not
  11188. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11189. */
  11190. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11191. /**
  11192. * The effect that is created when initializing the post process.
  11193. * @returns The created effect corresponding the the postprocess.
  11194. */
  11195. getEffect(): Effect;
  11196. /**
  11197. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11198. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11199. */
  11200. getContent(): Nullable<ArrayBufferView>;
  11201. private _createIndexBuffer;
  11202. /** @hidden */
  11203. _rebuild(): void;
  11204. /**
  11205. * Resets the texture in order to recreate its associated resources.
  11206. * This can be called in case of context loss
  11207. */
  11208. reset(): void;
  11209. protected _getDefines(): string;
  11210. /**
  11211. * Is the texture ready to be used ? (rendered at least once)
  11212. * @returns true if ready, otherwise, false.
  11213. */
  11214. isReady(): boolean;
  11215. /**
  11216. * Resets the refresh counter of the texture and start bak from scratch.
  11217. * Could be useful to regenerate the texture if it is setup to render only once.
  11218. */
  11219. resetRefreshCounter(): void;
  11220. /**
  11221. * Set the fragment shader to use in order to render the texture.
  11222. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11223. */
  11224. setFragment(fragment: any): void;
  11225. /**
  11226. * Define the refresh rate of the texture or the rendering frequency.
  11227. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11228. */
  11229. get refreshRate(): number;
  11230. set refreshRate(value: number);
  11231. /** @hidden */
  11232. _shouldRender(): boolean;
  11233. /**
  11234. * Get the size the texture is rendering at.
  11235. * @returns the size (texture is always squared)
  11236. */
  11237. getRenderSize(): number;
  11238. /**
  11239. * Resize the texture to new value.
  11240. * @param size Define the new size the texture should have
  11241. * @param generateMipMaps Define whether the new texture should create mip maps
  11242. */
  11243. resize(size: number, generateMipMaps: boolean): void;
  11244. private _checkUniform;
  11245. /**
  11246. * Set a texture in the shader program used to render.
  11247. * @param name Define the name of the uniform samplers as defined in the shader
  11248. * @param texture Define the texture to bind to this sampler
  11249. * @return the texture itself allowing "fluent" like uniform updates
  11250. */
  11251. setTexture(name: string, texture: Texture): ProceduralTexture;
  11252. /**
  11253. * Set a float in the shader.
  11254. * @param name Define the name of the uniform as defined in the shader
  11255. * @param value Define the value to give to the uniform
  11256. * @return the texture itself allowing "fluent" like uniform updates
  11257. */
  11258. setFloat(name: string, value: number): ProceduralTexture;
  11259. /**
  11260. * Set a int in the shader.
  11261. * @param name Define the name of the uniform as defined in the shader
  11262. * @param value Define the value to give to the uniform
  11263. * @return the texture itself allowing "fluent" like uniform updates
  11264. */
  11265. setInt(name: string, value: number): ProceduralTexture;
  11266. /**
  11267. * Set an array of floats in the shader.
  11268. * @param name Define the name of the uniform as defined in the shader
  11269. * @param value Define the value to give to the uniform
  11270. * @return the texture itself allowing "fluent" like uniform updates
  11271. */
  11272. setFloats(name: string, value: number[]): ProceduralTexture;
  11273. /**
  11274. * Set a vec3 in the shader from a Color3.
  11275. * @param name Define the name of the uniform as defined in the shader
  11276. * @param value Define the value to give to the uniform
  11277. * @return the texture itself allowing "fluent" like uniform updates
  11278. */
  11279. setColor3(name: string, value: Color3): ProceduralTexture;
  11280. /**
  11281. * Set a vec4 in the shader from a Color4.
  11282. * @param name Define the name of the uniform as defined in the shader
  11283. * @param value Define the value to give to the uniform
  11284. * @return the texture itself allowing "fluent" like uniform updates
  11285. */
  11286. setColor4(name: string, value: Color4): ProceduralTexture;
  11287. /**
  11288. * Set a vec2 in the shader from a Vector2.
  11289. * @param name Define the name of the uniform as defined in the shader
  11290. * @param value Define the value to give to the uniform
  11291. * @return the texture itself allowing "fluent" like uniform updates
  11292. */
  11293. setVector2(name: string, value: Vector2): ProceduralTexture;
  11294. /**
  11295. * Set a vec3 in the shader from a Vector3.
  11296. * @param name Define the name of the uniform as defined in the shader
  11297. * @param value Define the value to give to the uniform
  11298. * @return the texture itself allowing "fluent" like uniform updates
  11299. */
  11300. setVector3(name: string, value: Vector3): ProceduralTexture;
  11301. /**
  11302. * Set a mat4 in the shader from a MAtrix.
  11303. * @param name Define the name of the uniform as defined in the shader
  11304. * @param value Define the value to give to the uniform
  11305. * @return the texture itself allowing "fluent" like uniform updates
  11306. */
  11307. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11308. /**
  11309. * Render the texture to its associated render target.
  11310. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11311. */
  11312. render(useCameraPostProcess?: boolean): void;
  11313. /**
  11314. * Clone the texture.
  11315. * @returns the cloned texture
  11316. */
  11317. clone(): ProceduralTexture;
  11318. /**
  11319. * Dispose the texture and release its asoociated resources.
  11320. */
  11321. dispose(): void;
  11322. }
  11323. }
  11324. declare module "babylonjs/Particles/baseParticleSystem" {
  11325. import { Nullable } from "babylonjs/types";
  11326. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11328. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11329. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11330. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11331. import { Scene } from "babylonjs/scene";
  11332. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11333. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11334. import { Texture } from "babylonjs/Materials/Textures/texture";
  11335. import { Color4 } from "babylonjs/Maths/math.color";
  11336. import { Animation } from "babylonjs/Animations/animation";
  11337. /**
  11338. * This represents the base class for particle system in Babylon.
  11339. * 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.
  11340. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11341. * @example https://doc.babylonjs.com/babylon101/particles
  11342. */
  11343. export class BaseParticleSystem {
  11344. /**
  11345. * Source color is added to the destination color without alpha affecting the result
  11346. */
  11347. static BLENDMODE_ONEONE: number;
  11348. /**
  11349. * Blend current color and particle color using particle’s alpha
  11350. */
  11351. static BLENDMODE_STANDARD: number;
  11352. /**
  11353. * Add current color and particle color multiplied by particle’s alpha
  11354. */
  11355. static BLENDMODE_ADD: number;
  11356. /**
  11357. * Multiply current color with particle color
  11358. */
  11359. static BLENDMODE_MULTIPLY: number;
  11360. /**
  11361. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11362. */
  11363. static BLENDMODE_MULTIPLYADD: number;
  11364. /**
  11365. * List of animations used by the particle system.
  11366. */
  11367. animations: Animation[];
  11368. /**
  11369. * Gets or sets the unique id of the particle system
  11370. */
  11371. uniqueId: number;
  11372. /**
  11373. * The id of the Particle system.
  11374. */
  11375. id: string;
  11376. /**
  11377. * The friendly name of the Particle system.
  11378. */
  11379. name: string;
  11380. /**
  11381. * Snippet ID if the particle system was created from the snippet server
  11382. */
  11383. snippetId: string;
  11384. /**
  11385. * The rendering group used by the Particle system to chose when to render.
  11386. */
  11387. renderingGroupId: number;
  11388. /**
  11389. * The emitter represents the Mesh or position we are attaching the particle system to.
  11390. */
  11391. emitter: Nullable<AbstractMesh | Vector3>;
  11392. /**
  11393. * The maximum number of particles to emit per frame
  11394. */
  11395. emitRate: number;
  11396. /**
  11397. * If you want to launch only a few particles at once, that can be done, as well.
  11398. */
  11399. manualEmitCount: number;
  11400. /**
  11401. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11402. */
  11403. updateSpeed: number;
  11404. /**
  11405. * The amount of time the particle system is running (depends of the overall update speed).
  11406. */
  11407. targetStopDuration: number;
  11408. /**
  11409. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11410. */
  11411. disposeOnStop: boolean;
  11412. /**
  11413. * Minimum power of emitting particles.
  11414. */
  11415. minEmitPower: number;
  11416. /**
  11417. * Maximum power of emitting particles.
  11418. */
  11419. maxEmitPower: number;
  11420. /**
  11421. * Minimum life time of emitting particles.
  11422. */
  11423. minLifeTime: number;
  11424. /**
  11425. * Maximum life time of emitting particles.
  11426. */
  11427. maxLifeTime: number;
  11428. /**
  11429. * Minimum Size of emitting particles.
  11430. */
  11431. minSize: number;
  11432. /**
  11433. * Maximum Size of emitting particles.
  11434. */
  11435. maxSize: number;
  11436. /**
  11437. * Minimum scale of emitting particles on X axis.
  11438. */
  11439. minScaleX: number;
  11440. /**
  11441. * Maximum scale of emitting particles on X axis.
  11442. */
  11443. maxScaleX: number;
  11444. /**
  11445. * Minimum scale of emitting particles on Y axis.
  11446. */
  11447. minScaleY: number;
  11448. /**
  11449. * Maximum scale of emitting particles on Y axis.
  11450. */
  11451. maxScaleY: number;
  11452. /**
  11453. * Gets or sets the minimal initial rotation in radians.
  11454. */
  11455. minInitialRotation: number;
  11456. /**
  11457. * Gets or sets the maximal initial rotation in radians.
  11458. */
  11459. maxInitialRotation: number;
  11460. /**
  11461. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11462. */
  11463. minAngularSpeed: number;
  11464. /**
  11465. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11466. */
  11467. maxAngularSpeed: number;
  11468. /**
  11469. * The texture used to render each particle. (this can be a spritesheet)
  11470. */
  11471. particleTexture: Nullable<Texture>;
  11472. /**
  11473. * The layer mask we are rendering the particles through.
  11474. */
  11475. layerMask: number;
  11476. /**
  11477. * This can help using your own shader to render the particle system.
  11478. * The according effect will be created
  11479. */
  11480. customShader: any;
  11481. /**
  11482. * By default particle system starts as soon as they are created. This prevents the
  11483. * automatic start to happen and let you decide when to start emitting particles.
  11484. */
  11485. preventAutoStart: boolean;
  11486. private _noiseTexture;
  11487. /**
  11488. * Gets or sets a texture used to add random noise to particle positions
  11489. */
  11490. get noiseTexture(): Nullable<ProceduralTexture>;
  11491. set noiseTexture(value: Nullable<ProceduralTexture>);
  11492. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11493. noiseStrength: Vector3;
  11494. /**
  11495. * Callback triggered when the particle animation is ending.
  11496. */
  11497. onAnimationEnd: Nullable<() => void>;
  11498. /**
  11499. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11500. */
  11501. blendMode: number;
  11502. /**
  11503. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11504. * to override the particles.
  11505. */
  11506. forceDepthWrite: boolean;
  11507. /** 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 */
  11508. preWarmCycles: number;
  11509. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11510. preWarmStepOffset: number;
  11511. /**
  11512. * 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)
  11513. */
  11514. spriteCellChangeSpeed: number;
  11515. /**
  11516. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11517. */
  11518. startSpriteCellID: number;
  11519. /**
  11520. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11521. */
  11522. endSpriteCellID: number;
  11523. /**
  11524. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11525. */
  11526. spriteCellWidth: number;
  11527. /**
  11528. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11529. */
  11530. spriteCellHeight: number;
  11531. /**
  11532. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11533. */
  11534. spriteRandomStartCell: boolean;
  11535. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11536. translationPivot: Vector2;
  11537. /** @hidden */
  11538. protected _isAnimationSheetEnabled: boolean;
  11539. /**
  11540. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11541. */
  11542. beginAnimationOnStart: boolean;
  11543. /**
  11544. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11545. */
  11546. beginAnimationFrom: number;
  11547. /**
  11548. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11549. */
  11550. beginAnimationTo: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11553. */
  11554. beginAnimationLoop: boolean;
  11555. /**
  11556. * Gets or sets a world offset applied to all particles
  11557. */
  11558. worldOffset: Vector3;
  11559. /**
  11560. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11561. */
  11562. get isAnimationSheetEnabled(): boolean;
  11563. set isAnimationSheetEnabled(value: boolean);
  11564. /**
  11565. * Get hosting scene
  11566. * @returns the scene
  11567. */
  11568. getScene(): Scene;
  11569. /**
  11570. * You can use gravity if you want to give an orientation to your particles.
  11571. */
  11572. gravity: Vector3;
  11573. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11574. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11575. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11576. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11577. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11578. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11579. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11580. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11581. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11582. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11583. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11584. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11585. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11586. /**
  11587. * Defines the delay in milliseconds before starting the system (0 by default)
  11588. */
  11589. startDelay: number;
  11590. /**
  11591. * Gets the current list of drag gradients.
  11592. * You must use addDragGradient and removeDragGradient to udpate this list
  11593. * @returns the list of drag gradients
  11594. */
  11595. getDragGradients(): Nullable<Array<FactorGradient>>;
  11596. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11597. limitVelocityDamping: number;
  11598. /**
  11599. * Gets the current list of limit velocity gradients.
  11600. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11601. * @returns the list of limit velocity gradients
  11602. */
  11603. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11604. /**
  11605. * Gets the current list of color gradients.
  11606. * You must use addColorGradient and removeColorGradient to udpate this list
  11607. * @returns the list of color gradients
  11608. */
  11609. getColorGradients(): Nullable<Array<ColorGradient>>;
  11610. /**
  11611. * Gets the current list of size gradients.
  11612. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11613. * @returns the list of size gradients
  11614. */
  11615. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11616. /**
  11617. * Gets the current list of color remap gradients.
  11618. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11619. * @returns the list of color remap gradients
  11620. */
  11621. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11622. /**
  11623. * Gets the current list of alpha remap gradients.
  11624. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11625. * @returns the list of alpha remap gradients
  11626. */
  11627. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11628. /**
  11629. * Gets the current list of life time gradients.
  11630. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11631. * @returns the list of life time gradients
  11632. */
  11633. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11634. /**
  11635. * Gets the current list of angular speed gradients.
  11636. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11637. * @returns the list of angular speed gradients
  11638. */
  11639. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11640. /**
  11641. * Gets the current list of velocity gradients.
  11642. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11643. * @returns the list of velocity gradients
  11644. */
  11645. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11646. /**
  11647. * Gets the current list of start size gradients.
  11648. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11649. * @returns the list of start size gradients
  11650. */
  11651. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11652. /**
  11653. * Gets the current list of emit rate gradients.
  11654. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11655. * @returns the list of emit rate gradients
  11656. */
  11657. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11658. /**
  11659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11660. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11661. */
  11662. get direction1(): Vector3;
  11663. set direction1(value: Vector3);
  11664. /**
  11665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11667. */
  11668. get direction2(): Vector3;
  11669. set direction2(value: Vector3);
  11670. /**
  11671. * 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.
  11672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11673. */
  11674. get minEmitBox(): Vector3;
  11675. set minEmitBox(value: Vector3);
  11676. /**
  11677. * 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.
  11678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11679. */
  11680. get maxEmitBox(): Vector3;
  11681. set maxEmitBox(value: Vector3);
  11682. /**
  11683. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11684. */
  11685. color1: Color4;
  11686. /**
  11687. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11688. */
  11689. color2: Color4;
  11690. /**
  11691. * Color the particle will have at the end of its lifetime
  11692. */
  11693. colorDead: Color4;
  11694. /**
  11695. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11696. */
  11697. textureMask: Color4;
  11698. /**
  11699. * The particle emitter type defines the emitter used by the particle system.
  11700. * It can be for example box, sphere, or cone...
  11701. */
  11702. particleEmitterType: IParticleEmitterType;
  11703. /** @hidden */
  11704. _isSubEmitter: boolean;
  11705. /**
  11706. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11707. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11708. */
  11709. billboardMode: number;
  11710. protected _isBillboardBased: boolean;
  11711. /**
  11712. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11713. */
  11714. get isBillboardBased(): boolean;
  11715. set isBillboardBased(value: boolean);
  11716. /**
  11717. * The scene the particle system belongs to.
  11718. */
  11719. protected _scene: Scene;
  11720. /**
  11721. * Local cache of defines for image processing.
  11722. */
  11723. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11724. /**
  11725. * Default configuration related to image processing available in the standard Material.
  11726. */
  11727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11728. /**
  11729. * Gets the image processing configuration used either in this material.
  11730. */
  11731. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11732. /**
  11733. * Sets the Default image processing configuration used either in the this material.
  11734. *
  11735. * If sets to null, the scene one is in use.
  11736. */
  11737. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11738. /**
  11739. * Attaches a new image processing configuration to the Standard Material.
  11740. * @param configuration
  11741. */
  11742. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11743. /** @hidden */
  11744. protected _reset(): void;
  11745. /** @hidden */
  11746. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11747. /**
  11748. * Instantiates a particle system.
  11749. * 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.
  11750. * @param name The name of the particle system
  11751. */
  11752. constructor(name: string);
  11753. /**
  11754. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11755. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11756. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11757. * @returns the emitter
  11758. */
  11759. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11760. /**
  11761. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11762. * @param radius The radius of the hemisphere to emit from
  11763. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11764. * @returns the emitter
  11765. */
  11766. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11767. /**
  11768. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11769. * @param radius The radius of the sphere to emit from
  11770. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11771. * @returns the emitter
  11772. */
  11773. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11774. /**
  11775. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11776. * @param radius The radius of the sphere to emit from
  11777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11779. * @returns the emitter
  11780. */
  11781. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11782. /**
  11783. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11784. * @param radius The radius of the emission cylinder
  11785. * @param height The height of the emission cylinder
  11786. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11787. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11788. * @returns the emitter
  11789. */
  11790. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11791. /**
  11792. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11793. * @param radius The radius of the cylinder to emit from
  11794. * @param height The height of the emission cylinder
  11795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11798. * @returns the emitter
  11799. */
  11800. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11801. /**
  11802. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11803. * @param radius The radius of the cone to emit from
  11804. * @param angle The base angle of the cone
  11805. * @returns the emitter
  11806. */
  11807. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11808. /**
  11809. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11812. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11813. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11814. * @returns the emitter
  11815. */
  11816. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11817. }
  11818. }
  11819. declare module "babylonjs/Particles/subEmitter" {
  11820. import { Scene } from "babylonjs/scene";
  11821. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11822. /**
  11823. * Type of sub emitter
  11824. */
  11825. export enum SubEmitterType {
  11826. /**
  11827. * Attached to the particle over it's lifetime
  11828. */
  11829. ATTACHED = 0,
  11830. /**
  11831. * Created when the particle dies
  11832. */
  11833. END = 1
  11834. }
  11835. /**
  11836. * Sub emitter class used to emit particles from an existing particle
  11837. */
  11838. export class SubEmitter {
  11839. /**
  11840. * the particle system to be used by the sub emitter
  11841. */
  11842. particleSystem: ParticleSystem;
  11843. /**
  11844. * Type of the submitter (Default: END)
  11845. */
  11846. type: SubEmitterType;
  11847. /**
  11848. * 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)
  11849. * Note: This only is supported when using an emitter of type Mesh
  11850. */
  11851. inheritDirection: boolean;
  11852. /**
  11853. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11854. */
  11855. inheritedVelocityAmount: number;
  11856. /**
  11857. * Creates a sub emitter
  11858. * @param particleSystem the particle system to be used by the sub emitter
  11859. */
  11860. constructor(
  11861. /**
  11862. * the particle system to be used by the sub emitter
  11863. */
  11864. particleSystem: ParticleSystem);
  11865. /**
  11866. * Clones the sub emitter
  11867. * @returns the cloned sub emitter
  11868. */
  11869. clone(): SubEmitter;
  11870. /**
  11871. * Serialize current object to a JSON object
  11872. * @returns the serialized object
  11873. */
  11874. serialize(): any;
  11875. /** @hidden */
  11876. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11877. /**
  11878. * Creates a new SubEmitter from a serialized JSON version
  11879. * @param serializationObject defines the JSON object to read from
  11880. * @param scene defines the hosting scene
  11881. * @param rootUrl defines the rootUrl for data loading
  11882. * @returns a new SubEmitter
  11883. */
  11884. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11885. /** Release associated resources */
  11886. dispose(): void;
  11887. }
  11888. }
  11889. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11890. /** @hidden */
  11891. export var imageProcessingDeclaration: {
  11892. name: string;
  11893. shader: string;
  11894. };
  11895. }
  11896. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11897. /** @hidden */
  11898. export var imageProcessingFunctions: {
  11899. name: string;
  11900. shader: string;
  11901. };
  11902. }
  11903. declare module "babylonjs/Shaders/particles.fragment" {
  11904. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11905. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11907. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11908. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11909. /** @hidden */
  11910. export var particlesPixelShader: {
  11911. name: string;
  11912. shader: string;
  11913. };
  11914. }
  11915. declare module "babylonjs/Shaders/particles.vertex" {
  11916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11917. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11918. /** @hidden */
  11919. export var particlesVertexShader: {
  11920. name: string;
  11921. shader: string;
  11922. };
  11923. }
  11924. declare module "babylonjs/Particles/particleSystem" {
  11925. import { Nullable } from "babylonjs/types";
  11926. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11927. import { Observable } from "babylonjs/Misc/observable";
  11928. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11929. import { Effect } from "babylonjs/Materials/effect";
  11930. import { Scene, IDisposable } from "babylonjs/scene";
  11931. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11932. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11933. import { Particle } from "babylonjs/Particles/particle";
  11934. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11936. import "babylonjs/Shaders/particles.fragment";
  11937. import "babylonjs/Shaders/particles.vertex";
  11938. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11939. /**
  11940. * This represents a particle system in Babylon.
  11941. * 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.
  11942. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11943. * @example https://doc.babylonjs.com/babylon101/particles
  11944. */
  11945. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11946. /**
  11947. * Billboard mode will only apply to Y axis
  11948. */
  11949. static readonly BILLBOARDMODE_Y: number;
  11950. /**
  11951. * Billboard mode will apply to all axes
  11952. */
  11953. static readonly BILLBOARDMODE_ALL: number;
  11954. /**
  11955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11956. */
  11957. static readonly BILLBOARDMODE_STRETCHED: number;
  11958. /**
  11959. * This function can be defined to provide custom update for active particles.
  11960. * This function will be called instead of regular update (age, position, color, etc.).
  11961. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11962. */
  11963. updateFunction: (particles: Particle[]) => void;
  11964. private _emitterWorldMatrix;
  11965. /**
  11966. * This function can be defined to specify initial direction for every new particle.
  11967. * It by default use the emitterType defined function
  11968. */
  11969. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11970. /**
  11971. * This function can be defined to specify initial position for every new particle.
  11972. * It by default use the emitterType defined function
  11973. */
  11974. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11975. /**
  11976. * @hidden
  11977. */
  11978. _inheritedVelocityOffset: Vector3;
  11979. /**
  11980. * An event triggered when the system is disposed
  11981. */
  11982. onDisposeObservable: Observable<ParticleSystem>;
  11983. private _onDisposeObserver;
  11984. /**
  11985. * Sets a callback that will be triggered when the system is disposed
  11986. */
  11987. set onDispose(callback: () => void);
  11988. private _particles;
  11989. private _epsilon;
  11990. private _capacity;
  11991. private _stockParticles;
  11992. private _newPartsExcess;
  11993. private _vertexData;
  11994. private _vertexBuffer;
  11995. private _vertexBuffers;
  11996. private _spriteBuffer;
  11997. private _indexBuffer;
  11998. private _effect;
  11999. private _customEffect;
  12000. private _cachedDefines;
  12001. private _scaledColorStep;
  12002. private _colorDiff;
  12003. private _scaledDirection;
  12004. private _scaledGravity;
  12005. private _currentRenderId;
  12006. private _alive;
  12007. private _useInstancing;
  12008. private _started;
  12009. private _stopped;
  12010. private _actualFrame;
  12011. private _scaledUpdateSpeed;
  12012. private _vertexBufferSize;
  12013. /** @hidden */
  12014. _currentEmitRateGradient: Nullable<FactorGradient>;
  12015. /** @hidden */
  12016. _currentEmitRate1: number;
  12017. /** @hidden */
  12018. _currentEmitRate2: number;
  12019. /** @hidden */
  12020. _currentStartSizeGradient: Nullable<FactorGradient>;
  12021. /** @hidden */
  12022. _currentStartSize1: number;
  12023. /** @hidden */
  12024. _currentStartSize2: number;
  12025. private readonly _rawTextureWidth;
  12026. private _rampGradientsTexture;
  12027. private _useRampGradients;
  12028. /** Gets or sets a boolean indicating that ramp gradients must be used
  12029. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12030. */
  12031. get useRampGradients(): boolean;
  12032. set useRampGradients(value: boolean);
  12033. /**
  12034. * 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.
  12035. * 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: [])
  12036. */
  12037. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12038. private _subEmitters;
  12039. /**
  12040. * @hidden
  12041. * If the particle systems emitter should be disposed when the particle system is disposed
  12042. */
  12043. _disposeEmitterOnDispose: boolean;
  12044. /**
  12045. * The current active Sub-systems, this property is used by the root particle system only.
  12046. */
  12047. activeSubSystems: Array<ParticleSystem>;
  12048. /**
  12049. * Specifies if the particles are updated in emitter local space or world space
  12050. */
  12051. isLocal: boolean;
  12052. private _rootParticleSystem;
  12053. /**
  12054. * Gets the current list of active particles
  12055. */
  12056. get particles(): Particle[];
  12057. /**
  12058. * Gets the number of particles active at the same time.
  12059. * @returns The number of active particles.
  12060. */
  12061. getActiveCount(): number;
  12062. /**
  12063. * Returns the string "ParticleSystem"
  12064. * @returns a string containing the class name
  12065. */
  12066. getClassName(): string;
  12067. /**
  12068. * Gets a boolean indicating that the system is stopping
  12069. * @returns true if the system is currently stopping
  12070. */
  12071. isStopping(): boolean;
  12072. /**
  12073. * Instantiates a particle system.
  12074. * 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.
  12075. * @param name The name of the particle system
  12076. * @param capacity The max number of particles alive at the same time
  12077. * @param scene The scene the particle system belongs to
  12078. * @param customEffect a custom effect used to change the way particles are rendered by default
  12079. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12080. * @param epsilon Offset used to render the particles
  12081. */
  12082. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12083. private _addFactorGradient;
  12084. private _removeFactorGradient;
  12085. /**
  12086. * Adds a new life time gradient
  12087. * @param gradient defines the gradient to use (between 0 and 1)
  12088. * @param factor defines the life time factor to affect to the specified gradient
  12089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12090. * @returns the current particle system
  12091. */
  12092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12093. /**
  12094. * Remove a specific life time gradient
  12095. * @param gradient defines the gradient to remove
  12096. * @returns the current particle system
  12097. */
  12098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12099. /**
  12100. * Adds a new size gradient
  12101. * @param gradient defines the gradient to use (between 0 and 1)
  12102. * @param factor defines the size factor to affect to the specified gradient
  12103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12104. * @returns the current particle system
  12105. */
  12106. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12107. /**
  12108. * Remove a specific size gradient
  12109. * @param gradient defines the gradient to remove
  12110. * @returns the current particle system
  12111. */
  12112. removeSizeGradient(gradient: number): IParticleSystem;
  12113. /**
  12114. * Adds a new color remap gradient
  12115. * @param gradient defines the gradient to use (between 0 and 1)
  12116. * @param min defines the color remap minimal range
  12117. * @param max defines the color remap maximal range
  12118. * @returns the current particle system
  12119. */
  12120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12121. /**
  12122. * Remove a specific color remap gradient
  12123. * @param gradient defines the gradient to remove
  12124. * @returns the current particle system
  12125. */
  12126. removeColorRemapGradient(gradient: number): IParticleSystem;
  12127. /**
  12128. * Adds a new alpha remap gradient
  12129. * @param gradient defines the gradient to use (between 0 and 1)
  12130. * @param min defines the alpha remap minimal range
  12131. * @param max defines the alpha remap maximal range
  12132. * @returns the current particle system
  12133. */
  12134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12135. /**
  12136. * Remove a specific alpha remap gradient
  12137. * @param gradient defines the gradient to remove
  12138. * @returns the current particle system
  12139. */
  12140. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12141. /**
  12142. * Adds a new angular speed gradient
  12143. * @param gradient defines the gradient to use (between 0 and 1)
  12144. * @param factor defines the angular speed to affect to the specified gradient
  12145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12146. * @returns the current particle system
  12147. */
  12148. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12149. /**
  12150. * Remove a specific angular speed gradient
  12151. * @param gradient defines the gradient to remove
  12152. * @returns the current particle system
  12153. */
  12154. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12155. /**
  12156. * Adds a new velocity gradient
  12157. * @param gradient defines the gradient to use (between 0 and 1)
  12158. * @param factor defines the velocity to affect to the specified gradient
  12159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12160. * @returns the current particle system
  12161. */
  12162. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12163. /**
  12164. * Remove a specific velocity gradient
  12165. * @param gradient defines the gradient to remove
  12166. * @returns the current particle system
  12167. */
  12168. removeVelocityGradient(gradient: number): IParticleSystem;
  12169. /**
  12170. * Adds a new limit velocity gradient
  12171. * @param gradient defines the gradient to use (between 0 and 1)
  12172. * @param factor defines the limit velocity value to affect to the specified gradient
  12173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12174. * @returns the current particle system
  12175. */
  12176. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12177. /**
  12178. * Remove a specific limit velocity gradient
  12179. * @param gradient defines the gradient to remove
  12180. * @returns the current particle system
  12181. */
  12182. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12183. /**
  12184. * Adds a new drag gradient
  12185. * @param gradient defines the gradient to use (between 0 and 1)
  12186. * @param factor defines the drag value to affect to the specified gradient
  12187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12188. * @returns the current particle system
  12189. */
  12190. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12191. /**
  12192. * Remove a specific drag gradient
  12193. * @param gradient defines the gradient to remove
  12194. * @returns the current particle system
  12195. */
  12196. removeDragGradient(gradient: number): IParticleSystem;
  12197. /**
  12198. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12199. * @param gradient defines the gradient to use (between 0 and 1)
  12200. * @param factor defines the emit rate value to affect to the specified gradient
  12201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12202. * @returns the current particle system
  12203. */
  12204. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12205. /**
  12206. * Remove a specific emit rate gradient
  12207. * @param gradient defines the gradient to remove
  12208. * @returns the current particle system
  12209. */
  12210. removeEmitRateGradient(gradient: number): IParticleSystem;
  12211. /**
  12212. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12213. * @param gradient defines the gradient to use (between 0 and 1)
  12214. * @param factor defines the start size value to affect to the specified gradient
  12215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12216. * @returns the current particle system
  12217. */
  12218. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12219. /**
  12220. * Remove a specific start size gradient
  12221. * @param gradient defines the gradient to remove
  12222. * @returns the current particle system
  12223. */
  12224. removeStartSizeGradient(gradient: number): IParticleSystem;
  12225. private _createRampGradientTexture;
  12226. /**
  12227. * Gets the current list of ramp gradients.
  12228. * You must use addRampGradient and removeRampGradient to udpate this list
  12229. * @returns the list of ramp gradients
  12230. */
  12231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12232. /** Force the system to rebuild all gradients that need to be resync */
  12233. forceRefreshGradients(): void;
  12234. private _syncRampGradientTexture;
  12235. /**
  12236. * Adds a new ramp gradient used to remap particle colors
  12237. * @param gradient defines the gradient to use (between 0 and 1)
  12238. * @param color defines the color to affect to the specified gradient
  12239. * @returns the current particle system
  12240. */
  12241. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12242. /**
  12243. * Remove a specific ramp gradient
  12244. * @param gradient defines the gradient to remove
  12245. * @returns the current particle system
  12246. */
  12247. removeRampGradient(gradient: number): ParticleSystem;
  12248. /**
  12249. * Adds a new color gradient
  12250. * @param gradient defines the gradient to use (between 0 and 1)
  12251. * @param color1 defines the color to affect to the specified gradient
  12252. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12253. * @returns this particle system
  12254. */
  12255. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12256. /**
  12257. * Remove a specific color gradient
  12258. * @param gradient defines the gradient to remove
  12259. * @returns this particle system
  12260. */
  12261. removeColorGradient(gradient: number): IParticleSystem;
  12262. private _fetchR;
  12263. protected _reset(): void;
  12264. private _resetEffect;
  12265. private _createVertexBuffers;
  12266. private _createIndexBuffer;
  12267. /**
  12268. * Gets the maximum number of particles active at the same time.
  12269. * @returns The max number of active particles.
  12270. */
  12271. getCapacity(): number;
  12272. /**
  12273. * Gets whether there are still active particles in the system.
  12274. * @returns True if it is alive, otherwise false.
  12275. */
  12276. isAlive(): boolean;
  12277. /**
  12278. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12279. * @returns True if it has been started, otherwise false.
  12280. */
  12281. isStarted(): boolean;
  12282. private _prepareSubEmitterInternalArray;
  12283. /**
  12284. * Starts the particle system and begins to emit
  12285. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12286. */
  12287. start(delay?: number): void;
  12288. /**
  12289. * Stops the particle system.
  12290. * @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.
  12291. */
  12292. stop(stopSubEmitters?: boolean): void;
  12293. /**
  12294. * Remove all active particles
  12295. */
  12296. reset(): void;
  12297. /**
  12298. * @hidden (for internal use only)
  12299. */
  12300. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12301. /**
  12302. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12303. * Its lifetime will start back at 0.
  12304. */
  12305. recycleParticle: (particle: Particle) => void;
  12306. private _stopSubEmitters;
  12307. private _createParticle;
  12308. private _removeFromRoot;
  12309. private _emitFromParticle;
  12310. private _update;
  12311. /** @hidden */
  12312. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12313. /** @hidden */
  12314. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12315. /** @hidden */
  12316. private _getEffect;
  12317. /**
  12318. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12319. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12320. */
  12321. animate(preWarmOnly?: boolean): void;
  12322. private _appendParticleVertices;
  12323. /**
  12324. * Rebuilds the particle system.
  12325. */
  12326. rebuild(): void;
  12327. /**
  12328. * Is this system ready to be used/rendered
  12329. * @return true if the system is ready
  12330. */
  12331. isReady(): boolean;
  12332. private _render;
  12333. /**
  12334. * Renders the particle system in its current state.
  12335. * @returns the current number of particles
  12336. */
  12337. render(): number;
  12338. /**
  12339. * Disposes the particle system and free the associated resources
  12340. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12341. */
  12342. dispose(disposeTexture?: boolean): void;
  12343. /**
  12344. * Clones the particle system.
  12345. * @param name The name of the cloned object
  12346. * @param newEmitter The new emitter to use
  12347. * @returns the cloned particle system
  12348. */
  12349. clone(name: string, newEmitter: any): ParticleSystem;
  12350. /**
  12351. * Serializes the particle system to a JSON object
  12352. * @param serializeTexture defines if the texture must be serialized as well
  12353. * @returns the JSON object
  12354. */
  12355. serialize(serializeTexture?: boolean): any;
  12356. /** @hidden */
  12357. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12358. /** @hidden */
  12359. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12360. /**
  12361. * Parses a JSON object to create a particle system.
  12362. * @param parsedParticleSystem The JSON object to parse
  12363. * @param scene The scene to create the particle system in
  12364. * @param rootUrl The root url to use to load external dependencies like texture
  12365. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12366. * @returns the Parsed particle system
  12367. */
  12368. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12369. }
  12370. }
  12371. declare module "babylonjs/Particles/particle" {
  12372. import { Nullable } from "babylonjs/types";
  12373. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12374. import { Color4 } from "babylonjs/Maths/math.color";
  12375. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12376. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12377. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12378. /**
  12379. * A particle represents one of the element emitted by a particle system.
  12380. * This is mainly define by its coordinates, direction, velocity and age.
  12381. */
  12382. export class Particle {
  12383. /**
  12384. * The particle system the particle belongs to.
  12385. */
  12386. particleSystem: ParticleSystem;
  12387. private static _Count;
  12388. /**
  12389. * Unique ID of the particle
  12390. */
  12391. id: number;
  12392. /**
  12393. * The world position of the particle in the scene.
  12394. */
  12395. position: Vector3;
  12396. /**
  12397. * The world direction of the particle in the scene.
  12398. */
  12399. direction: Vector3;
  12400. /**
  12401. * The color of the particle.
  12402. */
  12403. color: Color4;
  12404. /**
  12405. * The color change of the particle per step.
  12406. */
  12407. colorStep: Color4;
  12408. /**
  12409. * Defines how long will the life of the particle be.
  12410. */
  12411. lifeTime: number;
  12412. /**
  12413. * The current age of the particle.
  12414. */
  12415. age: number;
  12416. /**
  12417. * The current size of the particle.
  12418. */
  12419. size: number;
  12420. /**
  12421. * The current scale of the particle.
  12422. */
  12423. scale: Vector2;
  12424. /**
  12425. * The current angle of the particle.
  12426. */
  12427. angle: number;
  12428. /**
  12429. * Defines how fast is the angle changing.
  12430. */
  12431. angularSpeed: number;
  12432. /**
  12433. * Defines the cell index used by the particle to be rendered from a sprite.
  12434. */
  12435. cellIndex: number;
  12436. /**
  12437. * The information required to support color remapping
  12438. */
  12439. remapData: Vector4;
  12440. /** @hidden */
  12441. _randomCellOffset?: number;
  12442. /** @hidden */
  12443. _initialDirection: Nullable<Vector3>;
  12444. /** @hidden */
  12445. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12446. /** @hidden */
  12447. _initialStartSpriteCellID: number;
  12448. /** @hidden */
  12449. _initialEndSpriteCellID: number;
  12450. /** @hidden */
  12451. _currentColorGradient: Nullable<ColorGradient>;
  12452. /** @hidden */
  12453. _currentColor1: Color4;
  12454. /** @hidden */
  12455. _currentColor2: Color4;
  12456. /** @hidden */
  12457. _currentSizeGradient: Nullable<FactorGradient>;
  12458. /** @hidden */
  12459. _currentSize1: number;
  12460. /** @hidden */
  12461. _currentSize2: number;
  12462. /** @hidden */
  12463. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12464. /** @hidden */
  12465. _currentAngularSpeed1: number;
  12466. /** @hidden */
  12467. _currentAngularSpeed2: number;
  12468. /** @hidden */
  12469. _currentVelocityGradient: Nullable<FactorGradient>;
  12470. /** @hidden */
  12471. _currentVelocity1: number;
  12472. /** @hidden */
  12473. _currentVelocity2: number;
  12474. /** @hidden */
  12475. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12476. /** @hidden */
  12477. _currentLimitVelocity1: number;
  12478. /** @hidden */
  12479. _currentLimitVelocity2: number;
  12480. /** @hidden */
  12481. _currentDragGradient: Nullable<FactorGradient>;
  12482. /** @hidden */
  12483. _currentDrag1: number;
  12484. /** @hidden */
  12485. _currentDrag2: number;
  12486. /** @hidden */
  12487. _randomNoiseCoordinates1: Vector3;
  12488. /** @hidden */
  12489. _randomNoiseCoordinates2: Vector3;
  12490. /** @hidden */
  12491. _localPosition?: Vector3;
  12492. /**
  12493. * Creates a new instance Particle
  12494. * @param particleSystem the particle system the particle belongs to
  12495. */
  12496. constructor(
  12497. /**
  12498. * The particle system the particle belongs to.
  12499. */
  12500. particleSystem: ParticleSystem);
  12501. private updateCellInfoFromSystem;
  12502. /**
  12503. * Defines how the sprite cell index is updated for the particle
  12504. */
  12505. updateCellIndex(): void;
  12506. /** @hidden */
  12507. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12508. /** @hidden */
  12509. _inheritParticleInfoToSubEmitters(): void;
  12510. /** @hidden */
  12511. _reset(): void;
  12512. /**
  12513. * Copy the properties of particle to another one.
  12514. * @param other the particle to copy the information to.
  12515. */
  12516. copyTo(other: Particle): void;
  12517. }
  12518. }
  12519. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12520. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12521. import { Effect } from "babylonjs/Materials/effect";
  12522. import { Particle } from "babylonjs/Particles/particle";
  12523. import { Scene } from "babylonjs/scene";
  12524. /**
  12525. * Particle emitter represents a volume emitting particles.
  12526. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12527. */
  12528. export interface IParticleEmitterType {
  12529. /**
  12530. * Called by the particle System when the direction is computed for the created particle.
  12531. * @param worldMatrix is the world matrix of the particle system
  12532. * @param directionToUpdate is the direction vector to update with the result
  12533. * @param particle is the particle we are computed the direction for
  12534. * @param isLocal defines if the direction should be set in local space
  12535. */
  12536. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12537. /**
  12538. * Called by the particle System when the position is computed for the created particle.
  12539. * @param worldMatrix is the world matrix of the particle system
  12540. * @param positionToUpdate is the position vector to update with the result
  12541. * @param particle is the particle we are computed the position for
  12542. * @param isLocal defines if the position should be set in local space
  12543. */
  12544. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12545. /**
  12546. * Clones the current emitter and returns a copy of it
  12547. * @returns the new emitter
  12548. */
  12549. clone(): IParticleEmitterType;
  12550. /**
  12551. * Called by the GPUParticleSystem to setup the update shader
  12552. * @param effect defines the update shader
  12553. */
  12554. applyToShader(effect: Effect): void;
  12555. /**
  12556. * Returns a string to use to update the GPU particles update shader
  12557. * @returns the effect defines string
  12558. */
  12559. getEffectDefines(): string;
  12560. /**
  12561. * Returns a string representing the class name
  12562. * @returns a string containing the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Serializes the particle system to a JSON object.
  12567. * @returns the JSON object
  12568. */
  12569. serialize(): any;
  12570. /**
  12571. * Parse properties from a JSON object
  12572. * @param serializationObject defines the JSON object
  12573. * @param scene defines the hosting scene
  12574. */
  12575. parse(serializationObject: any, scene: Scene): void;
  12576. }
  12577. }
  12578. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12580. import { Effect } from "babylonjs/Materials/effect";
  12581. import { Particle } from "babylonjs/Particles/particle";
  12582. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12583. /**
  12584. * Particle emitter emitting particles from the inside of a box.
  12585. * It emits the particles randomly between 2 given directions.
  12586. */
  12587. export class BoxParticleEmitter implements IParticleEmitterType {
  12588. /**
  12589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12590. */
  12591. direction1: Vector3;
  12592. /**
  12593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12594. */
  12595. direction2: Vector3;
  12596. /**
  12597. * 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.
  12598. */
  12599. minEmitBox: Vector3;
  12600. /**
  12601. * 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.
  12602. */
  12603. maxEmitBox: Vector3;
  12604. /**
  12605. * Creates a new instance BoxParticleEmitter
  12606. */
  12607. constructor();
  12608. /**
  12609. * Called by the particle System when the direction is computed for the created particle.
  12610. * @param worldMatrix is the world matrix of the particle system
  12611. * @param directionToUpdate is the direction vector to update with the result
  12612. * @param particle is the particle we are computed the direction for
  12613. * @param isLocal defines if the direction should be set in local space
  12614. */
  12615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12616. /**
  12617. * Called by the particle System when the position is computed for the created particle.
  12618. * @param worldMatrix is the world matrix of the particle system
  12619. * @param positionToUpdate is the position vector to update with the result
  12620. * @param particle is the particle we are computed the position for
  12621. * @param isLocal defines if the position should be set in local space
  12622. */
  12623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12624. /**
  12625. * Clones the current emitter and returns a copy of it
  12626. * @returns the new emitter
  12627. */
  12628. clone(): BoxParticleEmitter;
  12629. /**
  12630. * Called by the GPUParticleSystem to setup the update shader
  12631. * @param effect defines the update shader
  12632. */
  12633. applyToShader(effect: Effect): void;
  12634. /**
  12635. * Returns a string to use to update the GPU particles update shader
  12636. * @returns a string containng the defines string
  12637. */
  12638. getEffectDefines(): string;
  12639. /**
  12640. * Returns the string "BoxParticleEmitter"
  12641. * @returns a string containing the class name
  12642. */
  12643. getClassName(): string;
  12644. /**
  12645. * Serializes the particle system to a JSON object.
  12646. * @returns the JSON object
  12647. */
  12648. serialize(): any;
  12649. /**
  12650. * Parse properties from a JSON object
  12651. * @param serializationObject defines the JSON object
  12652. */
  12653. parse(serializationObject: any): void;
  12654. }
  12655. }
  12656. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12657. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12658. import { Effect } from "babylonjs/Materials/effect";
  12659. import { Particle } from "babylonjs/Particles/particle";
  12660. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12661. /**
  12662. * Particle emitter emitting particles from the inside of a cone.
  12663. * It emits the particles alongside the cone volume from the base to the particle.
  12664. * The emission direction might be randomized.
  12665. */
  12666. export class ConeParticleEmitter implements IParticleEmitterType {
  12667. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12668. directionRandomizer: number;
  12669. private _radius;
  12670. private _angle;
  12671. private _height;
  12672. /**
  12673. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12674. */
  12675. radiusRange: number;
  12676. /**
  12677. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12678. */
  12679. heightRange: number;
  12680. /**
  12681. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12682. */
  12683. emitFromSpawnPointOnly: boolean;
  12684. /**
  12685. * Gets or sets the radius of the emission cone
  12686. */
  12687. get radius(): number;
  12688. set radius(value: number);
  12689. /**
  12690. * Gets or sets the angle of the emission cone
  12691. */
  12692. get angle(): number;
  12693. set angle(value: number);
  12694. private _buildHeight;
  12695. /**
  12696. * Creates a new instance ConeParticleEmitter
  12697. * @param radius the radius of the emission cone (1 by default)
  12698. * @param angle the cone base angle (PI by default)
  12699. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12700. */
  12701. constructor(radius?: number, angle?: number,
  12702. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12703. directionRandomizer?: number);
  12704. /**
  12705. * Called by the particle System when the direction is computed for the created particle.
  12706. * @param worldMatrix is the world matrix of the particle system
  12707. * @param directionToUpdate is the direction vector to update with the result
  12708. * @param particle is the particle we are computed the direction for
  12709. * @param isLocal defines if the direction should be set in local space
  12710. */
  12711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12712. /**
  12713. * Called by the particle System when the position is computed for the created particle.
  12714. * @param worldMatrix is the world matrix of the particle system
  12715. * @param positionToUpdate is the position vector to update with the result
  12716. * @param particle is the particle we are computed the position for
  12717. * @param isLocal defines if the position should be set in local space
  12718. */
  12719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12720. /**
  12721. * Clones the current emitter and returns a copy of it
  12722. * @returns the new emitter
  12723. */
  12724. clone(): ConeParticleEmitter;
  12725. /**
  12726. * Called by the GPUParticleSystem to setup the update shader
  12727. * @param effect defines the update shader
  12728. */
  12729. applyToShader(effect: Effect): void;
  12730. /**
  12731. * Returns a string to use to update the GPU particles update shader
  12732. * @returns a string containng the defines string
  12733. */
  12734. getEffectDefines(): string;
  12735. /**
  12736. * Returns the string "ConeParticleEmitter"
  12737. * @returns a string containing the class name
  12738. */
  12739. getClassName(): string;
  12740. /**
  12741. * Serializes the particle system to a JSON object.
  12742. * @returns the JSON object
  12743. */
  12744. serialize(): any;
  12745. /**
  12746. * Parse properties from a JSON object
  12747. * @param serializationObject defines the JSON object
  12748. */
  12749. parse(serializationObject: any): void;
  12750. }
  12751. }
  12752. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12753. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12754. import { Effect } from "babylonjs/Materials/effect";
  12755. import { Particle } from "babylonjs/Particles/particle";
  12756. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12757. /**
  12758. * Particle emitter emitting particles from the inside of a cylinder.
  12759. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12760. */
  12761. export class CylinderParticleEmitter implements IParticleEmitterType {
  12762. /**
  12763. * The radius of the emission cylinder.
  12764. */
  12765. radius: number;
  12766. /**
  12767. * The height of the emission cylinder.
  12768. */
  12769. height: number;
  12770. /**
  12771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12772. */
  12773. radiusRange: number;
  12774. /**
  12775. * How much to randomize the particle direction [0-1].
  12776. */
  12777. directionRandomizer: number;
  12778. /**
  12779. * Creates a new instance CylinderParticleEmitter
  12780. * @param radius the radius of the emission cylinder (1 by default)
  12781. * @param height the height of the emission cylinder (1 by default)
  12782. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12783. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12784. */
  12785. constructor(
  12786. /**
  12787. * The radius of the emission cylinder.
  12788. */
  12789. radius?: number,
  12790. /**
  12791. * The height of the emission cylinder.
  12792. */
  12793. height?: number,
  12794. /**
  12795. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12796. */
  12797. radiusRange?: number,
  12798. /**
  12799. * How much to randomize the particle direction [0-1].
  12800. */
  12801. directionRandomizer?: number);
  12802. /**
  12803. * Called by the particle System when the direction is computed for the created particle.
  12804. * @param worldMatrix is the world matrix of the particle system
  12805. * @param directionToUpdate is the direction vector to update with the result
  12806. * @param particle is the particle we are computed the direction for
  12807. * @param isLocal defines if the direction should be set in local space
  12808. */
  12809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12810. /**
  12811. * Called by the particle System when the position is computed for the created particle.
  12812. * @param worldMatrix is the world matrix of the particle system
  12813. * @param positionToUpdate is the position vector to update with the result
  12814. * @param particle is the particle we are computed the position for
  12815. * @param isLocal defines if the position should be set in local space
  12816. */
  12817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12818. /**
  12819. * Clones the current emitter and returns a copy of it
  12820. * @returns the new emitter
  12821. */
  12822. clone(): CylinderParticleEmitter;
  12823. /**
  12824. * Called by the GPUParticleSystem to setup the update shader
  12825. * @param effect defines the update shader
  12826. */
  12827. applyToShader(effect: Effect): void;
  12828. /**
  12829. * Returns a string to use to update the GPU particles update shader
  12830. * @returns a string containng the defines string
  12831. */
  12832. getEffectDefines(): string;
  12833. /**
  12834. * Returns the string "CylinderParticleEmitter"
  12835. * @returns a string containing the class name
  12836. */
  12837. getClassName(): string;
  12838. /**
  12839. * Serializes the particle system to a JSON object.
  12840. * @returns the JSON object
  12841. */
  12842. serialize(): any;
  12843. /**
  12844. * Parse properties from a JSON object
  12845. * @param serializationObject defines the JSON object
  12846. */
  12847. parse(serializationObject: any): void;
  12848. }
  12849. /**
  12850. * Particle emitter emitting particles from the inside of a cylinder.
  12851. * It emits the particles randomly between two vectors.
  12852. */
  12853. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12854. /**
  12855. * The min limit of the emission direction.
  12856. */
  12857. direction1: Vector3;
  12858. /**
  12859. * The max limit of the emission direction.
  12860. */
  12861. direction2: Vector3;
  12862. /**
  12863. * Creates a new instance CylinderDirectedParticleEmitter
  12864. * @param radius the radius of the emission cylinder (1 by default)
  12865. * @param height the height of the emission cylinder (1 by default)
  12866. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12867. * @param direction1 the min limit of the emission direction (up vector by default)
  12868. * @param direction2 the max limit of the emission direction (up vector by default)
  12869. */
  12870. constructor(radius?: number, height?: number, radiusRange?: number,
  12871. /**
  12872. * The min limit of the emission direction.
  12873. */
  12874. direction1?: Vector3,
  12875. /**
  12876. * The max limit of the emission direction.
  12877. */
  12878. direction2?: Vector3);
  12879. /**
  12880. * Called by the particle System when the direction is computed for the created particle.
  12881. * @param worldMatrix is the world matrix of the particle system
  12882. * @param directionToUpdate is the direction vector to update with the result
  12883. * @param particle is the particle we are computed the direction for
  12884. */
  12885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12886. /**
  12887. * Clones the current emitter and returns a copy of it
  12888. * @returns the new emitter
  12889. */
  12890. clone(): CylinderDirectedParticleEmitter;
  12891. /**
  12892. * Called by the GPUParticleSystem to setup the update shader
  12893. * @param effect defines the update shader
  12894. */
  12895. applyToShader(effect: Effect): void;
  12896. /**
  12897. * Returns a string to use to update the GPU particles update shader
  12898. * @returns a string containng the defines string
  12899. */
  12900. getEffectDefines(): string;
  12901. /**
  12902. * Returns the string "CylinderDirectedParticleEmitter"
  12903. * @returns a string containing the class name
  12904. */
  12905. getClassName(): string;
  12906. /**
  12907. * Serializes the particle system to a JSON object.
  12908. * @returns the JSON object
  12909. */
  12910. serialize(): any;
  12911. /**
  12912. * Parse properties from a JSON object
  12913. * @param serializationObject defines the JSON object
  12914. */
  12915. parse(serializationObject: any): void;
  12916. }
  12917. }
  12918. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12919. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12920. import { Effect } from "babylonjs/Materials/effect";
  12921. import { Particle } from "babylonjs/Particles/particle";
  12922. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12923. /**
  12924. * Particle emitter emitting particles from the inside of a hemisphere.
  12925. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12926. */
  12927. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12928. /**
  12929. * The radius of the emission hemisphere.
  12930. */
  12931. radius: number;
  12932. /**
  12933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12934. */
  12935. radiusRange: number;
  12936. /**
  12937. * How much to randomize the particle direction [0-1].
  12938. */
  12939. directionRandomizer: number;
  12940. /**
  12941. * Creates a new instance HemisphericParticleEmitter
  12942. * @param radius the radius of the emission hemisphere (1 by default)
  12943. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12944. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12945. */
  12946. constructor(
  12947. /**
  12948. * The radius of the emission hemisphere.
  12949. */
  12950. radius?: number,
  12951. /**
  12952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12953. */
  12954. radiusRange?: number,
  12955. /**
  12956. * How much to randomize the particle direction [0-1].
  12957. */
  12958. directionRandomizer?: number);
  12959. /**
  12960. * Called by the particle System when the direction is computed for the created particle.
  12961. * @param worldMatrix is the world matrix of the particle system
  12962. * @param directionToUpdate is the direction vector to update with the result
  12963. * @param particle is the particle we are computed the direction for
  12964. * @param isLocal defines if the direction should be set in local space
  12965. */
  12966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12967. /**
  12968. * Called by the particle System when the position is computed for the created particle.
  12969. * @param worldMatrix is the world matrix of the particle system
  12970. * @param positionToUpdate is the position vector to update with the result
  12971. * @param particle is the particle we are computed the position for
  12972. * @param isLocal defines if the position should be set in local space
  12973. */
  12974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12975. /**
  12976. * Clones the current emitter and returns a copy of it
  12977. * @returns the new emitter
  12978. */
  12979. clone(): HemisphericParticleEmitter;
  12980. /**
  12981. * Called by the GPUParticleSystem to setup the update shader
  12982. * @param effect defines the update shader
  12983. */
  12984. applyToShader(effect: Effect): void;
  12985. /**
  12986. * Returns a string to use to update the GPU particles update shader
  12987. * @returns a string containng the defines string
  12988. */
  12989. getEffectDefines(): string;
  12990. /**
  12991. * Returns the string "HemisphericParticleEmitter"
  12992. * @returns a string containing the class name
  12993. */
  12994. getClassName(): string;
  12995. /**
  12996. * Serializes the particle system to a JSON object.
  12997. * @returns the JSON object
  12998. */
  12999. serialize(): any;
  13000. /**
  13001. * Parse properties from a JSON object
  13002. * @param serializationObject defines the JSON object
  13003. */
  13004. parse(serializationObject: any): void;
  13005. }
  13006. }
  13007. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13008. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13009. import { Effect } from "babylonjs/Materials/effect";
  13010. import { Particle } from "babylonjs/Particles/particle";
  13011. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13012. /**
  13013. * Particle emitter emitting particles from a point.
  13014. * It emits the particles randomly between 2 given directions.
  13015. */
  13016. export class PointParticleEmitter implements IParticleEmitterType {
  13017. /**
  13018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13019. */
  13020. direction1: Vector3;
  13021. /**
  13022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13023. */
  13024. direction2: Vector3;
  13025. /**
  13026. * Creates a new instance PointParticleEmitter
  13027. */
  13028. constructor();
  13029. /**
  13030. * Called by the particle System when the direction is computed for the created particle.
  13031. * @param worldMatrix is the world matrix of the particle system
  13032. * @param directionToUpdate is the direction vector to update with the result
  13033. * @param particle is the particle we are computed the direction for
  13034. * @param isLocal defines if the direction should be set in local space
  13035. */
  13036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13037. /**
  13038. * Called by the particle System when the position is computed for the created particle.
  13039. * @param worldMatrix is the world matrix of the particle system
  13040. * @param positionToUpdate is the position vector to update with the result
  13041. * @param particle is the particle we are computed the position for
  13042. * @param isLocal defines if the position should be set in local space
  13043. */
  13044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13045. /**
  13046. * Clones the current emitter and returns a copy of it
  13047. * @returns the new emitter
  13048. */
  13049. clone(): PointParticleEmitter;
  13050. /**
  13051. * Called by the GPUParticleSystem to setup the update shader
  13052. * @param effect defines the update shader
  13053. */
  13054. applyToShader(effect: Effect): void;
  13055. /**
  13056. * Returns a string to use to update the GPU particles update shader
  13057. * @returns a string containng the defines string
  13058. */
  13059. getEffectDefines(): string;
  13060. /**
  13061. * Returns the string "PointParticleEmitter"
  13062. * @returns a string containing the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Serializes the particle system to a JSON object.
  13067. * @returns the JSON object
  13068. */
  13069. serialize(): any;
  13070. /**
  13071. * Parse properties from a JSON object
  13072. * @param serializationObject defines the JSON object
  13073. */
  13074. parse(serializationObject: any): void;
  13075. }
  13076. }
  13077. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13078. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13079. import { Effect } from "babylonjs/Materials/effect";
  13080. import { Particle } from "babylonjs/Particles/particle";
  13081. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13082. /**
  13083. * Particle emitter emitting particles from the inside of a sphere.
  13084. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13085. */
  13086. export class SphereParticleEmitter implements IParticleEmitterType {
  13087. /**
  13088. * The radius of the emission sphere.
  13089. */
  13090. radius: number;
  13091. /**
  13092. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13093. */
  13094. radiusRange: number;
  13095. /**
  13096. * How much to randomize the particle direction [0-1].
  13097. */
  13098. directionRandomizer: number;
  13099. /**
  13100. * Creates a new instance SphereParticleEmitter
  13101. * @param radius the radius of the emission sphere (1 by default)
  13102. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13103. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13104. */
  13105. constructor(
  13106. /**
  13107. * The radius of the emission sphere.
  13108. */
  13109. radius?: number,
  13110. /**
  13111. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13112. */
  13113. radiusRange?: number,
  13114. /**
  13115. * How much to randomize the particle direction [0-1].
  13116. */
  13117. directionRandomizer?: number);
  13118. /**
  13119. * Called by the particle System when the direction is computed for the created particle.
  13120. * @param worldMatrix is the world matrix of the particle system
  13121. * @param directionToUpdate is the direction vector to update with the result
  13122. * @param particle is the particle we are computed the direction for
  13123. * @param isLocal defines if the direction should be set in local space
  13124. */
  13125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13126. /**
  13127. * Called by the particle System when the position is computed for the created particle.
  13128. * @param worldMatrix is the world matrix of the particle system
  13129. * @param positionToUpdate is the position vector to update with the result
  13130. * @param particle is the particle we are computed the position for
  13131. * @param isLocal defines if the position should be set in local space
  13132. */
  13133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13134. /**
  13135. * Clones the current emitter and returns a copy of it
  13136. * @returns the new emitter
  13137. */
  13138. clone(): SphereParticleEmitter;
  13139. /**
  13140. * Called by the GPUParticleSystem to setup the update shader
  13141. * @param effect defines the update shader
  13142. */
  13143. applyToShader(effect: Effect): void;
  13144. /**
  13145. * Returns a string to use to update the GPU particles update shader
  13146. * @returns a string containng the defines string
  13147. */
  13148. getEffectDefines(): string;
  13149. /**
  13150. * Returns the string "SphereParticleEmitter"
  13151. * @returns a string containing the class name
  13152. */
  13153. getClassName(): string;
  13154. /**
  13155. * Serializes the particle system to a JSON object.
  13156. * @returns the JSON object
  13157. */
  13158. serialize(): any;
  13159. /**
  13160. * Parse properties from a JSON object
  13161. * @param serializationObject defines the JSON object
  13162. */
  13163. parse(serializationObject: any): void;
  13164. }
  13165. /**
  13166. * Particle emitter emitting particles from the inside of a sphere.
  13167. * It emits the particles randomly between two vectors.
  13168. */
  13169. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13170. /**
  13171. * The min limit of the emission direction.
  13172. */
  13173. direction1: Vector3;
  13174. /**
  13175. * The max limit of the emission direction.
  13176. */
  13177. direction2: Vector3;
  13178. /**
  13179. * Creates a new instance SphereDirectedParticleEmitter
  13180. * @param radius the radius of the emission sphere (1 by default)
  13181. * @param direction1 the min limit of the emission direction (up vector by default)
  13182. * @param direction2 the max limit of the emission direction (up vector by default)
  13183. */
  13184. constructor(radius?: number,
  13185. /**
  13186. * The min limit of the emission direction.
  13187. */
  13188. direction1?: Vector3,
  13189. /**
  13190. * The max limit of the emission direction.
  13191. */
  13192. direction2?: Vector3);
  13193. /**
  13194. * Called by the particle System when the direction is computed for the created particle.
  13195. * @param worldMatrix is the world matrix of the particle system
  13196. * @param directionToUpdate is the direction vector to update with the result
  13197. * @param particle is the particle we are computed the direction for
  13198. */
  13199. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13200. /**
  13201. * Clones the current emitter and returns a copy of it
  13202. * @returns the new emitter
  13203. */
  13204. clone(): SphereDirectedParticleEmitter;
  13205. /**
  13206. * Called by the GPUParticleSystem to setup the update shader
  13207. * @param effect defines the update shader
  13208. */
  13209. applyToShader(effect: Effect): void;
  13210. /**
  13211. * Returns a string to use to update the GPU particles update shader
  13212. * @returns a string containng the defines string
  13213. */
  13214. getEffectDefines(): string;
  13215. /**
  13216. * Returns the string "SphereDirectedParticleEmitter"
  13217. * @returns a string containing the class name
  13218. */
  13219. getClassName(): string;
  13220. /**
  13221. * Serializes the particle system to a JSON object.
  13222. * @returns the JSON object
  13223. */
  13224. serialize(): any;
  13225. /**
  13226. * Parse properties from a JSON object
  13227. * @param serializationObject defines the JSON object
  13228. */
  13229. parse(serializationObject: any): void;
  13230. }
  13231. }
  13232. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13233. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13234. import { Effect } from "babylonjs/Materials/effect";
  13235. import { Particle } from "babylonjs/Particles/particle";
  13236. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13237. import { Nullable } from "babylonjs/types";
  13238. /**
  13239. * Particle emitter emitting particles from a custom list of positions.
  13240. */
  13241. export class CustomParticleEmitter implements IParticleEmitterType {
  13242. /**
  13243. * Gets or sets the position generator that will create the inital position of each particle.
  13244. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13245. */
  13246. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13247. /**
  13248. * Gets or sets the destination generator that will create the final destination of each particle.
  13249. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13250. */
  13251. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13252. /**
  13253. * Creates a new instance CustomParticleEmitter
  13254. */
  13255. constructor();
  13256. /**
  13257. * Called by the particle System when the direction is computed for the created particle.
  13258. * @param worldMatrix is the world matrix of the particle system
  13259. * @param directionToUpdate is the direction vector to update with the result
  13260. * @param particle is the particle we are computed the direction for
  13261. * @param isLocal defines if the direction should be set in local space
  13262. */
  13263. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13264. /**
  13265. * Called by the particle System when the position is computed for the created particle.
  13266. * @param worldMatrix is the world matrix of the particle system
  13267. * @param positionToUpdate is the position vector to update with the result
  13268. * @param particle is the particle we are computed the position for
  13269. * @param isLocal defines if the position should be set in local space
  13270. */
  13271. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13272. /**
  13273. * Clones the current emitter and returns a copy of it
  13274. * @returns the new emitter
  13275. */
  13276. clone(): CustomParticleEmitter;
  13277. /**
  13278. * Called by the GPUParticleSystem to setup the update shader
  13279. * @param effect defines the update shader
  13280. */
  13281. applyToShader(effect: Effect): void;
  13282. /**
  13283. * Returns a string to use to update the GPU particles update shader
  13284. * @returns a string containng the defines string
  13285. */
  13286. getEffectDefines(): string;
  13287. /**
  13288. * Returns the string "PointParticleEmitter"
  13289. * @returns a string containing the class name
  13290. */
  13291. getClassName(): string;
  13292. /**
  13293. * Serializes the particle system to a JSON object.
  13294. * @returns the JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Parse properties from a JSON object
  13299. * @param serializationObject defines the JSON object
  13300. */
  13301. parse(serializationObject: any): void;
  13302. }
  13303. }
  13304. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13305. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13306. import { Effect } from "babylonjs/Materials/effect";
  13307. import { Particle } from "babylonjs/Particles/particle";
  13308. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Scene } from "babylonjs/scene";
  13311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13312. /**
  13313. * Particle emitter emitting particles from the inside of a box.
  13314. * It emits the particles randomly between 2 given directions.
  13315. */
  13316. export class MeshParticleEmitter implements IParticleEmitterType {
  13317. private _indices;
  13318. private _positions;
  13319. private _normals;
  13320. private _storedNormal;
  13321. private _mesh;
  13322. /**
  13323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13324. */
  13325. direction1: Vector3;
  13326. /**
  13327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13328. */
  13329. direction2: Vector3;
  13330. /**
  13331. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13332. */
  13333. useMeshNormalsForDirection: boolean;
  13334. /** Defines the mesh to use as source */
  13335. get mesh(): Nullable<AbstractMesh>;
  13336. set mesh(value: Nullable<AbstractMesh>);
  13337. /**
  13338. * Creates a new instance MeshParticleEmitter
  13339. * @param mesh defines the mesh to use as source
  13340. */
  13341. constructor(mesh?: Nullable<AbstractMesh>);
  13342. /**
  13343. * Called by the particle System when the direction is computed for the created particle.
  13344. * @param worldMatrix is the world matrix of the particle system
  13345. * @param directionToUpdate is the direction vector to update with the result
  13346. * @param particle is the particle we are computed the direction for
  13347. * @param isLocal defines if the direction should be set in local space
  13348. */
  13349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13350. /**
  13351. * Called by the particle System when the position is computed for the created particle.
  13352. * @param worldMatrix is the world matrix of the particle system
  13353. * @param positionToUpdate is the position vector to update with the result
  13354. * @param particle is the particle we are computed the position for
  13355. * @param isLocal defines if the position should be set in local space
  13356. */
  13357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13358. /**
  13359. * Clones the current emitter and returns a copy of it
  13360. * @returns the new emitter
  13361. */
  13362. clone(): MeshParticleEmitter;
  13363. /**
  13364. * Called by the GPUParticleSystem to setup the update shader
  13365. * @param effect defines the update shader
  13366. */
  13367. applyToShader(effect: Effect): void;
  13368. /**
  13369. * Returns a string to use to update the GPU particles update shader
  13370. * @returns a string containng the defines string
  13371. */
  13372. getEffectDefines(): string;
  13373. /**
  13374. * Returns the string "BoxParticleEmitter"
  13375. * @returns a string containing the class name
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Serializes the particle system to a JSON object.
  13380. * @returns the JSON object
  13381. */
  13382. serialize(): any;
  13383. /**
  13384. * Parse properties from a JSON object
  13385. * @param serializationObject defines the JSON object
  13386. * @param scene defines the hosting scene
  13387. */
  13388. parse(serializationObject: any, scene: Scene): void;
  13389. }
  13390. }
  13391. declare module "babylonjs/Particles/EmitterTypes/index" {
  13392. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13393. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13394. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13395. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13396. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13397. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13398. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13399. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13400. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13401. }
  13402. declare module "babylonjs/Particles/IParticleSystem" {
  13403. import { Nullable } from "babylonjs/types";
  13404. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13408. import { Texture } from "babylonjs/Materials/Textures/texture";
  13409. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13410. import { Scene } from "babylonjs/scene";
  13411. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13412. import { Animation } from "babylonjs/Animations/animation";
  13413. /**
  13414. * Interface representing a particle system in Babylon.js.
  13415. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13416. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13417. */
  13418. export interface IParticleSystem {
  13419. /**
  13420. * List of animations used by the particle system.
  13421. */
  13422. animations: Animation[];
  13423. /**
  13424. * The id of the Particle system.
  13425. */
  13426. id: string;
  13427. /**
  13428. * The name of the Particle system.
  13429. */
  13430. name: string;
  13431. /**
  13432. * The emitter represents the Mesh or position we are attaching the particle system to.
  13433. */
  13434. emitter: Nullable<AbstractMesh | Vector3>;
  13435. /**
  13436. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13437. */
  13438. isBillboardBased: boolean;
  13439. /**
  13440. * The rendering group used by the Particle system to chose when to render.
  13441. */
  13442. renderingGroupId: number;
  13443. /**
  13444. * The layer mask we are rendering the particles through.
  13445. */
  13446. layerMask: number;
  13447. /**
  13448. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13449. */
  13450. updateSpeed: number;
  13451. /**
  13452. * The amount of time the particle system is running (depends of the overall update speed).
  13453. */
  13454. targetStopDuration: number;
  13455. /**
  13456. * The texture used to render each particle. (this can be a spritesheet)
  13457. */
  13458. particleTexture: Nullable<Texture>;
  13459. /**
  13460. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13461. */
  13462. blendMode: number;
  13463. /**
  13464. * Minimum life time of emitting particles.
  13465. */
  13466. minLifeTime: number;
  13467. /**
  13468. * Maximum life time of emitting particles.
  13469. */
  13470. maxLifeTime: number;
  13471. /**
  13472. * Minimum Size of emitting particles.
  13473. */
  13474. minSize: number;
  13475. /**
  13476. * Maximum Size of emitting particles.
  13477. */
  13478. maxSize: number;
  13479. /**
  13480. * Minimum scale of emitting particles on X axis.
  13481. */
  13482. minScaleX: number;
  13483. /**
  13484. * Maximum scale of emitting particles on X axis.
  13485. */
  13486. maxScaleX: number;
  13487. /**
  13488. * Minimum scale of emitting particles on Y axis.
  13489. */
  13490. minScaleY: number;
  13491. /**
  13492. * Maximum scale of emitting particles on Y axis.
  13493. */
  13494. maxScaleY: number;
  13495. /**
  13496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13497. */
  13498. color1: Color4;
  13499. /**
  13500. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13501. */
  13502. color2: Color4;
  13503. /**
  13504. * Color the particle will have at the end of its lifetime.
  13505. */
  13506. colorDead: Color4;
  13507. /**
  13508. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13509. */
  13510. emitRate: number;
  13511. /**
  13512. * You can use gravity if you want to give an orientation to your particles.
  13513. */
  13514. gravity: Vector3;
  13515. /**
  13516. * Minimum power of emitting particles.
  13517. */
  13518. minEmitPower: number;
  13519. /**
  13520. * Maximum power of emitting particles.
  13521. */
  13522. maxEmitPower: number;
  13523. /**
  13524. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13525. */
  13526. minAngularSpeed: number;
  13527. /**
  13528. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13529. */
  13530. maxAngularSpeed: number;
  13531. /**
  13532. * Gets or sets the minimal initial rotation in radians.
  13533. */
  13534. minInitialRotation: number;
  13535. /**
  13536. * Gets or sets the maximal initial rotation in radians.
  13537. */
  13538. maxInitialRotation: number;
  13539. /**
  13540. * The particle emitter type defines the emitter used by the particle system.
  13541. * It can be for example box, sphere, or cone...
  13542. */
  13543. particleEmitterType: Nullable<IParticleEmitterType>;
  13544. /**
  13545. * Defines the delay in milliseconds before starting the system (0 by default)
  13546. */
  13547. startDelay: number;
  13548. /**
  13549. * 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
  13550. */
  13551. preWarmCycles: number;
  13552. /**
  13553. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13554. */
  13555. preWarmStepOffset: number;
  13556. /**
  13557. * 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)
  13558. */
  13559. spriteCellChangeSpeed: number;
  13560. /**
  13561. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13562. */
  13563. startSpriteCellID: number;
  13564. /**
  13565. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13566. */
  13567. endSpriteCellID: number;
  13568. /**
  13569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13570. */
  13571. spriteCellWidth: number;
  13572. /**
  13573. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13574. */
  13575. spriteCellHeight: number;
  13576. /**
  13577. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13578. */
  13579. spriteRandomStartCell: boolean;
  13580. /**
  13581. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13582. */
  13583. isAnimationSheetEnabled: boolean;
  13584. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13585. translationPivot: Vector2;
  13586. /**
  13587. * Gets or sets a texture used to add random noise to particle positions
  13588. */
  13589. noiseTexture: Nullable<BaseTexture>;
  13590. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13591. noiseStrength: Vector3;
  13592. /**
  13593. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13594. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13595. */
  13596. billboardMode: number;
  13597. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13598. limitVelocityDamping: number;
  13599. /**
  13600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13601. */
  13602. beginAnimationOnStart: boolean;
  13603. /**
  13604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13605. */
  13606. beginAnimationFrom: number;
  13607. /**
  13608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13609. */
  13610. beginAnimationTo: number;
  13611. /**
  13612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13613. */
  13614. beginAnimationLoop: boolean;
  13615. /**
  13616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13617. */
  13618. disposeOnStop: boolean;
  13619. /**
  13620. * Specifies if the particles are updated in emitter local space or world space
  13621. */
  13622. isLocal: boolean;
  13623. /** Snippet ID if the particle system was created from the snippet server */
  13624. snippetId: string;
  13625. /**
  13626. * Gets the maximum number of particles active at the same time.
  13627. * @returns The max number of active particles.
  13628. */
  13629. getCapacity(): number;
  13630. /**
  13631. * Gets the number of particles active at the same time.
  13632. * @returns The number of active particles.
  13633. */
  13634. getActiveCount(): number;
  13635. /**
  13636. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13637. * @returns True if it has been started, otherwise false.
  13638. */
  13639. isStarted(): boolean;
  13640. /**
  13641. * Animates the particle system for this frame.
  13642. */
  13643. animate(): void;
  13644. /**
  13645. * Renders the particle system in its current state.
  13646. * @returns the current number of particles
  13647. */
  13648. render(): number;
  13649. /**
  13650. * Dispose the particle system and frees its associated resources.
  13651. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13652. */
  13653. dispose(disposeTexture?: boolean): void;
  13654. /**
  13655. * Clones the particle system.
  13656. * @param name The name of the cloned object
  13657. * @param newEmitter The new emitter to use
  13658. * @returns the cloned particle system
  13659. */
  13660. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13661. /**
  13662. * Serializes the particle system to a JSON object
  13663. * @param serializeTexture defines if the texture must be serialized as well
  13664. * @returns the JSON object
  13665. */
  13666. serialize(serializeTexture: boolean): any;
  13667. /**
  13668. * Rebuild the particle system
  13669. */
  13670. rebuild(): void;
  13671. /** Force the system to rebuild all gradients that need to be resync */
  13672. forceRefreshGradients(): void;
  13673. /**
  13674. * Starts the particle system and begins to emit
  13675. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13676. */
  13677. start(delay?: number): void;
  13678. /**
  13679. * Stops the particle system.
  13680. */
  13681. stop(): void;
  13682. /**
  13683. * Remove all active particles
  13684. */
  13685. reset(): void;
  13686. /**
  13687. * Gets a boolean indicating that the system is stopping
  13688. * @returns true if the system is currently stopping
  13689. */
  13690. isStopping(): boolean;
  13691. /**
  13692. * Is this system ready to be used/rendered
  13693. * @return true if the system is ready
  13694. */
  13695. isReady(): boolean;
  13696. /**
  13697. * Returns the string "ParticleSystem"
  13698. * @returns a string containing the class name
  13699. */
  13700. getClassName(): string;
  13701. /**
  13702. * Adds a new color gradient
  13703. * @param gradient defines the gradient to use (between 0 and 1)
  13704. * @param color1 defines the color to affect to the specified gradient
  13705. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13706. * @returns the current particle system
  13707. */
  13708. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13709. /**
  13710. * Remove a specific color gradient
  13711. * @param gradient defines the gradient to remove
  13712. * @returns the current particle system
  13713. */
  13714. removeColorGradient(gradient: number): IParticleSystem;
  13715. /**
  13716. * Adds a new size gradient
  13717. * @param gradient defines the gradient to use (between 0 and 1)
  13718. * @param factor defines the size factor to affect to the specified gradient
  13719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13720. * @returns the current particle system
  13721. */
  13722. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13723. /**
  13724. * Remove a specific size gradient
  13725. * @param gradient defines the gradient to remove
  13726. * @returns the current particle system
  13727. */
  13728. removeSizeGradient(gradient: number): IParticleSystem;
  13729. /**
  13730. * Gets the current list of color gradients.
  13731. * You must use addColorGradient and removeColorGradient to udpate this list
  13732. * @returns the list of color gradients
  13733. */
  13734. getColorGradients(): Nullable<Array<ColorGradient>>;
  13735. /**
  13736. * Gets the current list of size gradients.
  13737. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13738. * @returns the list of size gradients
  13739. */
  13740. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13741. /**
  13742. * Gets the current list of angular speed gradients.
  13743. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13744. * @returns the list of angular speed gradients
  13745. */
  13746. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13747. /**
  13748. * Adds a new angular speed gradient
  13749. * @param gradient defines the gradient to use (between 0 and 1)
  13750. * @param factor defines the angular speed to affect to the specified gradient
  13751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13752. * @returns the current particle system
  13753. */
  13754. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13755. /**
  13756. * Remove a specific angular speed gradient
  13757. * @param gradient defines the gradient to remove
  13758. * @returns the current particle system
  13759. */
  13760. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13761. /**
  13762. * Gets the current list of velocity gradients.
  13763. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13764. * @returns the list of velocity gradients
  13765. */
  13766. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13767. /**
  13768. * Adds a new velocity gradient
  13769. * @param gradient defines the gradient to use (between 0 and 1)
  13770. * @param factor defines the velocity to affect to the specified gradient
  13771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13772. * @returns the current particle system
  13773. */
  13774. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13775. /**
  13776. * Remove a specific velocity gradient
  13777. * @param gradient defines the gradient to remove
  13778. * @returns the current particle system
  13779. */
  13780. removeVelocityGradient(gradient: number): IParticleSystem;
  13781. /**
  13782. * Gets the current list of limit velocity gradients.
  13783. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13784. * @returns the list of limit velocity gradients
  13785. */
  13786. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13787. /**
  13788. * Adds a new limit velocity gradient
  13789. * @param gradient defines the gradient to use (between 0 and 1)
  13790. * @param factor defines the limit velocity to affect to the specified gradient
  13791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13792. * @returns the current particle system
  13793. */
  13794. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13795. /**
  13796. * Remove a specific limit velocity gradient
  13797. * @param gradient defines the gradient to remove
  13798. * @returns the current particle system
  13799. */
  13800. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13801. /**
  13802. * Adds a new drag gradient
  13803. * @param gradient defines the gradient to use (between 0 and 1)
  13804. * @param factor defines the drag to affect to the specified gradient
  13805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13806. * @returns the current particle system
  13807. */
  13808. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13809. /**
  13810. * Remove a specific drag gradient
  13811. * @param gradient defines the gradient to remove
  13812. * @returns the current particle system
  13813. */
  13814. removeDragGradient(gradient: number): IParticleSystem;
  13815. /**
  13816. * Gets the current list of drag gradients.
  13817. * You must use addDragGradient and removeDragGradient to udpate this list
  13818. * @returns the list of drag gradients
  13819. */
  13820. getDragGradients(): Nullable<Array<FactorGradient>>;
  13821. /**
  13822. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13823. * @param gradient defines the gradient to use (between 0 and 1)
  13824. * @param factor defines the emit rate to affect to the specified gradient
  13825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13826. * @returns the current particle system
  13827. */
  13828. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13829. /**
  13830. * Remove a specific emit rate gradient
  13831. * @param gradient defines the gradient to remove
  13832. * @returns the current particle system
  13833. */
  13834. removeEmitRateGradient(gradient: number): IParticleSystem;
  13835. /**
  13836. * Gets the current list of emit rate gradients.
  13837. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13838. * @returns the list of emit rate gradients
  13839. */
  13840. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13841. /**
  13842. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13843. * @param gradient defines the gradient to use (between 0 and 1)
  13844. * @param factor defines the start size to affect to the specified gradient
  13845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13846. * @returns the current particle system
  13847. */
  13848. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13849. /**
  13850. * Remove a specific start size gradient
  13851. * @param gradient defines the gradient to remove
  13852. * @returns the current particle system
  13853. */
  13854. removeStartSizeGradient(gradient: number): IParticleSystem;
  13855. /**
  13856. * Gets the current list of start size gradients.
  13857. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13858. * @returns the list of start size gradients
  13859. */
  13860. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13861. /**
  13862. * Adds a new life time gradient
  13863. * @param gradient defines the gradient to use (between 0 and 1)
  13864. * @param factor defines the life time factor to affect to the specified gradient
  13865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13866. * @returns the current particle system
  13867. */
  13868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13869. /**
  13870. * Remove a specific life time gradient
  13871. * @param gradient defines the gradient to remove
  13872. * @returns the current particle system
  13873. */
  13874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13875. /**
  13876. * Gets the current list of life time gradients.
  13877. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13878. * @returns the list of life time gradients
  13879. */
  13880. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13881. /**
  13882. * Gets the current list of color gradients.
  13883. * You must use addColorGradient and removeColorGradient to udpate this list
  13884. * @returns the list of color gradients
  13885. */
  13886. getColorGradients(): Nullable<Array<ColorGradient>>;
  13887. /**
  13888. * Adds a new ramp gradient used to remap particle colors
  13889. * @param gradient defines the gradient to use (between 0 and 1)
  13890. * @param color defines the color to affect to the specified gradient
  13891. * @returns the current particle system
  13892. */
  13893. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13894. /**
  13895. * Gets the current list of ramp gradients.
  13896. * You must use addRampGradient and removeRampGradient to udpate this list
  13897. * @returns the list of ramp gradients
  13898. */
  13899. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13900. /** Gets or sets a boolean indicating that ramp gradients must be used
  13901. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13902. */
  13903. useRampGradients: boolean;
  13904. /**
  13905. * Adds a new color remap gradient
  13906. * @param gradient defines the gradient to use (between 0 and 1)
  13907. * @param min defines the color remap minimal range
  13908. * @param max defines the color remap maximal range
  13909. * @returns the current particle system
  13910. */
  13911. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13912. /**
  13913. * Gets the current list of color remap gradients.
  13914. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13915. * @returns the list of color remap gradients
  13916. */
  13917. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13918. /**
  13919. * Adds a new alpha remap gradient
  13920. * @param gradient defines the gradient to use (between 0 and 1)
  13921. * @param min defines the alpha remap minimal range
  13922. * @param max defines the alpha remap maximal range
  13923. * @returns the current particle system
  13924. */
  13925. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13926. /**
  13927. * Gets the current list of alpha remap gradients.
  13928. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13929. * @returns the list of alpha remap gradients
  13930. */
  13931. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13932. /**
  13933. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13936. * @returns the emitter
  13937. */
  13938. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13939. /**
  13940. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13941. * @param radius The radius of the hemisphere to emit from
  13942. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13943. * @returns the emitter
  13944. */
  13945. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13946. /**
  13947. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13948. * @param radius The radius of the sphere to emit from
  13949. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13950. * @returns the emitter
  13951. */
  13952. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13953. /**
  13954. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13955. * @param radius The radius of the sphere to emit from
  13956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13958. * @returns the emitter
  13959. */
  13960. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13961. /**
  13962. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13963. * @param radius The radius of the emission cylinder
  13964. * @param height The height of the emission cylinder
  13965. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13966. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13967. * @returns the emitter
  13968. */
  13969. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13970. /**
  13971. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13972. * @param radius The radius of the cylinder to emit from
  13973. * @param height The height of the emission cylinder
  13974. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13975. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13976. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13977. * @returns the emitter
  13978. */
  13979. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13980. /**
  13981. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13982. * @param radius The radius of the cone to emit from
  13983. * @param angle The base angle of the cone
  13984. * @returns the emitter
  13985. */
  13986. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13987. /**
  13988. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13989. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13990. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13991. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13992. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13993. * @returns the emitter
  13994. */
  13995. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13996. /**
  13997. * Get hosting scene
  13998. * @returns the scene
  13999. */
  14000. getScene(): Scene;
  14001. }
  14002. }
  14003. declare module "babylonjs/Meshes/transformNode" {
  14004. import { DeepImmutable } from "babylonjs/types";
  14005. import { Observable } from "babylonjs/Misc/observable";
  14006. import { Nullable } from "babylonjs/types";
  14007. import { Camera } from "babylonjs/Cameras/camera";
  14008. import { Scene } from "babylonjs/scene";
  14009. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14010. import { Node } from "babylonjs/node";
  14011. import { Bone } from "babylonjs/Bones/bone";
  14012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14013. import { Space } from "babylonjs/Maths/math.axis";
  14014. /**
  14015. * 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.
  14016. * @see https://doc.babylonjs.com/how_to/transformnode
  14017. */
  14018. export class TransformNode extends Node {
  14019. /**
  14020. * Object will not rotate to face the camera
  14021. */
  14022. static BILLBOARDMODE_NONE: number;
  14023. /**
  14024. * Object will rotate to face the camera but only on the x axis
  14025. */
  14026. static BILLBOARDMODE_X: number;
  14027. /**
  14028. * Object will rotate to face the camera but only on the y axis
  14029. */
  14030. static BILLBOARDMODE_Y: number;
  14031. /**
  14032. * Object will rotate to face the camera but only on the z axis
  14033. */
  14034. static BILLBOARDMODE_Z: number;
  14035. /**
  14036. * Object will rotate to face the camera
  14037. */
  14038. static BILLBOARDMODE_ALL: number;
  14039. /**
  14040. * Object will rotate to face the camera's position instead of orientation
  14041. */
  14042. static BILLBOARDMODE_USE_POSITION: number;
  14043. private _forward;
  14044. private _forwardInverted;
  14045. private _up;
  14046. private _right;
  14047. private _rightInverted;
  14048. private _position;
  14049. private _rotation;
  14050. private _rotationQuaternion;
  14051. protected _scaling: Vector3;
  14052. protected _isDirty: boolean;
  14053. private _transformToBoneReferal;
  14054. private _isAbsoluteSynced;
  14055. private _billboardMode;
  14056. /**
  14057. * Gets or sets the billboard mode. Default is 0.
  14058. *
  14059. * | Value | Type | Description |
  14060. * | --- | --- | --- |
  14061. * | 0 | BILLBOARDMODE_NONE | |
  14062. * | 1 | BILLBOARDMODE_X | |
  14063. * | 2 | BILLBOARDMODE_Y | |
  14064. * | 4 | BILLBOARDMODE_Z | |
  14065. * | 7 | BILLBOARDMODE_ALL | |
  14066. *
  14067. */
  14068. get billboardMode(): number;
  14069. set billboardMode(value: number);
  14070. private _preserveParentRotationForBillboard;
  14071. /**
  14072. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14073. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14074. */
  14075. get preserveParentRotationForBillboard(): boolean;
  14076. set preserveParentRotationForBillboard(value: boolean);
  14077. /**
  14078. * 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
  14079. */
  14080. scalingDeterminant: number;
  14081. private _infiniteDistance;
  14082. /**
  14083. * Gets or sets the distance of the object to max, often used by skybox
  14084. */
  14085. get infiniteDistance(): boolean;
  14086. set infiniteDistance(value: boolean);
  14087. /**
  14088. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14089. * By default the system will update normals to compensate
  14090. */
  14091. ignoreNonUniformScaling: boolean;
  14092. /**
  14093. * 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
  14094. */
  14095. reIntegrateRotationIntoRotationQuaternion: boolean;
  14096. /** @hidden */
  14097. _poseMatrix: Nullable<Matrix>;
  14098. /** @hidden */
  14099. _localMatrix: Matrix;
  14100. private _usePivotMatrix;
  14101. private _absolutePosition;
  14102. private _absoluteScaling;
  14103. private _absoluteRotationQuaternion;
  14104. private _pivotMatrix;
  14105. private _pivotMatrixInverse;
  14106. protected _postMultiplyPivotMatrix: boolean;
  14107. protected _isWorldMatrixFrozen: boolean;
  14108. /** @hidden */
  14109. _indexInSceneTransformNodesArray: number;
  14110. /**
  14111. * An event triggered after the world matrix is updated
  14112. */
  14113. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14114. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14115. /**
  14116. * Gets a string identifying the name of the class
  14117. * @returns "TransformNode" string
  14118. */
  14119. getClassName(): string;
  14120. /**
  14121. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14122. */
  14123. get position(): Vector3;
  14124. set position(newPosition: Vector3);
  14125. /**
  14126. * 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)).
  14127. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14128. */
  14129. get rotation(): Vector3;
  14130. set rotation(newRotation: Vector3);
  14131. /**
  14132. * 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)).
  14133. */
  14134. get scaling(): Vector3;
  14135. set scaling(newScaling: Vector3);
  14136. /**
  14137. * 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).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. get rotationQuaternion(): Nullable<Quaternion>;
  14141. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14142. /**
  14143. * The forward direction of that transform in world space.
  14144. */
  14145. get forward(): Vector3;
  14146. /**
  14147. * The up direction of that transform in world space.
  14148. */
  14149. get up(): Vector3;
  14150. /**
  14151. * The right direction of that transform in world space.
  14152. */
  14153. get right(): Vector3;
  14154. /**
  14155. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14156. * @param matrix the matrix to copy the pose from
  14157. * @returns this TransformNode.
  14158. */
  14159. updatePoseMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Returns the mesh Pose matrix.
  14162. * @returns the pose matrix
  14163. */
  14164. getPoseMatrix(): Matrix;
  14165. /** @hidden */
  14166. _isSynchronized(): boolean;
  14167. /** @hidden */
  14168. _initCache(): void;
  14169. /**
  14170. * Flag the transform node as dirty (Forcing it to update everything)
  14171. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14172. * @returns this transform node
  14173. */
  14174. markAsDirty(property: string): TransformNode;
  14175. /**
  14176. * Returns the current mesh absolute position.
  14177. * Returns a Vector3.
  14178. */
  14179. get absolutePosition(): Vector3;
  14180. /**
  14181. * Returns the current mesh absolute scaling.
  14182. * Returns a Vector3.
  14183. */
  14184. get absoluteScaling(): Vector3;
  14185. /**
  14186. * Returns the current mesh absolute rotation.
  14187. * Returns a Quaternion.
  14188. */
  14189. get absoluteRotationQuaternion(): Quaternion;
  14190. /**
  14191. * Sets a new matrix to apply before all other transformation
  14192. * @param matrix defines the transform matrix
  14193. * @returns the current TransformNode
  14194. */
  14195. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14196. /**
  14197. * Sets a new pivot matrix to the current node
  14198. * @param matrix defines the new pivot matrix to use
  14199. * @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
  14200. * @returns the current TransformNode
  14201. */
  14202. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14203. /**
  14204. * Returns the mesh pivot matrix.
  14205. * Default : Identity.
  14206. * @returns the matrix
  14207. */
  14208. getPivotMatrix(): Matrix;
  14209. /**
  14210. * Instantiate (when possible) or clone that node with its hierarchy
  14211. * @param newParent defines the new parent to use for the instance (or clone)
  14212. * @param options defines options to configure how copy is done
  14213. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14214. * @returns an instance (or a clone) of the current node with its hiearchy
  14215. */
  14216. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14217. doNotInstantiate: boolean;
  14218. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14219. /**
  14220. * Prevents the World matrix to be computed any longer
  14221. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14222. * @returns the TransformNode.
  14223. */
  14224. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14225. /**
  14226. * Allows back the World matrix computation.
  14227. * @returns the TransformNode.
  14228. */
  14229. unfreezeWorldMatrix(): this;
  14230. /**
  14231. * True if the World matrix has been frozen.
  14232. */
  14233. get isWorldMatrixFrozen(): boolean;
  14234. /**
  14235. * Retuns the mesh absolute position in the World.
  14236. * @returns a Vector3.
  14237. */
  14238. getAbsolutePosition(): Vector3;
  14239. /**
  14240. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14241. * @param absolutePosition the absolute position to set
  14242. * @returns the TransformNode.
  14243. */
  14244. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14245. /**
  14246. * Sets the mesh position in its local space.
  14247. * @param vector3 the position to set in localspace
  14248. * @returns the TransformNode.
  14249. */
  14250. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14251. /**
  14252. * Returns the mesh position in the local space from the current World matrix values.
  14253. * @returns a new Vector3.
  14254. */
  14255. getPositionExpressedInLocalSpace(): Vector3;
  14256. /**
  14257. * Translates the mesh along the passed Vector3 in its local space.
  14258. * @param vector3 the distance to translate in localspace
  14259. * @returns the TransformNode.
  14260. */
  14261. locallyTranslate(vector3: Vector3): TransformNode;
  14262. private static _lookAtVectorCache;
  14263. /**
  14264. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14265. * @param targetPoint the position (must be in same space as current mesh) to look at
  14266. * @param yawCor optional yaw (y-axis) correction in radians
  14267. * @param pitchCor optional pitch (x-axis) correction in radians
  14268. * @param rollCor optional roll (z-axis) correction in radians
  14269. * @param space the choosen space of the target
  14270. * @returns the TransformNode.
  14271. */
  14272. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14273. /**
  14274. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14275. * This Vector3 is expressed in the World space.
  14276. * @param localAxis axis to rotate
  14277. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14278. */
  14279. getDirection(localAxis: Vector3): Vector3;
  14280. /**
  14281. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14282. * localAxis is expressed in the mesh local space.
  14283. * result is computed in the Wordl space from the mesh World matrix.
  14284. * @param localAxis axis to rotate
  14285. * @param result the resulting transformnode
  14286. * @returns this TransformNode.
  14287. */
  14288. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14289. /**
  14290. * Sets this transform node rotation to the given local axis.
  14291. * @param localAxis the axis in local space
  14292. * @param yawCor optional yaw (y-axis) correction in radians
  14293. * @param pitchCor optional pitch (x-axis) correction in radians
  14294. * @param rollCor optional roll (z-axis) correction in radians
  14295. * @returns this TransformNode
  14296. */
  14297. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14298. /**
  14299. * Sets a new pivot point to the current node
  14300. * @param point defines the new pivot point to use
  14301. * @param space defines if the point is in world or local space (local by default)
  14302. * @returns the current TransformNode
  14303. */
  14304. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14305. /**
  14306. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14307. * @returns the pivot point
  14308. */
  14309. getPivotPoint(): Vector3;
  14310. /**
  14311. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14312. * @param result the vector3 to store the result
  14313. * @returns this TransformNode.
  14314. */
  14315. getPivotPointToRef(result: Vector3): TransformNode;
  14316. /**
  14317. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14318. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14319. */
  14320. getAbsolutePivotPoint(): Vector3;
  14321. /**
  14322. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14323. * @param result vector3 to store the result
  14324. * @returns this TransformNode.
  14325. */
  14326. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14327. /**
  14328. * Defines the passed node as the parent of the current node.
  14329. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14330. * @see https://doc.babylonjs.com/how_to/parenting
  14331. * @param node the node ot set as the parent
  14332. * @returns this TransformNode.
  14333. */
  14334. setParent(node: Nullable<Node>): TransformNode;
  14335. private _nonUniformScaling;
  14336. /**
  14337. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14338. */
  14339. get nonUniformScaling(): boolean;
  14340. /** @hidden */
  14341. _updateNonUniformScalingState(value: boolean): boolean;
  14342. /**
  14343. * Attach the current TransformNode to another TransformNode associated with a bone
  14344. * @param bone Bone affecting the TransformNode
  14345. * @param affectedTransformNode TransformNode associated with the bone
  14346. * @returns this object
  14347. */
  14348. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14349. /**
  14350. * Detach the transform node if its associated with a bone
  14351. * @returns this object
  14352. */
  14353. detachFromBone(): TransformNode;
  14354. private static _rotationAxisCache;
  14355. /**
  14356. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14357. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14358. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14359. * The passed axis is also normalized.
  14360. * @param axis the axis to rotate around
  14361. * @param amount the amount to rotate in radians
  14362. * @param space Space to rotate in (Default: local)
  14363. * @returns the TransformNode.
  14364. */
  14365. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14366. /**
  14367. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14368. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14369. * The passed axis is also normalized. .
  14370. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14371. * @param point the point to rotate around
  14372. * @param axis the axis to rotate around
  14373. * @param amount the amount to rotate in radians
  14374. * @returns the TransformNode
  14375. */
  14376. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14377. /**
  14378. * Translates the mesh along the axis vector for the passed distance in the given space.
  14379. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14380. * @param axis the axis to translate in
  14381. * @param distance the distance to translate
  14382. * @param space Space to rotate in (Default: local)
  14383. * @returns the TransformNode.
  14384. */
  14385. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14386. /**
  14387. * Adds a rotation step to the mesh current rotation.
  14388. * x, y, z are Euler angles expressed in radians.
  14389. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14390. * This means this rotation is made in the mesh local space only.
  14391. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14392. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14393. * ```javascript
  14394. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14395. * ```
  14396. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14397. * 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.
  14398. * @param x Rotation to add
  14399. * @param y Rotation to add
  14400. * @param z Rotation to add
  14401. * @returns the TransformNode.
  14402. */
  14403. addRotation(x: number, y: number, z: number): TransformNode;
  14404. /**
  14405. * @hidden
  14406. */
  14407. protected _getEffectiveParent(): Nullable<Node>;
  14408. /**
  14409. * Computes the world matrix of the node
  14410. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14411. * @returns the world matrix
  14412. */
  14413. computeWorldMatrix(force?: boolean): Matrix;
  14414. /**
  14415. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14416. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14417. */
  14418. resetLocalMatrix(independentOfChildren?: boolean): void;
  14419. protected _afterComputeWorldMatrix(): void;
  14420. /**
  14421. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14422. * @param func callback function to add
  14423. *
  14424. * @returns the TransformNode.
  14425. */
  14426. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14427. /**
  14428. * Removes a registered callback function.
  14429. * @param func callback function to remove
  14430. * @returns the TransformNode.
  14431. */
  14432. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14433. /**
  14434. * Gets the position of the current mesh in camera space
  14435. * @param camera defines the camera to use
  14436. * @returns a position
  14437. */
  14438. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14439. /**
  14440. * Returns the distance from the mesh to the active camera
  14441. * @param camera defines the camera to use
  14442. * @returns the distance
  14443. */
  14444. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14445. /**
  14446. * Clone the current transform node
  14447. * @param name Name of the new clone
  14448. * @param newParent New parent for the clone
  14449. * @param doNotCloneChildren Do not clone children hierarchy
  14450. * @returns the new transform node
  14451. */
  14452. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14453. /**
  14454. * Serializes the objects information.
  14455. * @param currentSerializationObject defines the object to serialize in
  14456. * @returns the serialized object
  14457. */
  14458. serialize(currentSerializationObject?: any): any;
  14459. /**
  14460. * Returns a new TransformNode object parsed from the source provided.
  14461. * @param parsedTransformNode is the source.
  14462. * @param scene the scne the object belongs to
  14463. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14464. * @returns a new TransformNode object parsed from the source provided.
  14465. */
  14466. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14467. /**
  14468. * Get all child-transformNodes of this node
  14469. * @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
  14470. * @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
  14471. * @returns an array of TransformNode
  14472. */
  14473. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14474. /**
  14475. * Releases resources associated with this transform node.
  14476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14478. */
  14479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14480. /**
  14481. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14482. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14483. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14484. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14485. * @returns the current mesh
  14486. */
  14487. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14488. private _syncAbsoluteScalingAndRotation;
  14489. }
  14490. }
  14491. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14492. /**
  14493. * Class used to override all child animations of a given target
  14494. */
  14495. export class AnimationPropertiesOverride {
  14496. /**
  14497. * Gets or sets a value indicating if animation blending must be used
  14498. */
  14499. enableBlending: boolean;
  14500. /**
  14501. * Gets or sets the blending speed to use when enableBlending is true
  14502. */
  14503. blendingSpeed: number;
  14504. /**
  14505. * Gets or sets the default loop mode to use
  14506. */
  14507. loopMode: number;
  14508. }
  14509. }
  14510. declare module "babylonjs/Bones/bone" {
  14511. import { Skeleton } from "babylonjs/Bones/skeleton";
  14512. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14513. import { Nullable } from "babylonjs/types";
  14514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14516. import { Node } from "babylonjs/node";
  14517. import { Space } from "babylonjs/Maths/math.axis";
  14518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14519. /**
  14520. * Class used to store bone information
  14521. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14522. */
  14523. export class Bone extends Node {
  14524. /**
  14525. * defines the bone name
  14526. */
  14527. name: string;
  14528. private static _tmpVecs;
  14529. private static _tmpQuat;
  14530. private static _tmpMats;
  14531. /**
  14532. * Gets the list of child bones
  14533. */
  14534. children: Bone[];
  14535. /** Gets the animations associated with this bone */
  14536. animations: import("babylonjs/Animations/animation").Animation[];
  14537. /**
  14538. * Gets or sets bone length
  14539. */
  14540. length: number;
  14541. /**
  14542. * @hidden Internal only
  14543. * Set this value to map this bone to a different index in the transform matrices
  14544. * Set this value to -1 to exclude the bone from the transform matrices
  14545. */
  14546. _index: Nullable<number>;
  14547. private _skeleton;
  14548. private _localMatrix;
  14549. private _restPose;
  14550. private _baseMatrix;
  14551. private _absoluteTransform;
  14552. private _invertedAbsoluteTransform;
  14553. private _parent;
  14554. private _scalingDeterminant;
  14555. private _worldTransform;
  14556. private _localScaling;
  14557. private _localRotation;
  14558. private _localPosition;
  14559. private _needToDecompose;
  14560. private _needToCompose;
  14561. /** @hidden */
  14562. _linkedTransformNode: Nullable<TransformNode>;
  14563. /** @hidden */
  14564. _waitingTransformNodeId: Nullable<string>;
  14565. /** @hidden */
  14566. get _matrix(): Matrix;
  14567. /** @hidden */
  14568. set _matrix(value: Matrix);
  14569. /**
  14570. * Create a new bone
  14571. * @param name defines the bone name
  14572. * @param skeleton defines the parent skeleton
  14573. * @param parentBone defines the parent (can be null if the bone is the root)
  14574. * @param localMatrix defines the local matrix
  14575. * @param restPose defines the rest pose matrix
  14576. * @param baseMatrix defines the base matrix
  14577. * @param index defines index of the bone in the hiearchy
  14578. */
  14579. constructor(
  14580. /**
  14581. * defines the bone name
  14582. */
  14583. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14584. /**
  14585. * Gets the current object class name.
  14586. * @return the class name
  14587. */
  14588. getClassName(): string;
  14589. /**
  14590. * Gets the parent skeleton
  14591. * @returns a skeleton
  14592. */
  14593. getSkeleton(): Skeleton;
  14594. /**
  14595. * Gets parent bone
  14596. * @returns a bone or null if the bone is the root of the bone hierarchy
  14597. */
  14598. getParent(): Nullable<Bone>;
  14599. /**
  14600. * Returns an array containing the root bones
  14601. * @returns an array containing the root bones
  14602. */
  14603. getChildren(): Array<Bone>;
  14604. /**
  14605. * Gets the node index in matrix array generated for rendering
  14606. * @returns the node index
  14607. */
  14608. getIndex(): number;
  14609. /**
  14610. * Sets the parent bone
  14611. * @param parent defines the parent (can be null if the bone is the root)
  14612. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14613. */
  14614. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14615. /**
  14616. * Gets the local matrix
  14617. * @returns a matrix
  14618. */
  14619. getLocalMatrix(): Matrix;
  14620. /**
  14621. * Gets the base matrix (initial matrix which remains unchanged)
  14622. * @returns a matrix
  14623. */
  14624. getBaseMatrix(): Matrix;
  14625. /**
  14626. * Gets the rest pose matrix
  14627. * @returns a matrix
  14628. */
  14629. getRestPose(): Matrix;
  14630. /**
  14631. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14632. */
  14633. getWorldMatrix(): Matrix;
  14634. /**
  14635. * Sets the local matrix to rest pose matrix
  14636. */
  14637. returnToRest(): void;
  14638. /**
  14639. * Gets the inverse of the absolute transform matrix.
  14640. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14641. * @returns a matrix
  14642. */
  14643. getInvertedAbsoluteTransform(): Matrix;
  14644. /**
  14645. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14646. * @returns a matrix
  14647. */
  14648. getAbsoluteTransform(): Matrix;
  14649. /**
  14650. * Links with the given transform node.
  14651. * The local matrix of this bone is copied from the transform node every frame.
  14652. * @param transformNode defines the transform node to link to
  14653. */
  14654. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14655. /**
  14656. * Gets the node used to drive the bone's transformation
  14657. * @returns a transform node or null
  14658. */
  14659. getTransformNode(): Nullable<TransformNode>;
  14660. /** Gets or sets current position (in local space) */
  14661. get position(): Vector3;
  14662. set position(newPosition: Vector3);
  14663. /** Gets or sets current rotation (in local space) */
  14664. get rotation(): Vector3;
  14665. set rotation(newRotation: Vector3);
  14666. /** Gets or sets current rotation quaternion (in local space) */
  14667. get rotationQuaternion(): Quaternion;
  14668. set rotationQuaternion(newRotation: Quaternion);
  14669. /** Gets or sets current scaling (in local space) */
  14670. get scaling(): Vector3;
  14671. set scaling(newScaling: Vector3);
  14672. /**
  14673. * Gets the animation properties override
  14674. */
  14675. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14676. private _decompose;
  14677. private _compose;
  14678. /**
  14679. * Update the base and local matrices
  14680. * @param matrix defines the new base or local matrix
  14681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14682. * @param updateLocalMatrix defines if the local matrix should be updated
  14683. */
  14684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14685. /** @hidden */
  14686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14687. /**
  14688. * Flag the bone as dirty (Forcing it to update everything)
  14689. */
  14690. markAsDirty(): void;
  14691. /** @hidden */
  14692. _markAsDirtyAndCompose(): void;
  14693. private _markAsDirtyAndDecompose;
  14694. /**
  14695. * Translate the bone in local or world space
  14696. * @param vec The amount to translate the bone
  14697. * @param space The space that the translation is in
  14698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14699. */
  14700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14701. /**
  14702. * Set the postion of the bone in local or world space
  14703. * @param position The position to set the bone
  14704. * @param space The space that the position is in
  14705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14706. */
  14707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14708. /**
  14709. * Set the absolute position of the bone (world space)
  14710. * @param position The position to set the bone
  14711. * @param mesh The mesh that this bone is attached to
  14712. */
  14713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14714. /**
  14715. * Scale the bone on the x, y and z axes (in local space)
  14716. * @param x The amount to scale the bone on the x axis
  14717. * @param y The amount to scale the bone on the y axis
  14718. * @param z The amount to scale the bone on the z axis
  14719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14720. */
  14721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14722. /**
  14723. * Set the bone scaling in local space
  14724. * @param scale defines the scaling vector
  14725. */
  14726. setScale(scale: Vector3): void;
  14727. /**
  14728. * Gets the current scaling in local space
  14729. * @returns the current scaling vector
  14730. */
  14731. getScale(): Vector3;
  14732. /**
  14733. * Gets the current scaling in local space and stores it in a target vector
  14734. * @param result defines the target vector
  14735. */
  14736. getScaleToRef(result: Vector3): void;
  14737. /**
  14738. * Set the yaw, pitch, and roll of the bone in local or world space
  14739. * @param yaw The rotation of the bone on the y axis
  14740. * @param pitch The rotation of the bone on the x axis
  14741. * @param roll The rotation of the bone on the z axis
  14742. * @param space The space that the axes of rotation are in
  14743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14744. */
  14745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14746. /**
  14747. * Add a rotation to the bone on an axis in local or world space
  14748. * @param axis The axis to rotate the bone on
  14749. * @param amount The amount to rotate the bone
  14750. * @param space The space that the axis is in
  14751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14752. */
  14753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14754. /**
  14755. * Set the rotation of the bone to a particular axis angle in local or world space
  14756. * @param axis The axis to rotate the bone on
  14757. * @param angle The angle that the bone should be rotated to
  14758. * @param space The space that the axis is in
  14759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14760. */
  14761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14762. /**
  14763. * Set the euler rotation of the bone in local of world space
  14764. * @param rotation The euler rotation that the bone should be set to
  14765. * @param space The space that the rotation is in
  14766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14767. */
  14768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14769. /**
  14770. * Set the quaternion rotation of the bone in local of world space
  14771. * @param quat The quaternion rotation that the bone should be set to
  14772. * @param space The space that the rotation is in
  14773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14774. */
  14775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14776. /**
  14777. * Set the rotation matrix of the bone in local of world space
  14778. * @param rotMat The rotation matrix that the bone should be set to
  14779. * @param space The space that the rotation is in
  14780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14781. */
  14782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14783. private _rotateWithMatrix;
  14784. private _getNegativeRotationToRef;
  14785. /**
  14786. * Get the position of the bone in local or world space
  14787. * @param space The space that the returned position is in
  14788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14789. * @returns The position of the bone
  14790. */
  14791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14792. /**
  14793. * Copy the position of the bone to a vector3 in local or world space
  14794. * @param space The space that the returned position is in
  14795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14796. * @param result The vector3 to copy the position to
  14797. */
  14798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14799. /**
  14800. * Get the absolute position of the bone (world space)
  14801. * @param mesh The mesh that this bone is attached to
  14802. * @returns The absolute position of the bone
  14803. */
  14804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14805. /**
  14806. * Copy the absolute position of the bone (world space) to the result param
  14807. * @param mesh The mesh that this bone is attached to
  14808. * @param result The vector3 to copy the absolute position to
  14809. */
  14810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14811. /**
  14812. * Compute the absolute transforms of this bone and its children
  14813. */
  14814. computeAbsoluteTransforms(): void;
  14815. /**
  14816. * Get the world direction from an axis that is in the local space of the bone
  14817. * @param localAxis The local direction that is used to compute the world direction
  14818. * @param mesh The mesh that this bone is attached to
  14819. * @returns The world direction
  14820. */
  14821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14822. /**
  14823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14824. * @param localAxis The local direction that is used to compute the world direction
  14825. * @param mesh The mesh that this bone is attached to
  14826. * @param result The vector3 that the world direction will be copied to
  14827. */
  14828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14829. /**
  14830. * Get the euler rotation of the bone in local or world space
  14831. * @param space The space that the rotation should be in
  14832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14833. * @returns The euler rotation
  14834. */
  14835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14836. /**
  14837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14838. * @param space The space that the rotation should be in
  14839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14840. * @param result The vector3 that the rotation should be copied to
  14841. */
  14842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14843. /**
  14844. * Get the quaternion rotation of the bone in either local or world space
  14845. * @param space The space that the rotation should be in
  14846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14847. * @returns The quaternion rotation
  14848. */
  14849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14850. /**
  14851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14852. * @param space The space that the rotation should be in
  14853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14854. * @param result The quaternion that the rotation should be copied to
  14855. */
  14856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14857. /**
  14858. * Get the rotation matrix of the bone in local or world space
  14859. * @param space The space that the rotation should be in
  14860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14861. * @returns The rotation matrix
  14862. */
  14863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14864. /**
  14865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14866. * @param space The space that the rotation should be in
  14867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14868. * @param result The quaternion that the rotation should be copied to
  14869. */
  14870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14871. /**
  14872. * Get the world position of a point that is in the local space of the bone
  14873. * @param position The local position
  14874. * @param mesh The mesh that this bone is attached to
  14875. * @returns The world position
  14876. */
  14877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14878. /**
  14879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14880. * @param position The local position
  14881. * @param mesh The mesh that this bone is attached to
  14882. * @param result The vector3 that the world position should be copied to
  14883. */
  14884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14885. /**
  14886. * Get the local position of a point that is in world space
  14887. * @param position The world position
  14888. * @param mesh The mesh that this bone is attached to
  14889. * @returns The local position
  14890. */
  14891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14892. /**
  14893. * Get the local position of a point that is in world space and copy it to the result param
  14894. * @param position The world position
  14895. * @param mesh The mesh that this bone is attached to
  14896. * @param result The vector3 that the local position should be copied to
  14897. */
  14898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14899. }
  14900. }
  14901. declare module "babylonjs/Animations/runtimeAnimation" {
  14902. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14903. import { Animatable } from "babylonjs/Animations/animatable";
  14904. import { Scene } from "babylonjs/scene";
  14905. /**
  14906. * Defines a runtime animation
  14907. */
  14908. export class RuntimeAnimation {
  14909. private _events;
  14910. /**
  14911. * The current frame of the runtime animation
  14912. */
  14913. private _currentFrame;
  14914. /**
  14915. * The animation used by the runtime animation
  14916. */
  14917. private _animation;
  14918. /**
  14919. * The target of the runtime animation
  14920. */
  14921. private _target;
  14922. /**
  14923. * The initiating animatable
  14924. */
  14925. private _host;
  14926. /**
  14927. * The original value of the runtime animation
  14928. */
  14929. private _originalValue;
  14930. /**
  14931. * The original blend value of the runtime animation
  14932. */
  14933. private _originalBlendValue;
  14934. /**
  14935. * The offsets cache of the runtime animation
  14936. */
  14937. private _offsetsCache;
  14938. /**
  14939. * The high limits cache of the runtime animation
  14940. */
  14941. private _highLimitsCache;
  14942. /**
  14943. * Specifies if the runtime animation has been stopped
  14944. */
  14945. private _stopped;
  14946. /**
  14947. * The blending factor of the runtime animation
  14948. */
  14949. private _blendingFactor;
  14950. /**
  14951. * The BabylonJS scene
  14952. */
  14953. private _scene;
  14954. /**
  14955. * The current value of the runtime animation
  14956. */
  14957. private _currentValue;
  14958. /** @hidden */
  14959. _animationState: _IAnimationState;
  14960. /**
  14961. * The active target of the runtime animation
  14962. */
  14963. private _activeTargets;
  14964. private _currentActiveTarget;
  14965. private _directTarget;
  14966. /**
  14967. * The target path of the runtime animation
  14968. */
  14969. private _targetPath;
  14970. /**
  14971. * The weight of the runtime animation
  14972. */
  14973. private _weight;
  14974. /**
  14975. * The ratio offset of the runtime animation
  14976. */
  14977. private _ratioOffset;
  14978. /**
  14979. * The previous delay of the runtime animation
  14980. */
  14981. private _previousDelay;
  14982. /**
  14983. * The previous ratio of the runtime animation
  14984. */
  14985. private _previousRatio;
  14986. private _enableBlending;
  14987. private _keys;
  14988. private _minFrame;
  14989. private _maxFrame;
  14990. private _minValue;
  14991. private _maxValue;
  14992. private _targetIsArray;
  14993. /**
  14994. * Gets the current frame of the runtime animation
  14995. */
  14996. get currentFrame(): number;
  14997. /**
  14998. * Gets the weight of the runtime animation
  14999. */
  15000. get weight(): number;
  15001. /**
  15002. * Gets the current value of the runtime animation
  15003. */
  15004. get currentValue(): any;
  15005. /**
  15006. * Gets the target path of the runtime animation
  15007. */
  15008. get targetPath(): string;
  15009. /**
  15010. * Gets the actual target of the runtime animation
  15011. */
  15012. get target(): any;
  15013. /**
  15014. * Gets the additive state of the runtime animation
  15015. */
  15016. get isAdditive(): boolean;
  15017. /** @hidden */
  15018. _onLoop: () => void;
  15019. /**
  15020. * Create a new RuntimeAnimation object
  15021. * @param target defines the target of the animation
  15022. * @param animation defines the source animation object
  15023. * @param scene defines the hosting scene
  15024. * @param host defines the initiating Animatable
  15025. */
  15026. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15027. private _preparePath;
  15028. /**
  15029. * Gets the animation from the runtime animation
  15030. */
  15031. get animation(): Animation;
  15032. /**
  15033. * Resets the runtime animation to the beginning
  15034. * @param restoreOriginal defines whether to restore the target property to the original value
  15035. */
  15036. reset(restoreOriginal?: boolean): void;
  15037. /**
  15038. * Specifies if the runtime animation is stopped
  15039. * @returns Boolean specifying if the runtime animation is stopped
  15040. */
  15041. isStopped(): boolean;
  15042. /**
  15043. * Disposes of the runtime animation
  15044. */
  15045. dispose(): void;
  15046. /**
  15047. * Apply the interpolated value to the target
  15048. * @param currentValue defines the value computed by the animation
  15049. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15050. */
  15051. setValue(currentValue: any, weight: number): void;
  15052. private _getOriginalValues;
  15053. private _setValue;
  15054. /**
  15055. * Gets the loop pmode of the runtime animation
  15056. * @returns Loop Mode
  15057. */
  15058. private _getCorrectLoopMode;
  15059. /**
  15060. * Move the current animation to a given frame
  15061. * @param frame defines the frame to move to
  15062. */
  15063. goToFrame(frame: number): void;
  15064. /**
  15065. * @hidden Internal use only
  15066. */
  15067. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15068. /**
  15069. * Execute the current animation
  15070. * @param delay defines the delay to add to the current frame
  15071. * @param from defines the lower bound of the animation range
  15072. * @param to defines the upper bound of the animation range
  15073. * @param loop defines if the current animation must loop
  15074. * @param speedRatio defines the current speed ratio
  15075. * @param weight defines the weight of the animation (default is -1 so no weight)
  15076. * @param onLoop optional callback called when animation loops
  15077. * @returns a boolean indicating if the animation is running
  15078. */
  15079. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15080. }
  15081. }
  15082. declare module "babylonjs/Animations/animatable" {
  15083. import { Animation } from "babylonjs/Animations/animation";
  15084. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15085. import { Nullable } from "babylonjs/types";
  15086. import { Observable } from "babylonjs/Misc/observable";
  15087. import { Scene } from "babylonjs/scene";
  15088. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15089. import { Node } from "babylonjs/node";
  15090. /**
  15091. * Class used to store an actual running animation
  15092. */
  15093. export class Animatable {
  15094. /** defines the target object */
  15095. target: any;
  15096. /** defines the starting frame number (default is 0) */
  15097. fromFrame: number;
  15098. /** defines the ending frame number (default is 100) */
  15099. toFrame: number;
  15100. /** defines if the animation must loop (default is false) */
  15101. loopAnimation: boolean;
  15102. /** defines a callback to call when animation ends if it is not looping */
  15103. onAnimationEnd?: (() => void) | null | undefined;
  15104. /** defines a callback to call when animation loops */
  15105. onAnimationLoop?: (() => void) | null | undefined;
  15106. /** defines whether the animation should be evaluated additively */
  15107. isAdditive: boolean;
  15108. private _localDelayOffset;
  15109. private _pausedDelay;
  15110. private _runtimeAnimations;
  15111. private _paused;
  15112. private _scene;
  15113. private _speedRatio;
  15114. private _weight;
  15115. private _syncRoot;
  15116. /**
  15117. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15118. * This will only apply for non looping animation (default is true)
  15119. */
  15120. disposeOnEnd: boolean;
  15121. /**
  15122. * Gets a boolean indicating if the animation has started
  15123. */
  15124. animationStarted: boolean;
  15125. /**
  15126. * Observer raised when the animation ends
  15127. */
  15128. onAnimationEndObservable: Observable<Animatable>;
  15129. /**
  15130. * Observer raised when the animation loops
  15131. */
  15132. onAnimationLoopObservable: Observable<Animatable>;
  15133. /**
  15134. * Gets the root Animatable used to synchronize and normalize animations
  15135. */
  15136. get syncRoot(): Nullable<Animatable>;
  15137. /**
  15138. * Gets the current frame of the first RuntimeAnimation
  15139. * Used to synchronize Animatables
  15140. */
  15141. get masterFrame(): number;
  15142. /**
  15143. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15144. */
  15145. get weight(): number;
  15146. set weight(value: number);
  15147. /**
  15148. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15149. */
  15150. get speedRatio(): number;
  15151. set speedRatio(value: number);
  15152. /**
  15153. * Creates a new Animatable
  15154. * @param scene defines the hosting scene
  15155. * @param target defines the target object
  15156. * @param fromFrame defines the starting frame number (default is 0)
  15157. * @param toFrame defines the ending frame number (default is 100)
  15158. * @param loopAnimation defines if the animation must loop (default is false)
  15159. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15160. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15161. * @param animations defines a group of animation to add to the new Animatable
  15162. * @param onAnimationLoop defines a callback to call when animation loops
  15163. * @param isAdditive defines whether the animation should be evaluated additively
  15164. */
  15165. constructor(scene: Scene,
  15166. /** defines the target object */
  15167. target: any,
  15168. /** defines the starting frame number (default is 0) */
  15169. fromFrame?: number,
  15170. /** defines the ending frame number (default is 100) */
  15171. toFrame?: number,
  15172. /** defines if the animation must loop (default is false) */
  15173. loopAnimation?: boolean, speedRatio?: number,
  15174. /** defines a callback to call when animation ends if it is not looping */
  15175. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15176. /** defines a callback to call when animation loops */
  15177. onAnimationLoop?: (() => void) | null | undefined,
  15178. /** defines whether the animation should be evaluated additively */
  15179. isAdditive?: boolean);
  15180. /**
  15181. * Synchronize and normalize current Animatable with a source Animatable
  15182. * This is useful when using animation weights and when animations are not of the same length
  15183. * @param root defines the root Animatable to synchronize with
  15184. * @returns the current Animatable
  15185. */
  15186. syncWith(root: Animatable): Animatable;
  15187. /**
  15188. * Gets the list of runtime animations
  15189. * @returns an array of RuntimeAnimation
  15190. */
  15191. getAnimations(): RuntimeAnimation[];
  15192. /**
  15193. * Adds more animations to the current animatable
  15194. * @param target defines the target of the animations
  15195. * @param animations defines the new animations to add
  15196. */
  15197. appendAnimations(target: any, animations: Animation[]): void;
  15198. /**
  15199. * Gets the source animation for a specific property
  15200. * @param property defines the propertyu to look for
  15201. * @returns null or the source animation for the given property
  15202. */
  15203. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15204. /**
  15205. * Gets the runtime animation for a specific property
  15206. * @param property defines the propertyu to look for
  15207. * @returns null or the runtime animation for the given property
  15208. */
  15209. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15210. /**
  15211. * Resets the animatable to its original state
  15212. */
  15213. reset(): void;
  15214. /**
  15215. * Allows the animatable to blend with current running animations
  15216. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15217. * @param blendingSpeed defines the blending speed to use
  15218. */
  15219. enableBlending(blendingSpeed: number): void;
  15220. /**
  15221. * Disable animation blending
  15222. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15223. */
  15224. disableBlending(): void;
  15225. /**
  15226. * Jump directly to a given frame
  15227. * @param frame defines the frame to jump to
  15228. */
  15229. goToFrame(frame: number): void;
  15230. /**
  15231. * Pause the animation
  15232. */
  15233. pause(): void;
  15234. /**
  15235. * Restart the animation
  15236. */
  15237. restart(): void;
  15238. private _raiseOnAnimationEnd;
  15239. /**
  15240. * Stop and delete the current animation
  15241. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15242. * @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)
  15243. */
  15244. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15245. /**
  15246. * Wait asynchronously for the animation to end
  15247. * @returns a promise which will be fullfilled when the animation ends
  15248. */
  15249. waitAsync(): Promise<Animatable>;
  15250. /** @hidden */
  15251. _animate(delay: number): boolean;
  15252. }
  15253. module "babylonjs/scene" {
  15254. interface Scene {
  15255. /** @hidden */
  15256. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15257. /** @hidden */
  15258. _processLateAnimationBindingsForMatrices(holder: {
  15259. totalWeight: number;
  15260. totalAdditiveWeight: number;
  15261. animations: RuntimeAnimation[];
  15262. additiveAnimations: RuntimeAnimation[];
  15263. originalValue: Matrix;
  15264. }): any;
  15265. /** @hidden */
  15266. _processLateAnimationBindingsForQuaternions(holder: {
  15267. totalWeight: number;
  15268. totalAdditiveWeight: number;
  15269. animations: RuntimeAnimation[];
  15270. additiveAnimations: RuntimeAnimation[];
  15271. originalValue: Quaternion;
  15272. }, refQuaternion: Quaternion): Quaternion;
  15273. /** @hidden */
  15274. _processLateAnimationBindings(): void;
  15275. /**
  15276. * Will start the animation sequence of a given target
  15277. * @param target defines the target
  15278. * @param from defines from which frame should animation start
  15279. * @param to defines until which frame should animation run.
  15280. * @param weight defines the weight to apply to the animation (1.0 by default)
  15281. * @param loop defines if the animation loops
  15282. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15283. * @param onAnimationEnd defines the function to be executed when the animation ends
  15284. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15285. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15286. * @param onAnimationLoop defines the callback to call when an animation loops
  15287. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15288. * @returns the animatable object created for this animation
  15289. */
  15290. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15291. /**
  15292. * Will start the animation sequence of a given target
  15293. * @param target defines the target
  15294. * @param from defines from which frame should animation start
  15295. * @param to defines until which frame should animation run.
  15296. * @param loop defines if the animation loops
  15297. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15298. * @param onAnimationEnd defines the function to be executed when the animation ends
  15299. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15300. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15301. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15302. * @param onAnimationLoop defines the callback to call when an animation loops
  15303. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15304. * @returns the animatable object created for this animation
  15305. */
  15306. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15307. /**
  15308. * Will start the animation sequence of a given target and its hierarchy
  15309. * @param target defines the target
  15310. * @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.
  15311. * @param from defines from which frame should animation start
  15312. * @param to defines until which frame should animation run.
  15313. * @param loop defines if the animation loops
  15314. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15315. * @param onAnimationEnd defines the function to be executed when the animation ends
  15316. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15317. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15318. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15319. * @param onAnimationLoop defines the callback to call when an animation loops
  15320. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15321. * @returns the list of created animatables
  15322. */
  15323. 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, isAdditive?: boolean): Animatable[];
  15324. /**
  15325. * Begin a new animation on a given node
  15326. * @param target defines the target where the animation will take place
  15327. * @param animations defines the list of animations to start
  15328. * @param from defines the initial value
  15329. * @param to defines the final value
  15330. * @param loop defines if you want animation to loop (off by default)
  15331. * @param speedRatio defines the speed ratio to apply to all animations
  15332. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15333. * @param onAnimationLoop defines the callback to call when an animation loops
  15334. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15335. * @returns the list of created animatables
  15336. */
  15337. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15338. /**
  15339. * Begin a new animation on a given node and its hierarchy
  15340. * @param target defines the root node where the animation will take place
  15341. * @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.
  15342. * @param animations defines the list of animations to start
  15343. * @param from defines the initial value
  15344. * @param to defines the final value
  15345. * @param loop defines if you want animation to loop (off by default)
  15346. * @param speedRatio defines the speed ratio to apply to all animations
  15347. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15348. * @param onAnimationLoop defines the callback to call when an animation loops
  15349. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15350. * @returns the list of animatables created for all nodes
  15351. */
  15352. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15353. /**
  15354. * Gets the animatable associated with a specific target
  15355. * @param target defines the target of the animatable
  15356. * @returns the required animatable if found
  15357. */
  15358. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15359. /**
  15360. * Gets all animatables associated with a given target
  15361. * @param target defines the target to look animatables for
  15362. * @returns an array of Animatables
  15363. */
  15364. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15365. /**
  15366. * Stops and removes all animations that have been applied to the scene
  15367. */
  15368. stopAllAnimations(): void;
  15369. /**
  15370. * Gets the current delta time used by animation engine
  15371. */
  15372. deltaTime: number;
  15373. }
  15374. }
  15375. module "babylonjs/Bones/bone" {
  15376. interface Bone {
  15377. /**
  15378. * Copy an animation range from another bone
  15379. * @param source defines the source bone
  15380. * @param rangeName defines the range name to copy
  15381. * @param frameOffset defines the frame offset
  15382. * @param rescaleAsRequired defines if rescaling must be applied if required
  15383. * @param skelDimensionsRatio defines the scaling ratio
  15384. * @returns true if operation was successful
  15385. */
  15386. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15387. }
  15388. }
  15389. }
  15390. declare module "babylonjs/Bones/skeleton" {
  15391. import { Bone } from "babylonjs/Bones/bone";
  15392. import { Observable } from "babylonjs/Misc/observable";
  15393. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15394. import { Scene } from "babylonjs/scene";
  15395. import { Nullable } from "babylonjs/types";
  15396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15397. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15398. import { Animatable } from "babylonjs/Animations/animatable";
  15399. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15400. import { Animation } from "babylonjs/Animations/animation";
  15401. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15402. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15404. /**
  15405. * Class used to handle skinning animations
  15406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15407. */
  15408. export class Skeleton implements IAnimatable {
  15409. /** defines the skeleton name */
  15410. name: string;
  15411. /** defines the skeleton Id */
  15412. id: string;
  15413. /**
  15414. * Defines the list of child bones
  15415. */
  15416. bones: Bone[];
  15417. /**
  15418. * Defines an estimate of the dimension of the skeleton at rest
  15419. */
  15420. dimensionsAtRest: Vector3;
  15421. /**
  15422. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15423. */
  15424. needInitialSkinMatrix: boolean;
  15425. /**
  15426. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15427. */
  15428. overrideMesh: Nullable<AbstractMesh>;
  15429. /**
  15430. * Gets the list of animations attached to this skeleton
  15431. */
  15432. animations: Array<Animation>;
  15433. private _scene;
  15434. private _isDirty;
  15435. private _transformMatrices;
  15436. private _transformMatrixTexture;
  15437. private _meshesWithPoseMatrix;
  15438. private _animatables;
  15439. private _identity;
  15440. private _synchronizedWithMesh;
  15441. private _ranges;
  15442. private _lastAbsoluteTransformsUpdateId;
  15443. private _canUseTextureForBones;
  15444. private _uniqueId;
  15445. /** @hidden */
  15446. _numBonesWithLinkedTransformNode: number;
  15447. /** @hidden */
  15448. _hasWaitingData: Nullable<boolean>;
  15449. /**
  15450. * Specifies if the skeleton should be serialized
  15451. */
  15452. doNotSerialize: boolean;
  15453. private _useTextureToStoreBoneMatrices;
  15454. /**
  15455. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15456. * Please note that this option is not available if the hardware does not support it
  15457. */
  15458. get useTextureToStoreBoneMatrices(): boolean;
  15459. set useTextureToStoreBoneMatrices(value: boolean);
  15460. private _animationPropertiesOverride;
  15461. /**
  15462. * Gets or sets the animation properties override
  15463. */
  15464. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15465. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15466. /**
  15467. * List of inspectable custom properties (used by the Inspector)
  15468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15469. */
  15470. inspectableCustomProperties: IInspectable[];
  15471. /**
  15472. * An observable triggered before computing the skeleton's matrices
  15473. */
  15474. onBeforeComputeObservable: Observable<Skeleton>;
  15475. /**
  15476. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15477. */
  15478. get isUsingTextureForMatrices(): boolean;
  15479. /**
  15480. * Gets the unique ID of this skeleton
  15481. */
  15482. get uniqueId(): number;
  15483. /**
  15484. * Creates a new skeleton
  15485. * @param name defines the skeleton name
  15486. * @param id defines the skeleton Id
  15487. * @param scene defines the hosting scene
  15488. */
  15489. constructor(
  15490. /** defines the skeleton name */
  15491. name: string,
  15492. /** defines the skeleton Id */
  15493. id: string, scene: Scene);
  15494. /**
  15495. * Gets the current object class name.
  15496. * @return the class name
  15497. */
  15498. getClassName(): string;
  15499. /**
  15500. * Returns an array containing the root bones
  15501. * @returns an array containing the root bones
  15502. */
  15503. getChildren(): Array<Bone>;
  15504. /**
  15505. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15506. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15507. * @returns a Float32Array containing matrices data
  15508. */
  15509. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15510. /**
  15511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15512. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15513. * @returns a raw texture containing the data
  15514. */
  15515. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15516. /**
  15517. * Gets the current hosting scene
  15518. * @returns a scene object
  15519. */
  15520. getScene(): Scene;
  15521. /**
  15522. * Gets a string representing the current skeleton data
  15523. * @param fullDetails defines a boolean indicating if we want a verbose version
  15524. * @returns a string representing the current skeleton data
  15525. */
  15526. toString(fullDetails?: boolean): string;
  15527. /**
  15528. * Get bone's index searching by name
  15529. * @param name defines bone's name to search for
  15530. * @return the indice of the bone. Returns -1 if not found
  15531. */
  15532. getBoneIndexByName(name: string): number;
  15533. /**
  15534. * Creater a new animation range
  15535. * @param name defines the name of the range
  15536. * @param from defines the start key
  15537. * @param to defines the end key
  15538. */
  15539. createAnimationRange(name: string, from: number, to: number): void;
  15540. /**
  15541. * Delete a specific animation range
  15542. * @param name defines the name of the range
  15543. * @param deleteFrames defines if frames must be removed as well
  15544. */
  15545. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15546. /**
  15547. * Gets a specific animation range
  15548. * @param name defines the name of the range to look for
  15549. * @returns the requested animation range or null if not found
  15550. */
  15551. getAnimationRange(name: string): Nullable<AnimationRange>;
  15552. /**
  15553. * Gets the list of all animation ranges defined on this skeleton
  15554. * @returns an array
  15555. */
  15556. getAnimationRanges(): Nullable<AnimationRange>[];
  15557. /**
  15558. * Copy animation range from a source skeleton.
  15559. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15560. * @param source defines the source skeleton
  15561. * @param name defines the name of the range to copy
  15562. * @param rescaleAsRequired defines if rescaling must be applied if required
  15563. * @returns true if operation was successful
  15564. */
  15565. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15566. /**
  15567. * Forces the skeleton to go to rest pose
  15568. */
  15569. returnToRest(): void;
  15570. private _getHighestAnimationFrame;
  15571. /**
  15572. * Begin a specific animation range
  15573. * @param name defines the name of the range to start
  15574. * @param loop defines if looping must be turned on (false by default)
  15575. * @param speedRatio defines the speed ratio to apply (1 by default)
  15576. * @param onAnimationEnd defines a callback which will be called when animation will end
  15577. * @returns a new animatable
  15578. */
  15579. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15580. /**
  15581. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15582. * @param skeleton defines the Skeleton containing the animation range to convert
  15583. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15584. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15585. * @returns the original skeleton
  15586. */
  15587. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15588. /** @hidden */
  15589. _markAsDirty(): void;
  15590. /** @hidden */
  15591. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15592. /** @hidden */
  15593. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15594. private _computeTransformMatrices;
  15595. /**
  15596. * Build all resources required to render a skeleton
  15597. */
  15598. prepare(): void;
  15599. /**
  15600. * Gets the list of animatables currently running for this skeleton
  15601. * @returns an array of animatables
  15602. */
  15603. getAnimatables(): IAnimatable[];
  15604. /**
  15605. * Clone the current skeleton
  15606. * @param name defines the name of the new skeleton
  15607. * @param id defines the id of the new skeleton
  15608. * @returns the new skeleton
  15609. */
  15610. clone(name: string, id?: string): Skeleton;
  15611. /**
  15612. * Enable animation blending for this skeleton
  15613. * @param blendingSpeed defines the blending speed to apply
  15614. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15615. */
  15616. enableBlending(blendingSpeed?: number): void;
  15617. /**
  15618. * Releases all resources associated with the current skeleton
  15619. */
  15620. dispose(): void;
  15621. /**
  15622. * Serialize the skeleton in a JSON object
  15623. * @returns a JSON object
  15624. */
  15625. serialize(): any;
  15626. /**
  15627. * Creates a new skeleton from serialized data
  15628. * @param parsedSkeleton defines the serialized data
  15629. * @param scene defines the hosting scene
  15630. * @returns a new skeleton
  15631. */
  15632. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15633. /**
  15634. * Compute all node absolute transforms
  15635. * @param forceUpdate defines if computation must be done even if cache is up to date
  15636. */
  15637. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15638. /**
  15639. * Gets the root pose matrix
  15640. * @returns a matrix
  15641. */
  15642. getPoseMatrix(): Nullable<Matrix>;
  15643. /**
  15644. * Sorts bones per internal index
  15645. */
  15646. sortBones(): void;
  15647. private _sortBones;
  15648. }
  15649. }
  15650. declare module "babylonjs/Meshes/instancedMesh" {
  15651. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15652. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15653. import { Camera } from "babylonjs/Cameras/camera";
  15654. import { Node } from "babylonjs/node";
  15655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15656. import { Mesh } from "babylonjs/Meshes/mesh";
  15657. import { Material } from "babylonjs/Materials/material";
  15658. import { Skeleton } from "babylonjs/Bones/skeleton";
  15659. import { Light } from "babylonjs/Lights/light";
  15660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15661. /**
  15662. * Creates an instance based on a source mesh.
  15663. */
  15664. export class InstancedMesh extends AbstractMesh {
  15665. private _sourceMesh;
  15666. private _currentLOD;
  15667. /** @hidden */
  15668. _indexInSourceMeshInstanceArray: number;
  15669. constructor(name: string, source: Mesh);
  15670. /**
  15671. * Returns the string "InstancedMesh".
  15672. */
  15673. getClassName(): string;
  15674. /** Gets the list of lights affecting that mesh */
  15675. get lightSources(): Light[];
  15676. _resyncLightSources(): void;
  15677. _resyncLightSource(light: Light): void;
  15678. _removeLightSource(light: Light, dispose: boolean): void;
  15679. /**
  15680. * If the source mesh receives shadows
  15681. */
  15682. get receiveShadows(): boolean;
  15683. /**
  15684. * The material of the source mesh
  15685. */
  15686. get material(): Nullable<Material>;
  15687. /**
  15688. * Visibility of the source mesh
  15689. */
  15690. get visibility(): number;
  15691. /**
  15692. * Skeleton of the source mesh
  15693. */
  15694. get skeleton(): Nullable<Skeleton>;
  15695. /**
  15696. * Rendering ground id of the source mesh
  15697. */
  15698. get renderingGroupId(): number;
  15699. set renderingGroupId(value: number);
  15700. /**
  15701. * Returns the total number of vertices (integer).
  15702. */
  15703. getTotalVertices(): number;
  15704. /**
  15705. * Returns a positive integer : the total number of indices in this mesh geometry.
  15706. * @returns the numner of indices or zero if the mesh has no geometry.
  15707. */
  15708. getTotalIndices(): number;
  15709. /**
  15710. * The source mesh of the instance
  15711. */
  15712. get sourceMesh(): Mesh;
  15713. /**
  15714. * Is this node ready to be used/rendered
  15715. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15716. * @return {boolean} is it ready
  15717. */
  15718. isReady(completeCheck?: boolean): boolean;
  15719. /**
  15720. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15721. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15722. * @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.
  15723. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15724. */
  15725. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15726. /**
  15727. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15728. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15729. * The `data` are either a numeric array either a Float32Array.
  15730. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15731. * 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).
  15732. * Note that a new underlying VertexBuffer object is created each call.
  15733. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15734. *
  15735. * Possible `kind` values :
  15736. * - VertexBuffer.PositionKind
  15737. * - VertexBuffer.UVKind
  15738. * - VertexBuffer.UV2Kind
  15739. * - VertexBuffer.UV3Kind
  15740. * - VertexBuffer.UV4Kind
  15741. * - VertexBuffer.UV5Kind
  15742. * - VertexBuffer.UV6Kind
  15743. * - VertexBuffer.ColorKind
  15744. * - VertexBuffer.MatricesIndicesKind
  15745. * - VertexBuffer.MatricesIndicesExtraKind
  15746. * - VertexBuffer.MatricesWeightsKind
  15747. * - VertexBuffer.MatricesWeightsExtraKind
  15748. *
  15749. * Returns the Mesh.
  15750. */
  15751. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15752. /**
  15753. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15754. * If the mesh has no geometry, it is simply returned as it is.
  15755. * The `data` are either a numeric array either a Float32Array.
  15756. * No new underlying VertexBuffer object is created.
  15757. * 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.
  15758. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15759. *
  15760. * Possible `kind` values :
  15761. * - VertexBuffer.PositionKind
  15762. * - VertexBuffer.UVKind
  15763. * - VertexBuffer.UV2Kind
  15764. * - VertexBuffer.UV3Kind
  15765. * - VertexBuffer.UV4Kind
  15766. * - VertexBuffer.UV5Kind
  15767. * - VertexBuffer.UV6Kind
  15768. * - VertexBuffer.ColorKind
  15769. * - VertexBuffer.MatricesIndicesKind
  15770. * - VertexBuffer.MatricesIndicesExtraKind
  15771. * - VertexBuffer.MatricesWeightsKind
  15772. * - VertexBuffer.MatricesWeightsExtraKind
  15773. *
  15774. * Returns the Mesh.
  15775. */
  15776. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15777. /**
  15778. * Sets the mesh indices.
  15779. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15780. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15781. * This method creates a new index buffer each call.
  15782. * Returns the Mesh.
  15783. */
  15784. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15785. /**
  15786. * Boolean : True if the mesh owns the requested kind of data.
  15787. */
  15788. isVerticesDataPresent(kind: string): boolean;
  15789. /**
  15790. * Returns an array of indices (IndicesArray).
  15791. */
  15792. getIndices(): Nullable<IndicesArray>;
  15793. get _positions(): Nullable<Vector3[]>;
  15794. /**
  15795. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15796. * This means the mesh underlying bounding box and sphere are recomputed.
  15797. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15798. * @returns the current mesh
  15799. */
  15800. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15801. /** @hidden */
  15802. _preActivate(): InstancedMesh;
  15803. /** @hidden */
  15804. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15805. /** @hidden */
  15806. _postActivate(): void;
  15807. getWorldMatrix(): Matrix;
  15808. get isAnInstance(): boolean;
  15809. /**
  15810. * Returns the current associated LOD AbstractMesh.
  15811. */
  15812. getLOD(camera: Camera): AbstractMesh;
  15813. /** @hidden */
  15814. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15815. /** @hidden */
  15816. _syncSubMeshes(): InstancedMesh;
  15817. /** @hidden */
  15818. _generatePointsArray(): boolean;
  15819. /**
  15820. * Creates a new InstancedMesh from the current mesh.
  15821. * - name (string) : the cloned mesh name
  15822. * - newParent (optional Node) : the optional Node to parent the clone to.
  15823. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15824. *
  15825. * Returns the clone.
  15826. */
  15827. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15828. /**
  15829. * Disposes the InstancedMesh.
  15830. * Returns nothing.
  15831. */
  15832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15833. }
  15834. module "babylonjs/Meshes/mesh" {
  15835. interface Mesh {
  15836. /**
  15837. * Register a custom buffer that will be instanced
  15838. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15839. * @param kind defines the buffer kind
  15840. * @param stride defines the stride in floats
  15841. */
  15842. registerInstancedBuffer(kind: string, stride: number): void;
  15843. /** @hidden */
  15844. _userInstancedBuffersStorage: {
  15845. data: {
  15846. [key: string]: Float32Array;
  15847. };
  15848. sizes: {
  15849. [key: string]: number;
  15850. };
  15851. vertexBuffers: {
  15852. [key: string]: Nullable<VertexBuffer>;
  15853. };
  15854. strides: {
  15855. [key: string]: number;
  15856. };
  15857. };
  15858. }
  15859. }
  15860. module "babylonjs/Meshes/abstractMesh" {
  15861. interface AbstractMesh {
  15862. /**
  15863. * Object used to store instanced buffers defined by user
  15864. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15865. */
  15866. instancedBuffers: {
  15867. [key: string]: any;
  15868. };
  15869. }
  15870. }
  15871. }
  15872. declare module "babylonjs/Materials/shaderMaterial" {
  15873. import { Nullable } from "babylonjs/types";
  15874. import { Scene } from "babylonjs/scene";
  15875. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15877. import { Mesh } from "babylonjs/Meshes/mesh";
  15878. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15880. import { Effect } from "babylonjs/Materials/effect";
  15881. import { Material } from "babylonjs/Materials/material";
  15882. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15883. /**
  15884. * Defines the options associated with the creation of a shader material.
  15885. */
  15886. export interface IShaderMaterialOptions {
  15887. /**
  15888. * Does the material work in alpha blend mode
  15889. */
  15890. needAlphaBlending: boolean;
  15891. /**
  15892. * Does the material work in alpha test mode
  15893. */
  15894. needAlphaTesting: boolean;
  15895. /**
  15896. * The list of attribute names used in the shader
  15897. */
  15898. attributes: string[];
  15899. /**
  15900. * The list of unifrom names used in the shader
  15901. */
  15902. uniforms: string[];
  15903. /**
  15904. * The list of UBO names used in the shader
  15905. */
  15906. uniformBuffers: string[];
  15907. /**
  15908. * The list of sampler names used in the shader
  15909. */
  15910. samplers: string[];
  15911. /**
  15912. * The list of defines used in the shader
  15913. */
  15914. defines: string[];
  15915. }
  15916. /**
  15917. * 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.
  15918. *
  15919. * This returned material effects how the mesh will look based on the code in the shaders.
  15920. *
  15921. * @see http://doc.babylonjs.com/how_to/shader_material
  15922. */
  15923. export class ShaderMaterial extends Material {
  15924. private _shaderPath;
  15925. private _options;
  15926. private _textures;
  15927. private _textureArrays;
  15928. private _floats;
  15929. private _ints;
  15930. private _floatsArrays;
  15931. private _colors3;
  15932. private _colors3Arrays;
  15933. private _colors4;
  15934. private _colors4Arrays;
  15935. private _vectors2;
  15936. private _vectors3;
  15937. private _vectors4;
  15938. private _matrices;
  15939. private _matrixArrays;
  15940. private _matrices3x3;
  15941. private _matrices2x2;
  15942. private _vectors2Arrays;
  15943. private _vectors3Arrays;
  15944. private _vectors4Arrays;
  15945. private _cachedWorldViewMatrix;
  15946. private _cachedWorldViewProjectionMatrix;
  15947. private _renderId;
  15948. private _multiview;
  15949. private _cachedDefines;
  15950. /**
  15951. * Instantiate a new shader material.
  15952. * 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.
  15953. * This returned material effects how the mesh will look based on the code in the shaders.
  15954. * @see http://doc.babylonjs.com/how_to/shader_material
  15955. * @param name Define the name of the material in the scene
  15956. * @param scene Define the scene the material belongs to
  15957. * @param shaderPath Defines the route to the shader code in one of three ways:
  15958. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15959. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15960. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15961. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15962. * @param options Define the options used to create the shader
  15963. */
  15964. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15965. /**
  15966. * Gets the shader path used to define the shader code
  15967. * It can be modified to trigger a new compilation
  15968. */
  15969. get shaderPath(): any;
  15970. /**
  15971. * Sets the shader path used to define the shader code
  15972. * It can be modified to trigger a new compilation
  15973. */
  15974. set shaderPath(shaderPath: any);
  15975. /**
  15976. * Gets the options used to compile the shader.
  15977. * They can be modified to trigger a new compilation
  15978. */
  15979. get options(): IShaderMaterialOptions;
  15980. /**
  15981. * Gets the current class name of the material e.g. "ShaderMaterial"
  15982. * Mainly use in serialization.
  15983. * @returns the class name
  15984. */
  15985. getClassName(): string;
  15986. /**
  15987. * Specifies if the material will require alpha blending
  15988. * @returns a boolean specifying if alpha blending is needed
  15989. */
  15990. needAlphaBlending(): boolean;
  15991. /**
  15992. * Specifies if this material should be rendered in alpha test mode
  15993. * @returns a boolean specifying if an alpha test is needed.
  15994. */
  15995. needAlphaTesting(): boolean;
  15996. private _checkUniform;
  15997. /**
  15998. * Set a texture in the shader.
  15999. * @param name Define the name of the uniform samplers as defined in the shader
  16000. * @param texture Define the texture to bind to this sampler
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16004. /**
  16005. * Set a texture array in the shader.
  16006. * @param name Define the name of the uniform sampler array as defined in the shader
  16007. * @param textures Define the list of textures to bind to this sampler
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16011. /**
  16012. * Set a float in the shader.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setFloat(name: string, value: number): ShaderMaterial;
  16018. /**
  16019. * Set a int in the shader.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setInt(name: string, value: number): ShaderMaterial;
  16025. /**
  16026. * Set an array of floats in the shader.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setFloats(name: string, value: number[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec3 in the shader from a Color3.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setColor3(name: string, value: Color3): ShaderMaterial;
  16039. /**
  16040. * Set a vec3 array in the shader from a Color3 array.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16046. /**
  16047. * Set a vec4 in the shader from a Color4.
  16048. * @param name Define the name of the uniform as defined in the shader
  16049. * @param value Define the value to give to the uniform
  16050. * @return the material itself allowing "fluent" like uniform updates
  16051. */
  16052. setColor4(name: string, value: Color4): ShaderMaterial;
  16053. /**
  16054. * Set a vec4 array in the shader from a Color4 array.
  16055. * @param name Define the name of the uniform as defined in the shader
  16056. * @param value Define the value to give to the uniform
  16057. * @return the material itself allowing "fluent" like uniform updates
  16058. */
  16059. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16060. /**
  16061. * Set a vec2 in the shader from a Vector2.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the material itself allowing "fluent" like uniform updates
  16065. */
  16066. setVector2(name: string, value: Vector2): ShaderMaterial;
  16067. /**
  16068. * Set a vec3 in the shader from a Vector3.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the material itself allowing "fluent" like uniform updates
  16072. */
  16073. setVector3(name: string, value: Vector3): ShaderMaterial;
  16074. /**
  16075. * Set a vec4 in the shader from a Vector4.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the material itself allowing "fluent" like uniform updates
  16079. */
  16080. setVector4(name: string, value: Vector4): ShaderMaterial;
  16081. /**
  16082. * Set a mat4 in the shader from a Matrix.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the material itself allowing "fluent" like uniform updates
  16086. */
  16087. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16088. /**
  16089. * Set a float32Array in the shader from a matrix array.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the material itself allowing "fluent" like uniform updates
  16093. */
  16094. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16095. /**
  16096. * Set a mat3 in the shader from a Float32Array.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the material itself allowing "fluent" like uniform updates
  16100. */
  16101. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16102. /**
  16103. * Set a mat2 in the shader from a Float32Array.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the material itself allowing "fluent" like uniform updates
  16107. */
  16108. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16109. /**
  16110. * Set a vec2 array in the shader from a number array.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the material itself allowing "fluent" like uniform updates
  16114. */
  16115. setArray2(name: string, value: number[]): ShaderMaterial;
  16116. /**
  16117. * Set a vec3 array in the shader from a number array.
  16118. * @param name Define the name of the uniform as defined in the shader
  16119. * @param value Define the value to give to the uniform
  16120. * @return the material itself allowing "fluent" like uniform updates
  16121. */
  16122. setArray3(name: string, value: number[]): ShaderMaterial;
  16123. /**
  16124. * Set a vec4 array in the shader from a number array.
  16125. * @param name Define the name of the uniform as defined in the shader
  16126. * @param value Define the value to give to the uniform
  16127. * @return the material itself allowing "fluent" like uniform updates
  16128. */
  16129. setArray4(name: string, value: number[]): ShaderMaterial;
  16130. private _checkCache;
  16131. /**
  16132. * Specifies that the submesh is ready to be used
  16133. * @param mesh defines the mesh to check
  16134. * @param subMesh defines which submesh to check
  16135. * @param useInstances specifies that instances should be used
  16136. * @returns a boolean indicating that the submesh is ready or not
  16137. */
  16138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16139. /**
  16140. * Checks if the material is ready to render the requested mesh
  16141. * @param mesh Define the mesh to render
  16142. * @param useInstances Define whether or not the material is used with instances
  16143. * @returns true if ready, otherwise false
  16144. */
  16145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16146. /**
  16147. * Binds the world matrix to the material
  16148. * @param world defines the world transformation matrix
  16149. * @param effectOverride - If provided, use this effect instead of internal effect
  16150. */
  16151. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16152. /**
  16153. * Binds the submesh to this material by preparing the effect and shader to draw
  16154. * @param world defines the world transformation matrix
  16155. * @param mesh defines the mesh containing the submesh
  16156. * @param subMesh defines the submesh to bind the material to
  16157. */
  16158. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16159. /**
  16160. * Binds the material to the mesh
  16161. * @param world defines the world transformation matrix
  16162. * @param mesh defines the mesh to bind the material to
  16163. * @param effectOverride - If provided, use this effect instead of internal effect
  16164. */
  16165. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16166. protected _afterBind(mesh?: Mesh): void;
  16167. /**
  16168. * Gets the active textures from the material
  16169. * @returns an array of textures
  16170. */
  16171. getActiveTextures(): BaseTexture[];
  16172. /**
  16173. * Specifies if the material uses a texture
  16174. * @param texture defines the texture to check against the material
  16175. * @returns a boolean specifying if the material uses the texture
  16176. */
  16177. hasTexture(texture: BaseTexture): boolean;
  16178. /**
  16179. * Makes a duplicate of the material, and gives it a new name
  16180. * @param name defines the new name for the duplicated material
  16181. * @returns the cloned material
  16182. */
  16183. clone(name: string): ShaderMaterial;
  16184. /**
  16185. * Disposes the material
  16186. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16187. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16188. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16189. */
  16190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16191. /**
  16192. * Serializes this material in a JSON representation
  16193. * @returns the serialized material object
  16194. */
  16195. serialize(): any;
  16196. /**
  16197. * Creates a shader material from parsed shader material data
  16198. * @param source defines the JSON represnetation of the material
  16199. * @param scene defines the hosting scene
  16200. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16201. * @returns a new material
  16202. */
  16203. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16204. }
  16205. }
  16206. declare module "babylonjs/Shaders/color.fragment" {
  16207. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16208. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16209. /** @hidden */
  16210. export var colorPixelShader: {
  16211. name: string;
  16212. shader: string;
  16213. };
  16214. }
  16215. declare module "babylonjs/Shaders/color.vertex" {
  16216. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16217. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16218. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16219. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16220. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16222. /** @hidden */
  16223. export var colorVertexShader: {
  16224. name: string;
  16225. shader: string;
  16226. };
  16227. }
  16228. declare module "babylonjs/Meshes/linesMesh" {
  16229. import { Nullable } from "babylonjs/types";
  16230. import { Scene } from "babylonjs/scene";
  16231. import { Color3 } from "babylonjs/Maths/math.color";
  16232. import { Node } from "babylonjs/node";
  16233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16234. import { Mesh } from "babylonjs/Meshes/mesh";
  16235. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16236. import { Effect } from "babylonjs/Materials/effect";
  16237. import { Material } from "babylonjs/Materials/material";
  16238. import "babylonjs/Shaders/color.fragment";
  16239. import "babylonjs/Shaders/color.vertex";
  16240. /**
  16241. * Line mesh
  16242. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16243. */
  16244. export class LinesMesh extends Mesh {
  16245. /**
  16246. * If vertex color should be applied to the mesh
  16247. */
  16248. readonly useVertexColor?: boolean | undefined;
  16249. /**
  16250. * If vertex alpha should be applied to the mesh
  16251. */
  16252. readonly useVertexAlpha?: boolean | undefined;
  16253. /**
  16254. * Color of the line (Default: White)
  16255. */
  16256. color: Color3;
  16257. /**
  16258. * Alpha of the line (Default: 1)
  16259. */
  16260. alpha: number;
  16261. /**
  16262. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16263. * This margin is expressed in world space coordinates, so its value may vary.
  16264. * Default value is 0.1
  16265. */
  16266. intersectionThreshold: number;
  16267. private _colorShader;
  16268. private color4;
  16269. /**
  16270. * Creates a new LinesMesh
  16271. * @param name defines the name
  16272. * @param scene defines the hosting scene
  16273. * @param parent defines the parent mesh if any
  16274. * @param source defines the optional source LinesMesh used to clone data from
  16275. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16276. * When false, achieved by calling a clone(), also passing False.
  16277. * This will make creation of children, recursive.
  16278. * @param useVertexColor defines if this LinesMesh supports vertex color
  16279. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16280. */
  16281. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16282. /**
  16283. * If vertex color should be applied to the mesh
  16284. */
  16285. useVertexColor?: boolean | undefined,
  16286. /**
  16287. * If vertex alpha should be applied to the mesh
  16288. */
  16289. useVertexAlpha?: boolean | undefined);
  16290. private _addClipPlaneDefine;
  16291. private _removeClipPlaneDefine;
  16292. isReady(): boolean;
  16293. /**
  16294. * Returns the string "LineMesh"
  16295. */
  16296. getClassName(): string;
  16297. /**
  16298. * @hidden
  16299. */
  16300. get material(): Material;
  16301. /**
  16302. * @hidden
  16303. */
  16304. set material(value: Material);
  16305. /**
  16306. * @hidden
  16307. */
  16308. get checkCollisions(): boolean;
  16309. /** @hidden */
  16310. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16311. /** @hidden */
  16312. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16313. /**
  16314. * Disposes of the line mesh
  16315. * @param doNotRecurse If children should be disposed
  16316. */
  16317. dispose(doNotRecurse?: boolean): void;
  16318. /**
  16319. * Returns a new LineMesh object cloned from the current one.
  16320. */
  16321. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16322. /**
  16323. * Creates a new InstancedLinesMesh object from the mesh model.
  16324. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16325. * @param name defines the name of the new instance
  16326. * @returns a new InstancedLinesMesh
  16327. */
  16328. createInstance(name: string): InstancedLinesMesh;
  16329. }
  16330. /**
  16331. * Creates an instance based on a source LinesMesh
  16332. */
  16333. export class InstancedLinesMesh extends InstancedMesh {
  16334. /**
  16335. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16336. * This margin is expressed in world space coordinates, so its value may vary.
  16337. * Initilized with the intersectionThreshold value of the source LinesMesh
  16338. */
  16339. intersectionThreshold: number;
  16340. constructor(name: string, source: LinesMesh);
  16341. /**
  16342. * Returns the string "InstancedLinesMesh".
  16343. */
  16344. getClassName(): string;
  16345. }
  16346. }
  16347. declare module "babylonjs/Shaders/line.fragment" {
  16348. /** @hidden */
  16349. export var linePixelShader: {
  16350. name: string;
  16351. shader: string;
  16352. };
  16353. }
  16354. declare module "babylonjs/Shaders/line.vertex" {
  16355. /** @hidden */
  16356. export var lineVertexShader: {
  16357. name: string;
  16358. shader: string;
  16359. };
  16360. }
  16361. declare module "babylonjs/Rendering/edgesRenderer" {
  16362. import { Nullable } from "babylonjs/types";
  16363. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16365. import { Vector3 } from "babylonjs/Maths/math.vector";
  16366. import { IDisposable } from "babylonjs/scene";
  16367. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16368. import "babylonjs/Shaders/line.fragment";
  16369. import "babylonjs/Shaders/line.vertex";
  16370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16371. module "babylonjs/Meshes/abstractMesh" {
  16372. interface AbstractMesh {
  16373. /**
  16374. * Gets the edgesRenderer associated with the mesh
  16375. */
  16376. edgesRenderer: Nullable<EdgesRenderer>;
  16377. }
  16378. }
  16379. module "babylonjs/Meshes/linesMesh" {
  16380. interface LinesMesh {
  16381. /**
  16382. * Enables the edge rendering mode on the mesh.
  16383. * This mode makes the mesh edges visible
  16384. * @param epsilon defines the maximal distance between two angles to detect a face
  16385. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16386. * @returns the currentAbstractMesh
  16387. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16388. */
  16389. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16390. }
  16391. }
  16392. module "babylonjs/Meshes/linesMesh" {
  16393. interface InstancedLinesMesh {
  16394. /**
  16395. * Enables the edge rendering mode on the mesh.
  16396. * This mode makes the mesh edges visible
  16397. * @param epsilon defines the maximal distance between two angles to detect a face
  16398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16399. * @returns the current InstancedLinesMesh
  16400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16401. */
  16402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16403. }
  16404. }
  16405. /**
  16406. * Defines the minimum contract an Edges renderer should follow.
  16407. */
  16408. export interface IEdgesRenderer extends IDisposable {
  16409. /**
  16410. * Gets or sets a boolean indicating if the edgesRenderer is active
  16411. */
  16412. isEnabled: boolean;
  16413. /**
  16414. * Renders the edges of the attached mesh,
  16415. */
  16416. render(): void;
  16417. /**
  16418. * Checks wether or not the edges renderer is ready to render.
  16419. * @return true if ready, otherwise false.
  16420. */
  16421. isReady(): boolean;
  16422. }
  16423. /**
  16424. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16425. */
  16426. export class EdgesRenderer implements IEdgesRenderer {
  16427. /**
  16428. * Define the size of the edges with an orthographic camera
  16429. */
  16430. edgesWidthScalerForOrthographic: number;
  16431. /**
  16432. * Define the size of the edges with a perspective camera
  16433. */
  16434. edgesWidthScalerForPerspective: number;
  16435. protected _source: AbstractMesh;
  16436. protected _linesPositions: number[];
  16437. protected _linesNormals: number[];
  16438. protected _linesIndices: number[];
  16439. protected _epsilon: number;
  16440. protected _indicesCount: number;
  16441. protected _lineShader: ShaderMaterial;
  16442. protected _ib: DataBuffer;
  16443. protected _buffers: {
  16444. [key: string]: Nullable<VertexBuffer>;
  16445. };
  16446. protected _checkVerticesInsteadOfIndices: boolean;
  16447. private _meshRebuildObserver;
  16448. private _meshDisposeObserver;
  16449. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16450. isEnabled: boolean;
  16451. /**
  16452. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16453. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16454. * @param source Mesh used to create edges
  16455. * @param epsilon sum of angles in adjacency to check for edge
  16456. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16457. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16458. */
  16459. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16460. protected _prepareRessources(): void;
  16461. /** @hidden */
  16462. _rebuild(): void;
  16463. /**
  16464. * Releases the required resources for the edges renderer
  16465. */
  16466. dispose(): void;
  16467. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16468. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16469. /**
  16470. * Checks if the pair of p0 and p1 is en edge
  16471. * @param faceIndex
  16472. * @param edge
  16473. * @param faceNormals
  16474. * @param p0
  16475. * @param p1
  16476. * @private
  16477. */
  16478. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16479. /**
  16480. * push line into the position, normal and index buffer
  16481. * @protected
  16482. */
  16483. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16484. /**
  16485. * Generates lines edges from adjacencjes
  16486. * @private
  16487. */
  16488. _generateEdgesLines(): void;
  16489. /**
  16490. * Checks wether or not the edges renderer is ready to render.
  16491. * @return true if ready, otherwise false.
  16492. */
  16493. isReady(): boolean;
  16494. /**
  16495. * Renders the edges of the attached mesh,
  16496. */
  16497. render(): void;
  16498. }
  16499. /**
  16500. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16501. */
  16502. export class LineEdgesRenderer extends EdgesRenderer {
  16503. /**
  16504. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16505. * @param source LineMesh used to generate edges
  16506. * @param epsilon not important (specified angle for edge detection)
  16507. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16508. */
  16509. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16510. /**
  16511. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16512. */
  16513. _generateEdgesLines(): void;
  16514. }
  16515. }
  16516. declare module "babylonjs/Rendering/renderingGroup" {
  16517. import { SmartArray } from "babylonjs/Misc/smartArray";
  16518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16520. import { Nullable } from "babylonjs/types";
  16521. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16522. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16523. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16524. import { Material } from "babylonjs/Materials/material";
  16525. import { Scene } from "babylonjs/scene";
  16526. /**
  16527. * This represents the object necessary to create a rendering group.
  16528. * This is exclusively used and created by the rendering manager.
  16529. * To modify the behavior, you use the available helpers in your scene or meshes.
  16530. * @hidden
  16531. */
  16532. export class RenderingGroup {
  16533. index: number;
  16534. private static _zeroVector;
  16535. private _scene;
  16536. private _opaqueSubMeshes;
  16537. private _transparentSubMeshes;
  16538. private _alphaTestSubMeshes;
  16539. private _depthOnlySubMeshes;
  16540. private _particleSystems;
  16541. private _spriteManagers;
  16542. private _opaqueSortCompareFn;
  16543. private _alphaTestSortCompareFn;
  16544. private _transparentSortCompareFn;
  16545. private _renderOpaque;
  16546. private _renderAlphaTest;
  16547. private _renderTransparent;
  16548. /** @hidden */
  16549. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16550. onBeforeTransparentRendering: () => void;
  16551. /**
  16552. * Set the opaque sort comparison function.
  16553. * If null the sub meshes will be render in the order they were created
  16554. */
  16555. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16556. /**
  16557. * Set the alpha test sort comparison function.
  16558. * If null the sub meshes will be render in the order they were created
  16559. */
  16560. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16561. /**
  16562. * Set the transparent sort comparison function.
  16563. * If null the sub meshes will be render in the order they were created
  16564. */
  16565. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16566. /**
  16567. * Creates a new rendering group.
  16568. * @param index The rendering group index
  16569. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16570. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16571. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16572. */
  16573. 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>);
  16574. /**
  16575. * Render all the sub meshes contained in the group.
  16576. * @param customRenderFunction Used to override the default render behaviour of the group.
  16577. * @returns true if rendered some submeshes.
  16578. */
  16579. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16580. /**
  16581. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16582. * @param subMeshes The submeshes to render
  16583. */
  16584. private renderOpaqueSorted;
  16585. /**
  16586. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16587. * @param subMeshes The submeshes to render
  16588. */
  16589. private renderAlphaTestSorted;
  16590. /**
  16591. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16592. * @param subMeshes The submeshes to render
  16593. */
  16594. private renderTransparentSorted;
  16595. /**
  16596. * Renders the submeshes in a specified order.
  16597. * @param subMeshes The submeshes to sort before render
  16598. * @param sortCompareFn The comparison function use to sort
  16599. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16600. * @param transparent Specifies to activate blending if true
  16601. */
  16602. private static renderSorted;
  16603. /**
  16604. * Renders the submeshes in the order they were dispatched (no sort applied).
  16605. * @param subMeshes The submeshes to render
  16606. */
  16607. private static renderUnsorted;
  16608. /**
  16609. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16610. * are rendered back to front if in the same alpha index.
  16611. *
  16612. * @param a The first submesh
  16613. * @param b The second submesh
  16614. * @returns The result of the comparison
  16615. */
  16616. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16617. /**
  16618. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16619. * are rendered back to front.
  16620. *
  16621. * @param a The first submesh
  16622. * @param b The second submesh
  16623. * @returns The result of the comparison
  16624. */
  16625. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16626. /**
  16627. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16628. * are rendered front to back (prevent overdraw).
  16629. *
  16630. * @param a The first submesh
  16631. * @param b The second submesh
  16632. * @returns The result of the comparison
  16633. */
  16634. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16635. /**
  16636. * Resets the different lists of submeshes to prepare a new frame.
  16637. */
  16638. prepare(): void;
  16639. dispose(): void;
  16640. /**
  16641. * Inserts the submesh in its correct queue depending on its material.
  16642. * @param subMesh The submesh to dispatch
  16643. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16644. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16645. */
  16646. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16647. dispatchSprites(spriteManager: ISpriteManager): void;
  16648. dispatchParticles(particleSystem: IParticleSystem): void;
  16649. private _renderParticles;
  16650. private _renderSprites;
  16651. }
  16652. }
  16653. declare module "babylonjs/Rendering/renderingManager" {
  16654. import { Nullable } from "babylonjs/types";
  16655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16657. import { SmartArray } from "babylonjs/Misc/smartArray";
  16658. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16660. import { Material } from "babylonjs/Materials/material";
  16661. import { Scene } from "babylonjs/scene";
  16662. import { Camera } from "babylonjs/Cameras/camera";
  16663. /**
  16664. * Interface describing the different options available in the rendering manager
  16665. * regarding Auto Clear between groups.
  16666. */
  16667. export interface IRenderingManagerAutoClearSetup {
  16668. /**
  16669. * Defines whether or not autoclear is enable.
  16670. */
  16671. autoClear: boolean;
  16672. /**
  16673. * Defines whether or not to autoclear the depth buffer.
  16674. */
  16675. depth: boolean;
  16676. /**
  16677. * Defines whether or not to autoclear the stencil buffer.
  16678. */
  16679. stencil: boolean;
  16680. }
  16681. /**
  16682. * This class is used by the onRenderingGroupObservable
  16683. */
  16684. export class RenderingGroupInfo {
  16685. /**
  16686. * The Scene that being rendered
  16687. */
  16688. scene: Scene;
  16689. /**
  16690. * The camera currently used for the rendering pass
  16691. */
  16692. camera: Nullable<Camera>;
  16693. /**
  16694. * The ID of the renderingGroup being processed
  16695. */
  16696. renderingGroupId: number;
  16697. }
  16698. /**
  16699. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16700. * It is enable to manage the different groups as well as the different necessary sort functions.
  16701. * This should not be used directly aside of the few static configurations
  16702. */
  16703. export class RenderingManager {
  16704. /**
  16705. * The max id used for rendering groups (not included)
  16706. */
  16707. static MAX_RENDERINGGROUPS: number;
  16708. /**
  16709. * The min id used for rendering groups (included)
  16710. */
  16711. static MIN_RENDERINGGROUPS: number;
  16712. /**
  16713. * Used to globally prevent autoclearing scenes.
  16714. */
  16715. static AUTOCLEAR: boolean;
  16716. /**
  16717. * @hidden
  16718. */
  16719. _useSceneAutoClearSetup: boolean;
  16720. private _scene;
  16721. private _renderingGroups;
  16722. private _depthStencilBufferAlreadyCleaned;
  16723. private _autoClearDepthStencil;
  16724. private _customOpaqueSortCompareFn;
  16725. private _customAlphaTestSortCompareFn;
  16726. private _customTransparentSortCompareFn;
  16727. private _renderingGroupInfo;
  16728. /**
  16729. * Instantiates a new rendering group for a particular scene
  16730. * @param scene Defines the scene the groups belongs to
  16731. */
  16732. constructor(scene: Scene);
  16733. private _clearDepthStencilBuffer;
  16734. /**
  16735. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16736. * @hidden
  16737. */
  16738. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16739. /**
  16740. * Resets the different information of the group to prepare a new frame
  16741. * @hidden
  16742. */
  16743. reset(): void;
  16744. /**
  16745. * Dispose and release the group and its associated resources.
  16746. * @hidden
  16747. */
  16748. dispose(): void;
  16749. /**
  16750. * Clear the info related to rendering groups preventing retention points during dispose.
  16751. */
  16752. freeRenderingGroups(): void;
  16753. private _prepareRenderingGroup;
  16754. /**
  16755. * Add a sprite manager to the rendering manager in order to render it this frame.
  16756. * @param spriteManager Define the sprite manager to render
  16757. */
  16758. dispatchSprites(spriteManager: ISpriteManager): void;
  16759. /**
  16760. * Add a particle system to the rendering manager in order to render it this frame.
  16761. * @param particleSystem Define the particle system to render
  16762. */
  16763. dispatchParticles(particleSystem: IParticleSystem): void;
  16764. /**
  16765. * Add a submesh to the manager in order to render it this frame
  16766. * @param subMesh The submesh to dispatch
  16767. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16768. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16769. */
  16770. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16771. /**
  16772. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16773. * This allowed control for front to back rendering or reversly depending of the special needs.
  16774. *
  16775. * @param renderingGroupId The rendering group id corresponding to its index
  16776. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16777. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16778. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16779. */
  16780. 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;
  16781. /**
  16782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16783. *
  16784. * @param renderingGroupId The rendering group id corresponding to its index
  16785. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16786. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16787. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16788. */
  16789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16790. /**
  16791. * Gets the current auto clear configuration for one rendering group of the rendering
  16792. * manager.
  16793. * @param index the rendering group index to get the information for
  16794. * @returns The auto clear setup for the requested rendering group
  16795. */
  16796. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16797. }
  16798. }
  16799. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16800. import { SmartArray } from "babylonjs/Misc/smartArray";
  16801. import { Nullable } from "babylonjs/types";
  16802. import { Scene } from "babylonjs/scene";
  16803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16806. import { Mesh } from "babylonjs/Meshes/mesh";
  16807. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16808. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16809. import { Effect } from "babylonjs/Materials/effect";
  16810. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16811. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16812. import "babylonjs/Shaders/shadowMap.fragment";
  16813. import "babylonjs/Shaders/shadowMap.vertex";
  16814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16815. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  16816. import { Observable } from "babylonjs/Misc/observable";
  16817. /**
  16818. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16819. */
  16820. export interface ICustomShaderOptions {
  16821. /**
  16822. * Gets or sets the custom shader name to use
  16823. */
  16824. shaderName: string;
  16825. /**
  16826. * The list of attribute names used in the shader
  16827. */
  16828. attributes?: string[];
  16829. /**
  16830. * The list of unifrom names used in the shader
  16831. */
  16832. uniforms?: string[];
  16833. /**
  16834. * The list of sampler names used in the shader
  16835. */
  16836. samplers?: string[];
  16837. /**
  16838. * The list of defines used in the shader
  16839. */
  16840. defines?: string[];
  16841. }
  16842. /**
  16843. * Interface to implement to create a shadow generator compatible with BJS.
  16844. */
  16845. export interface IShadowGenerator {
  16846. /**
  16847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16848. * @returns The render target texture if present otherwise, null
  16849. */
  16850. getShadowMap(): Nullable<RenderTargetTexture>;
  16851. /**
  16852. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16853. * @param subMesh The submesh we want to render in the shadow map
  16854. * @param useInstances Defines wether will draw in the map using instances
  16855. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16856. * @returns true if ready otherwise, false
  16857. */
  16858. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16859. /**
  16860. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16861. * @param defines Defines of the material we want to update
  16862. * @param lightIndex Index of the light in the enabled light list of the material
  16863. */
  16864. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16865. /**
  16866. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16867. * defined in the generator but impacting the effect).
  16868. * It implies the unifroms available on the materials are the standard BJS ones.
  16869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16870. * @param effect The effect we are binfing the information for
  16871. */
  16872. bindShadowLight(lightIndex: string, effect: Effect): void;
  16873. /**
  16874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16875. * (eq to shadow prjection matrix * light transform matrix)
  16876. * @returns The transform matrix used to create the shadow map
  16877. */
  16878. getTransformMatrix(): Matrix;
  16879. /**
  16880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16881. * Cube and 2D textures for instance.
  16882. */
  16883. recreateShadowMap(): void;
  16884. /**
  16885. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16886. * @param onCompiled Callback triggered at the and of the effects compilation
  16887. * @param options Sets of optional options forcing the compilation with different modes
  16888. */
  16889. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16890. useInstances: boolean;
  16891. }>): void;
  16892. /**
  16893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16894. * @param options Sets of optional options forcing the compilation with different modes
  16895. * @returns A promise that resolves when the compilation completes
  16896. */
  16897. forceCompilationAsync(options?: Partial<{
  16898. useInstances: boolean;
  16899. }>): Promise<void>;
  16900. /**
  16901. * Serializes the shadow generator setup to a json object.
  16902. * @returns The serialized JSON object
  16903. */
  16904. serialize(): any;
  16905. /**
  16906. * Disposes the Shadow map and related Textures and effects.
  16907. */
  16908. dispose(): void;
  16909. }
  16910. /**
  16911. * Default implementation IShadowGenerator.
  16912. * This is the main object responsible of generating shadows in the framework.
  16913. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16914. */
  16915. export class ShadowGenerator implements IShadowGenerator {
  16916. /**
  16917. * Name of the shadow generator class
  16918. */
  16919. static CLASSNAME: string;
  16920. /**
  16921. * Shadow generator mode None: no filtering applied.
  16922. */
  16923. static readonly FILTER_NONE: number;
  16924. /**
  16925. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16926. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16927. */
  16928. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16929. /**
  16930. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16931. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16932. */
  16933. static readonly FILTER_POISSONSAMPLING: number;
  16934. /**
  16935. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16936. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16937. */
  16938. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16939. /**
  16940. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16941. * edge artifacts on steep falloff.
  16942. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16943. */
  16944. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16945. /**
  16946. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16947. * edge artifacts on steep falloff.
  16948. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16949. */
  16950. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16951. /**
  16952. * Shadow generator mode PCF: Percentage Closer Filtering
  16953. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16954. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16955. */
  16956. static readonly FILTER_PCF: number;
  16957. /**
  16958. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16959. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16960. * Contact Hardening
  16961. */
  16962. static readonly FILTER_PCSS: number;
  16963. /**
  16964. * Reserved for PCF and PCSS
  16965. * Highest Quality.
  16966. *
  16967. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16968. *
  16969. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16970. */
  16971. static readonly QUALITY_HIGH: number;
  16972. /**
  16973. * Reserved for PCF and PCSS
  16974. * Good tradeoff for quality/perf cross devices
  16975. *
  16976. * Execute PCF on a 3*3 kernel.
  16977. *
  16978. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16979. */
  16980. static readonly QUALITY_MEDIUM: number;
  16981. /**
  16982. * Reserved for PCF and PCSS
  16983. * The lowest quality but the fastest.
  16984. *
  16985. * Execute PCF on a 1*1 kernel.
  16986. *
  16987. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16988. */
  16989. static readonly QUALITY_LOW: number;
  16990. /** Gets or sets the custom shader name to use */
  16991. customShaderOptions: ICustomShaderOptions;
  16992. /**
  16993. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16994. */
  16995. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16996. /**
  16997. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16998. */
  16999. onAfterShadowMapRenderObservable: Observable<Effect>;
  17000. /**
  17001. * Observable triggered before a mesh is rendered in the shadow map.
  17002. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17003. */
  17004. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17005. /**
  17006. * Observable triggered after a mesh is rendered in the shadow map.
  17007. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17008. */
  17009. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17010. protected _bias: number;
  17011. /**
  17012. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17013. */
  17014. get bias(): number;
  17015. /**
  17016. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17017. */
  17018. set bias(bias: number);
  17019. protected _normalBias: number;
  17020. /**
  17021. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17022. */
  17023. get normalBias(): number;
  17024. /**
  17025. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17026. */
  17027. set normalBias(normalBias: number);
  17028. protected _blurBoxOffset: number;
  17029. /**
  17030. * Gets the blur box offset: offset applied during the blur pass.
  17031. * Only useful if useKernelBlur = false
  17032. */
  17033. get blurBoxOffset(): number;
  17034. /**
  17035. * Sets the blur box offset: offset applied during the blur pass.
  17036. * Only useful if useKernelBlur = false
  17037. */
  17038. set blurBoxOffset(value: number);
  17039. protected _blurScale: number;
  17040. /**
  17041. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17042. * 2 means half of the size.
  17043. */
  17044. get blurScale(): number;
  17045. /**
  17046. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17047. * 2 means half of the size.
  17048. */
  17049. set blurScale(value: number);
  17050. protected _blurKernel: number;
  17051. /**
  17052. * Gets the blur kernel: kernel size of the blur pass.
  17053. * Only useful if useKernelBlur = true
  17054. */
  17055. get blurKernel(): number;
  17056. /**
  17057. * Sets the blur kernel: kernel size of the blur pass.
  17058. * Only useful if useKernelBlur = true
  17059. */
  17060. set blurKernel(value: number);
  17061. protected _useKernelBlur: boolean;
  17062. /**
  17063. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17064. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17065. */
  17066. get useKernelBlur(): boolean;
  17067. /**
  17068. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17069. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17070. */
  17071. set useKernelBlur(value: boolean);
  17072. protected _depthScale: number;
  17073. /**
  17074. * Gets the depth scale used in ESM mode.
  17075. */
  17076. get depthScale(): number;
  17077. /**
  17078. * Sets the depth scale used in ESM mode.
  17079. * This can override the scale stored on the light.
  17080. */
  17081. set depthScale(value: number);
  17082. protected _validateFilter(filter: number): number;
  17083. protected _filter: number;
  17084. /**
  17085. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17086. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17087. */
  17088. get filter(): number;
  17089. /**
  17090. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17091. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17092. */
  17093. set filter(value: number);
  17094. /**
  17095. * Gets if the current filter is set to Poisson Sampling.
  17096. */
  17097. get usePoissonSampling(): boolean;
  17098. /**
  17099. * Sets the current filter to Poisson Sampling.
  17100. */
  17101. set usePoissonSampling(value: boolean);
  17102. /**
  17103. * Gets if the current filter is set to ESM.
  17104. */
  17105. get useExponentialShadowMap(): boolean;
  17106. /**
  17107. * Sets the current filter is to ESM.
  17108. */
  17109. set useExponentialShadowMap(value: boolean);
  17110. /**
  17111. * Gets if the current filter is set to filtered ESM.
  17112. */
  17113. get useBlurExponentialShadowMap(): boolean;
  17114. /**
  17115. * Gets if the current filter is set to filtered ESM.
  17116. */
  17117. set useBlurExponentialShadowMap(value: boolean);
  17118. /**
  17119. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17120. * exponential to prevent steep falloff artifacts).
  17121. */
  17122. get useCloseExponentialShadowMap(): boolean;
  17123. /**
  17124. * Sets the current filter to "close ESM" (using the inverse of the
  17125. * exponential to prevent steep falloff artifacts).
  17126. */
  17127. set useCloseExponentialShadowMap(value: boolean);
  17128. /**
  17129. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17130. * exponential to prevent steep falloff artifacts).
  17131. */
  17132. get useBlurCloseExponentialShadowMap(): boolean;
  17133. /**
  17134. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17135. * exponential to prevent steep falloff artifacts).
  17136. */
  17137. set useBlurCloseExponentialShadowMap(value: boolean);
  17138. /**
  17139. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17140. */
  17141. get usePercentageCloserFiltering(): boolean;
  17142. /**
  17143. * Sets the current filter to "PCF" (percentage closer filtering).
  17144. */
  17145. set usePercentageCloserFiltering(value: boolean);
  17146. protected _filteringQuality: number;
  17147. /**
  17148. * Gets the PCF or PCSS Quality.
  17149. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17150. */
  17151. get filteringQuality(): number;
  17152. /**
  17153. * Sets the PCF or PCSS Quality.
  17154. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17155. */
  17156. set filteringQuality(filteringQuality: number);
  17157. /**
  17158. * Gets if the current filter is set to "PCSS" (contact hardening).
  17159. */
  17160. get useContactHardeningShadow(): boolean;
  17161. /**
  17162. * Sets the current filter to "PCSS" (contact hardening).
  17163. */
  17164. set useContactHardeningShadow(value: boolean);
  17165. protected _contactHardeningLightSizeUVRatio: number;
  17166. /**
  17167. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17168. * Using a ratio helps keeping shape stability independently of the map size.
  17169. *
  17170. * It does not account for the light projection as it was having too much
  17171. * instability during the light setup or during light position changes.
  17172. *
  17173. * Only valid if useContactHardeningShadow is true.
  17174. */
  17175. get contactHardeningLightSizeUVRatio(): number;
  17176. /**
  17177. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17178. * Using a ratio helps keeping shape stability independently of the map size.
  17179. *
  17180. * It does not account for the light projection as it was having too much
  17181. * instability during the light setup or during light position changes.
  17182. *
  17183. * Only valid if useContactHardeningShadow is true.
  17184. */
  17185. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17186. protected _darkness: number;
  17187. /** Gets or sets the actual darkness of a shadow */
  17188. get darkness(): number;
  17189. set darkness(value: number);
  17190. /**
  17191. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17192. * 0 means strongest and 1 would means no shadow.
  17193. * @returns the darkness.
  17194. */
  17195. getDarkness(): number;
  17196. /**
  17197. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17198. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17199. * @returns the shadow generator allowing fluent coding.
  17200. */
  17201. setDarkness(darkness: number): ShadowGenerator;
  17202. protected _transparencyShadow: boolean;
  17203. /** Gets or sets the ability to have transparent shadow */
  17204. get transparencyShadow(): boolean;
  17205. set transparencyShadow(value: boolean);
  17206. /**
  17207. * Sets the ability to have transparent shadow (boolean).
  17208. * @param transparent True if transparent else False
  17209. * @returns the shadow generator allowing fluent coding
  17210. */
  17211. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17212. /**
  17213. * Enables or disables shadows with varying strength based on the transparency
  17214. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17215. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17216. * mesh.visibility * alphaTexture.a
  17217. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17218. */
  17219. enableSoftTransparentShadow: boolean;
  17220. protected _shadowMap: Nullable<RenderTargetTexture>;
  17221. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17222. /**
  17223. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17224. * @returns The render target texture if present otherwise, null
  17225. */
  17226. getShadowMap(): Nullable<RenderTargetTexture>;
  17227. /**
  17228. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17229. * @returns The render target texture if the shadow map is present otherwise, null
  17230. */
  17231. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17232. /**
  17233. * Gets the class name of that object
  17234. * @returns "ShadowGenerator"
  17235. */
  17236. getClassName(): string;
  17237. /**
  17238. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17239. * @param mesh Mesh to add
  17240. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17241. * @returns the Shadow Generator itself
  17242. */
  17243. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17244. /**
  17245. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17246. * @param mesh Mesh to remove
  17247. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17248. * @returns the Shadow Generator itself
  17249. */
  17250. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17251. /**
  17252. * Controls the extent to which the shadows fade out at the edge of the frustum
  17253. */
  17254. frustumEdgeFalloff: number;
  17255. protected _light: IShadowLight;
  17256. /**
  17257. * Returns the associated light object.
  17258. * @returns the light generating the shadow
  17259. */
  17260. getLight(): IShadowLight;
  17261. /**
  17262. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17263. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17264. * It might on the other hand introduce peter panning.
  17265. */
  17266. forceBackFacesOnly: boolean;
  17267. protected _scene: Scene;
  17268. protected _lightDirection: Vector3;
  17269. protected _effect: Effect;
  17270. protected _viewMatrix: Matrix;
  17271. protected _projectionMatrix: Matrix;
  17272. protected _transformMatrix: Matrix;
  17273. protected _cachedPosition: Vector3;
  17274. protected _cachedDirection: Vector3;
  17275. protected _cachedDefines: string;
  17276. protected _currentRenderID: number;
  17277. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17278. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17279. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17280. protected _blurPostProcesses: PostProcess[];
  17281. protected _mapSize: number;
  17282. protected _currentFaceIndex: number;
  17283. protected _currentFaceIndexCache: number;
  17284. protected _textureType: number;
  17285. protected _defaultTextureMatrix: Matrix;
  17286. protected _storedUniqueId: Nullable<number>;
  17287. /** @hidden */
  17288. static _SceneComponentInitialization: (scene: Scene) => void;
  17289. /**
  17290. * Creates a ShadowGenerator object.
  17291. * A ShadowGenerator is the required tool to use the shadows.
  17292. * Each light casting shadows needs to use its own ShadowGenerator.
  17293. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17294. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17295. * @param light The light object generating the shadows.
  17296. * @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.
  17297. */
  17298. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17299. protected _initializeGenerator(): void;
  17300. protected _createTargetRenderTexture(): void;
  17301. protected _initializeShadowMap(): void;
  17302. protected _initializeBlurRTTAndPostProcesses(): void;
  17303. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17304. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17305. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17306. protected _applyFilterValues(): void;
  17307. /**
  17308. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17309. * @param onCompiled Callback triggered at the and of the effects compilation
  17310. * @param options Sets of optional options forcing the compilation with different modes
  17311. */
  17312. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17313. useInstances: boolean;
  17314. }>): void;
  17315. /**
  17316. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17317. * @param options Sets of optional options forcing the compilation with different modes
  17318. * @returns A promise that resolves when the compilation completes
  17319. */
  17320. forceCompilationAsync(options?: Partial<{
  17321. useInstances: boolean;
  17322. }>): Promise<void>;
  17323. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17324. private _prepareShadowDefines;
  17325. /**
  17326. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17327. * @param subMesh The submesh we want to render in the shadow map
  17328. * @param useInstances Defines wether will draw in the map using instances
  17329. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17330. * @returns true if ready otherwise, false
  17331. */
  17332. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17333. /**
  17334. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17335. * @param defines Defines of the material we want to update
  17336. * @param lightIndex Index of the light in the enabled light list of the material
  17337. */
  17338. prepareDefines(defines: any, lightIndex: number): void;
  17339. /**
  17340. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17341. * defined in the generator but impacting the effect).
  17342. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17343. * @param effect The effect we are binfing the information for
  17344. */
  17345. bindShadowLight(lightIndex: string, effect: Effect): void;
  17346. /**
  17347. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17348. * (eq to shadow prjection matrix * light transform matrix)
  17349. * @returns The transform matrix used to create the shadow map
  17350. */
  17351. getTransformMatrix(): Matrix;
  17352. /**
  17353. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17354. * Cube and 2D textures for instance.
  17355. */
  17356. recreateShadowMap(): void;
  17357. protected _disposeBlurPostProcesses(): void;
  17358. protected _disposeRTTandPostProcesses(): void;
  17359. /**
  17360. * Disposes the ShadowGenerator.
  17361. * Returns nothing.
  17362. */
  17363. dispose(): void;
  17364. /**
  17365. * Serializes the shadow generator setup to a json object.
  17366. * @returns The serialized JSON object
  17367. */
  17368. serialize(): any;
  17369. /**
  17370. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17371. * @param parsedShadowGenerator The JSON object to parse
  17372. * @param scene The scene to create the shadow map for
  17373. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17374. * @returns The parsed shadow generator
  17375. */
  17376. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17377. }
  17378. }
  17379. declare module "babylonjs/Lights/light" {
  17380. import { Nullable } from "babylonjs/types";
  17381. import { Scene } from "babylonjs/scene";
  17382. import { Vector3 } from "babylonjs/Maths/math.vector";
  17383. import { Color3 } from "babylonjs/Maths/math.color";
  17384. import { Node } from "babylonjs/node";
  17385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17386. import { Effect } from "babylonjs/Materials/effect";
  17387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17388. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17389. /**
  17390. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17391. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17392. * 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.
  17393. */
  17394. export abstract class Light extends Node {
  17395. /**
  17396. * Falloff Default: light is falling off following the material specification:
  17397. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17398. */
  17399. static readonly FALLOFF_DEFAULT: number;
  17400. /**
  17401. * Falloff Physical: light is falling off following the inverse squared distance law.
  17402. */
  17403. static readonly FALLOFF_PHYSICAL: number;
  17404. /**
  17405. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17406. * to enhance interoperability with other engines.
  17407. */
  17408. static readonly FALLOFF_GLTF: number;
  17409. /**
  17410. * Falloff Standard: light is falling off like in the standard material
  17411. * to enhance interoperability with other materials.
  17412. */
  17413. static readonly FALLOFF_STANDARD: number;
  17414. /**
  17415. * If every light affecting the material is in this lightmapMode,
  17416. * material.lightmapTexture adds or multiplies
  17417. * (depends on material.useLightmapAsShadowmap)
  17418. * after every other light calculations.
  17419. */
  17420. static readonly LIGHTMAP_DEFAULT: number;
  17421. /**
  17422. * material.lightmapTexture as only diffuse lighting from this light
  17423. * adds only specular lighting from this light
  17424. * adds dynamic shadows
  17425. */
  17426. static readonly LIGHTMAP_SPECULAR: number;
  17427. /**
  17428. * material.lightmapTexture as only lighting
  17429. * no light calculation from this light
  17430. * only adds dynamic shadows from this light
  17431. */
  17432. static readonly LIGHTMAP_SHADOWSONLY: number;
  17433. /**
  17434. * Each light type uses the default quantity according to its type:
  17435. * point/spot lights use luminous intensity
  17436. * directional lights use illuminance
  17437. */
  17438. static readonly INTENSITYMODE_AUTOMATIC: number;
  17439. /**
  17440. * lumen (lm)
  17441. */
  17442. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17443. /**
  17444. * candela (lm/sr)
  17445. */
  17446. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17447. /**
  17448. * lux (lm/m^2)
  17449. */
  17450. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17451. /**
  17452. * nit (cd/m^2)
  17453. */
  17454. static readonly INTENSITYMODE_LUMINANCE: number;
  17455. /**
  17456. * Light type const id of the point light.
  17457. */
  17458. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17459. /**
  17460. * Light type const id of the directional light.
  17461. */
  17462. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17463. /**
  17464. * Light type const id of the spot light.
  17465. */
  17466. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17467. /**
  17468. * Light type const id of the hemispheric light.
  17469. */
  17470. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17471. /**
  17472. * Diffuse gives the basic color to an object.
  17473. */
  17474. diffuse: Color3;
  17475. /**
  17476. * Specular produces a highlight color on an object.
  17477. * Note: This is note affecting PBR materials.
  17478. */
  17479. specular: Color3;
  17480. /**
  17481. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17482. * falling off base on range or angle.
  17483. * This can be set to any values in Light.FALLOFF_x.
  17484. *
  17485. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17486. * other types of materials.
  17487. */
  17488. falloffType: number;
  17489. /**
  17490. * Strength of the light.
  17491. * Note: By default it is define in the framework own unit.
  17492. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17493. */
  17494. intensity: number;
  17495. private _range;
  17496. protected _inverseSquaredRange: number;
  17497. /**
  17498. * Defines how far from the source the light is impacting in scene units.
  17499. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17500. */
  17501. get range(): number;
  17502. /**
  17503. * Defines how far from the source the light is impacting in scene units.
  17504. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17505. */
  17506. set range(value: number);
  17507. /**
  17508. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17509. * of light.
  17510. */
  17511. private _photometricScale;
  17512. private _intensityMode;
  17513. /**
  17514. * Gets the photometric scale used to interpret the intensity.
  17515. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17516. */
  17517. get intensityMode(): number;
  17518. /**
  17519. * Sets the photometric scale used to interpret the intensity.
  17520. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17521. */
  17522. set intensityMode(value: number);
  17523. private _radius;
  17524. /**
  17525. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17526. */
  17527. get radius(): number;
  17528. /**
  17529. * sets the light radius used by PBR Materials to simulate soft area lights.
  17530. */
  17531. set radius(value: number);
  17532. private _renderPriority;
  17533. /**
  17534. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17535. * exceeding the number allowed of the materials.
  17536. */
  17537. renderPriority: number;
  17538. private _shadowEnabled;
  17539. /**
  17540. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17541. * the current shadow generator.
  17542. */
  17543. get shadowEnabled(): boolean;
  17544. /**
  17545. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17546. * the current shadow generator.
  17547. */
  17548. set shadowEnabled(value: boolean);
  17549. private _includedOnlyMeshes;
  17550. /**
  17551. * Gets the only meshes impacted by this light.
  17552. */
  17553. get includedOnlyMeshes(): AbstractMesh[];
  17554. /**
  17555. * Sets the only meshes impacted by this light.
  17556. */
  17557. set includedOnlyMeshes(value: AbstractMesh[]);
  17558. private _excludedMeshes;
  17559. /**
  17560. * Gets the meshes not impacted by this light.
  17561. */
  17562. get excludedMeshes(): AbstractMesh[];
  17563. /**
  17564. * Sets the meshes not impacted by this light.
  17565. */
  17566. set excludedMeshes(value: AbstractMesh[]);
  17567. private _excludeWithLayerMask;
  17568. /**
  17569. * Gets the layer id use to find what meshes are not impacted by the light.
  17570. * Inactive if 0
  17571. */
  17572. get excludeWithLayerMask(): number;
  17573. /**
  17574. * Sets the layer id use to find what meshes are not impacted by the light.
  17575. * Inactive if 0
  17576. */
  17577. set excludeWithLayerMask(value: number);
  17578. private _includeOnlyWithLayerMask;
  17579. /**
  17580. * Gets the layer id use to find what meshes are impacted by the light.
  17581. * Inactive if 0
  17582. */
  17583. get includeOnlyWithLayerMask(): number;
  17584. /**
  17585. * Sets the layer id use to find what meshes are impacted by the light.
  17586. * Inactive if 0
  17587. */
  17588. set includeOnlyWithLayerMask(value: number);
  17589. private _lightmapMode;
  17590. /**
  17591. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17592. */
  17593. get lightmapMode(): number;
  17594. /**
  17595. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17596. */
  17597. set lightmapMode(value: number);
  17598. /**
  17599. * Shadow generator associted to the light.
  17600. * @hidden Internal use only.
  17601. */
  17602. _shadowGenerator: Nullable<IShadowGenerator>;
  17603. /**
  17604. * @hidden Internal use only.
  17605. */
  17606. _excludedMeshesIds: string[];
  17607. /**
  17608. * @hidden Internal use only.
  17609. */
  17610. _includedOnlyMeshesIds: string[];
  17611. /**
  17612. * The current light unifom buffer.
  17613. * @hidden Internal use only.
  17614. */
  17615. _uniformBuffer: UniformBuffer;
  17616. /** @hidden */
  17617. _renderId: number;
  17618. /**
  17619. * Creates a Light object in the scene.
  17620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17621. * @param name The firendly name of the light
  17622. * @param scene The scene the light belongs too
  17623. */
  17624. constructor(name: string, scene: Scene);
  17625. protected abstract _buildUniformLayout(): void;
  17626. /**
  17627. * Sets the passed Effect "effect" with the Light information.
  17628. * @param effect The effect to update
  17629. * @param lightIndex The index of the light in the effect to update
  17630. * @returns The light
  17631. */
  17632. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17633. /**
  17634. * Sets the passed Effect "effect" with the Light textures.
  17635. * @param effect The effect to update
  17636. * @param lightIndex The index of the light in the effect to update
  17637. * @returns The light
  17638. */
  17639. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17640. /**
  17641. * Binds the lights information from the scene to the effect for the given mesh.
  17642. * @param lightIndex Light index
  17643. * @param scene The scene where the light belongs to
  17644. * @param effect The effect we are binding the data to
  17645. * @param useSpecular Defines if specular is supported
  17646. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17647. */
  17648. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17649. /**
  17650. * Sets the passed Effect "effect" with the Light information.
  17651. * @param effect The effect to update
  17652. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17653. * @returns The light
  17654. */
  17655. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17656. /**
  17657. * Returns the string "Light".
  17658. * @returns the class name
  17659. */
  17660. getClassName(): string;
  17661. /** @hidden */
  17662. readonly _isLight: boolean;
  17663. /**
  17664. * Converts the light information to a readable string for debug purpose.
  17665. * @param fullDetails Supports for multiple levels of logging within scene loading
  17666. * @returns the human readable light info
  17667. */
  17668. toString(fullDetails?: boolean): string;
  17669. /** @hidden */
  17670. protected _syncParentEnabledState(): void;
  17671. /**
  17672. * Set the enabled state of this node.
  17673. * @param value - the new enabled state
  17674. */
  17675. setEnabled(value: boolean): void;
  17676. /**
  17677. * Returns the Light associated shadow generator if any.
  17678. * @return the associated shadow generator.
  17679. */
  17680. getShadowGenerator(): Nullable<IShadowGenerator>;
  17681. /**
  17682. * Returns a Vector3, the absolute light position in the World.
  17683. * @returns the world space position of the light
  17684. */
  17685. getAbsolutePosition(): Vector3;
  17686. /**
  17687. * Specifies if the light will affect the passed mesh.
  17688. * @param mesh The mesh to test against the light
  17689. * @return true the mesh is affected otherwise, false.
  17690. */
  17691. canAffectMesh(mesh: AbstractMesh): boolean;
  17692. /**
  17693. * Sort function to order lights for rendering.
  17694. * @param a First Light object to compare to second.
  17695. * @param b Second Light object to compare first.
  17696. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17697. */
  17698. static CompareLightsPriority(a: Light, b: Light): number;
  17699. /**
  17700. * Releases resources associated with this node.
  17701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17703. */
  17704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17705. /**
  17706. * Returns the light type ID (integer).
  17707. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17708. */
  17709. getTypeID(): number;
  17710. /**
  17711. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17712. * @returns the scaled intensity in intensity mode unit
  17713. */
  17714. getScaledIntensity(): number;
  17715. /**
  17716. * Returns a new Light object, named "name", from the current one.
  17717. * @param name The name of the cloned light
  17718. * @returns the new created light
  17719. */
  17720. clone(name: string): Nullable<Light>;
  17721. /**
  17722. * Serializes the current light into a Serialization object.
  17723. * @returns the serialized object.
  17724. */
  17725. serialize(): any;
  17726. /**
  17727. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17728. * This new light is named "name" and added to the passed scene.
  17729. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17730. * @param name The friendly name of the light
  17731. * @param scene The scene the new light will belong to
  17732. * @returns the constructor function
  17733. */
  17734. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17735. /**
  17736. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17737. * @param parsedLight The JSON representation of the light
  17738. * @param scene The scene to create the parsed light in
  17739. * @returns the created light after parsing
  17740. */
  17741. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17742. private _hookArrayForExcluded;
  17743. private _hookArrayForIncludedOnly;
  17744. private _resyncMeshes;
  17745. /**
  17746. * Forces the meshes to update their light related information in their rendering used effects
  17747. * @hidden Internal Use Only
  17748. */
  17749. _markMeshesAsLightDirty(): void;
  17750. /**
  17751. * Recomputes the cached photometric scale if needed.
  17752. */
  17753. private _computePhotometricScale;
  17754. /**
  17755. * Returns the Photometric Scale according to the light type and intensity mode.
  17756. */
  17757. private _getPhotometricScale;
  17758. /**
  17759. * Reorder the light in the scene according to their defined priority.
  17760. * @hidden Internal Use Only
  17761. */
  17762. _reorderLightsInScene(): void;
  17763. /**
  17764. * Prepares the list of defines specific to the light type.
  17765. * @param defines the list of defines
  17766. * @param lightIndex defines the index of the light for the effect
  17767. */
  17768. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17769. }
  17770. }
  17771. declare module "babylonjs/Actions/action" {
  17772. import { Observable } from "babylonjs/Misc/observable";
  17773. import { Condition } from "babylonjs/Actions/condition";
  17774. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17775. import { ActionManager } from "babylonjs/Actions/actionManager";
  17776. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17777. /**
  17778. * Interface used to define Action
  17779. */
  17780. export interface IAction {
  17781. /**
  17782. * Trigger for the action
  17783. */
  17784. trigger: number;
  17785. /** Options of the trigger */
  17786. triggerOptions: any;
  17787. /**
  17788. * Gets the trigger parameters
  17789. * @returns the trigger parameters
  17790. */
  17791. getTriggerParameter(): any;
  17792. /**
  17793. * Internal only - executes current action event
  17794. * @hidden
  17795. */
  17796. _executeCurrent(evt?: ActionEvent): void;
  17797. /**
  17798. * Serialize placeholder for child classes
  17799. * @param parent of child
  17800. * @returns the serialized object
  17801. */
  17802. serialize(parent: any): any;
  17803. /**
  17804. * Internal only
  17805. * @hidden
  17806. */
  17807. _prepare(): void;
  17808. /**
  17809. * Internal only - manager for action
  17810. * @hidden
  17811. */
  17812. _actionManager: AbstractActionManager;
  17813. /**
  17814. * Adds action to chain of actions, may be a DoNothingAction
  17815. * @param action defines the next action to execute
  17816. * @returns The action passed in
  17817. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17818. */
  17819. then(action: IAction): IAction;
  17820. }
  17821. /**
  17822. * The action to be carried out following a trigger
  17823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17824. */
  17825. export class Action implements IAction {
  17826. /** the trigger, with or without parameters, for the action */
  17827. triggerOptions: any;
  17828. /**
  17829. * Trigger for the action
  17830. */
  17831. trigger: number;
  17832. /**
  17833. * Internal only - manager for action
  17834. * @hidden
  17835. */
  17836. _actionManager: ActionManager;
  17837. private _nextActiveAction;
  17838. private _child;
  17839. private _condition?;
  17840. private _triggerParameter;
  17841. /**
  17842. * An event triggered prior to action being executed.
  17843. */
  17844. onBeforeExecuteObservable: Observable<Action>;
  17845. /**
  17846. * Creates a new Action
  17847. * @param triggerOptions the trigger, with or without parameters, for the action
  17848. * @param condition an optional determinant of action
  17849. */
  17850. constructor(
  17851. /** the trigger, with or without parameters, for the action */
  17852. triggerOptions: any, condition?: Condition);
  17853. /**
  17854. * Internal only
  17855. * @hidden
  17856. */
  17857. _prepare(): void;
  17858. /**
  17859. * Gets the trigger parameters
  17860. * @returns the trigger parameters
  17861. */
  17862. getTriggerParameter(): any;
  17863. /**
  17864. * Internal only - executes current action event
  17865. * @hidden
  17866. */
  17867. _executeCurrent(evt?: ActionEvent): void;
  17868. /**
  17869. * Execute placeholder for child classes
  17870. * @param evt optional action event
  17871. */
  17872. execute(evt?: ActionEvent): void;
  17873. /**
  17874. * Skips to next active action
  17875. */
  17876. skipToNextActiveAction(): void;
  17877. /**
  17878. * Adds action to chain of actions, may be a DoNothingAction
  17879. * @param action defines the next action to execute
  17880. * @returns The action passed in
  17881. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17882. */
  17883. then(action: Action): Action;
  17884. /**
  17885. * Internal only
  17886. * @hidden
  17887. */
  17888. _getProperty(propertyPath: string): string;
  17889. /**
  17890. * Internal only
  17891. * @hidden
  17892. */
  17893. _getEffectiveTarget(target: any, propertyPath: string): any;
  17894. /**
  17895. * Serialize placeholder for child classes
  17896. * @param parent of child
  17897. * @returns the serialized object
  17898. */
  17899. serialize(parent: any): any;
  17900. /**
  17901. * Internal only called by serialize
  17902. * @hidden
  17903. */
  17904. protected _serialize(serializedAction: any, parent?: any): any;
  17905. /**
  17906. * Internal only
  17907. * @hidden
  17908. */
  17909. static _SerializeValueAsString: (value: any) => string;
  17910. /**
  17911. * Internal only
  17912. * @hidden
  17913. */
  17914. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17915. name: string;
  17916. targetType: string;
  17917. value: string;
  17918. };
  17919. }
  17920. }
  17921. declare module "babylonjs/Actions/condition" {
  17922. import { ActionManager } from "babylonjs/Actions/actionManager";
  17923. /**
  17924. * A Condition applied to an Action
  17925. */
  17926. export class Condition {
  17927. /**
  17928. * Internal only - manager for action
  17929. * @hidden
  17930. */
  17931. _actionManager: ActionManager;
  17932. /**
  17933. * Internal only
  17934. * @hidden
  17935. */
  17936. _evaluationId: number;
  17937. /**
  17938. * Internal only
  17939. * @hidden
  17940. */
  17941. _currentResult: boolean;
  17942. /**
  17943. * Creates a new Condition
  17944. * @param actionManager the manager of the action the condition is applied to
  17945. */
  17946. constructor(actionManager: ActionManager);
  17947. /**
  17948. * Check if the current condition is valid
  17949. * @returns a boolean
  17950. */
  17951. isValid(): boolean;
  17952. /**
  17953. * Internal only
  17954. * @hidden
  17955. */
  17956. _getProperty(propertyPath: string): string;
  17957. /**
  17958. * Internal only
  17959. * @hidden
  17960. */
  17961. _getEffectiveTarget(target: any, propertyPath: string): any;
  17962. /**
  17963. * Serialize placeholder for child classes
  17964. * @returns the serialized object
  17965. */
  17966. serialize(): any;
  17967. /**
  17968. * Internal only
  17969. * @hidden
  17970. */
  17971. protected _serialize(serializedCondition: any): any;
  17972. }
  17973. /**
  17974. * Defines specific conditional operators as extensions of Condition
  17975. */
  17976. export class ValueCondition extends Condition {
  17977. /** path to specify the property of the target the conditional operator uses */
  17978. propertyPath: string;
  17979. /** the value compared by the conditional operator against the current value of the property */
  17980. value: any;
  17981. /** the conditional operator, default ValueCondition.IsEqual */
  17982. operator: number;
  17983. /**
  17984. * Internal only
  17985. * @hidden
  17986. */
  17987. private static _IsEqual;
  17988. /**
  17989. * Internal only
  17990. * @hidden
  17991. */
  17992. private static _IsDifferent;
  17993. /**
  17994. * Internal only
  17995. * @hidden
  17996. */
  17997. private static _IsGreater;
  17998. /**
  17999. * Internal only
  18000. * @hidden
  18001. */
  18002. private static _IsLesser;
  18003. /**
  18004. * returns the number for IsEqual
  18005. */
  18006. static get IsEqual(): number;
  18007. /**
  18008. * Returns the number for IsDifferent
  18009. */
  18010. static get IsDifferent(): number;
  18011. /**
  18012. * Returns the number for IsGreater
  18013. */
  18014. static get IsGreater(): number;
  18015. /**
  18016. * Returns the number for IsLesser
  18017. */
  18018. static get IsLesser(): number;
  18019. /**
  18020. * Internal only The action manager for the condition
  18021. * @hidden
  18022. */
  18023. _actionManager: ActionManager;
  18024. /**
  18025. * Internal only
  18026. * @hidden
  18027. */
  18028. private _target;
  18029. /**
  18030. * Internal only
  18031. * @hidden
  18032. */
  18033. private _effectiveTarget;
  18034. /**
  18035. * Internal only
  18036. * @hidden
  18037. */
  18038. private _property;
  18039. /**
  18040. * Creates a new ValueCondition
  18041. * @param actionManager manager for the action the condition applies to
  18042. * @param target for the action
  18043. * @param propertyPath path to specify the property of the target the conditional operator uses
  18044. * @param value the value compared by the conditional operator against the current value of the property
  18045. * @param operator the conditional operator, default ValueCondition.IsEqual
  18046. */
  18047. constructor(actionManager: ActionManager, target: any,
  18048. /** path to specify the property of the target the conditional operator uses */
  18049. propertyPath: string,
  18050. /** the value compared by the conditional operator against the current value of the property */
  18051. value: any,
  18052. /** the conditional operator, default ValueCondition.IsEqual */
  18053. operator?: number);
  18054. /**
  18055. * Compares the given value with the property value for the specified conditional operator
  18056. * @returns the result of the comparison
  18057. */
  18058. isValid(): boolean;
  18059. /**
  18060. * Serialize the ValueCondition into a JSON compatible object
  18061. * @returns serialization object
  18062. */
  18063. serialize(): any;
  18064. /**
  18065. * Gets the name of the conditional operator for the ValueCondition
  18066. * @param operator the conditional operator
  18067. * @returns the name
  18068. */
  18069. static GetOperatorName(operator: number): string;
  18070. }
  18071. /**
  18072. * Defines a predicate condition as an extension of Condition
  18073. */
  18074. export class PredicateCondition extends Condition {
  18075. /** defines the predicate function used to validate the condition */
  18076. predicate: () => boolean;
  18077. /**
  18078. * Internal only - manager for action
  18079. * @hidden
  18080. */
  18081. _actionManager: ActionManager;
  18082. /**
  18083. * Creates a new PredicateCondition
  18084. * @param actionManager manager for the action the condition applies to
  18085. * @param predicate defines the predicate function used to validate the condition
  18086. */
  18087. constructor(actionManager: ActionManager,
  18088. /** defines the predicate function used to validate the condition */
  18089. predicate: () => boolean);
  18090. /**
  18091. * @returns the validity of the predicate condition
  18092. */
  18093. isValid(): boolean;
  18094. }
  18095. /**
  18096. * Defines a state condition as an extension of Condition
  18097. */
  18098. export class StateCondition extends Condition {
  18099. /** Value to compare with target state */
  18100. value: string;
  18101. /**
  18102. * Internal only - manager for action
  18103. * @hidden
  18104. */
  18105. _actionManager: ActionManager;
  18106. /**
  18107. * Internal only
  18108. * @hidden
  18109. */
  18110. private _target;
  18111. /**
  18112. * Creates a new StateCondition
  18113. * @param actionManager manager for the action the condition applies to
  18114. * @param target of the condition
  18115. * @param value to compare with target state
  18116. */
  18117. constructor(actionManager: ActionManager, target: any,
  18118. /** Value to compare with target state */
  18119. value: string);
  18120. /**
  18121. * Gets a boolean indicating if the current condition is met
  18122. * @returns the validity of the state
  18123. */
  18124. isValid(): boolean;
  18125. /**
  18126. * Serialize the StateCondition into a JSON compatible object
  18127. * @returns serialization object
  18128. */
  18129. serialize(): any;
  18130. }
  18131. }
  18132. declare module "babylonjs/Actions/directActions" {
  18133. import { Action } from "babylonjs/Actions/action";
  18134. import { Condition } from "babylonjs/Actions/condition";
  18135. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18136. /**
  18137. * This defines an action responsible to toggle a boolean once triggered.
  18138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18139. */
  18140. export class SwitchBooleanAction extends Action {
  18141. /**
  18142. * The path to the boolean property in the target object
  18143. */
  18144. propertyPath: string;
  18145. private _target;
  18146. private _effectiveTarget;
  18147. private _property;
  18148. /**
  18149. * Instantiate the action
  18150. * @param triggerOptions defines the trigger options
  18151. * @param target defines the object containing the boolean
  18152. * @param propertyPath defines the path to the boolean property in the target object
  18153. * @param condition defines the trigger related conditions
  18154. */
  18155. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18156. /** @hidden */
  18157. _prepare(): void;
  18158. /**
  18159. * Execute the action toggle the boolean value.
  18160. */
  18161. execute(): void;
  18162. /**
  18163. * Serializes the actions and its related information.
  18164. * @param parent defines the object to serialize in
  18165. * @returns the serialized object
  18166. */
  18167. serialize(parent: any): any;
  18168. }
  18169. /**
  18170. * This defines an action responsible to set a the state field of the target
  18171. * to a desired value once triggered.
  18172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18173. */
  18174. export class SetStateAction extends Action {
  18175. /**
  18176. * The value to store in the state field.
  18177. */
  18178. value: string;
  18179. private _target;
  18180. /**
  18181. * Instantiate the action
  18182. * @param triggerOptions defines the trigger options
  18183. * @param target defines the object containing the state property
  18184. * @param value defines the value to store in the state field
  18185. * @param condition defines the trigger related conditions
  18186. */
  18187. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18188. /**
  18189. * Execute the action and store the value on the target state property.
  18190. */
  18191. execute(): void;
  18192. /**
  18193. * Serializes the actions and its related information.
  18194. * @param parent defines the object to serialize in
  18195. * @returns the serialized object
  18196. */
  18197. serialize(parent: any): any;
  18198. }
  18199. /**
  18200. * This defines an action responsible to set a property of the target
  18201. * to a desired value once triggered.
  18202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18203. */
  18204. export class SetValueAction extends Action {
  18205. /**
  18206. * The path of the property to set in the target.
  18207. */
  18208. propertyPath: string;
  18209. /**
  18210. * The value to set in the property
  18211. */
  18212. value: any;
  18213. private _target;
  18214. private _effectiveTarget;
  18215. private _property;
  18216. /**
  18217. * Instantiate the action
  18218. * @param triggerOptions defines the trigger options
  18219. * @param target defines the object containing the property
  18220. * @param propertyPath defines the path of the property to set in the target
  18221. * @param value defines the value to set in the property
  18222. * @param condition defines the trigger related conditions
  18223. */
  18224. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18225. /** @hidden */
  18226. _prepare(): void;
  18227. /**
  18228. * Execute the action and set the targetted property to the desired value.
  18229. */
  18230. execute(): void;
  18231. /**
  18232. * Serializes the actions and its related information.
  18233. * @param parent defines the object to serialize in
  18234. * @returns the serialized object
  18235. */
  18236. serialize(parent: any): any;
  18237. }
  18238. /**
  18239. * This defines an action responsible to increment the target value
  18240. * to a desired value once triggered.
  18241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18242. */
  18243. export class IncrementValueAction extends Action {
  18244. /**
  18245. * The path of the property to increment in the target.
  18246. */
  18247. propertyPath: string;
  18248. /**
  18249. * The value we should increment the property by.
  18250. */
  18251. value: any;
  18252. private _target;
  18253. private _effectiveTarget;
  18254. private _property;
  18255. /**
  18256. * Instantiate the action
  18257. * @param triggerOptions defines the trigger options
  18258. * @param target defines the object containing the property
  18259. * @param propertyPath defines the path of the property to increment in the target
  18260. * @param value defines the value value we should increment the property by
  18261. * @param condition defines the trigger related conditions
  18262. */
  18263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18264. /** @hidden */
  18265. _prepare(): void;
  18266. /**
  18267. * Execute the action and increment the target of the value amount.
  18268. */
  18269. execute(): void;
  18270. /**
  18271. * Serializes the actions and its related information.
  18272. * @param parent defines the object to serialize in
  18273. * @returns the serialized object
  18274. */
  18275. serialize(parent: any): any;
  18276. }
  18277. /**
  18278. * This defines an action responsible to start an animation once triggered.
  18279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18280. */
  18281. export class PlayAnimationAction extends Action {
  18282. /**
  18283. * Where the animation should start (animation frame)
  18284. */
  18285. from: number;
  18286. /**
  18287. * Where the animation should stop (animation frame)
  18288. */
  18289. to: number;
  18290. /**
  18291. * Define if the animation should loop or stop after the first play.
  18292. */
  18293. loop?: boolean;
  18294. private _target;
  18295. /**
  18296. * Instantiate the action
  18297. * @param triggerOptions defines the trigger options
  18298. * @param target defines the target animation or animation name
  18299. * @param from defines from where the animation should start (animation frame)
  18300. * @param end defines where the animation should stop (animation frame)
  18301. * @param loop defines if the animation should loop or stop after the first play
  18302. * @param condition defines the trigger related conditions
  18303. */
  18304. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18305. /** @hidden */
  18306. _prepare(): void;
  18307. /**
  18308. * Execute the action and play the animation.
  18309. */
  18310. execute(): void;
  18311. /**
  18312. * Serializes the actions and its related information.
  18313. * @param parent defines the object to serialize in
  18314. * @returns the serialized object
  18315. */
  18316. serialize(parent: any): any;
  18317. }
  18318. /**
  18319. * This defines an action responsible to stop an animation once triggered.
  18320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18321. */
  18322. export class StopAnimationAction extends Action {
  18323. private _target;
  18324. /**
  18325. * Instantiate the action
  18326. * @param triggerOptions defines the trigger options
  18327. * @param target defines the target animation or animation name
  18328. * @param condition defines the trigger related conditions
  18329. */
  18330. constructor(triggerOptions: any, target: any, condition?: Condition);
  18331. /** @hidden */
  18332. _prepare(): void;
  18333. /**
  18334. * Execute the action and stop the animation.
  18335. */
  18336. execute(): void;
  18337. /**
  18338. * Serializes the actions and its related information.
  18339. * @param parent defines the object to serialize in
  18340. * @returns the serialized object
  18341. */
  18342. serialize(parent: any): any;
  18343. }
  18344. /**
  18345. * This defines an action responsible that does nothing once triggered.
  18346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18347. */
  18348. export class DoNothingAction extends Action {
  18349. /**
  18350. * Instantiate the action
  18351. * @param triggerOptions defines the trigger options
  18352. * @param condition defines the trigger related conditions
  18353. */
  18354. constructor(triggerOptions?: any, condition?: Condition);
  18355. /**
  18356. * Execute the action and do nothing.
  18357. */
  18358. execute(): void;
  18359. /**
  18360. * Serializes the actions and its related information.
  18361. * @param parent defines the object to serialize in
  18362. * @returns the serialized object
  18363. */
  18364. serialize(parent: any): any;
  18365. }
  18366. /**
  18367. * This defines an action responsible to trigger several actions once triggered.
  18368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18369. */
  18370. export class CombineAction extends Action {
  18371. /**
  18372. * The list of aggregated animations to run.
  18373. */
  18374. children: Action[];
  18375. /**
  18376. * Instantiate the action
  18377. * @param triggerOptions defines the trigger options
  18378. * @param children defines the list of aggregated animations to run
  18379. * @param condition defines the trigger related conditions
  18380. */
  18381. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18382. /** @hidden */
  18383. _prepare(): void;
  18384. /**
  18385. * Execute the action and executes all the aggregated actions.
  18386. */
  18387. execute(evt: ActionEvent): void;
  18388. /**
  18389. * Serializes the actions and its related information.
  18390. * @param parent defines the object to serialize in
  18391. * @returns the serialized object
  18392. */
  18393. serialize(parent: any): any;
  18394. }
  18395. /**
  18396. * This defines an action responsible to run code (external event) once triggered.
  18397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18398. */
  18399. export class ExecuteCodeAction extends Action {
  18400. /**
  18401. * The callback function to run.
  18402. */
  18403. func: (evt: ActionEvent) => void;
  18404. /**
  18405. * Instantiate the action
  18406. * @param triggerOptions defines the trigger options
  18407. * @param func defines the callback function to run
  18408. * @param condition defines the trigger related conditions
  18409. */
  18410. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18411. /**
  18412. * Execute the action and run the attached code.
  18413. */
  18414. execute(evt: ActionEvent): void;
  18415. }
  18416. /**
  18417. * This defines an action responsible to set the parent property of the target once triggered.
  18418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18419. */
  18420. export class SetParentAction extends Action {
  18421. private _parent;
  18422. private _target;
  18423. /**
  18424. * Instantiate the action
  18425. * @param triggerOptions defines the trigger options
  18426. * @param target defines the target containing the parent property
  18427. * @param parent defines from where the animation should start (animation frame)
  18428. * @param condition defines the trigger related conditions
  18429. */
  18430. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18431. /** @hidden */
  18432. _prepare(): void;
  18433. /**
  18434. * Execute the action and set the parent property.
  18435. */
  18436. execute(): void;
  18437. /**
  18438. * Serializes the actions and its related information.
  18439. * @param parent defines the object to serialize in
  18440. * @returns the serialized object
  18441. */
  18442. serialize(parent: any): any;
  18443. }
  18444. }
  18445. declare module "babylonjs/Actions/actionManager" {
  18446. import { Nullable } from "babylonjs/types";
  18447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18448. import { Scene } from "babylonjs/scene";
  18449. import { IAction } from "babylonjs/Actions/action";
  18450. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18451. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18452. /**
  18453. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18454. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18456. */
  18457. export class ActionManager extends AbstractActionManager {
  18458. /**
  18459. * Nothing
  18460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18461. */
  18462. static readonly NothingTrigger: number;
  18463. /**
  18464. * On pick
  18465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18466. */
  18467. static readonly OnPickTrigger: number;
  18468. /**
  18469. * On left pick
  18470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18471. */
  18472. static readonly OnLeftPickTrigger: number;
  18473. /**
  18474. * On right pick
  18475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18476. */
  18477. static readonly OnRightPickTrigger: number;
  18478. /**
  18479. * On center pick
  18480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18481. */
  18482. static readonly OnCenterPickTrigger: number;
  18483. /**
  18484. * On pick down
  18485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18486. */
  18487. static readonly OnPickDownTrigger: number;
  18488. /**
  18489. * On double pick
  18490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18491. */
  18492. static readonly OnDoublePickTrigger: number;
  18493. /**
  18494. * On pick up
  18495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18496. */
  18497. static readonly OnPickUpTrigger: number;
  18498. /**
  18499. * On pick out.
  18500. * This trigger will only be raised if you also declared a OnPickDown
  18501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18502. */
  18503. static readonly OnPickOutTrigger: number;
  18504. /**
  18505. * On long press
  18506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18507. */
  18508. static readonly OnLongPressTrigger: number;
  18509. /**
  18510. * On pointer over
  18511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18512. */
  18513. static readonly OnPointerOverTrigger: number;
  18514. /**
  18515. * On pointer out
  18516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18517. */
  18518. static readonly OnPointerOutTrigger: number;
  18519. /**
  18520. * On every frame
  18521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18522. */
  18523. static readonly OnEveryFrameTrigger: number;
  18524. /**
  18525. * On intersection enter
  18526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18527. */
  18528. static readonly OnIntersectionEnterTrigger: number;
  18529. /**
  18530. * On intersection exit
  18531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18532. */
  18533. static readonly OnIntersectionExitTrigger: number;
  18534. /**
  18535. * On key down
  18536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18537. */
  18538. static readonly OnKeyDownTrigger: number;
  18539. /**
  18540. * On key up
  18541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18542. */
  18543. static readonly OnKeyUpTrigger: number;
  18544. private _scene;
  18545. /**
  18546. * Creates a new action manager
  18547. * @param scene defines the hosting scene
  18548. */
  18549. constructor(scene: Scene);
  18550. /**
  18551. * Releases all associated resources
  18552. */
  18553. dispose(): void;
  18554. /**
  18555. * Gets hosting scene
  18556. * @returns the hosting scene
  18557. */
  18558. getScene(): Scene;
  18559. /**
  18560. * Does this action manager handles actions of any of the given triggers
  18561. * @param triggers defines the triggers to be tested
  18562. * @return a boolean indicating whether one (or more) of the triggers is handled
  18563. */
  18564. hasSpecificTriggers(triggers: number[]): boolean;
  18565. /**
  18566. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18567. * speed.
  18568. * @param triggerA defines the trigger to be tested
  18569. * @param triggerB defines the trigger to be tested
  18570. * @return a boolean indicating whether one (or more) of the triggers is handled
  18571. */
  18572. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18573. /**
  18574. * Does this action manager handles actions of a given trigger
  18575. * @param trigger defines the trigger to be tested
  18576. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18577. * @return whether the trigger is handled
  18578. */
  18579. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18580. /**
  18581. * Does this action manager has pointer triggers
  18582. */
  18583. get hasPointerTriggers(): boolean;
  18584. /**
  18585. * Does this action manager has pick triggers
  18586. */
  18587. get hasPickTriggers(): boolean;
  18588. /**
  18589. * Registers an action to this action manager
  18590. * @param action defines the action to be registered
  18591. * @return the action amended (prepared) after registration
  18592. */
  18593. registerAction(action: IAction): Nullable<IAction>;
  18594. /**
  18595. * Unregisters an action to this action manager
  18596. * @param action defines the action to be unregistered
  18597. * @return a boolean indicating whether the action has been unregistered
  18598. */
  18599. unregisterAction(action: IAction): Boolean;
  18600. /**
  18601. * Process a specific trigger
  18602. * @param trigger defines the trigger to process
  18603. * @param evt defines the event details to be processed
  18604. */
  18605. processTrigger(trigger: number, evt?: IActionEvent): void;
  18606. /** @hidden */
  18607. _getEffectiveTarget(target: any, propertyPath: string): any;
  18608. /** @hidden */
  18609. _getProperty(propertyPath: string): string;
  18610. /**
  18611. * Serialize this manager to a JSON object
  18612. * @param name defines the property name to store this manager
  18613. * @returns a JSON representation of this manager
  18614. */
  18615. serialize(name: string): any;
  18616. /**
  18617. * Creates a new ActionManager from a JSON data
  18618. * @param parsedActions defines the JSON data to read from
  18619. * @param object defines the hosting mesh
  18620. * @param scene defines the hosting scene
  18621. */
  18622. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18623. /**
  18624. * Get a trigger name by index
  18625. * @param trigger defines the trigger index
  18626. * @returns a trigger name
  18627. */
  18628. static GetTriggerName(trigger: number): string;
  18629. }
  18630. }
  18631. declare module "babylonjs/Sprites/sprite" {
  18632. import { Vector3 } from "babylonjs/Maths/math.vector";
  18633. import { Nullable } from "babylonjs/types";
  18634. import { ActionManager } from "babylonjs/Actions/actionManager";
  18635. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18636. import { Color4 } from "babylonjs/Maths/math.color";
  18637. import { Observable } from "babylonjs/Misc/observable";
  18638. /**
  18639. * Class used to represent a sprite
  18640. * @see http://doc.babylonjs.com/babylon101/sprites
  18641. */
  18642. export class Sprite {
  18643. /** defines the name */
  18644. name: string;
  18645. /** Gets or sets the current world position */
  18646. position: Vector3;
  18647. /** Gets or sets the main color */
  18648. color: Color4;
  18649. /** Gets or sets the width */
  18650. width: number;
  18651. /** Gets or sets the height */
  18652. height: number;
  18653. /** Gets or sets rotation angle */
  18654. angle: number;
  18655. /** Gets or sets the cell index in the sprite sheet */
  18656. cellIndex: number;
  18657. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18658. cellRef: string;
  18659. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18660. invertU: number;
  18661. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18662. invertV: number;
  18663. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18664. disposeWhenFinishedAnimating: boolean;
  18665. /** Gets the list of attached animations */
  18666. animations: Animation[];
  18667. /** Gets or sets a boolean indicating if the sprite can be picked */
  18668. isPickable: boolean;
  18669. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18670. useAlphaForPicking: boolean;
  18671. /** @hidden */
  18672. _xOffset: number;
  18673. /** @hidden */
  18674. _yOffset: number;
  18675. /** @hidden */
  18676. _xSize: number;
  18677. /** @hidden */
  18678. _ySize: number;
  18679. /**
  18680. * Gets or sets the associated action manager
  18681. */
  18682. actionManager: Nullable<ActionManager>;
  18683. /**
  18684. * An event triggered when the control has been disposed
  18685. */
  18686. onDisposeObservable: Observable<Sprite>;
  18687. private _animationStarted;
  18688. private _loopAnimation;
  18689. private _fromIndex;
  18690. private _toIndex;
  18691. private _delay;
  18692. private _direction;
  18693. private _manager;
  18694. private _time;
  18695. private _onAnimationEnd;
  18696. /**
  18697. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18698. */
  18699. isVisible: boolean;
  18700. /**
  18701. * Gets or sets the sprite size
  18702. */
  18703. get size(): number;
  18704. set size(value: number);
  18705. /**
  18706. * Creates a new Sprite
  18707. * @param name defines the name
  18708. * @param manager defines the manager
  18709. */
  18710. constructor(
  18711. /** defines the name */
  18712. name: string, manager: ISpriteManager);
  18713. /**
  18714. * Starts an animation
  18715. * @param from defines the initial key
  18716. * @param to defines the end key
  18717. * @param loop defines if the animation must loop
  18718. * @param delay defines the start delay (in ms)
  18719. * @param onAnimationEnd defines a callback to call when animation ends
  18720. */
  18721. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18722. /** Stops current animation (if any) */
  18723. stopAnimation(): void;
  18724. /** @hidden */
  18725. _animate(deltaTime: number): void;
  18726. /** Release associated resources */
  18727. dispose(): void;
  18728. }
  18729. }
  18730. declare module "babylonjs/Collisions/pickingInfo" {
  18731. import { Nullable } from "babylonjs/types";
  18732. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18734. import { Sprite } from "babylonjs/Sprites/sprite";
  18735. import { Ray } from "babylonjs/Culling/ray";
  18736. /**
  18737. * Information about the result of picking within a scene
  18738. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18739. */
  18740. export class PickingInfo {
  18741. /** @hidden */
  18742. _pickingUnavailable: boolean;
  18743. /**
  18744. * If the pick collided with an object
  18745. */
  18746. hit: boolean;
  18747. /**
  18748. * Distance away where the pick collided
  18749. */
  18750. distance: number;
  18751. /**
  18752. * The location of pick collision
  18753. */
  18754. pickedPoint: Nullable<Vector3>;
  18755. /**
  18756. * The mesh corresponding the the pick collision
  18757. */
  18758. pickedMesh: Nullable<AbstractMesh>;
  18759. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18760. bu: number;
  18761. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18762. bv: number;
  18763. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18764. faceId: number;
  18765. /** Id of the the submesh that was picked */
  18766. subMeshId: number;
  18767. /** If a sprite was picked, this will be the sprite the pick collided with */
  18768. pickedSprite: Nullable<Sprite>;
  18769. /**
  18770. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18771. */
  18772. originMesh: Nullable<AbstractMesh>;
  18773. /**
  18774. * The ray that was used to perform the picking.
  18775. */
  18776. ray: Nullable<Ray>;
  18777. /**
  18778. * Gets the normal correspodning to the face the pick collided with
  18779. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18780. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18781. * @returns The normal correspodning to the face the pick collided with
  18782. */
  18783. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18784. /**
  18785. * Gets the texture coordinates of where the pick occured
  18786. * @returns the vector containing the coordnates of the texture
  18787. */
  18788. getTextureCoordinates(): Nullable<Vector2>;
  18789. }
  18790. }
  18791. declare module "babylonjs/Events/pointerEvents" {
  18792. import { Nullable } from "babylonjs/types";
  18793. import { Vector2 } from "babylonjs/Maths/math.vector";
  18794. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18795. import { Ray } from "babylonjs/Culling/ray";
  18796. /**
  18797. * Gather the list of pointer event types as constants.
  18798. */
  18799. export class PointerEventTypes {
  18800. /**
  18801. * 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.
  18802. */
  18803. static readonly POINTERDOWN: number;
  18804. /**
  18805. * The pointerup event is fired when a pointer is no longer active.
  18806. */
  18807. static readonly POINTERUP: number;
  18808. /**
  18809. * The pointermove event is fired when a pointer changes coordinates.
  18810. */
  18811. static readonly POINTERMOVE: number;
  18812. /**
  18813. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18814. */
  18815. static readonly POINTERWHEEL: number;
  18816. /**
  18817. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18818. */
  18819. static readonly POINTERPICK: number;
  18820. /**
  18821. * The pointertap event is fired when a the object has been touched and released without drag.
  18822. */
  18823. static readonly POINTERTAP: number;
  18824. /**
  18825. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18826. */
  18827. static readonly POINTERDOUBLETAP: number;
  18828. }
  18829. /**
  18830. * Base class of pointer info types.
  18831. */
  18832. export class PointerInfoBase {
  18833. /**
  18834. * Defines the type of event (PointerEventTypes)
  18835. */
  18836. type: number;
  18837. /**
  18838. * Defines the related dom event
  18839. */
  18840. event: PointerEvent | MouseWheelEvent;
  18841. /**
  18842. * Instantiates the base class of pointers info.
  18843. * @param type Defines the type of event (PointerEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (PointerEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: PointerEvent | MouseWheelEvent);
  18855. }
  18856. /**
  18857. * This class is used to store pointer related info for the onPrePointerObservable event.
  18858. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18859. */
  18860. export class PointerInfoPre extends PointerInfoBase {
  18861. /**
  18862. * Ray from a pointer if availible (eg. 6dof controller)
  18863. */
  18864. ray: Nullable<Ray>;
  18865. /**
  18866. * Defines the local position of the pointer on the canvas.
  18867. */
  18868. localPosition: Vector2;
  18869. /**
  18870. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18875. * @param type Defines the type of event (PointerEventTypes)
  18876. * @param event Defines the related dom event
  18877. * @param localX Defines the local x coordinates of the pointer when the event occured
  18878. * @param localY Defines the local y coordinates of the pointer when the event occured
  18879. */
  18880. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18881. }
  18882. /**
  18883. * This type contains all the data related to a pointer event in Babylon.js.
  18884. * 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.
  18885. */
  18886. export class PointerInfo extends PointerInfoBase {
  18887. /**
  18888. * Defines the picking info associated to the info (if any)\
  18889. */
  18890. pickInfo: Nullable<PickingInfo>;
  18891. /**
  18892. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18893. * @param type Defines the type of event (PointerEventTypes)
  18894. * @param event Defines the related dom event
  18895. * @param pickInfo Defines the picking info associated to the info (if any)\
  18896. */
  18897. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18898. /**
  18899. * Defines the picking info associated to the info (if any)\
  18900. */
  18901. pickInfo: Nullable<PickingInfo>);
  18902. }
  18903. /**
  18904. * Data relating to a touch event on the screen.
  18905. */
  18906. export interface PointerTouch {
  18907. /**
  18908. * X coordinate of touch.
  18909. */
  18910. x: number;
  18911. /**
  18912. * Y coordinate of touch.
  18913. */
  18914. y: number;
  18915. /**
  18916. * Id of touch. Unique for each finger.
  18917. */
  18918. pointerId: number;
  18919. /**
  18920. * Event type passed from DOM.
  18921. */
  18922. type: any;
  18923. }
  18924. }
  18925. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18926. import { Observable } from "babylonjs/Misc/observable";
  18927. import { Nullable } from "babylonjs/types";
  18928. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18930. /**
  18931. * Manage the mouse inputs to control the movement of a free camera.
  18932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18933. */
  18934. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18935. /**
  18936. * Define if touch is enabled in the mouse input
  18937. */
  18938. touchEnabled: boolean;
  18939. /**
  18940. * Defines the camera the input is attached to.
  18941. */
  18942. camera: FreeCamera;
  18943. /**
  18944. * Defines the buttons associated with the input to handle camera move.
  18945. */
  18946. buttons: number[];
  18947. /**
  18948. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18949. */
  18950. angularSensibility: number;
  18951. private _pointerInput;
  18952. private _onMouseMove;
  18953. private _observer;
  18954. private previousPosition;
  18955. /**
  18956. * Observable for when a pointer move event occurs containing the move offset
  18957. */
  18958. onPointerMovedObservable: Observable<{
  18959. offsetX: number;
  18960. offsetY: number;
  18961. }>;
  18962. /**
  18963. * @hidden
  18964. * If the camera should be rotated automatically based on pointer movement
  18965. */
  18966. _allowCameraRotation: boolean;
  18967. /**
  18968. * Manage the mouse inputs to control the movement of a free camera.
  18969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18970. * @param touchEnabled Defines if touch is enabled or not
  18971. */
  18972. constructor(
  18973. /**
  18974. * Define if touch is enabled in the mouse input
  18975. */
  18976. touchEnabled?: boolean);
  18977. /**
  18978. * Attach the input controls to a specific dom element to get the input from.
  18979. * @param element Defines the element the controls should be listened from
  18980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18981. */
  18982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18983. /**
  18984. * Called on JS contextmenu event.
  18985. * Override this method to provide functionality.
  18986. */
  18987. protected onContextMenu(evt: PointerEvent): void;
  18988. /**
  18989. * Detach the current controls from the specified dom element.
  18990. * @param element Defines the element to stop listening the inputs from
  18991. */
  18992. detachControl(element: Nullable<HTMLElement>): void;
  18993. /**
  18994. * Gets the class name of the current intput.
  18995. * @returns the class name
  18996. */
  18997. getClassName(): string;
  18998. /**
  18999. * Get the friendly name associated with the input class.
  19000. * @returns the input friendly name
  19001. */
  19002. getSimpleName(): string;
  19003. }
  19004. }
  19005. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19006. import { Nullable } from "babylonjs/types";
  19007. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19009. /**
  19010. * Manage the touch inputs to control the movement of a free camera.
  19011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19012. */
  19013. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19014. /**
  19015. * Defines the camera the input is attached to.
  19016. */
  19017. camera: FreeCamera;
  19018. /**
  19019. * Defines the touch sensibility for rotation.
  19020. * The higher the faster.
  19021. */
  19022. touchAngularSensibility: number;
  19023. /**
  19024. * Defines the touch sensibility for move.
  19025. * The higher the faster.
  19026. */
  19027. touchMoveSensibility: number;
  19028. private _offsetX;
  19029. private _offsetY;
  19030. private _pointerPressed;
  19031. private _pointerInput;
  19032. private _observer;
  19033. private _onLostFocus;
  19034. /**
  19035. * Attach the input controls to a specific dom element to get the input from.
  19036. * @param element Defines the element the controls should be listened from
  19037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19038. */
  19039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19040. /**
  19041. * Detach the current controls from the specified dom element.
  19042. * @param element Defines the element to stop listening the inputs from
  19043. */
  19044. detachControl(element: Nullable<HTMLElement>): void;
  19045. /**
  19046. * Update the current camera state depending on the inputs that have been used this frame.
  19047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19048. */
  19049. checkInputs(): void;
  19050. /**
  19051. * Gets the class name of the current intput.
  19052. * @returns the class name
  19053. */
  19054. getClassName(): string;
  19055. /**
  19056. * Get the friendly name associated with the input class.
  19057. * @returns the input friendly name
  19058. */
  19059. getSimpleName(): string;
  19060. }
  19061. }
  19062. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19063. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19064. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19065. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19066. import { Nullable } from "babylonjs/types";
  19067. /**
  19068. * Default Inputs manager for the FreeCamera.
  19069. * It groups all the default supported inputs for ease of use.
  19070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19071. */
  19072. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19073. /**
  19074. * @hidden
  19075. */
  19076. _mouseInput: Nullable<FreeCameraMouseInput>;
  19077. /**
  19078. * Instantiates a new FreeCameraInputsManager.
  19079. * @param camera Defines the camera the inputs belong to
  19080. */
  19081. constructor(camera: FreeCamera);
  19082. /**
  19083. * Add keyboard input support to the input manager.
  19084. * @returns the current input manager
  19085. */
  19086. addKeyboard(): FreeCameraInputsManager;
  19087. /**
  19088. * Add mouse input support to the input manager.
  19089. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19090. * @returns the current input manager
  19091. */
  19092. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19093. /**
  19094. * Removes the mouse input support from the manager
  19095. * @returns the current input manager
  19096. */
  19097. removeMouse(): FreeCameraInputsManager;
  19098. /**
  19099. * Add touch input support to the input manager.
  19100. * @returns the current input manager
  19101. */
  19102. addTouch(): FreeCameraInputsManager;
  19103. /**
  19104. * Remove all attached input methods from a camera
  19105. */
  19106. clear(): void;
  19107. }
  19108. }
  19109. declare module "babylonjs/Cameras/freeCamera" {
  19110. import { Vector3 } from "babylonjs/Maths/math.vector";
  19111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19112. import { Scene } from "babylonjs/scene";
  19113. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19114. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19115. /**
  19116. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19117. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19118. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19119. */
  19120. export class FreeCamera extends TargetCamera {
  19121. /**
  19122. * Define the collision ellipsoid of the camera.
  19123. * This is helpful to simulate a camera body like the player body around the camera
  19124. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19125. */
  19126. ellipsoid: Vector3;
  19127. /**
  19128. * Define an offset for the position of the ellipsoid around the camera.
  19129. * This can be helpful to determine the center of the body near the gravity center of the body
  19130. * instead of its head.
  19131. */
  19132. ellipsoidOffset: Vector3;
  19133. /**
  19134. * Enable or disable collisions of the camera with the rest of the scene objects.
  19135. */
  19136. checkCollisions: boolean;
  19137. /**
  19138. * Enable or disable gravity on the camera.
  19139. */
  19140. applyGravity: boolean;
  19141. /**
  19142. * Define the input manager associated to the camera.
  19143. */
  19144. inputs: FreeCameraInputsManager;
  19145. /**
  19146. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19147. * Higher values reduce sensitivity.
  19148. */
  19149. get angularSensibility(): number;
  19150. /**
  19151. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19152. * Higher values reduce sensitivity.
  19153. */
  19154. set angularSensibility(value: number);
  19155. /**
  19156. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19157. */
  19158. get keysUp(): number[];
  19159. set keysUp(value: number[]);
  19160. /**
  19161. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19162. */
  19163. get keysUpward(): number[];
  19164. set keysUpward(value: number[]);
  19165. /**
  19166. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19167. */
  19168. get keysDown(): number[];
  19169. set keysDown(value: number[]);
  19170. /**
  19171. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19172. */
  19173. get keysDownward(): number[];
  19174. set keysDownward(value: number[]);
  19175. /**
  19176. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19177. */
  19178. get keysLeft(): number[];
  19179. set keysLeft(value: number[]);
  19180. /**
  19181. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19182. */
  19183. get keysRight(): number[];
  19184. set keysRight(value: number[]);
  19185. /**
  19186. * Event raised when the camera collide with a mesh in the scene.
  19187. */
  19188. onCollide: (collidedMesh: AbstractMesh) => void;
  19189. private _collider;
  19190. private _needMoveForGravity;
  19191. private _oldPosition;
  19192. private _diffPosition;
  19193. private _newPosition;
  19194. /** @hidden */
  19195. _localDirection: Vector3;
  19196. /** @hidden */
  19197. _transformedDirection: Vector3;
  19198. /**
  19199. * Instantiates a Free Camera.
  19200. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19201. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19203. * @param name Define the name of the camera in the scene
  19204. * @param position Define the start position of the camera in the scene
  19205. * @param scene Define the scene the camera belongs to
  19206. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19207. */
  19208. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19209. /**
  19210. * Attached controls to the current camera.
  19211. * @param element Defines the element the controls should be listened from
  19212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19213. */
  19214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19215. /**
  19216. * Detach the current controls from the camera.
  19217. * The camera will stop reacting to inputs.
  19218. * @param element Defines the element to stop listening the inputs from
  19219. */
  19220. detachControl(element: HTMLElement): void;
  19221. private _collisionMask;
  19222. /**
  19223. * Define a collision mask to limit the list of object the camera can collide with
  19224. */
  19225. get collisionMask(): number;
  19226. set collisionMask(mask: number);
  19227. /** @hidden */
  19228. _collideWithWorld(displacement: Vector3): void;
  19229. private _onCollisionPositionChange;
  19230. /** @hidden */
  19231. _checkInputs(): void;
  19232. /** @hidden */
  19233. _decideIfNeedsToMove(): boolean;
  19234. /** @hidden */
  19235. _updatePosition(): void;
  19236. /**
  19237. * Destroy the camera and release the current resources hold by it.
  19238. */
  19239. dispose(): void;
  19240. /**
  19241. * Gets the current object class name.
  19242. * @return the class name
  19243. */
  19244. getClassName(): string;
  19245. }
  19246. }
  19247. declare module "babylonjs/Gamepads/gamepad" {
  19248. import { Observable } from "babylonjs/Misc/observable";
  19249. /**
  19250. * Represents a gamepad control stick position
  19251. */
  19252. export class StickValues {
  19253. /**
  19254. * The x component of the control stick
  19255. */
  19256. x: number;
  19257. /**
  19258. * The y component of the control stick
  19259. */
  19260. y: number;
  19261. /**
  19262. * Initializes the gamepad x and y control stick values
  19263. * @param x The x component of the gamepad control stick value
  19264. * @param y The y component of the gamepad control stick value
  19265. */
  19266. constructor(
  19267. /**
  19268. * The x component of the control stick
  19269. */
  19270. x: number,
  19271. /**
  19272. * The y component of the control stick
  19273. */
  19274. y: number);
  19275. }
  19276. /**
  19277. * An interface which manages callbacks for gamepad button changes
  19278. */
  19279. export interface GamepadButtonChanges {
  19280. /**
  19281. * Called when a gamepad has been changed
  19282. */
  19283. changed: boolean;
  19284. /**
  19285. * Called when a gamepad press event has been triggered
  19286. */
  19287. pressChanged: boolean;
  19288. /**
  19289. * Called when a touch event has been triggered
  19290. */
  19291. touchChanged: boolean;
  19292. /**
  19293. * Called when a value has changed
  19294. */
  19295. valueChanged: boolean;
  19296. }
  19297. /**
  19298. * Represents a gamepad
  19299. */
  19300. export class Gamepad {
  19301. /**
  19302. * The id of the gamepad
  19303. */
  19304. id: string;
  19305. /**
  19306. * The index of the gamepad
  19307. */
  19308. index: number;
  19309. /**
  19310. * The browser gamepad
  19311. */
  19312. browserGamepad: any;
  19313. /**
  19314. * Specifies what type of gamepad this represents
  19315. */
  19316. type: number;
  19317. private _leftStick;
  19318. private _rightStick;
  19319. /** @hidden */
  19320. _isConnected: boolean;
  19321. private _leftStickAxisX;
  19322. private _leftStickAxisY;
  19323. private _rightStickAxisX;
  19324. private _rightStickAxisY;
  19325. /**
  19326. * Triggered when the left control stick has been changed
  19327. */
  19328. private _onleftstickchanged;
  19329. /**
  19330. * Triggered when the right control stick has been changed
  19331. */
  19332. private _onrightstickchanged;
  19333. /**
  19334. * Represents a gamepad controller
  19335. */
  19336. static GAMEPAD: number;
  19337. /**
  19338. * Represents a generic controller
  19339. */
  19340. static GENERIC: number;
  19341. /**
  19342. * Represents an XBox controller
  19343. */
  19344. static XBOX: number;
  19345. /**
  19346. * Represents a pose-enabled controller
  19347. */
  19348. static POSE_ENABLED: number;
  19349. /**
  19350. * Represents an Dual Shock controller
  19351. */
  19352. static DUALSHOCK: number;
  19353. /**
  19354. * Specifies whether the left control stick should be Y-inverted
  19355. */
  19356. protected _invertLeftStickY: boolean;
  19357. /**
  19358. * Specifies if the gamepad has been connected
  19359. */
  19360. get isConnected(): boolean;
  19361. /**
  19362. * Initializes the gamepad
  19363. * @param id The id of the gamepad
  19364. * @param index The index of the gamepad
  19365. * @param browserGamepad The browser gamepad
  19366. * @param leftStickX The x component of the left joystick
  19367. * @param leftStickY The y component of the left joystick
  19368. * @param rightStickX The x component of the right joystick
  19369. * @param rightStickY The y component of the right joystick
  19370. */
  19371. constructor(
  19372. /**
  19373. * The id of the gamepad
  19374. */
  19375. id: string,
  19376. /**
  19377. * The index of the gamepad
  19378. */
  19379. index: number,
  19380. /**
  19381. * The browser gamepad
  19382. */
  19383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19384. /**
  19385. * Callback triggered when the left joystick has changed
  19386. * @param callback
  19387. */
  19388. onleftstickchanged(callback: (values: StickValues) => void): void;
  19389. /**
  19390. * Callback triggered when the right joystick has changed
  19391. * @param callback
  19392. */
  19393. onrightstickchanged(callback: (values: StickValues) => void): void;
  19394. /**
  19395. * Gets the left joystick
  19396. */
  19397. get leftStick(): StickValues;
  19398. /**
  19399. * Sets the left joystick values
  19400. */
  19401. set leftStick(newValues: StickValues);
  19402. /**
  19403. * Gets the right joystick
  19404. */
  19405. get rightStick(): StickValues;
  19406. /**
  19407. * Sets the right joystick value
  19408. */
  19409. set rightStick(newValues: StickValues);
  19410. /**
  19411. * Updates the gamepad joystick positions
  19412. */
  19413. update(): void;
  19414. /**
  19415. * Disposes the gamepad
  19416. */
  19417. dispose(): void;
  19418. }
  19419. /**
  19420. * Represents a generic gamepad
  19421. */
  19422. export class GenericPad extends Gamepad {
  19423. private _buttons;
  19424. private _onbuttondown;
  19425. private _onbuttonup;
  19426. /**
  19427. * Observable triggered when a button has been pressed
  19428. */
  19429. onButtonDownObservable: Observable<number>;
  19430. /**
  19431. * Observable triggered when a button has been released
  19432. */
  19433. onButtonUpObservable: Observable<number>;
  19434. /**
  19435. * Callback triggered when a button has been pressed
  19436. * @param callback Called when a button has been pressed
  19437. */
  19438. onbuttondown(callback: (buttonPressed: number) => void): void;
  19439. /**
  19440. * Callback triggered when a button has been released
  19441. * @param callback Called when a button has been released
  19442. */
  19443. onbuttonup(callback: (buttonReleased: number) => void): void;
  19444. /**
  19445. * Initializes the generic gamepad
  19446. * @param id The id of the generic gamepad
  19447. * @param index The index of the generic gamepad
  19448. * @param browserGamepad The browser gamepad
  19449. */
  19450. constructor(id: string, index: number, browserGamepad: any);
  19451. private _setButtonValue;
  19452. /**
  19453. * Updates the generic gamepad
  19454. */
  19455. update(): void;
  19456. /**
  19457. * Disposes the generic gamepad
  19458. */
  19459. dispose(): void;
  19460. }
  19461. }
  19462. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19463. import { Observable } from "babylonjs/Misc/observable";
  19464. import { Nullable } from "babylonjs/types";
  19465. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19468. import { Ray } from "babylonjs/Culling/ray";
  19469. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19470. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19471. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19472. /**
  19473. * Defines the types of pose enabled controllers that are supported
  19474. */
  19475. export enum PoseEnabledControllerType {
  19476. /**
  19477. * HTC Vive
  19478. */
  19479. VIVE = 0,
  19480. /**
  19481. * Oculus Rift
  19482. */
  19483. OCULUS = 1,
  19484. /**
  19485. * Windows mixed reality
  19486. */
  19487. WINDOWS = 2,
  19488. /**
  19489. * Samsung gear VR
  19490. */
  19491. GEAR_VR = 3,
  19492. /**
  19493. * Google Daydream
  19494. */
  19495. DAYDREAM = 4,
  19496. /**
  19497. * Generic
  19498. */
  19499. GENERIC = 5
  19500. }
  19501. /**
  19502. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19503. */
  19504. export interface MutableGamepadButton {
  19505. /**
  19506. * Value of the button/trigger
  19507. */
  19508. value: number;
  19509. /**
  19510. * If the button/trigger is currently touched
  19511. */
  19512. touched: boolean;
  19513. /**
  19514. * If the button/trigger is currently pressed
  19515. */
  19516. pressed: boolean;
  19517. }
  19518. /**
  19519. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19520. * @hidden
  19521. */
  19522. export interface ExtendedGamepadButton extends GamepadButton {
  19523. /**
  19524. * If the button/trigger is currently pressed
  19525. */
  19526. readonly pressed: boolean;
  19527. /**
  19528. * If the button/trigger is currently touched
  19529. */
  19530. readonly touched: boolean;
  19531. /**
  19532. * Value of the button/trigger
  19533. */
  19534. readonly value: number;
  19535. }
  19536. /** @hidden */
  19537. export interface _GamePadFactory {
  19538. /**
  19539. * Returns whether or not the current gamepad can be created for this type of controller.
  19540. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19541. * @returns true if it can be created, otherwise false
  19542. */
  19543. canCreate(gamepadInfo: any): boolean;
  19544. /**
  19545. * Creates a new instance of the Gamepad.
  19546. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19547. * @returns the new gamepad instance
  19548. */
  19549. create(gamepadInfo: any): Gamepad;
  19550. }
  19551. /**
  19552. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19553. */
  19554. export class PoseEnabledControllerHelper {
  19555. /** @hidden */
  19556. static _ControllerFactories: _GamePadFactory[];
  19557. /** @hidden */
  19558. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19559. /**
  19560. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19561. * @param vrGamepad the gamepad to initialized
  19562. * @returns a vr controller of the type the gamepad identified as
  19563. */
  19564. static InitiateController(vrGamepad: any): Gamepad;
  19565. }
  19566. /**
  19567. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19568. */
  19569. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19570. /**
  19571. * If the controller is used in a webXR session
  19572. */
  19573. isXR: boolean;
  19574. private _deviceRoomPosition;
  19575. private _deviceRoomRotationQuaternion;
  19576. /**
  19577. * The device position in babylon space
  19578. */
  19579. devicePosition: Vector3;
  19580. /**
  19581. * The device rotation in babylon space
  19582. */
  19583. deviceRotationQuaternion: Quaternion;
  19584. /**
  19585. * The scale factor of the device in babylon space
  19586. */
  19587. deviceScaleFactor: number;
  19588. /**
  19589. * (Likely devicePosition should be used instead) The device position in its room space
  19590. */
  19591. position: Vector3;
  19592. /**
  19593. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19594. */
  19595. rotationQuaternion: Quaternion;
  19596. /**
  19597. * The type of controller (Eg. Windows mixed reality)
  19598. */
  19599. controllerType: PoseEnabledControllerType;
  19600. protected _calculatedPosition: Vector3;
  19601. private _calculatedRotation;
  19602. /**
  19603. * The raw pose from the device
  19604. */
  19605. rawPose: DevicePose;
  19606. private _trackPosition;
  19607. private _maxRotationDistFromHeadset;
  19608. private _draggedRoomRotation;
  19609. /**
  19610. * @hidden
  19611. */
  19612. _disableTrackPosition(fixedPosition: Vector3): void;
  19613. /**
  19614. * Internal, the mesh attached to the controller
  19615. * @hidden
  19616. */
  19617. _mesh: Nullable<AbstractMesh>;
  19618. private _poseControlledCamera;
  19619. private _leftHandSystemQuaternion;
  19620. /**
  19621. * Internal, matrix used to convert room space to babylon space
  19622. * @hidden
  19623. */
  19624. _deviceToWorld: Matrix;
  19625. /**
  19626. * Node to be used when casting a ray from the controller
  19627. * @hidden
  19628. */
  19629. _pointingPoseNode: Nullable<TransformNode>;
  19630. /**
  19631. * Name of the child mesh that can be used to cast a ray from the controller
  19632. */
  19633. static readonly POINTING_POSE: string;
  19634. /**
  19635. * Creates a new PoseEnabledController from a gamepad
  19636. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19637. */
  19638. constructor(browserGamepad: any);
  19639. private _workingMatrix;
  19640. /**
  19641. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19642. */
  19643. update(): void;
  19644. /**
  19645. * Updates only the pose device and mesh without doing any button event checking
  19646. */
  19647. protected _updatePoseAndMesh(): void;
  19648. /**
  19649. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19650. * @param poseData raw pose fromthe device
  19651. */
  19652. updateFromDevice(poseData: DevicePose): void;
  19653. /**
  19654. * @hidden
  19655. */
  19656. _meshAttachedObservable: Observable<AbstractMesh>;
  19657. /**
  19658. * Attaches a mesh to the controller
  19659. * @param mesh the mesh to be attached
  19660. */
  19661. attachToMesh(mesh: AbstractMesh): void;
  19662. /**
  19663. * Attaches the controllers mesh to a camera
  19664. * @param camera the camera the mesh should be attached to
  19665. */
  19666. attachToPoseControlledCamera(camera: TargetCamera): void;
  19667. /**
  19668. * Disposes of the controller
  19669. */
  19670. dispose(): void;
  19671. /**
  19672. * The mesh that is attached to the controller
  19673. */
  19674. get mesh(): Nullable<AbstractMesh>;
  19675. /**
  19676. * Gets the ray of the controller in the direction the controller is pointing
  19677. * @param length the length the resulting ray should be
  19678. * @returns a ray in the direction the controller is pointing
  19679. */
  19680. getForwardRay(length?: number): Ray;
  19681. }
  19682. }
  19683. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19684. import { Observable } from "babylonjs/Misc/observable";
  19685. import { Scene } from "babylonjs/scene";
  19686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19687. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19688. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19689. import { Nullable } from "babylonjs/types";
  19690. /**
  19691. * Defines the WebVRController object that represents controllers tracked in 3D space
  19692. */
  19693. export abstract class WebVRController extends PoseEnabledController {
  19694. /**
  19695. * Internal, the default controller model for the controller
  19696. */
  19697. protected _defaultModel: Nullable<AbstractMesh>;
  19698. /**
  19699. * Fired when the trigger state has changed
  19700. */
  19701. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19702. /**
  19703. * Fired when the main button state has changed
  19704. */
  19705. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19706. /**
  19707. * Fired when the secondary button state has changed
  19708. */
  19709. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19710. /**
  19711. * Fired when the pad state has changed
  19712. */
  19713. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19714. /**
  19715. * Fired when controllers stick values have changed
  19716. */
  19717. onPadValuesChangedObservable: Observable<StickValues>;
  19718. /**
  19719. * Array of button availible on the controller
  19720. */
  19721. protected _buttons: Array<MutableGamepadButton>;
  19722. private _onButtonStateChange;
  19723. /**
  19724. * Fired when a controller button's state has changed
  19725. * @param callback the callback containing the button that was modified
  19726. */
  19727. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19728. /**
  19729. * X and Y axis corresponding to the controllers joystick
  19730. */
  19731. pad: StickValues;
  19732. /**
  19733. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19734. */
  19735. hand: string;
  19736. /**
  19737. * The default controller model for the controller
  19738. */
  19739. get defaultModel(): Nullable<AbstractMesh>;
  19740. /**
  19741. * Creates a new WebVRController from a gamepad
  19742. * @param vrGamepad the gamepad that the WebVRController should be created from
  19743. */
  19744. constructor(vrGamepad: any);
  19745. /**
  19746. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Function to be called when a button is modified
  19751. */
  19752. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19753. /**
  19754. * Loads a mesh and attaches it to the controller
  19755. * @param scene the scene the mesh should be added to
  19756. * @param meshLoaded callback for when the mesh has been loaded
  19757. */
  19758. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19759. private _setButtonValue;
  19760. private _changes;
  19761. private _checkChanges;
  19762. /**
  19763. * Disposes of th webVRCOntroller
  19764. */
  19765. dispose(): void;
  19766. }
  19767. }
  19768. declare module "babylonjs/Lights/hemisphericLight" {
  19769. import { Nullable } from "babylonjs/types";
  19770. import { Scene } from "babylonjs/scene";
  19771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19772. import { Color3 } from "babylonjs/Maths/math.color";
  19773. import { Effect } from "babylonjs/Materials/effect";
  19774. import { Light } from "babylonjs/Lights/light";
  19775. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19776. /**
  19777. * The HemisphericLight simulates the ambient environment light,
  19778. * so the passed direction is the light reflection direction, not the incoming direction.
  19779. */
  19780. export class HemisphericLight extends Light {
  19781. /**
  19782. * The groundColor is the light in the opposite direction to the one specified during creation.
  19783. * 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.
  19784. */
  19785. groundColor: Color3;
  19786. /**
  19787. * The light reflection direction, not the incoming direction.
  19788. */
  19789. direction: Vector3;
  19790. /**
  19791. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19792. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19793. * The HemisphericLight can't cast shadows.
  19794. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19795. * @param name The friendly name of the light
  19796. * @param direction The direction of the light reflection
  19797. * @param scene The scene the light belongs to
  19798. */
  19799. constructor(name: string, direction: Vector3, scene: Scene);
  19800. protected _buildUniformLayout(): void;
  19801. /**
  19802. * Returns the string "HemisphericLight".
  19803. * @return The class name
  19804. */
  19805. getClassName(): string;
  19806. /**
  19807. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19808. * Returns the updated direction.
  19809. * @param target The target the direction should point to
  19810. * @return The computed direction
  19811. */
  19812. setDirectionToTarget(target: Vector3): Vector3;
  19813. /**
  19814. * Returns the shadow generator associated to the light.
  19815. * @returns Always null for hemispheric lights because it does not support shadows.
  19816. */
  19817. getShadowGenerator(): Nullable<IShadowGenerator>;
  19818. /**
  19819. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19820. * @param effect The effect to update
  19821. * @param lightIndex The index of the light in the effect to update
  19822. * @returns The hemispheric light
  19823. */
  19824. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19825. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19826. /**
  19827. * Computes the world matrix of the node
  19828. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19829. * @param useWasUpdatedFlag defines a reserved property
  19830. * @returns the world matrix
  19831. */
  19832. computeWorldMatrix(): Matrix;
  19833. /**
  19834. * Returns the integer 3.
  19835. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19836. */
  19837. getTypeID(): number;
  19838. /**
  19839. * Prepares the list of defines specific to the light type.
  19840. * @param defines the list of defines
  19841. * @param lightIndex defines the index of the light for the effect
  19842. */
  19843. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19844. }
  19845. }
  19846. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19847. /** @hidden */
  19848. export var vrMultiviewToSingleviewPixelShader: {
  19849. name: string;
  19850. shader: string;
  19851. };
  19852. }
  19853. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19855. import { Scene } from "babylonjs/scene";
  19856. /**
  19857. * Renders to multiple views with a single draw call
  19858. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19859. */
  19860. export class MultiviewRenderTarget extends RenderTargetTexture {
  19861. /**
  19862. * Creates a multiview render target
  19863. * @param scene scene used with the render target
  19864. * @param size the size of the render target (used for each view)
  19865. */
  19866. constructor(scene: Scene, size?: number | {
  19867. width: number;
  19868. height: number;
  19869. } | {
  19870. ratio: number;
  19871. });
  19872. /**
  19873. * @hidden
  19874. * @param faceIndex the face index, if its a cube texture
  19875. */
  19876. _bindFrameBuffer(faceIndex?: number): void;
  19877. /**
  19878. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19879. * @returns the view count
  19880. */
  19881. getViewCount(): number;
  19882. }
  19883. }
  19884. declare module "babylonjs/Maths/math.frustum" {
  19885. import { Matrix } from "babylonjs/Maths/math.vector";
  19886. import { DeepImmutable } from "babylonjs/types";
  19887. import { Plane } from "babylonjs/Maths/math.plane";
  19888. /**
  19889. * Represents a camera frustum
  19890. */
  19891. export class Frustum {
  19892. /**
  19893. * Gets the planes representing the frustum
  19894. * @param transform matrix to be applied to the returned planes
  19895. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19896. */
  19897. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19898. /**
  19899. * Gets the near frustum plane transformed by the transform matrix
  19900. * @param transform transformation matrix to be applied to the resulting frustum plane
  19901. * @param frustumPlane the resuling frustum plane
  19902. */
  19903. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19904. /**
  19905. * Gets the far frustum plane transformed by the transform matrix
  19906. * @param transform transformation matrix to be applied to the resulting frustum plane
  19907. * @param frustumPlane the resuling frustum plane
  19908. */
  19909. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19910. /**
  19911. * Gets the left frustum plane transformed by the transform matrix
  19912. * @param transform transformation matrix to be applied to the resulting frustum plane
  19913. * @param frustumPlane the resuling frustum plane
  19914. */
  19915. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19916. /**
  19917. * Gets the right frustum plane transformed by the transform matrix
  19918. * @param transform transformation matrix to be applied to the resulting frustum plane
  19919. * @param frustumPlane the resuling frustum plane
  19920. */
  19921. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19922. /**
  19923. * Gets the top frustum plane transformed by the transform matrix
  19924. * @param transform transformation matrix to be applied to the resulting frustum plane
  19925. * @param frustumPlane the resuling frustum plane
  19926. */
  19927. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19928. /**
  19929. * Gets the bottom frustum plane transformed by the transform matrix
  19930. * @param transform transformation matrix to be applied to the resulting frustum plane
  19931. * @param frustumPlane the resuling frustum plane
  19932. */
  19933. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19934. /**
  19935. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19936. * @param transform transformation matrix to be applied to the resulting frustum planes
  19937. * @param frustumPlanes the resuling frustum planes
  19938. */
  19939. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19940. }
  19941. }
  19942. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19943. import { Camera } from "babylonjs/Cameras/camera";
  19944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19945. import { Nullable } from "babylonjs/types";
  19946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19947. import { Matrix } from "babylonjs/Maths/math.vector";
  19948. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19949. module "babylonjs/Engines/engine" {
  19950. interface Engine {
  19951. /**
  19952. * Creates a new multiview render target
  19953. * @param width defines the width of the texture
  19954. * @param height defines the height of the texture
  19955. * @returns the created multiview texture
  19956. */
  19957. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19958. /**
  19959. * Binds a multiview framebuffer to be drawn to
  19960. * @param multiviewTexture texture to bind
  19961. */
  19962. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19963. }
  19964. }
  19965. module "babylonjs/Cameras/camera" {
  19966. interface Camera {
  19967. /**
  19968. * @hidden
  19969. * 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)
  19970. */
  19971. _useMultiviewToSingleView: boolean;
  19972. /**
  19973. * @hidden
  19974. * 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)
  19975. */
  19976. _multiviewTexture: Nullable<RenderTargetTexture>;
  19977. /**
  19978. * @hidden
  19979. * ensures the multiview texture of the camera exists and has the specified width/height
  19980. * @param width height to set on the multiview texture
  19981. * @param height width to set on the multiview texture
  19982. */
  19983. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19984. }
  19985. }
  19986. module "babylonjs/scene" {
  19987. interface Scene {
  19988. /** @hidden */
  19989. _transformMatrixR: Matrix;
  19990. /** @hidden */
  19991. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19992. /** @hidden */
  19993. _createMultiviewUbo(): void;
  19994. /** @hidden */
  19995. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19996. /** @hidden */
  19997. _renderMultiviewToSingleView(camera: Camera): void;
  19998. }
  19999. }
  20000. }
  20001. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20002. import { Camera } from "babylonjs/Cameras/camera";
  20003. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20004. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20005. import "babylonjs/Engines/Extensions/engine.multiview";
  20006. /**
  20007. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20008. * This will not be used for webXR as it supports displaying texture arrays directly
  20009. */
  20010. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20011. /**
  20012. * Initializes a VRMultiviewToSingleview
  20013. * @param name name of the post process
  20014. * @param camera camera to be applied to
  20015. * @param scaleFactor scaling factor to the size of the output texture
  20016. */
  20017. constructor(name: string, camera: Camera, scaleFactor: number);
  20018. }
  20019. }
  20020. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20021. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20022. import { Nullable } from "babylonjs/types";
  20023. import { Size } from "babylonjs/Maths/math.size";
  20024. import { Observable } from "babylonjs/Misc/observable";
  20025. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20026. /**
  20027. * Interface used to define additional presentation attributes
  20028. */
  20029. export interface IVRPresentationAttributes {
  20030. /**
  20031. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20032. */
  20033. highRefreshRate: boolean;
  20034. /**
  20035. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20036. */
  20037. foveationLevel: number;
  20038. }
  20039. module "babylonjs/Engines/engine" {
  20040. interface Engine {
  20041. /** @hidden */
  20042. _vrDisplay: any;
  20043. /** @hidden */
  20044. _vrSupported: boolean;
  20045. /** @hidden */
  20046. _oldSize: Size;
  20047. /** @hidden */
  20048. _oldHardwareScaleFactor: number;
  20049. /** @hidden */
  20050. _vrExclusivePointerMode: boolean;
  20051. /** @hidden */
  20052. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20053. /** @hidden */
  20054. _onVRDisplayPointerRestricted: () => void;
  20055. /** @hidden */
  20056. _onVRDisplayPointerUnrestricted: () => void;
  20057. /** @hidden */
  20058. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20059. /** @hidden */
  20060. _onVrDisplayDisconnect: Nullable<() => void>;
  20061. /** @hidden */
  20062. _onVrDisplayPresentChange: Nullable<() => void>;
  20063. /**
  20064. * Observable signaled when VR display mode changes
  20065. */
  20066. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20067. /**
  20068. * Observable signaled when VR request present is complete
  20069. */
  20070. onVRRequestPresentComplete: Observable<boolean>;
  20071. /**
  20072. * Observable signaled when VR request present starts
  20073. */
  20074. onVRRequestPresentStart: Observable<Engine>;
  20075. /**
  20076. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20077. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20078. */
  20079. isInVRExclusivePointerMode: boolean;
  20080. /**
  20081. * Gets a boolean indicating if a webVR device was detected
  20082. * @returns true if a webVR device was detected
  20083. */
  20084. isVRDevicePresent(): boolean;
  20085. /**
  20086. * Gets the current webVR device
  20087. * @returns the current webVR device (or null)
  20088. */
  20089. getVRDevice(): any;
  20090. /**
  20091. * Initializes a webVR display and starts listening to display change events
  20092. * The onVRDisplayChangedObservable will be notified upon these changes
  20093. * @returns A promise containing a VRDisplay and if vr is supported
  20094. */
  20095. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20096. /** @hidden */
  20097. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20098. /**
  20099. * Gets or sets the presentation attributes used to configure VR rendering
  20100. */
  20101. vrPresentationAttributes?: IVRPresentationAttributes;
  20102. /**
  20103. * Call this function to switch to webVR mode
  20104. * Will do nothing if webVR is not supported or if there is no webVR device
  20105. * @param options the webvr options provided to the camera. mainly used for multiview
  20106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20107. */
  20108. enableVR(options: WebVROptions): void;
  20109. /** @hidden */
  20110. _onVRFullScreenTriggered(): void;
  20111. }
  20112. }
  20113. }
  20114. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20115. import { Nullable } from "babylonjs/types";
  20116. import { Observable } from "babylonjs/Misc/observable";
  20117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20118. import { Scene } from "babylonjs/scene";
  20119. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20121. import { Node } from "babylonjs/node";
  20122. import { Ray } from "babylonjs/Culling/ray";
  20123. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20124. import "babylonjs/Engines/Extensions/engine.webVR";
  20125. /**
  20126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20127. * IMPORTANT!! The data is right-hand data.
  20128. * @export
  20129. * @interface DevicePose
  20130. */
  20131. export interface DevicePose {
  20132. /**
  20133. * The position of the device, values in array are [x,y,z].
  20134. */
  20135. readonly position: Nullable<Float32Array>;
  20136. /**
  20137. * The linearVelocity of the device, values in array are [x,y,z].
  20138. */
  20139. readonly linearVelocity: Nullable<Float32Array>;
  20140. /**
  20141. * The linearAcceleration of the device, values in array are [x,y,z].
  20142. */
  20143. readonly linearAcceleration: Nullable<Float32Array>;
  20144. /**
  20145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20146. */
  20147. readonly orientation: Nullable<Float32Array>;
  20148. /**
  20149. * The angularVelocity of the device, values in array are [x,y,z].
  20150. */
  20151. readonly angularVelocity: Nullable<Float32Array>;
  20152. /**
  20153. * The angularAcceleration of the device, values in array are [x,y,z].
  20154. */
  20155. readonly angularAcceleration: Nullable<Float32Array>;
  20156. }
  20157. /**
  20158. * Interface representing a pose controlled object in Babylon.
  20159. * A pose controlled object has both regular pose values as well as pose values
  20160. * from an external device such as a VR head mounted display
  20161. */
  20162. export interface PoseControlled {
  20163. /**
  20164. * The position of the object in babylon space.
  20165. */
  20166. position: Vector3;
  20167. /**
  20168. * The rotation quaternion of the object in babylon space.
  20169. */
  20170. rotationQuaternion: Quaternion;
  20171. /**
  20172. * The position of the device in babylon space.
  20173. */
  20174. devicePosition?: Vector3;
  20175. /**
  20176. * The rotation quaternion of the device in babylon space.
  20177. */
  20178. deviceRotationQuaternion: Quaternion;
  20179. /**
  20180. * The raw pose coming from the device.
  20181. */
  20182. rawPose: Nullable<DevicePose>;
  20183. /**
  20184. * The scale of the device to be used when translating from device space to babylon space.
  20185. */
  20186. deviceScaleFactor: number;
  20187. /**
  20188. * Updates the poseControlled values based on the input device pose.
  20189. * @param poseData the pose data to update the object with
  20190. */
  20191. updateFromDevice(poseData: DevicePose): void;
  20192. }
  20193. /**
  20194. * Set of options to customize the webVRCamera
  20195. */
  20196. export interface WebVROptions {
  20197. /**
  20198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20199. */
  20200. trackPosition?: boolean;
  20201. /**
  20202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20203. */
  20204. positionScale?: number;
  20205. /**
  20206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20207. */
  20208. displayName?: string;
  20209. /**
  20210. * Should the native controller meshes be initialized. (default: true)
  20211. */
  20212. controllerMeshes?: boolean;
  20213. /**
  20214. * Creating a default HemiLight only on controllers. (default: true)
  20215. */
  20216. defaultLightingOnControllers?: boolean;
  20217. /**
  20218. * If you don't want to use the default VR button of the helper. (default: false)
  20219. */
  20220. useCustomVRButton?: boolean;
  20221. /**
  20222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20223. */
  20224. customVRButton?: HTMLButtonElement;
  20225. /**
  20226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20227. */
  20228. rayLength?: number;
  20229. /**
  20230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20231. */
  20232. defaultHeight?: number;
  20233. /**
  20234. * If multiview should be used if availible (default: false)
  20235. */
  20236. useMultiview?: boolean;
  20237. }
  20238. /**
  20239. * This represents a WebVR camera.
  20240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20241. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20242. */
  20243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20244. private webVROptions;
  20245. /**
  20246. * @hidden
  20247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20248. */
  20249. _vrDevice: any;
  20250. /**
  20251. * The rawPose of the vrDevice.
  20252. */
  20253. rawPose: Nullable<DevicePose>;
  20254. private _onVREnabled;
  20255. private _specsVersion;
  20256. private _attached;
  20257. private _frameData;
  20258. protected _descendants: Array<Node>;
  20259. private _deviceRoomPosition;
  20260. /** @hidden */
  20261. _deviceRoomRotationQuaternion: Quaternion;
  20262. private _standingMatrix;
  20263. /**
  20264. * Represents device position in babylon space.
  20265. */
  20266. devicePosition: Vector3;
  20267. /**
  20268. * Represents device rotation in babylon space.
  20269. */
  20270. deviceRotationQuaternion: Quaternion;
  20271. /**
  20272. * The scale of the device to be used when translating from device space to babylon space.
  20273. */
  20274. deviceScaleFactor: number;
  20275. private _deviceToWorld;
  20276. private _worldToDevice;
  20277. /**
  20278. * References to the webVR controllers for the vrDevice.
  20279. */
  20280. controllers: Array<WebVRController>;
  20281. /**
  20282. * Emits an event when a controller is attached.
  20283. */
  20284. onControllersAttachedObservable: Observable<WebVRController[]>;
  20285. /**
  20286. * Emits an event when a controller's mesh has been loaded;
  20287. */
  20288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20289. /**
  20290. * Emits an event when the HMD's pose has been updated.
  20291. */
  20292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20293. private _poseSet;
  20294. /**
  20295. * If the rig cameras be used as parent instead of this camera.
  20296. */
  20297. rigParenting: boolean;
  20298. private _lightOnControllers;
  20299. private _defaultHeight?;
  20300. /**
  20301. * Instantiates a WebVRFreeCamera.
  20302. * @param name The name of the WebVRFreeCamera
  20303. * @param position The starting anchor position for the camera
  20304. * @param scene The scene the camera belongs to
  20305. * @param webVROptions a set of customizable options for the webVRCamera
  20306. */
  20307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20308. /**
  20309. * Gets the device distance from the ground in meters.
  20310. * @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.
  20311. */
  20312. deviceDistanceToRoomGround(): number;
  20313. /**
  20314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20316. */
  20317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20318. /**
  20319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20320. * @returns A promise with a boolean set to if the standing matrix is supported.
  20321. */
  20322. useStandingMatrixAsync(): Promise<boolean>;
  20323. /**
  20324. * Disposes the camera
  20325. */
  20326. dispose(): void;
  20327. /**
  20328. * Gets a vrController by name.
  20329. * @param name The name of the controller to retreive
  20330. * @returns the controller matching the name specified or null if not found
  20331. */
  20332. getControllerByName(name: string): Nullable<WebVRController>;
  20333. private _leftController;
  20334. /**
  20335. * The controller corresponding to the users left hand.
  20336. */
  20337. get leftController(): Nullable<WebVRController>;
  20338. private _rightController;
  20339. /**
  20340. * The controller corresponding to the users right hand.
  20341. */
  20342. get rightController(): Nullable<WebVRController>;
  20343. /**
  20344. * Casts a ray forward from the vrCamera's gaze.
  20345. * @param length Length of the ray (default: 100)
  20346. * @returns the ray corresponding to the gaze
  20347. */
  20348. getForwardRay(length?: number): Ray;
  20349. /**
  20350. * @hidden
  20351. * Updates the camera based on device's frame data
  20352. */
  20353. _checkInputs(): void;
  20354. /**
  20355. * Updates the poseControlled values based on the input device pose.
  20356. * @param poseData Pose coming from the device
  20357. */
  20358. updateFromDevice(poseData: DevicePose): void;
  20359. private _htmlElementAttached;
  20360. private _detachIfAttached;
  20361. /**
  20362. * WebVR's attach control will start broadcasting frames to the device.
  20363. * Note that in certain browsers (chrome for example) this function must be called
  20364. * within a user-interaction callback. Example:
  20365. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20366. *
  20367. * @param element html element to attach the vrDevice to
  20368. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20369. */
  20370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20371. /**
  20372. * Detaches the camera from the html element and disables VR
  20373. *
  20374. * @param element html element to detach from
  20375. */
  20376. detachControl(element: HTMLElement): void;
  20377. /**
  20378. * @returns the name of this class
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Calls resetPose on the vrDisplay
  20383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20384. */
  20385. resetToCurrentRotation(): void;
  20386. /**
  20387. * @hidden
  20388. * Updates the rig cameras (left and right eye)
  20389. */
  20390. _updateRigCameras(): void;
  20391. private _workingVector;
  20392. private _oneVector;
  20393. private _workingMatrix;
  20394. private updateCacheCalled;
  20395. private _correctPositionIfNotTrackPosition;
  20396. /**
  20397. * @hidden
  20398. * Updates the cached values of the camera
  20399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20400. */
  20401. _updateCache(ignoreParentClass?: boolean): void;
  20402. /**
  20403. * @hidden
  20404. * Get current device position in babylon world
  20405. */
  20406. _computeDevicePosition(): void;
  20407. /**
  20408. * Updates the current device position and rotation in the babylon world
  20409. */
  20410. update(): void;
  20411. /**
  20412. * @hidden
  20413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20414. * @returns an identity matrix
  20415. */
  20416. _getViewMatrix(): Matrix;
  20417. private _tmpMatrix;
  20418. /**
  20419. * This function is called by the two RIG cameras.
  20420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20421. * @hidden
  20422. */
  20423. _getWebVRViewMatrix(): Matrix;
  20424. /** @hidden */
  20425. _getWebVRProjectionMatrix(): Matrix;
  20426. private _onGamepadConnectedObserver;
  20427. private _onGamepadDisconnectedObserver;
  20428. private _updateCacheWhenTrackingDisabledObserver;
  20429. /**
  20430. * Initializes the controllers and their meshes
  20431. */
  20432. initControllers(): void;
  20433. }
  20434. }
  20435. declare module "babylonjs/PostProcesses/postProcess" {
  20436. import { Nullable } from "babylonjs/types";
  20437. import { SmartArray } from "babylonjs/Misc/smartArray";
  20438. import { Observable } from "babylonjs/Misc/observable";
  20439. import { Vector2 } from "babylonjs/Maths/math.vector";
  20440. import { Camera } from "babylonjs/Cameras/camera";
  20441. import { Effect } from "babylonjs/Materials/effect";
  20442. import "babylonjs/Shaders/postprocess.vertex";
  20443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20444. import { Engine } from "babylonjs/Engines/engine";
  20445. import { Color4 } from "babylonjs/Maths/math.color";
  20446. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20448. /**
  20449. * Size options for a post process
  20450. */
  20451. export type PostProcessOptions = {
  20452. width: number;
  20453. height: number;
  20454. };
  20455. /**
  20456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20458. */
  20459. export class PostProcess {
  20460. /** Name of the PostProcess. */
  20461. name: string;
  20462. /**
  20463. * Gets or sets the unique id of the post process
  20464. */
  20465. uniqueId: number;
  20466. /**
  20467. * Width of the texture to apply the post process on
  20468. */
  20469. width: number;
  20470. /**
  20471. * Height of the texture to apply the post process on
  20472. */
  20473. height: number;
  20474. /**
  20475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20476. * @hidden
  20477. */
  20478. _outputTexture: Nullable<InternalTexture>;
  20479. /**
  20480. * Sampling mode used by the shader
  20481. * See https://doc.babylonjs.com/classes/3.1/texture
  20482. */
  20483. renderTargetSamplingMode: number;
  20484. /**
  20485. * Clear color to use when screen clearing
  20486. */
  20487. clearColor: Color4;
  20488. /**
  20489. * If the buffer needs to be cleared before applying the post process. (default: true)
  20490. * Should be set to false if shader will overwrite all previous pixels.
  20491. */
  20492. autoClear: boolean;
  20493. /**
  20494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20495. */
  20496. alphaMode: number;
  20497. /**
  20498. * Sets the setAlphaBlendConstants of the babylon engine
  20499. */
  20500. alphaConstants: Color4;
  20501. /**
  20502. * Animations to be used for the post processing
  20503. */
  20504. animations: import("babylonjs/Animations/animation").Animation[];
  20505. /**
  20506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20508. */
  20509. enablePixelPerfectMode: boolean;
  20510. /**
  20511. * Force the postprocess to be applied without taking in account viewport
  20512. */
  20513. forceFullscreenViewport: boolean;
  20514. /**
  20515. * List of inspectable custom properties (used by the Inspector)
  20516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20517. */
  20518. inspectableCustomProperties: IInspectable[];
  20519. /**
  20520. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20521. *
  20522. * | Value | Type | Description |
  20523. * | ----- | ----------------------------------- | ----------- |
  20524. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20525. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20526. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20527. *
  20528. */
  20529. scaleMode: number;
  20530. /**
  20531. * Force textures to be a power of two (default: false)
  20532. */
  20533. alwaysForcePOT: boolean;
  20534. private _samples;
  20535. /**
  20536. * Number of sample textures (default: 1)
  20537. */
  20538. get samples(): number;
  20539. set samples(n: number);
  20540. /**
  20541. * Modify the scale of the post process to be the same as the viewport (default: false)
  20542. */
  20543. adaptScaleToCurrentViewport: boolean;
  20544. private _camera;
  20545. private _scene;
  20546. private _engine;
  20547. private _options;
  20548. private _reusable;
  20549. private _textureType;
  20550. private _textureFormat;
  20551. /**
  20552. * Smart array of input and output textures for the post process.
  20553. * @hidden
  20554. */
  20555. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20556. /**
  20557. * The index in _textures that corresponds to the output texture.
  20558. * @hidden
  20559. */
  20560. _currentRenderTextureInd: number;
  20561. private _effect;
  20562. private _samplers;
  20563. private _fragmentUrl;
  20564. private _vertexUrl;
  20565. private _parameters;
  20566. private _scaleRatio;
  20567. protected _indexParameters: any;
  20568. private _shareOutputWithPostProcess;
  20569. private _texelSize;
  20570. private _forcedOutputTexture;
  20571. /**
  20572. * Returns the fragment url or shader name used in the post process.
  20573. * @returns the fragment url or name in the shader store.
  20574. */
  20575. getEffectName(): string;
  20576. /**
  20577. * An event triggered when the postprocess is activated.
  20578. */
  20579. onActivateObservable: Observable<Camera>;
  20580. private _onActivateObserver;
  20581. /**
  20582. * A function that is added to the onActivateObservable
  20583. */
  20584. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20585. /**
  20586. * An event triggered when the postprocess changes its size.
  20587. */
  20588. onSizeChangedObservable: Observable<PostProcess>;
  20589. private _onSizeChangedObserver;
  20590. /**
  20591. * A function that is added to the onSizeChangedObservable
  20592. */
  20593. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20594. /**
  20595. * An event triggered when the postprocess applies its effect.
  20596. */
  20597. onApplyObservable: Observable<Effect>;
  20598. private _onApplyObserver;
  20599. /**
  20600. * A function that is added to the onApplyObservable
  20601. */
  20602. set onApply(callback: (effect: Effect) => void);
  20603. /**
  20604. * An event triggered before rendering the postprocess
  20605. */
  20606. onBeforeRenderObservable: Observable<Effect>;
  20607. private _onBeforeRenderObserver;
  20608. /**
  20609. * A function that is added to the onBeforeRenderObservable
  20610. */
  20611. set onBeforeRender(callback: (effect: Effect) => void);
  20612. /**
  20613. * An event triggered after rendering the postprocess
  20614. */
  20615. onAfterRenderObservable: Observable<Effect>;
  20616. private _onAfterRenderObserver;
  20617. /**
  20618. * A function that is added to the onAfterRenderObservable
  20619. */
  20620. set onAfterRender(callback: (efect: Effect) => void);
  20621. /**
  20622. * 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
  20623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20624. */
  20625. get inputTexture(): InternalTexture;
  20626. set inputTexture(value: InternalTexture);
  20627. /**
  20628. * Gets the camera which post process is applied to.
  20629. * @returns The camera the post process is applied to.
  20630. */
  20631. getCamera(): Camera;
  20632. /**
  20633. * Gets the texel size of the postprocess.
  20634. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20635. */
  20636. get texelSize(): Vector2;
  20637. /**
  20638. * Creates a new instance PostProcess
  20639. * @param name The name of the PostProcess.
  20640. * @param fragmentUrl The url of the fragment shader to be used.
  20641. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20642. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20643. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20644. * @param camera The camera to apply the render pass to.
  20645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20646. * @param engine The engine which the post process will be applied. (default: current engine)
  20647. * @param reusable If the post process can be reused on the same frame. (default: false)
  20648. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20649. * @param textureType Type of textures used when performing the post process. (default: 0)
  20650. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20651. * @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
  20652. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20653. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20654. */
  20655. constructor(
  20656. /** Name of the PostProcess. */
  20657. 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, textureFormat?: number);
  20658. /**
  20659. * Gets a string idenfifying the name of the class
  20660. * @returns "PostProcess" string
  20661. */
  20662. getClassName(): string;
  20663. /**
  20664. * Gets the engine which this post process belongs to.
  20665. * @returns The engine the post process was enabled with.
  20666. */
  20667. getEngine(): Engine;
  20668. /**
  20669. * The effect that is created when initializing the post process.
  20670. * @returns The created effect corresponding the the postprocess.
  20671. */
  20672. getEffect(): Effect;
  20673. /**
  20674. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20675. * @param postProcess The post process to share the output with.
  20676. * @returns This post process.
  20677. */
  20678. shareOutputWith(postProcess: PostProcess): PostProcess;
  20679. /**
  20680. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20681. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20682. */
  20683. useOwnOutput(): void;
  20684. /**
  20685. * Updates the effect with the current post process compile time values and recompiles the shader.
  20686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20689. * @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
  20690. * @param onCompiled Called when the shader has been compiled.
  20691. * @param onError Called if there is an error when compiling a shader.
  20692. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20693. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20694. */
  20695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  20696. /**
  20697. * The post process is reusable if it can be used multiple times within one frame.
  20698. * @returns If the post process is reusable
  20699. */
  20700. isReusable(): boolean;
  20701. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20702. markTextureDirty(): void;
  20703. /**
  20704. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20705. * 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.
  20706. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20707. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20708. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20709. * @returns The target texture that was bound to be written to.
  20710. */
  20711. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20712. /**
  20713. * If the post process is supported.
  20714. */
  20715. get isSupported(): boolean;
  20716. /**
  20717. * The aspect ratio of the output texture.
  20718. */
  20719. get aspectRatio(): number;
  20720. /**
  20721. * Get a value indicating if the post-process is ready to be used
  20722. * @returns true if the post-process is ready (shader is compiled)
  20723. */
  20724. isReady(): boolean;
  20725. /**
  20726. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20727. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20728. */
  20729. apply(): Nullable<Effect>;
  20730. private _disposeTextures;
  20731. /**
  20732. * Disposes the post process.
  20733. * @param camera The camera to dispose the post process on.
  20734. */
  20735. dispose(camera?: Camera): void;
  20736. }
  20737. }
  20738. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20739. /** @hidden */
  20740. export var kernelBlurVaryingDeclaration: {
  20741. name: string;
  20742. shader: string;
  20743. };
  20744. }
  20745. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20746. /** @hidden */
  20747. export var kernelBlurFragment: {
  20748. name: string;
  20749. shader: string;
  20750. };
  20751. }
  20752. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20753. /** @hidden */
  20754. export var kernelBlurFragment2: {
  20755. name: string;
  20756. shader: string;
  20757. };
  20758. }
  20759. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20760. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20761. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20762. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20763. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20764. /** @hidden */
  20765. export var kernelBlurPixelShader: {
  20766. name: string;
  20767. shader: string;
  20768. };
  20769. }
  20770. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20771. /** @hidden */
  20772. export var kernelBlurVertex: {
  20773. name: string;
  20774. shader: string;
  20775. };
  20776. }
  20777. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20778. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20779. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20780. /** @hidden */
  20781. export var kernelBlurVertexShader: {
  20782. name: string;
  20783. shader: string;
  20784. };
  20785. }
  20786. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20787. import { Vector2 } from "babylonjs/Maths/math.vector";
  20788. import { Nullable } from "babylonjs/types";
  20789. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20790. import { Camera } from "babylonjs/Cameras/camera";
  20791. import { Effect } from "babylonjs/Materials/effect";
  20792. import { Engine } from "babylonjs/Engines/engine";
  20793. import "babylonjs/Shaders/kernelBlur.fragment";
  20794. import "babylonjs/Shaders/kernelBlur.vertex";
  20795. /**
  20796. * The Blur Post Process which blurs an image based on a kernel and direction.
  20797. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20798. */
  20799. export class BlurPostProcess extends PostProcess {
  20800. /** The direction in which to blur the image. */
  20801. direction: Vector2;
  20802. private blockCompilation;
  20803. protected _kernel: number;
  20804. protected _idealKernel: number;
  20805. protected _packedFloat: boolean;
  20806. private _staticDefines;
  20807. /**
  20808. * Sets the length in pixels of the blur sample region
  20809. */
  20810. set kernel(v: number);
  20811. /**
  20812. * Gets the length in pixels of the blur sample region
  20813. */
  20814. get kernel(): number;
  20815. /**
  20816. * Sets wether or not the blur needs to unpack/repack floats
  20817. */
  20818. set packedFloat(v: boolean);
  20819. /**
  20820. * Gets wether or not the blur is unpacking/repacking floats
  20821. */
  20822. get packedFloat(): boolean;
  20823. /**
  20824. * Creates a new instance BlurPostProcess
  20825. * @param name The name of the effect.
  20826. * @param direction The direction in which to blur the image.
  20827. * @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.
  20828. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20829. * @param camera The camera to apply the render pass to.
  20830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20831. * @param engine The engine which the post process will be applied. (default: current engine)
  20832. * @param reusable If the post process can be reused on the same frame. (default: false)
  20833. * @param textureType Type of textures used when performing the post process. (default: 0)
  20834. * @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)
  20835. */
  20836. constructor(name: string,
  20837. /** The direction in which to blur the image. */
  20838. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20839. /**
  20840. * Updates the effect with the current post process compile time values and recompiles the shader.
  20841. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20842. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20843. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20844. * @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
  20845. * @param onCompiled Called when the shader has been compiled.
  20846. * @param onError Called if there is an error when compiling a shader.
  20847. */
  20848. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20849. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20850. /**
  20851. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20852. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20853. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20854. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20855. * The gaps between physical kernels are compensated for in the weighting of the samples
  20856. * @param idealKernel Ideal blur kernel.
  20857. * @return Nearest best kernel.
  20858. */
  20859. protected _nearestBestKernel(idealKernel: number): number;
  20860. /**
  20861. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20862. * @param x The point on the Gaussian distribution to sample.
  20863. * @return the value of the Gaussian function at x.
  20864. */
  20865. protected _gaussianWeight(x: number): number;
  20866. /**
  20867. * Generates a string that can be used as a floating point number in GLSL.
  20868. * @param x Value to print.
  20869. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20870. * @return GLSL float string.
  20871. */
  20872. protected _glslFloat(x: number, decimalFigures?: number): string;
  20873. }
  20874. }
  20875. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20876. import { Scene } from "babylonjs/scene";
  20877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20878. import { Plane } from "babylonjs/Maths/math.plane";
  20879. /**
  20880. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20881. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20882. * You can then easily use it as a reflectionTexture on a flat surface.
  20883. * In case the surface is not a plane, please consider relying on reflection probes.
  20884. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20885. */
  20886. export class MirrorTexture extends RenderTargetTexture {
  20887. private scene;
  20888. /**
  20889. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20890. * 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.
  20891. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20892. */
  20893. mirrorPlane: Plane;
  20894. /**
  20895. * Define the blur ratio used to blur the reflection if needed.
  20896. */
  20897. set blurRatio(value: number);
  20898. get blurRatio(): number;
  20899. /**
  20900. * Define the adaptive blur kernel used to blur the reflection if needed.
  20901. * This will autocompute the closest best match for the `blurKernel`
  20902. */
  20903. set adaptiveBlurKernel(value: number);
  20904. /**
  20905. * Define the blur kernel used to blur the reflection if needed.
  20906. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20907. */
  20908. set blurKernel(value: number);
  20909. /**
  20910. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20911. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20912. */
  20913. set blurKernelX(value: number);
  20914. get blurKernelX(): number;
  20915. /**
  20916. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20917. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20918. */
  20919. set blurKernelY(value: number);
  20920. get blurKernelY(): number;
  20921. private _autoComputeBlurKernel;
  20922. protected _onRatioRescale(): void;
  20923. private _updateGammaSpace;
  20924. private _imageProcessingConfigChangeObserver;
  20925. private _transformMatrix;
  20926. private _mirrorMatrix;
  20927. private _savedViewMatrix;
  20928. private _blurX;
  20929. private _blurY;
  20930. private _adaptiveBlurKernel;
  20931. private _blurKernelX;
  20932. private _blurKernelY;
  20933. private _blurRatio;
  20934. /**
  20935. * Instantiates a Mirror Texture.
  20936. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20937. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20938. * You can then easily use it as a reflectionTexture on a flat surface.
  20939. * In case the surface is not a plane, please consider relying on reflection probes.
  20940. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20941. * @param name
  20942. * @param size
  20943. * @param scene
  20944. * @param generateMipMaps
  20945. * @param type
  20946. * @param samplingMode
  20947. * @param generateDepthBuffer
  20948. */
  20949. constructor(name: string, size: number | {
  20950. width: number;
  20951. height: number;
  20952. } | {
  20953. ratio: number;
  20954. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20955. private _preparePostProcesses;
  20956. /**
  20957. * Clone the mirror texture.
  20958. * @returns the cloned texture
  20959. */
  20960. clone(): MirrorTexture;
  20961. /**
  20962. * Serialize the texture to a JSON representation you could use in Parse later on
  20963. * @returns the serialized JSON representation
  20964. */
  20965. serialize(): any;
  20966. /**
  20967. * Dispose the texture and release its associated resources.
  20968. */
  20969. dispose(): void;
  20970. }
  20971. }
  20972. declare module "babylonjs/Materials/Textures/texture" {
  20973. import { Observable } from "babylonjs/Misc/observable";
  20974. import { Nullable } from "babylonjs/types";
  20975. import { Matrix } from "babylonjs/Maths/math.vector";
  20976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20977. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20978. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20979. import { Scene } from "babylonjs/scene";
  20980. /**
  20981. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20982. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20983. */
  20984. export class Texture extends BaseTexture {
  20985. /**
  20986. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20987. */
  20988. static SerializeBuffers: boolean;
  20989. /** @hidden */
  20990. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20991. /** @hidden */
  20992. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20993. /** @hidden */
  20994. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20995. /** nearest is mag = nearest and min = nearest and mip = linear */
  20996. static readonly NEAREST_SAMPLINGMODE: number;
  20997. /** nearest is mag = nearest and min = nearest and mip = linear */
  20998. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21000. static readonly BILINEAR_SAMPLINGMODE: number;
  21001. /** Bilinear is mag = linear and min = linear and mip = nearest */
  21002. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  21003. /** Trilinear is mag = linear and min = linear and mip = linear */
  21004. static readonly TRILINEAR_SAMPLINGMODE: number;
  21005. /** Trilinear is mag = linear and min = linear and mip = linear */
  21006. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  21007. /** mag = nearest and min = nearest and mip = nearest */
  21008. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  21009. /** mag = nearest and min = linear and mip = nearest */
  21010. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  21011. /** mag = nearest and min = linear and mip = linear */
  21012. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  21013. /** mag = nearest and min = linear and mip = none */
  21014. static readonly NEAREST_LINEAR: number;
  21015. /** mag = nearest and min = nearest and mip = none */
  21016. static readonly NEAREST_NEAREST: number;
  21017. /** mag = linear and min = nearest and mip = nearest */
  21018. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  21019. /** mag = linear and min = nearest and mip = linear */
  21020. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  21021. /** mag = linear and min = linear and mip = none */
  21022. static readonly LINEAR_LINEAR: number;
  21023. /** mag = linear and min = nearest and mip = none */
  21024. static readonly LINEAR_NEAREST: number;
  21025. /** Explicit coordinates mode */
  21026. static readonly EXPLICIT_MODE: number;
  21027. /** Spherical coordinates mode */
  21028. static readonly SPHERICAL_MODE: number;
  21029. /** Planar coordinates mode */
  21030. static readonly PLANAR_MODE: number;
  21031. /** Cubic coordinates mode */
  21032. static readonly CUBIC_MODE: number;
  21033. /** Projection coordinates mode */
  21034. static readonly PROJECTION_MODE: number;
  21035. /** Inverse Cubic coordinates mode */
  21036. static readonly SKYBOX_MODE: number;
  21037. /** Inverse Cubic coordinates mode */
  21038. static readonly INVCUBIC_MODE: number;
  21039. /** Equirectangular coordinates mode */
  21040. static readonly EQUIRECTANGULAR_MODE: number;
  21041. /** Equirectangular Fixed coordinates mode */
  21042. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21043. /** Equirectangular Fixed Mirrored coordinates mode */
  21044. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21045. /** Texture is not repeating outside of 0..1 UVs */
  21046. static readonly CLAMP_ADDRESSMODE: number;
  21047. /** Texture is repeating outside of 0..1 UVs */
  21048. static readonly WRAP_ADDRESSMODE: number;
  21049. /** Texture is repeating and mirrored */
  21050. static readonly MIRROR_ADDRESSMODE: number;
  21051. /**
  21052. * 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
  21053. */
  21054. static UseSerializedUrlIfAny: boolean;
  21055. /**
  21056. * Define the url of the texture.
  21057. */
  21058. url: Nullable<string>;
  21059. /**
  21060. * Define an offset on the texture to offset the u coordinates of the UVs
  21061. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21062. */
  21063. uOffset: number;
  21064. /**
  21065. * Define an offset on the texture to offset the v coordinates of the UVs
  21066. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21067. */
  21068. vOffset: number;
  21069. /**
  21070. * Define an offset on the texture to scale the u coordinates of the UVs
  21071. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21072. */
  21073. uScale: number;
  21074. /**
  21075. * Define an offset on the texture to scale the v coordinates of the UVs
  21076. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21077. */
  21078. vScale: number;
  21079. /**
  21080. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21081. * @see http://doc.babylonjs.com/how_to/more_materials
  21082. */
  21083. uAng: number;
  21084. /**
  21085. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21086. * @see http://doc.babylonjs.com/how_to/more_materials
  21087. */
  21088. vAng: number;
  21089. /**
  21090. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21091. * @see http://doc.babylonjs.com/how_to/more_materials
  21092. */
  21093. wAng: number;
  21094. /**
  21095. * Defines the center of rotation (U)
  21096. */
  21097. uRotationCenter: number;
  21098. /**
  21099. * Defines the center of rotation (V)
  21100. */
  21101. vRotationCenter: number;
  21102. /**
  21103. * Defines the center of rotation (W)
  21104. */
  21105. wRotationCenter: number;
  21106. /**
  21107. * Are mip maps generated for this texture or not.
  21108. */
  21109. get noMipmap(): boolean;
  21110. /**
  21111. * List of inspectable custom properties (used by the Inspector)
  21112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21113. */
  21114. inspectableCustomProperties: Nullable<IInspectable[]>;
  21115. private _noMipmap;
  21116. /** @hidden */
  21117. _invertY: boolean;
  21118. private _rowGenerationMatrix;
  21119. private _cachedTextureMatrix;
  21120. private _projectionModeMatrix;
  21121. private _t0;
  21122. private _t1;
  21123. private _t2;
  21124. private _cachedUOffset;
  21125. private _cachedVOffset;
  21126. private _cachedUScale;
  21127. private _cachedVScale;
  21128. private _cachedUAng;
  21129. private _cachedVAng;
  21130. private _cachedWAng;
  21131. private _cachedProjectionMatrixId;
  21132. private _cachedCoordinatesMode;
  21133. /** @hidden */
  21134. protected _initialSamplingMode: number;
  21135. /** @hidden */
  21136. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21137. private _deleteBuffer;
  21138. protected _format: Nullable<number>;
  21139. private _delayedOnLoad;
  21140. private _delayedOnError;
  21141. private _mimeType?;
  21142. /**
  21143. * Observable triggered once the texture has been loaded.
  21144. */
  21145. onLoadObservable: Observable<Texture>;
  21146. protected _isBlocking: boolean;
  21147. /**
  21148. * Is the texture preventing material to render while loading.
  21149. * If false, a default texture will be used instead of the loading one during the preparation step.
  21150. */
  21151. set isBlocking(value: boolean);
  21152. get isBlocking(): boolean;
  21153. /**
  21154. * Get the current sampling mode associated with the texture.
  21155. */
  21156. get samplingMode(): number;
  21157. /**
  21158. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21159. */
  21160. get invertY(): boolean;
  21161. /**
  21162. * Instantiates a new texture.
  21163. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21164. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21165. * @param url defines the url of the picture to load as a texture
  21166. * @param sceneOrEngine defines the scene or engine the texture will belong to
  21167. * @param noMipmap defines if the texture will require mip maps or not
  21168. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21169. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21170. * @param onLoad defines a callback triggered when the texture has been loaded
  21171. * @param onError defines a callback triggered when an error occurred during the loading session
  21172. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21173. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21174. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21175. * @param mimeType defines an optional mime type information
  21176. */
  21177. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  21178. /**
  21179. * Update the url (and optional buffer) of this texture if url was null during construction.
  21180. * @param url the url of the texture
  21181. * @param buffer the buffer of the texture (defaults to null)
  21182. * @param onLoad callback called when the texture is loaded (defaults to null)
  21183. */
  21184. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21185. /**
  21186. * Finish the loading sequence of a texture flagged as delayed load.
  21187. * @hidden
  21188. */
  21189. delayLoad(): void;
  21190. private _prepareRowForTextureGeneration;
  21191. /**
  21192. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21193. * @returns the transform matrix of the texture.
  21194. */
  21195. getTextureMatrix(uBase?: number): Matrix;
  21196. /**
  21197. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21198. * @returns The reflection texture transform
  21199. */
  21200. getReflectionTextureMatrix(): Matrix;
  21201. /**
  21202. * Clones the texture.
  21203. * @returns the cloned texture
  21204. */
  21205. clone(): Texture;
  21206. /**
  21207. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21208. * @returns The JSON representation of the texture
  21209. */
  21210. serialize(): any;
  21211. /**
  21212. * Get the current class name of the texture useful for serialization or dynamic coding.
  21213. * @returns "Texture"
  21214. */
  21215. getClassName(): string;
  21216. /**
  21217. * Dispose the texture and release its associated resources.
  21218. */
  21219. dispose(): void;
  21220. /**
  21221. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21222. * @param parsedTexture Define the JSON representation of the texture
  21223. * @param scene Define the scene the parsed texture should be instantiated in
  21224. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21225. * @returns The parsed texture if successful
  21226. */
  21227. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21228. /**
  21229. * Creates a texture from its base 64 representation.
  21230. * @param data Define the base64 payload without the data: prefix
  21231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21232. * @param scene Define the scene the texture should belong to
  21233. * @param noMipmap Forces the texture to not create mip map information if true
  21234. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21235. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21236. * @param onLoad define a callback triggered when the texture has been loaded
  21237. * @param onError define a callback triggered when an error occurred during the loading session
  21238. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21239. * @returns the created texture
  21240. */
  21241. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21242. /**
  21243. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21244. * @param data Define the base64 payload without the data: prefix
  21245. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21246. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21247. * @param scene Define the scene the texture should belong to
  21248. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21249. * @param noMipmap Forces the texture to not create mip map information if true
  21250. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21251. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21252. * @param onLoad define a callback triggered when the texture has been loaded
  21253. * @param onError define a callback triggered when an error occurred during the loading session
  21254. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21255. * @returns the created texture
  21256. */
  21257. 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;
  21258. }
  21259. }
  21260. declare module "babylonjs/PostProcesses/postProcessManager" {
  21261. import { Nullable } from "babylonjs/types";
  21262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21264. import { Scene } from "babylonjs/scene";
  21265. /**
  21266. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21267. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21268. */
  21269. export class PostProcessManager {
  21270. private _scene;
  21271. private _indexBuffer;
  21272. private _vertexBuffers;
  21273. /**
  21274. * Creates a new instance PostProcess
  21275. * @param scene The scene that the post process is associated with.
  21276. */
  21277. constructor(scene: Scene);
  21278. private _prepareBuffers;
  21279. private _buildIndexBuffer;
  21280. /**
  21281. * Rebuilds the vertex buffers of the manager.
  21282. * @hidden
  21283. */
  21284. _rebuild(): void;
  21285. /**
  21286. * Prepares a frame to be run through a post process.
  21287. * @param sourceTexture The input texture to the post procesess. (default: null)
  21288. * @param postProcesses An array of post processes to be run. (default: null)
  21289. * @returns True if the post processes were able to be run.
  21290. * @hidden
  21291. */
  21292. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21293. /**
  21294. * Manually render a set of post processes to a texture.
  21295. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21296. * @param postProcesses An array of post processes to be run.
  21297. * @param targetTexture The target texture to render to.
  21298. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21299. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21300. * @param lodLevel defines which lod of the texture to render to
  21301. */
  21302. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21303. /**
  21304. * Finalize the result of the output of the postprocesses.
  21305. * @param doNotPresent If true the result will not be displayed to the screen.
  21306. * @param targetTexture The target texture to render to.
  21307. * @param faceIndex The index of the face to bind the target texture to.
  21308. * @param postProcesses The array of post processes to render.
  21309. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21310. * @hidden
  21311. */
  21312. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21313. /**
  21314. * Disposes of the post process manager.
  21315. */
  21316. dispose(): void;
  21317. }
  21318. }
  21319. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21320. import { Observable } from "babylonjs/Misc/observable";
  21321. import { SmartArray } from "babylonjs/Misc/smartArray";
  21322. import { Nullable, Immutable } from "babylonjs/types";
  21323. import { Camera } from "babylonjs/Cameras/camera";
  21324. import { Scene } from "babylonjs/scene";
  21325. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21326. import { Color4 } from "babylonjs/Maths/math.color";
  21327. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21331. import { Texture } from "babylonjs/Materials/Textures/texture";
  21332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21333. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21334. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21335. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21336. import { Engine } from "babylonjs/Engines/engine";
  21337. /**
  21338. * This Helps creating a texture that will be created from a camera in your scene.
  21339. * It is basically a dynamic texture that could be used to create special effects for instance.
  21340. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21341. */
  21342. export class RenderTargetTexture extends Texture {
  21343. isCube: boolean;
  21344. /**
  21345. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21346. */
  21347. static readonly REFRESHRATE_RENDER_ONCE: number;
  21348. /**
  21349. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21350. */
  21351. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21352. /**
  21353. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21354. * the central point of your effect and can save a lot of performances.
  21355. */
  21356. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21357. /**
  21358. * Use this predicate to dynamically define the list of mesh you want to render.
  21359. * If set, the renderList property will be overwritten.
  21360. */
  21361. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21362. private _renderList;
  21363. /**
  21364. * Use this list to define the list of mesh you want to render.
  21365. */
  21366. get renderList(): Nullable<Array<AbstractMesh>>;
  21367. set renderList(value: Nullable<Array<AbstractMesh>>);
  21368. /**
  21369. * Use this function to overload the renderList array at rendering time.
  21370. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21371. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21372. * the cube (if the RTT is a cube, else layerOrFace=0).
  21373. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21374. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21375. * hold dummy elements!
  21376. */
  21377. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21378. private _hookArray;
  21379. /**
  21380. * Define if particles should be rendered in your texture.
  21381. */
  21382. renderParticles: boolean;
  21383. /**
  21384. * Define if sprites should be rendered in your texture.
  21385. */
  21386. renderSprites: boolean;
  21387. /**
  21388. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21389. */
  21390. coordinatesMode: number;
  21391. /**
  21392. * Define the camera used to render the texture.
  21393. */
  21394. activeCamera: Nullable<Camera>;
  21395. /**
  21396. * Override the mesh isReady function with your own one.
  21397. */
  21398. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21399. /**
  21400. * Override the render function of the texture with your own one.
  21401. */
  21402. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21403. /**
  21404. * Define if camera post processes should be use while rendering the texture.
  21405. */
  21406. useCameraPostProcesses: boolean;
  21407. /**
  21408. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21409. */
  21410. ignoreCameraViewport: boolean;
  21411. private _postProcessManager;
  21412. private _postProcesses;
  21413. private _resizeObserver;
  21414. /**
  21415. * An event triggered when the texture is unbind.
  21416. */
  21417. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21418. /**
  21419. * An event triggered when the texture is unbind.
  21420. */
  21421. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21422. private _onAfterUnbindObserver;
  21423. /**
  21424. * Set a after unbind callback in the texture.
  21425. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21426. */
  21427. set onAfterUnbind(callback: () => void);
  21428. /**
  21429. * An event triggered before rendering the texture
  21430. */
  21431. onBeforeRenderObservable: Observable<number>;
  21432. private _onBeforeRenderObserver;
  21433. /**
  21434. * Set a before render callback in the texture.
  21435. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21436. */
  21437. set onBeforeRender(callback: (faceIndex: number) => void);
  21438. /**
  21439. * An event triggered after rendering the texture
  21440. */
  21441. onAfterRenderObservable: Observable<number>;
  21442. private _onAfterRenderObserver;
  21443. /**
  21444. * Set a after render callback in the texture.
  21445. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21446. */
  21447. set onAfterRender(callback: (faceIndex: number) => void);
  21448. /**
  21449. * An event triggered after the texture clear
  21450. */
  21451. onClearObservable: Observable<Engine>;
  21452. private _onClearObserver;
  21453. /**
  21454. * Set a clear callback in the texture.
  21455. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21456. */
  21457. set onClear(callback: (Engine: Engine) => void);
  21458. /**
  21459. * An event triggered when the texture is resized.
  21460. */
  21461. onResizeObservable: Observable<RenderTargetTexture>;
  21462. /**
  21463. * Define the clear color of the Render Target if it should be different from the scene.
  21464. */
  21465. clearColor: Color4;
  21466. protected _size: number | {
  21467. width: number;
  21468. height: number;
  21469. layers?: number;
  21470. };
  21471. protected _initialSizeParameter: number | {
  21472. width: number;
  21473. height: number;
  21474. } | {
  21475. ratio: number;
  21476. };
  21477. protected _sizeRatio: Nullable<number>;
  21478. /** @hidden */
  21479. _generateMipMaps: boolean;
  21480. protected _renderingManager: RenderingManager;
  21481. /** @hidden */
  21482. _waitingRenderList: string[];
  21483. protected _doNotChangeAspectRatio: boolean;
  21484. protected _currentRefreshId: number;
  21485. protected _refreshRate: number;
  21486. protected _textureMatrix: Matrix;
  21487. protected _samples: number;
  21488. protected _renderTargetOptions: RenderTargetCreationOptions;
  21489. /**
  21490. * Gets render target creation options that were used.
  21491. */
  21492. get renderTargetOptions(): RenderTargetCreationOptions;
  21493. protected _onRatioRescale(): void;
  21494. /**
  21495. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21496. * It must define where the camera used to render the texture is set
  21497. */
  21498. boundingBoxPosition: Vector3;
  21499. private _boundingBoxSize;
  21500. /**
  21501. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21502. * When defined, the cubemap will switch to local mode
  21503. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21504. * @example https://www.babylonjs-playground.com/#RNASML
  21505. */
  21506. set boundingBoxSize(value: Vector3);
  21507. get boundingBoxSize(): Vector3;
  21508. /**
  21509. * In case the RTT has been created with a depth texture, get the associated
  21510. * depth texture.
  21511. * Otherwise, return null.
  21512. */
  21513. get depthStencilTexture(): Nullable<InternalTexture>;
  21514. /**
  21515. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21516. * or used a shadow, depth texture...
  21517. * @param name The friendly name of the texture
  21518. * @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)
  21519. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21520. * @param generateMipMaps True if mip maps need to be generated after render.
  21521. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21522. * @param type The type of the buffer in the RTT (int, half float, float...)
  21523. * @param isCube True if a cube texture needs to be created
  21524. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21525. * @param generateDepthBuffer True to generate a depth buffer
  21526. * @param generateStencilBuffer True to generate a stencil buffer
  21527. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21528. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21529. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21530. */
  21531. constructor(name: string, size: number | {
  21532. width: number;
  21533. height: number;
  21534. layers?: number;
  21535. } | {
  21536. ratio: number;
  21537. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21538. /**
  21539. * Creates a depth stencil texture.
  21540. * This is only available in WebGL 2 or with the depth texture extension available.
  21541. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21542. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21543. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21544. */
  21545. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21546. private _processSizeParameter;
  21547. /**
  21548. * Define the number of samples to use in case of MSAA.
  21549. * It defaults to one meaning no MSAA has been enabled.
  21550. */
  21551. get samples(): number;
  21552. set samples(value: number);
  21553. /**
  21554. * Resets the refresh counter of the texture and start bak from scratch.
  21555. * Could be useful to regenerate the texture if it is setup to render only once.
  21556. */
  21557. resetRefreshCounter(): void;
  21558. /**
  21559. * Define the refresh rate of the texture or the rendering frequency.
  21560. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21561. */
  21562. get refreshRate(): number;
  21563. set refreshRate(value: number);
  21564. /**
  21565. * Adds a post process to the render target rendering passes.
  21566. * @param postProcess define the post process to add
  21567. */
  21568. addPostProcess(postProcess: PostProcess): void;
  21569. /**
  21570. * Clear all the post processes attached to the render target
  21571. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21572. */
  21573. clearPostProcesses(dispose?: boolean): void;
  21574. /**
  21575. * Remove one of the post process from the list of attached post processes to the texture
  21576. * @param postProcess define the post process to remove from the list
  21577. */
  21578. removePostProcess(postProcess: PostProcess): void;
  21579. /** @hidden */
  21580. _shouldRender(): boolean;
  21581. /**
  21582. * Gets the actual render size of the texture.
  21583. * @returns the width of the render size
  21584. */
  21585. getRenderSize(): number;
  21586. /**
  21587. * Gets the actual render width of the texture.
  21588. * @returns the width of the render size
  21589. */
  21590. getRenderWidth(): number;
  21591. /**
  21592. * Gets the actual render height of the texture.
  21593. * @returns the height of the render size
  21594. */
  21595. getRenderHeight(): number;
  21596. /**
  21597. * Gets the actual number of layers of the texture.
  21598. * @returns the number of layers
  21599. */
  21600. getRenderLayers(): number;
  21601. /**
  21602. * Get if the texture can be rescaled or not.
  21603. */
  21604. get canRescale(): boolean;
  21605. /**
  21606. * Resize the texture using a ratio.
  21607. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21608. */
  21609. scale(ratio: number): void;
  21610. /**
  21611. * Get the texture reflection matrix used to rotate/transform the reflection.
  21612. * @returns the reflection matrix
  21613. */
  21614. getReflectionTextureMatrix(): Matrix;
  21615. /**
  21616. * Resize the texture to a new desired size.
  21617. * Be carrefull as it will recreate all the data in the new texture.
  21618. * @param size Define the new size. It can be:
  21619. * - a number for squared texture,
  21620. * - an object containing { width: number, height: number }
  21621. * - or an object containing a ratio { ratio: number }
  21622. */
  21623. resize(size: number | {
  21624. width: number;
  21625. height: number;
  21626. } | {
  21627. ratio: number;
  21628. }): void;
  21629. private _defaultRenderListPrepared;
  21630. /**
  21631. * Renders all the objects from the render list into the texture.
  21632. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21633. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21634. */
  21635. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21636. private _bestReflectionRenderTargetDimension;
  21637. private _prepareRenderingManager;
  21638. /**
  21639. * @hidden
  21640. * @param faceIndex face index to bind to if this is a cubetexture
  21641. * @param layer defines the index of the texture to bind in the array
  21642. */
  21643. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21644. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21645. private renderToTarget;
  21646. /**
  21647. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21648. * This allowed control for front to back rendering or reversly depending of the special needs.
  21649. *
  21650. * @param renderingGroupId The rendering group id corresponding to its index
  21651. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21652. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21653. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21654. */
  21655. 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;
  21656. /**
  21657. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21658. *
  21659. * @param renderingGroupId The rendering group id corresponding to its index
  21660. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21661. */
  21662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21663. /**
  21664. * Clones the texture.
  21665. * @returns the cloned texture
  21666. */
  21667. clone(): RenderTargetTexture;
  21668. /**
  21669. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21670. * @returns The JSON representation of the texture
  21671. */
  21672. serialize(): any;
  21673. /**
  21674. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21675. */
  21676. disposeFramebufferObjects(): void;
  21677. /**
  21678. * Dispose the texture and release its associated resources.
  21679. */
  21680. dispose(): void;
  21681. /** @hidden */
  21682. _rebuild(): void;
  21683. /**
  21684. * Clear the info related to rendering groups preventing retention point in material dispose.
  21685. */
  21686. freeRenderingGroups(): void;
  21687. /**
  21688. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21689. * @returns the view count
  21690. */
  21691. getViewCount(): number;
  21692. }
  21693. }
  21694. declare module "babylonjs/Misc/guid" {
  21695. /**
  21696. * Class used to manipulate GUIDs
  21697. */
  21698. export class GUID {
  21699. /**
  21700. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21701. * Be aware Math.random() could cause collisions, but:
  21702. * "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"
  21703. * @returns a pseudo random id
  21704. */
  21705. static RandomId(): string;
  21706. }
  21707. }
  21708. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21709. import { Nullable } from "babylonjs/types";
  21710. import { Scene } from "babylonjs/scene";
  21711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21712. import { Material } from "babylonjs/Materials/material";
  21713. import { Effect } from "babylonjs/Materials/effect";
  21714. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21715. /**
  21716. * Options to be used when creating a shadow depth material
  21717. */
  21718. export interface IIOptionShadowDepthMaterial {
  21719. /** Variables in the vertex shader code that need to have their names remapped.
  21720. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21721. * "var_name" should be either: worldPos or vNormalW
  21722. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21723. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21724. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21725. */
  21726. remappedVariables?: string[];
  21727. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21728. standalone?: boolean;
  21729. }
  21730. /**
  21731. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21732. */
  21733. export class ShadowDepthWrapper {
  21734. private _scene;
  21735. private _options?;
  21736. private _baseMaterial;
  21737. private _onEffectCreatedObserver;
  21738. private _subMeshToEffect;
  21739. private _subMeshToDepthEffect;
  21740. private _meshes;
  21741. /** @hidden */
  21742. _matriceNames: any;
  21743. /** Gets the standalone status of the wrapper */
  21744. get standalone(): boolean;
  21745. /** Gets the base material the wrapper is built upon */
  21746. get baseMaterial(): Material;
  21747. /**
  21748. * Instantiate a new shadow depth wrapper.
  21749. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21750. * generate the shadow depth map. For more information, please refer to the documentation:
  21751. * https://doc.babylonjs.com/babylon101/shadows
  21752. * @param baseMaterial Material to wrap
  21753. * @param scene Define the scene the material belongs to
  21754. * @param options Options used to create the wrapper
  21755. */
  21756. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21757. /**
  21758. * Gets the effect to use to generate the depth map
  21759. * @param subMesh subMesh to get the effect for
  21760. * @param shadowGenerator shadow generator to get the effect for
  21761. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21762. */
  21763. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21764. /**
  21765. * Specifies that the submesh is ready to be used for depth rendering
  21766. * @param subMesh submesh to check
  21767. * @param defines the list of defines to take into account when checking the effect
  21768. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21769. * @param useInstances specifies that instances should be used
  21770. * @returns a boolean indicating that the submesh is ready or not
  21771. */
  21772. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21773. /**
  21774. * Disposes the resources
  21775. */
  21776. dispose(): void;
  21777. private _makeEffect;
  21778. }
  21779. }
  21780. declare module "babylonjs/Materials/material" {
  21781. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21782. import { SmartArray } from "babylonjs/Misc/smartArray";
  21783. import { Observable } from "babylonjs/Misc/observable";
  21784. import { Nullable } from "babylonjs/types";
  21785. import { Scene } from "babylonjs/scene";
  21786. import { Matrix } from "babylonjs/Maths/math.vector";
  21787. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21789. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21790. import { Effect } from "babylonjs/Materials/effect";
  21791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21793. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21794. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21795. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21796. import { Mesh } from "babylonjs/Meshes/mesh";
  21797. import { Animation } from "babylonjs/Animations/animation";
  21798. /**
  21799. * Options for compiling materials.
  21800. */
  21801. export interface IMaterialCompilationOptions {
  21802. /**
  21803. * Defines whether clip planes are enabled.
  21804. */
  21805. clipPlane: boolean;
  21806. /**
  21807. * Defines whether instances are enabled.
  21808. */
  21809. useInstances: boolean;
  21810. }
  21811. /**
  21812. * Base class for the main features of a material in Babylon.js
  21813. */
  21814. export class Material implements IAnimatable {
  21815. /**
  21816. * Returns the triangle fill mode
  21817. */
  21818. static readonly TriangleFillMode: number;
  21819. /**
  21820. * Returns the wireframe mode
  21821. */
  21822. static readonly WireFrameFillMode: number;
  21823. /**
  21824. * Returns the point fill mode
  21825. */
  21826. static readonly PointFillMode: number;
  21827. /**
  21828. * Returns the point list draw mode
  21829. */
  21830. static readonly PointListDrawMode: number;
  21831. /**
  21832. * Returns the line list draw mode
  21833. */
  21834. static readonly LineListDrawMode: number;
  21835. /**
  21836. * Returns the line loop draw mode
  21837. */
  21838. static readonly LineLoopDrawMode: number;
  21839. /**
  21840. * Returns the line strip draw mode
  21841. */
  21842. static readonly LineStripDrawMode: number;
  21843. /**
  21844. * Returns the triangle strip draw mode
  21845. */
  21846. static readonly TriangleStripDrawMode: number;
  21847. /**
  21848. * Returns the triangle fan draw mode
  21849. */
  21850. static readonly TriangleFanDrawMode: number;
  21851. /**
  21852. * Stores the clock-wise side orientation
  21853. */
  21854. static readonly ClockWiseSideOrientation: number;
  21855. /**
  21856. * Stores the counter clock-wise side orientation
  21857. */
  21858. static readonly CounterClockWiseSideOrientation: number;
  21859. /**
  21860. * The dirty texture flag value
  21861. */
  21862. static readonly TextureDirtyFlag: number;
  21863. /**
  21864. * The dirty light flag value
  21865. */
  21866. static readonly LightDirtyFlag: number;
  21867. /**
  21868. * The dirty fresnel flag value
  21869. */
  21870. static readonly FresnelDirtyFlag: number;
  21871. /**
  21872. * The dirty attribute flag value
  21873. */
  21874. static readonly AttributesDirtyFlag: number;
  21875. /**
  21876. * The dirty misc flag value
  21877. */
  21878. static readonly MiscDirtyFlag: number;
  21879. /**
  21880. * The all dirty flag value
  21881. */
  21882. static readonly AllDirtyFlag: number;
  21883. /**
  21884. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21885. */
  21886. static readonly MATERIAL_OPAQUE: number;
  21887. /**
  21888. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21889. */
  21890. static readonly MATERIAL_ALPHATEST: number;
  21891. /**
  21892. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21893. */
  21894. static readonly MATERIAL_ALPHABLEND: number;
  21895. /**
  21896. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21897. * They are also discarded below the alpha cutoff threshold to improve performances.
  21898. */
  21899. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21900. /**
  21901. * Custom callback helping to override the default shader used in the material.
  21902. */
  21903. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21904. /**
  21905. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21906. */
  21907. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21908. /**
  21909. * The ID of the material
  21910. */
  21911. id: string;
  21912. /**
  21913. * Gets or sets the unique id of the material
  21914. */
  21915. uniqueId: number;
  21916. /**
  21917. * The name of the material
  21918. */
  21919. name: string;
  21920. /**
  21921. * Gets or sets user defined metadata
  21922. */
  21923. metadata: any;
  21924. /**
  21925. * For internal use only. Please do not use.
  21926. */
  21927. reservedDataStore: any;
  21928. /**
  21929. * Specifies if the ready state should be checked on each call
  21930. */
  21931. checkReadyOnEveryCall: boolean;
  21932. /**
  21933. * Specifies if the ready state should be checked once
  21934. */
  21935. checkReadyOnlyOnce: boolean;
  21936. /**
  21937. * The state of the material
  21938. */
  21939. state: string;
  21940. /**
  21941. * The alpha value of the material
  21942. */
  21943. protected _alpha: number;
  21944. /**
  21945. * List of inspectable custom properties (used by the Inspector)
  21946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21947. */
  21948. inspectableCustomProperties: IInspectable[];
  21949. /**
  21950. * Sets the alpha value of the material
  21951. */
  21952. set alpha(value: number);
  21953. /**
  21954. * Gets the alpha value of the material
  21955. */
  21956. get alpha(): number;
  21957. /**
  21958. * Specifies if back face culling is enabled
  21959. */
  21960. protected _backFaceCulling: boolean;
  21961. /**
  21962. * Sets the back-face culling state
  21963. */
  21964. set backFaceCulling(value: boolean);
  21965. /**
  21966. * Gets the back-face culling state
  21967. */
  21968. get backFaceCulling(): boolean;
  21969. /**
  21970. * Stores the value for side orientation
  21971. */
  21972. sideOrientation: number;
  21973. /**
  21974. * Callback triggered when the material is compiled
  21975. */
  21976. onCompiled: Nullable<(effect: Effect) => void>;
  21977. /**
  21978. * Callback triggered when an error occurs
  21979. */
  21980. onError: Nullable<(effect: Effect, errors: string) => void>;
  21981. /**
  21982. * Callback triggered to get the render target textures
  21983. */
  21984. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21985. /**
  21986. * Gets a boolean indicating that current material needs to register RTT
  21987. */
  21988. get hasRenderTargetTextures(): boolean;
  21989. /**
  21990. * Specifies if the material should be serialized
  21991. */
  21992. doNotSerialize: boolean;
  21993. /**
  21994. * @hidden
  21995. */
  21996. _storeEffectOnSubMeshes: boolean;
  21997. /**
  21998. * Stores the animations for the material
  21999. */
  22000. animations: Nullable<Array<Animation>>;
  22001. /**
  22002. * An event triggered when the material is disposed
  22003. */
  22004. onDisposeObservable: Observable<Material>;
  22005. /**
  22006. * An observer which watches for dispose events
  22007. */
  22008. private _onDisposeObserver;
  22009. private _onUnBindObservable;
  22010. /**
  22011. * Called during a dispose event
  22012. */
  22013. set onDispose(callback: () => void);
  22014. private _onBindObservable;
  22015. /**
  22016. * An event triggered when the material is bound
  22017. */
  22018. get onBindObservable(): Observable<AbstractMesh>;
  22019. /**
  22020. * An observer which watches for bind events
  22021. */
  22022. private _onBindObserver;
  22023. /**
  22024. * Called during a bind event
  22025. */
  22026. set onBind(callback: (Mesh: AbstractMesh) => void);
  22027. /**
  22028. * An event triggered when the material is unbound
  22029. */
  22030. get onUnBindObservable(): Observable<Material>;
  22031. protected _onEffectCreatedObservable: Nullable<Observable<{
  22032. effect: Effect;
  22033. subMesh: Nullable<SubMesh>;
  22034. }>>;
  22035. /**
  22036. * An event triggered when the effect is (re)created
  22037. */
  22038. get onEffectCreatedObservable(): Observable<{
  22039. effect: Effect;
  22040. subMesh: Nullable<SubMesh>;
  22041. }>;
  22042. /**
  22043. * Stores the value of the alpha mode
  22044. */
  22045. private _alphaMode;
  22046. /**
  22047. * Sets the value of the alpha mode.
  22048. *
  22049. * | Value | Type | Description |
  22050. * | --- | --- | --- |
  22051. * | 0 | ALPHA_DISABLE | |
  22052. * | 1 | ALPHA_ADD | |
  22053. * | 2 | ALPHA_COMBINE | |
  22054. * | 3 | ALPHA_SUBTRACT | |
  22055. * | 4 | ALPHA_MULTIPLY | |
  22056. * | 5 | ALPHA_MAXIMIZED | |
  22057. * | 6 | ALPHA_ONEONE | |
  22058. * | 7 | ALPHA_PREMULTIPLIED | |
  22059. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22060. * | 9 | ALPHA_INTERPOLATE | |
  22061. * | 10 | ALPHA_SCREENMODE | |
  22062. *
  22063. */
  22064. set alphaMode(value: number);
  22065. /**
  22066. * Gets the value of the alpha mode
  22067. */
  22068. get alphaMode(): number;
  22069. /**
  22070. * Stores the state of the need depth pre-pass value
  22071. */
  22072. private _needDepthPrePass;
  22073. /**
  22074. * Sets the need depth pre-pass value
  22075. */
  22076. set needDepthPrePass(value: boolean);
  22077. /**
  22078. * Gets the depth pre-pass value
  22079. */
  22080. get needDepthPrePass(): boolean;
  22081. /**
  22082. * Specifies if depth writing should be disabled
  22083. */
  22084. disableDepthWrite: boolean;
  22085. /**
  22086. * Specifies if color writing should be disabled
  22087. */
  22088. disableColorWrite: boolean;
  22089. /**
  22090. * Specifies if depth writing should be forced
  22091. */
  22092. forceDepthWrite: boolean;
  22093. /**
  22094. * Specifies the depth function that should be used. 0 means the default engine function
  22095. */
  22096. depthFunction: number;
  22097. /**
  22098. * Specifies if there should be a separate pass for culling
  22099. */
  22100. separateCullingPass: boolean;
  22101. /**
  22102. * Stores the state specifing if fog should be enabled
  22103. */
  22104. private _fogEnabled;
  22105. /**
  22106. * Sets the state for enabling fog
  22107. */
  22108. set fogEnabled(value: boolean);
  22109. /**
  22110. * Gets the value of the fog enabled state
  22111. */
  22112. get fogEnabled(): boolean;
  22113. /**
  22114. * Stores the size of points
  22115. */
  22116. pointSize: number;
  22117. /**
  22118. * Stores the z offset value
  22119. */
  22120. zOffset: number;
  22121. get wireframe(): boolean;
  22122. /**
  22123. * Sets the state of wireframe mode
  22124. */
  22125. set wireframe(value: boolean);
  22126. /**
  22127. * Gets the value specifying if point clouds are enabled
  22128. */
  22129. get pointsCloud(): boolean;
  22130. /**
  22131. * Sets the state of point cloud mode
  22132. */
  22133. set pointsCloud(value: boolean);
  22134. /**
  22135. * Gets the material fill mode
  22136. */
  22137. get fillMode(): number;
  22138. /**
  22139. * Sets the material fill mode
  22140. */
  22141. set fillMode(value: number);
  22142. /**
  22143. * @hidden
  22144. * Stores the effects for the material
  22145. */
  22146. _effect: Nullable<Effect>;
  22147. /**
  22148. * Specifies if uniform buffers should be used
  22149. */
  22150. private _useUBO;
  22151. /**
  22152. * Stores a reference to the scene
  22153. */
  22154. private _scene;
  22155. /**
  22156. * Stores the fill mode state
  22157. */
  22158. private _fillMode;
  22159. /**
  22160. * Specifies if the depth write state should be cached
  22161. */
  22162. private _cachedDepthWriteState;
  22163. /**
  22164. * Specifies if the color write state should be cached
  22165. */
  22166. private _cachedColorWriteState;
  22167. /**
  22168. * Specifies if the depth function state should be cached
  22169. */
  22170. private _cachedDepthFunctionState;
  22171. /**
  22172. * Stores the uniform buffer
  22173. */
  22174. protected _uniformBuffer: UniformBuffer;
  22175. /** @hidden */
  22176. _indexInSceneMaterialArray: number;
  22177. /** @hidden */
  22178. meshMap: Nullable<{
  22179. [id: string]: AbstractMesh | undefined;
  22180. }>;
  22181. /**
  22182. * Creates a material instance
  22183. * @param name defines the name of the material
  22184. * @param scene defines the scene to reference
  22185. * @param doNotAdd specifies if the material should be added to the scene
  22186. */
  22187. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22188. /**
  22189. * Returns a string representation of the current material
  22190. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22191. * @returns a string with material information
  22192. */
  22193. toString(fullDetails?: boolean): string;
  22194. /**
  22195. * Gets the class name of the material
  22196. * @returns a string with the class name of the material
  22197. */
  22198. getClassName(): string;
  22199. /**
  22200. * Specifies if updates for the material been locked
  22201. */
  22202. get isFrozen(): boolean;
  22203. /**
  22204. * Locks updates for the material
  22205. */
  22206. freeze(): void;
  22207. /**
  22208. * Unlocks updates for the material
  22209. */
  22210. unfreeze(): void;
  22211. /**
  22212. * Specifies if the material is ready to be used
  22213. * @param mesh defines the mesh to check
  22214. * @param useInstances specifies if instances should be used
  22215. * @returns a boolean indicating if the material is ready to be used
  22216. */
  22217. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22218. /**
  22219. * Specifies that the submesh is ready to be used
  22220. * @param mesh defines the mesh to check
  22221. * @param subMesh defines which submesh to check
  22222. * @param useInstances specifies that instances should be used
  22223. * @returns a boolean indicating that the submesh is ready or not
  22224. */
  22225. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22226. /**
  22227. * Returns the material effect
  22228. * @returns the effect associated with the material
  22229. */
  22230. getEffect(): Nullable<Effect>;
  22231. /**
  22232. * Returns the current scene
  22233. * @returns a Scene
  22234. */
  22235. getScene(): Scene;
  22236. /**
  22237. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22238. */
  22239. protected _forceAlphaTest: boolean;
  22240. /**
  22241. * The transparency mode of the material.
  22242. */
  22243. protected _transparencyMode: Nullable<number>;
  22244. /**
  22245. * Gets the current transparency mode.
  22246. */
  22247. get transparencyMode(): Nullable<number>;
  22248. /**
  22249. * Sets the transparency mode of the material.
  22250. *
  22251. * | Value | Type | Description |
  22252. * | ----- | ----------------------------------- | ----------- |
  22253. * | 0 | OPAQUE | |
  22254. * | 1 | ALPHATEST | |
  22255. * | 2 | ALPHABLEND | |
  22256. * | 3 | ALPHATESTANDBLEND | |
  22257. *
  22258. */
  22259. set transparencyMode(value: Nullable<number>);
  22260. /**
  22261. * Returns true if alpha blending should be disabled.
  22262. */
  22263. protected get _disableAlphaBlending(): boolean;
  22264. /**
  22265. * Specifies whether or not this material should be rendered in alpha blend mode.
  22266. * @returns a boolean specifying if alpha blending is needed
  22267. */
  22268. needAlphaBlending(): boolean;
  22269. /**
  22270. * Specifies if the mesh will require alpha blending
  22271. * @param mesh defines the mesh to check
  22272. * @returns a boolean specifying if alpha blending is needed for the mesh
  22273. */
  22274. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22275. /**
  22276. * Specifies whether or not this material should be rendered in alpha test mode.
  22277. * @returns a boolean specifying if an alpha test is needed.
  22278. */
  22279. needAlphaTesting(): boolean;
  22280. /**
  22281. * Specifies if material alpha testing should be turned on for the mesh
  22282. * @param mesh defines the mesh to check
  22283. */
  22284. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22285. /**
  22286. * Gets the texture used for the alpha test
  22287. * @returns the texture to use for alpha testing
  22288. */
  22289. getAlphaTestTexture(): Nullable<BaseTexture>;
  22290. /**
  22291. * Marks the material to indicate that it needs to be re-calculated
  22292. */
  22293. markDirty(): void;
  22294. /** @hidden */
  22295. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22296. /**
  22297. * Binds the material to the mesh
  22298. * @param world defines the world transformation matrix
  22299. * @param mesh defines the mesh to bind the material to
  22300. */
  22301. bind(world: Matrix, mesh?: Mesh): void;
  22302. /**
  22303. * Binds the submesh to the material
  22304. * @param world defines the world transformation matrix
  22305. * @param mesh defines the mesh containing the submesh
  22306. * @param subMesh defines the submesh to bind the material to
  22307. */
  22308. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22309. /**
  22310. * Binds the world matrix to the material
  22311. * @param world defines the world transformation matrix
  22312. */
  22313. bindOnlyWorldMatrix(world: Matrix): void;
  22314. /**
  22315. * Binds the scene's uniform buffer to the effect.
  22316. * @param effect defines the effect to bind to the scene uniform buffer
  22317. * @param sceneUbo defines the uniform buffer storing scene data
  22318. */
  22319. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22320. /**
  22321. * Binds the view matrix to the effect
  22322. * @param effect defines the effect to bind the view matrix to
  22323. */
  22324. bindView(effect: Effect): void;
  22325. /**
  22326. * Binds the view projection matrix to the effect
  22327. * @param effect defines the effect to bind the view projection matrix to
  22328. */
  22329. bindViewProjection(effect: Effect): void;
  22330. /**
  22331. * Processes to execute after binding the material to a mesh
  22332. * @param mesh defines the rendered mesh
  22333. */
  22334. protected _afterBind(mesh?: Mesh): void;
  22335. /**
  22336. * Unbinds the material from the mesh
  22337. */
  22338. unbind(): void;
  22339. /**
  22340. * Gets the active textures from the material
  22341. * @returns an array of textures
  22342. */
  22343. getActiveTextures(): BaseTexture[];
  22344. /**
  22345. * Specifies if the material uses a texture
  22346. * @param texture defines the texture to check against the material
  22347. * @returns a boolean specifying if the material uses the texture
  22348. */
  22349. hasTexture(texture: BaseTexture): boolean;
  22350. /**
  22351. * Makes a duplicate of the material, and gives it a new name
  22352. * @param name defines the new name for the duplicated material
  22353. * @returns the cloned material
  22354. */
  22355. clone(name: string): Nullable<Material>;
  22356. /**
  22357. * Gets the meshes bound to the material
  22358. * @returns an array of meshes bound to the material
  22359. */
  22360. getBindedMeshes(): AbstractMesh[];
  22361. /**
  22362. * Force shader compilation
  22363. * @param mesh defines the mesh associated with this material
  22364. * @param onCompiled defines a function to execute once the material is compiled
  22365. * @param options defines the options to configure the compilation
  22366. * @param onError defines a function to execute if the material fails compiling
  22367. */
  22368. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22369. /**
  22370. * Force shader compilation
  22371. * @param mesh defines the mesh that will use this material
  22372. * @param options defines additional options for compiling the shaders
  22373. * @returns a promise that resolves when the compilation completes
  22374. */
  22375. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22376. private static readonly _AllDirtyCallBack;
  22377. private static readonly _ImageProcessingDirtyCallBack;
  22378. private static readonly _TextureDirtyCallBack;
  22379. private static readonly _FresnelDirtyCallBack;
  22380. private static readonly _MiscDirtyCallBack;
  22381. private static readonly _LightsDirtyCallBack;
  22382. private static readonly _AttributeDirtyCallBack;
  22383. private static _FresnelAndMiscDirtyCallBack;
  22384. private static _TextureAndMiscDirtyCallBack;
  22385. private static readonly _DirtyCallbackArray;
  22386. private static readonly _RunDirtyCallBacks;
  22387. /**
  22388. * Marks a define in the material to indicate that it needs to be re-computed
  22389. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22390. */
  22391. markAsDirty(flag: number): void;
  22392. /**
  22393. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22394. * @param func defines a function which checks material defines against the submeshes
  22395. */
  22396. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22397. /**
  22398. * Indicates that we need to re-calculated for all submeshes
  22399. */
  22400. protected _markAllSubMeshesAsAllDirty(): void;
  22401. /**
  22402. * Indicates that image processing needs to be re-calculated for all submeshes
  22403. */
  22404. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22405. /**
  22406. * Indicates that textures need to be re-calculated for all submeshes
  22407. */
  22408. protected _markAllSubMeshesAsTexturesDirty(): void;
  22409. /**
  22410. * Indicates that fresnel needs to be re-calculated for all submeshes
  22411. */
  22412. protected _markAllSubMeshesAsFresnelDirty(): void;
  22413. /**
  22414. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22415. */
  22416. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22417. /**
  22418. * Indicates that lights need to be re-calculated for all submeshes
  22419. */
  22420. protected _markAllSubMeshesAsLightsDirty(): void;
  22421. /**
  22422. * Indicates that attributes need to be re-calculated for all submeshes
  22423. */
  22424. protected _markAllSubMeshesAsAttributesDirty(): void;
  22425. /**
  22426. * Indicates that misc needs to be re-calculated for all submeshes
  22427. */
  22428. protected _markAllSubMeshesAsMiscDirty(): void;
  22429. /**
  22430. * Indicates that textures and misc need to be re-calculated for all submeshes
  22431. */
  22432. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22433. /**
  22434. * Disposes the material
  22435. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22436. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22437. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22438. */
  22439. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22440. /** @hidden */
  22441. private releaseVertexArrayObject;
  22442. /**
  22443. * Serializes this material
  22444. * @returns the serialized material object
  22445. */
  22446. serialize(): any;
  22447. /**
  22448. * Creates a material from parsed material data
  22449. * @param parsedMaterial defines parsed material data
  22450. * @param scene defines the hosting scene
  22451. * @param rootUrl defines the root URL to use to load textures
  22452. * @returns a new material
  22453. */
  22454. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22455. }
  22456. }
  22457. declare module "babylonjs/Materials/multiMaterial" {
  22458. import { Nullable } from "babylonjs/types";
  22459. import { Scene } from "babylonjs/scene";
  22460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22461. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22463. import { Material } from "babylonjs/Materials/material";
  22464. /**
  22465. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22466. * separate meshes. This can be use to improve performances.
  22467. * @see http://doc.babylonjs.com/how_to/multi_materials
  22468. */
  22469. export class MultiMaterial extends Material {
  22470. private _subMaterials;
  22471. /**
  22472. * Gets or Sets the list of Materials used within the multi material.
  22473. * They need to be ordered according to the submeshes order in the associated mesh
  22474. */
  22475. get subMaterials(): Nullable<Material>[];
  22476. set subMaterials(value: Nullable<Material>[]);
  22477. /**
  22478. * Function used to align with Node.getChildren()
  22479. * @returns the list of Materials used within the multi material
  22480. */
  22481. getChildren(): Nullable<Material>[];
  22482. /**
  22483. * Instantiates a new Multi Material
  22484. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22485. * separate meshes. This can be use to improve performances.
  22486. * @see http://doc.babylonjs.com/how_to/multi_materials
  22487. * @param name Define the name in the scene
  22488. * @param scene Define the scene the material belongs to
  22489. */
  22490. constructor(name: string, scene: Scene);
  22491. private _hookArray;
  22492. /**
  22493. * Get one of the submaterial by its index in the submaterials array
  22494. * @param index The index to look the sub material at
  22495. * @returns The Material if the index has been defined
  22496. */
  22497. getSubMaterial(index: number): Nullable<Material>;
  22498. /**
  22499. * Get the list of active textures for the whole sub materials list.
  22500. * @returns All the textures that will be used during the rendering
  22501. */
  22502. getActiveTextures(): BaseTexture[];
  22503. /**
  22504. * Gets the current class name of the material e.g. "MultiMaterial"
  22505. * Mainly use in serialization.
  22506. * @returns the class name
  22507. */
  22508. getClassName(): string;
  22509. /**
  22510. * Checks if the material is ready to render the requested sub mesh
  22511. * @param mesh Define the mesh the submesh belongs to
  22512. * @param subMesh Define the sub mesh to look readyness for
  22513. * @param useInstances Define whether or not the material is used with instances
  22514. * @returns true if ready, otherwise false
  22515. */
  22516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22517. /**
  22518. * Clones the current material and its related sub materials
  22519. * @param name Define the name of the newly cloned material
  22520. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22521. * @returns the cloned material
  22522. */
  22523. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22524. /**
  22525. * Serializes the materials into a JSON representation.
  22526. * @returns the JSON representation
  22527. */
  22528. serialize(): any;
  22529. /**
  22530. * Dispose the material and release its associated resources
  22531. * @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)
  22532. * @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)
  22533. * @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)
  22534. */
  22535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22536. /**
  22537. * Creates a MultiMaterial from parsed MultiMaterial data.
  22538. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22539. * @param scene defines the hosting scene
  22540. * @returns a new MultiMaterial
  22541. */
  22542. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22543. }
  22544. }
  22545. declare module "babylonjs/Meshes/subMesh" {
  22546. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22547. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22548. import { Engine } from "babylonjs/Engines/engine";
  22549. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22550. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22551. import { Effect } from "babylonjs/Materials/effect";
  22552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22553. import { Plane } from "babylonjs/Maths/math.plane";
  22554. import { Collider } from "babylonjs/Collisions/collider";
  22555. import { Material } from "babylonjs/Materials/material";
  22556. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22558. import { Mesh } from "babylonjs/Meshes/mesh";
  22559. import { Ray } from "babylonjs/Culling/ray";
  22560. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22561. /**
  22562. * Base class for submeshes
  22563. */
  22564. export class BaseSubMesh {
  22565. /** @hidden */
  22566. _materialDefines: Nullable<MaterialDefines>;
  22567. /** @hidden */
  22568. _materialEffect: Nullable<Effect>;
  22569. /** @hidden */
  22570. _effectOverride: Nullable<Effect>;
  22571. /**
  22572. * Gets material defines used by the effect associated to the sub mesh
  22573. */
  22574. get materialDefines(): Nullable<MaterialDefines>;
  22575. /**
  22576. * Sets material defines used by the effect associated to the sub mesh
  22577. */
  22578. set materialDefines(defines: Nullable<MaterialDefines>);
  22579. /**
  22580. * Gets associated effect
  22581. */
  22582. get effect(): Nullable<Effect>;
  22583. /**
  22584. * Sets associated effect (effect used to render this submesh)
  22585. * @param effect defines the effect to associate with
  22586. * @param defines defines the set of defines used to compile this effect
  22587. */
  22588. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22589. }
  22590. /**
  22591. * Defines a subdivision inside a mesh
  22592. */
  22593. export class SubMesh extends BaseSubMesh implements ICullable {
  22594. /** the material index to use */
  22595. materialIndex: number;
  22596. /** vertex index start */
  22597. verticesStart: number;
  22598. /** vertices count */
  22599. verticesCount: number;
  22600. /** index start */
  22601. indexStart: number;
  22602. /** indices count */
  22603. indexCount: number;
  22604. /** @hidden */
  22605. _linesIndexCount: number;
  22606. private _mesh;
  22607. private _renderingMesh;
  22608. private _boundingInfo;
  22609. private _linesIndexBuffer;
  22610. /** @hidden */
  22611. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22612. /** @hidden */
  22613. _trianglePlanes: Plane[];
  22614. /** @hidden */
  22615. _lastColliderTransformMatrix: Nullable<Matrix>;
  22616. /** @hidden */
  22617. _renderId: number;
  22618. /** @hidden */
  22619. _alphaIndex: number;
  22620. /** @hidden */
  22621. _distanceToCamera: number;
  22622. /** @hidden */
  22623. _id: number;
  22624. private _currentMaterial;
  22625. /**
  22626. * Add a new submesh to a mesh
  22627. * @param materialIndex defines the material index to use
  22628. * @param verticesStart defines vertex index start
  22629. * @param verticesCount defines vertices count
  22630. * @param indexStart defines index start
  22631. * @param indexCount defines indices count
  22632. * @param mesh defines the parent mesh
  22633. * @param renderingMesh defines an optional rendering mesh
  22634. * @param createBoundingBox defines if bounding box should be created for this submesh
  22635. * @returns the new submesh
  22636. */
  22637. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22638. /**
  22639. * Creates a new submesh
  22640. * @param materialIndex defines the material index to use
  22641. * @param verticesStart defines vertex index start
  22642. * @param verticesCount defines vertices count
  22643. * @param indexStart defines index start
  22644. * @param indexCount defines indices count
  22645. * @param mesh defines the parent mesh
  22646. * @param renderingMesh defines an optional rendering mesh
  22647. * @param createBoundingBox defines if bounding box should be created for this submesh
  22648. */
  22649. constructor(
  22650. /** the material index to use */
  22651. materialIndex: number,
  22652. /** vertex index start */
  22653. verticesStart: number,
  22654. /** vertices count */
  22655. verticesCount: number,
  22656. /** index start */
  22657. indexStart: number,
  22658. /** indices count */
  22659. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22660. /**
  22661. * Returns true if this submesh covers the entire parent mesh
  22662. * @ignorenaming
  22663. */
  22664. get IsGlobal(): boolean;
  22665. /**
  22666. * Returns the submesh BoudingInfo object
  22667. * @returns current bounding info (or mesh's one if the submesh is global)
  22668. */
  22669. getBoundingInfo(): BoundingInfo;
  22670. /**
  22671. * Sets the submesh BoundingInfo
  22672. * @param boundingInfo defines the new bounding info to use
  22673. * @returns the SubMesh
  22674. */
  22675. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22676. /**
  22677. * Returns the mesh of the current submesh
  22678. * @return the parent mesh
  22679. */
  22680. getMesh(): AbstractMesh;
  22681. /**
  22682. * Returns the rendering mesh of the submesh
  22683. * @returns the rendering mesh (could be different from parent mesh)
  22684. */
  22685. getRenderingMesh(): Mesh;
  22686. /**
  22687. * Returns the submesh material
  22688. * @returns null or the current material
  22689. */
  22690. getMaterial(): Nullable<Material>;
  22691. /**
  22692. * Sets a new updated BoundingInfo object to the submesh
  22693. * @param data defines an optional position array to use to determine the bounding info
  22694. * @returns the SubMesh
  22695. */
  22696. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22697. /** @hidden */
  22698. _checkCollision(collider: Collider): boolean;
  22699. /**
  22700. * Updates the submesh BoundingInfo
  22701. * @param world defines the world matrix to use to update the bounding info
  22702. * @returns the submesh
  22703. */
  22704. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22705. /**
  22706. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22707. * @param frustumPlanes defines the frustum planes
  22708. * @returns true if the submesh is intersecting with the frustum
  22709. */
  22710. isInFrustum(frustumPlanes: Plane[]): boolean;
  22711. /**
  22712. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22713. * @param frustumPlanes defines the frustum planes
  22714. * @returns true if the submesh is inside the frustum
  22715. */
  22716. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22717. /**
  22718. * Renders the submesh
  22719. * @param enableAlphaMode defines if alpha needs to be used
  22720. * @returns the submesh
  22721. */
  22722. render(enableAlphaMode: boolean): SubMesh;
  22723. /**
  22724. * @hidden
  22725. */
  22726. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22727. /**
  22728. * Checks if the submesh intersects with a ray
  22729. * @param ray defines the ray to test
  22730. * @returns true is the passed ray intersects the submesh bounding box
  22731. */
  22732. canIntersects(ray: Ray): boolean;
  22733. /**
  22734. * Intersects current submesh with a ray
  22735. * @param ray defines the ray to test
  22736. * @param positions defines mesh's positions array
  22737. * @param indices defines mesh's indices array
  22738. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22739. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22740. * @returns intersection info or null if no intersection
  22741. */
  22742. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22743. /** @hidden */
  22744. private _intersectLines;
  22745. /** @hidden */
  22746. private _intersectUnIndexedLines;
  22747. /** @hidden */
  22748. private _intersectTriangles;
  22749. /** @hidden */
  22750. private _intersectUnIndexedTriangles;
  22751. /** @hidden */
  22752. _rebuild(): void;
  22753. /**
  22754. * Creates a new submesh from the passed mesh
  22755. * @param newMesh defines the new hosting mesh
  22756. * @param newRenderingMesh defines an optional rendering mesh
  22757. * @returns the new submesh
  22758. */
  22759. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22760. /**
  22761. * Release associated resources
  22762. */
  22763. dispose(): void;
  22764. /**
  22765. * Gets the class name
  22766. * @returns the string "SubMesh".
  22767. */
  22768. getClassName(): string;
  22769. /**
  22770. * Creates a new submesh from indices data
  22771. * @param materialIndex the index of the main mesh material
  22772. * @param startIndex the index where to start the copy in the mesh indices array
  22773. * @param indexCount the number of indices to copy then from the startIndex
  22774. * @param mesh the main mesh to create the submesh from
  22775. * @param renderingMesh the optional rendering mesh
  22776. * @returns a new submesh
  22777. */
  22778. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22779. }
  22780. }
  22781. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22782. /**
  22783. * Class used to represent data loading progression
  22784. */
  22785. export class SceneLoaderFlags {
  22786. private static _ForceFullSceneLoadingForIncremental;
  22787. private static _ShowLoadingScreen;
  22788. private static _CleanBoneMatrixWeights;
  22789. private static _loggingLevel;
  22790. /**
  22791. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22792. */
  22793. static get ForceFullSceneLoadingForIncremental(): boolean;
  22794. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22795. /**
  22796. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22797. */
  22798. static get ShowLoadingScreen(): boolean;
  22799. static set ShowLoadingScreen(value: boolean);
  22800. /**
  22801. * Defines the current logging level (while loading the scene)
  22802. * @ignorenaming
  22803. */
  22804. static get loggingLevel(): number;
  22805. static set loggingLevel(value: number);
  22806. /**
  22807. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22808. */
  22809. static get CleanBoneMatrixWeights(): boolean;
  22810. static set CleanBoneMatrixWeights(value: boolean);
  22811. }
  22812. }
  22813. declare module "babylonjs/Meshes/geometry" {
  22814. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22815. import { Scene } from "babylonjs/scene";
  22816. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22817. import { Engine } from "babylonjs/Engines/engine";
  22818. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22819. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22820. import { Effect } from "babylonjs/Materials/effect";
  22821. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22822. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22823. import { Mesh } from "babylonjs/Meshes/mesh";
  22824. /**
  22825. * Class used to store geometry data (vertex buffers + index buffer)
  22826. */
  22827. export class Geometry implements IGetSetVerticesData {
  22828. /**
  22829. * Gets or sets the ID of the geometry
  22830. */
  22831. id: string;
  22832. /**
  22833. * Gets or sets the unique ID of the geometry
  22834. */
  22835. uniqueId: number;
  22836. /**
  22837. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22838. */
  22839. delayLoadState: number;
  22840. /**
  22841. * Gets the file containing the data to load when running in delay load state
  22842. */
  22843. delayLoadingFile: Nullable<string>;
  22844. /**
  22845. * Callback called when the geometry is updated
  22846. */
  22847. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22848. private _scene;
  22849. private _engine;
  22850. private _meshes;
  22851. private _totalVertices;
  22852. /** @hidden */
  22853. _indices: IndicesArray;
  22854. /** @hidden */
  22855. _vertexBuffers: {
  22856. [key: string]: VertexBuffer;
  22857. };
  22858. private _isDisposed;
  22859. private _extend;
  22860. private _boundingBias;
  22861. /** @hidden */
  22862. _delayInfo: Array<string>;
  22863. private _indexBuffer;
  22864. private _indexBufferIsUpdatable;
  22865. /** @hidden */
  22866. _boundingInfo: Nullable<BoundingInfo>;
  22867. /** @hidden */
  22868. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22869. /** @hidden */
  22870. _softwareSkinningFrameId: number;
  22871. private _vertexArrayObjects;
  22872. private _updatable;
  22873. /** @hidden */
  22874. _positions: Nullable<Vector3[]>;
  22875. /**
  22876. * 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
  22877. */
  22878. get boundingBias(): Vector2;
  22879. /**
  22880. * 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
  22881. */
  22882. set boundingBias(value: Vector2);
  22883. /**
  22884. * Static function used to attach a new empty geometry to a mesh
  22885. * @param mesh defines the mesh to attach the geometry to
  22886. * @returns the new Geometry
  22887. */
  22888. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22889. /** Get the list of meshes using this geometry */
  22890. get meshes(): Mesh[];
  22891. /**
  22892. * Creates a new geometry
  22893. * @param id defines the unique ID
  22894. * @param scene defines the hosting scene
  22895. * @param vertexData defines the VertexData used to get geometry data
  22896. * @param updatable defines if geometry must be updatable (false by default)
  22897. * @param mesh defines the mesh that will be associated with the geometry
  22898. */
  22899. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22900. /**
  22901. * Gets the current extend of the geometry
  22902. */
  22903. get extend(): {
  22904. minimum: Vector3;
  22905. maximum: Vector3;
  22906. };
  22907. /**
  22908. * Gets the hosting scene
  22909. * @returns the hosting Scene
  22910. */
  22911. getScene(): Scene;
  22912. /**
  22913. * Gets the hosting engine
  22914. * @returns the hosting Engine
  22915. */
  22916. getEngine(): Engine;
  22917. /**
  22918. * Defines if the geometry is ready to use
  22919. * @returns true if the geometry is ready to be used
  22920. */
  22921. isReady(): boolean;
  22922. /**
  22923. * Gets a value indicating that the geometry should not be serialized
  22924. */
  22925. get doNotSerialize(): boolean;
  22926. /** @hidden */
  22927. _rebuild(): void;
  22928. /**
  22929. * Affects all geometry data in one call
  22930. * @param vertexData defines the geometry data
  22931. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22932. */
  22933. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22934. /**
  22935. * Set specific vertex data
  22936. * @param kind defines the data kind (Position, normal, etc...)
  22937. * @param data defines the vertex data to use
  22938. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22939. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22940. */
  22941. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22942. /**
  22943. * Removes a specific vertex data
  22944. * @param kind defines the data kind (Position, normal, etc...)
  22945. */
  22946. removeVerticesData(kind: string): void;
  22947. /**
  22948. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22949. * @param buffer defines the vertex buffer to use
  22950. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22951. */
  22952. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22953. /**
  22954. * Update a specific vertex buffer
  22955. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22956. * It will do nothing if the buffer is not updatable
  22957. * @param kind defines the data kind (Position, normal, etc...)
  22958. * @param data defines the data to use
  22959. * @param offset defines the offset in the target buffer where to store the data
  22960. * @param useBytes set to true if the offset is in bytes
  22961. */
  22962. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22963. /**
  22964. * Update a specific vertex buffer
  22965. * This function will create a new buffer if the current one is not updatable
  22966. * @param kind defines the data kind (Position, normal, etc...)
  22967. * @param data defines the data to use
  22968. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22969. */
  22970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22971. private _updateBoundingInfo;
  22972. /** @hidden */
  22973. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22974. /**
  22975. * Gets total number of vertices
  22976. * @returns the total number of vertices
  22977. */
  22978. getTotalVertices(): number;
  22979. /**
  22980. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22981. * @param kind defines the data kind (Position, normal, etc...)
  22982. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22983. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22984. * @returns a float array containing vertex data
  22985. */
  22986. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22987. /**
  22988. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22989. * @param kind defines the data kind (Position, normal, etc...)
  22990. * @returns true if the vertex buffer with the specified kind is updatable
  22991. */
  22992. isVertexBufferUpdatable(kind: string): boolean;
  22993. /**
  22994. * Gets a specific vertex buffer
  22995. * @param kind defines the data kind (Position, normal, etc...)
  22996. * @returns a VertexBuffer
  22997. */
  22998. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22999. /**
  23000. * Returns all vertex buffers
  23001. * @return an object holding all vertex buffers indexed by kind
  23002. */
  23003. getVertexBuffers(): Nullable<{
  23004. [key: string]: VertexBuffer;
  23005. }>;
  23006. /**
  23007. * Gets a boolean indicating if specific vertex buffer is present
  23008. * @param kind defines the data kind (Position, normal, etc...)
  23009. * @returns true if data is present
  23010. */
  23011. isVerticesDataPresent(kind: string): boolean;
  23012. /**
  23013. * Gets a list of all attached data kinds (Position, normal, etc...)
  23014. * @returns a list of string containing all kinds
  23015. */
  23016. getVerticesDataKinds(): string[];
  23017. /**
  23018. * Update index buffer
  23019. * @param indices defines the indices to store in the index buffer
  23020. * @param offset defines the offset in the target buffer where to store the data
  23021. * @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)
  23022. */
  23023. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23024. /**
  23025. * Creates a new index buffer
  23026. * @param indices defines the indices to store in the index buffer
  23027. * @param totalVertices defines the total number of vertices (could be null)
  23028. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23029. */
  23030. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23031. /**
  23032. * Return the total number of indices
  23033. * @returns the total number of indices
  23034. */
  23035. getTotalIndices(): number;
  23036. /**
  23037. * Gets the index buffer array
  23038. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23040. * @returns the index buffer array
  23041. */
  23042. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23043. /**
  23044. * Gets the index buffer
  23045. * @return the index buffer
  23046. */
  23047. getIndexBuffer(): Nullable<DataBuffer>;
  23048. /** @hidden */
  23049. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23050. /**
  23051. * Release the associated resources for a specific mesh
  23052. * @param mesh defines the source mesh
  23053. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23054. */
  23055. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23056. /**
  23057. * Apply current geometry to a given mesh
  23058. * @param mesh defines the mesh to apply geometry to
  23059. */
  23060. applyToMesh(mesh: Mesh): void;
  23061. private _updateExtend;
  23062. private _applyToMesh;
  23063. private notifyUpdate;
  23064. /**
  23065. * Load the geometry if it was flagged as delay loaded
  23066. * @param scene defines the hosting scene
  23067. * @param onLoaded defines a callback called when the geometry is loaded
  23068. */
  23069. load(scene: Scene, onLoaded?: () => void): void;
  23070. private _queueLoad;
  23071. /**
  23072. * Invert the geometry to move from a right handed system to a left handed one.
  23073. */
  23074. toLeftHanded(): void;
  23075. /** @hidden */
  23076. _resetPointsArrayCache(): void;
  23077. /** @hidden */
  23078. _generatePointsArray(): boolean;
  23079. /**
  23080. * Gets a value indicating if the geometry is disposed
  23081. * @returns true if the geometry was disposed
  23082. */
  23083. isDisposed(): boolean;
  23084. private _disposeVertexArrayObjects;
  23085. /**
  23086. * Free all associated resources
  23087. */
  23088. dispose(): void;
  23089. /**
  23090. * Clone the current geometry into a new geometry
  23091. * @param id defines the unique ID of the new geometry
  23092. * @returns a new geometry object
  23093. */
  23094. copy(id: string): Geometry;
  23095. /**
  23096. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23097. * @return a JSON representation of the current geometry data (without the vertices data)
  23098. */
  23099. serialize(): any;
  23100. private toNumberArray;
  23101. /**
  23102. * Serialize all vertices data into a JSON oject
  23103. * @returns a JSON representation of the current geometry data
  23104. */
  23105. serializeVerticeData(): any;
  23106. /**
  23107. * Extracts a clone of a mesh geometry
  23108. * @param mesh defines the source mesh
  23109. * @param id defines the unique ID of the new geometry object
  23110. * @returns the new geometry object
  23111. */
  23112. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23113. /**
  23114. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23115. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23116. * Be aware Math.random() could cause collisions, but:
  23117. * "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"
  23118. * @returns a string containing a new GUID
  23119. */
  23120. static RandomId(): string;
  23121. /** @hidden */
  23122. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23123. private static _CleanMatricesWeights;
  23124. /**
  23125. * Create a new geometry from persisted data (Using .babylon file format)
  23126. * @param parsedVertexData defines the persisted data
  23127. * @param scene defines the hosting scene
  23128. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23129. * @returns the new geometry object
  23130. */
  23131. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23132. }
  23133. }
  23134. declare module "babylonjs/Meshes/mesh.vertexData" {
  23135. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23136. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23137. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23138. import { Geometry } from "babylonjs/Meshes/geometry";
  23139. import { Mesh } from "babylonjs/Meshes/mesh";
  23140. /**
  23141. * Define an interface for all classes that will get and set the data on vertices
  23142. */
  23143. export interface IGetSetVerticesData {
  23144. /**
  23145. * Gets a boolean indicating if specific vertex data is present
  23146. * @param kind defines the vertex data kind to use
  23147. * @returns true is data kind is present
  23148. */
  23149. isVerticesDataPresent(kind: string): boolean;
  23150. /**
  23151. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23152. * @param kind defines the data kind (Position, normal, etc...)
  23153. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23154. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23155. * @returns a float array containing vertex data
  23156. */
  23157. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23158. /**
  23159. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23160. * @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.
  23161. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23162. * @returns the indices array or an empty array if the mesh has no geometry
  23163. */
  23164. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23165. /**
  23166. * Set specific vertex data
  23167. * @param kind defines the data kind (Position, normal, etc...)
  23168. * @param data defines the vertex data to use
  23169. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23170. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23171. */
  23172. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23173. /**
  23174. * Update a specific associated vertex buffer
  23175. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23176. * - VertexBuffer.PositionKind
  23177. * - VertexBuffer.UVKind
  23178. * - VertexBuffer.UV2Kind
  23179. * - VertexBuffer.UV3Kind
  23180. * - VertexBuffer.UV4Kind
  23181. * - VertexBuffer.UV5Kind
  23182. * - VertexBuffer.UV6Kind
  23183. * - VertexBuffer.ColorKind
  23184. * - VertexBuffer.MatricesIndicesKind
  23185. * - VertexBuffer.MatricesIndicesExtraKind
  23186. * - VertexBuffer.MatricesWeightsKind
  23187. * - VertexBuffer.MatricesWeightsExtraKind
  23188. * @param data defines the data source
  23189. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23190. * @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)
  23191. */
  23192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23193. /**
  23194. * Creates a new index buffer
  23195. * @param indices defines the indices to store in the index buffer
  23196. * @param totalVertices defines the total number of vertices (could be null)
  23197. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23198. */
  23199. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23200. }
  23201. /**
  23202. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23203. */
  23204. export class VertexData {
  23205. /**
  23206. * Mesh side orientation : usually the external or front surface
  23207. */
  23208. static readonly FRONTSIDE: number;
  23209. /**
  23210. * Mesh side orientation : usually the internal or back surface
  23211. */
  23212. static readonly BACKSIDE: number;
  23213. /**
  23214. * Mesh side orientation : both internal and external or front and back surfaces
  23215. */
  23216. static readonly DOUBLESIDE: number;
  23217. /**
  23218. * Mesh side orientation : by default, `FRONTSIDE`
  23219. */
  23220. static readonly DEFAULTSIDE: number;
  23221. /**
  23222. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23223. */
  23224. positions: Nullable<FloatArray>;
  23225. /**
  23226. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23227. */
  23228. normals: Nullable<FloatArray>;
  23229. /**
  23230. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23231. */
  23232. tangents: Nullable<FloatArray>;
  23233. /**
  23234. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23235. */
  23236. uvs: Nullable<FloatArray>;
  23237. /**
  23238. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23239. */
  23240. uvs2: Nullable<FloatArray>;
  23241. /**
  23242. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23243. */
  23244. uvs3: Nullable<FloatArray>;
  23245. /**
  23246. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23247. */
  23248. uvs4: Nullable<FloatArray>;
  23249. /**
  23250. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23251. */
  23252. uvs5: Nullable<FloatArray>;
  23253. /**
  23254. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23255. */
  23256. uvs6: Nullable<FloatArray>;
  23257. /**
  23258. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23259. */
  23260. colors: Nullable<FloatArray>;
  23261. /**
  23262. * 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).
  23263. */
  23264. matricesIndices: Nullable<FloatArray>;
  23265. /**
  23266. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23267. */
  23268. matricesWeights: Nullable<FloatArray>;
  23269. /**
  23270. * An array extending the number of possible indices
  23271. */
  23272. matricesIndicesExtra: Nullable<FloatArray>;
  23273. /**
  23274. * An array extending the number of possible weights when the number of indices is extended
  23275. */
  23276. matricesWeightsExtra: Nullable<FloatArray>;
  23277. /**
  23278. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23279. */
  23280. indices: Nullable<IndicesArray>;
  23281. /**
  23282. * Uses the passed data array to set the set the values for the specified kind of data
  23283. * @param data a linear array of floating numbers
  23284. * @param kind the type of data that is being set, eg positions, colors etc
  23285. */
  23286. set(data: FloatArray, kind: string): void;
  23287. /**
  23288. * Associates the vertexData to the passed Mesh.
  23289. * Sets it as updatable or not (default `false`)
  23290. * @param mesh the mesh the vertexData is applied to
  23291. * @param updatable when used and having the value true allows new data to update the vertexData
  23292. * @returns the VertexData
  23293. */
  23294. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23295. /**
  23296. * Associates the vertexData to the passed Geometry.
  23297. * Sets it as updatable or not (default `false`)
  23298. * @param geometry the geometry the vertexData is applied to
  23299. * @param updatable when used and having the value true allows new data to update the vertexData
  23300. * @returns VertexData
  23301. */
  23302. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23303. /**
  23304. * Updates the associated mesh
  23305. * @param mesh the mesh to be updated
  23306. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23307. * @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
  23308. * @returns VertexData
  23309. */
  23310. updateMesh(mesh: Mesh): VertexData;
  23311. /**
  23312. * Updates the associated geometry
  23313. * @param geometry the geometry to be updated
  23314. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23315. * @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
  23316. * @returns VertexData.
  23317. */
  23318. updateGeometry(geometry: Geometry): VertexData;
  23319. private _applyTo;
  23320. private _update;
  23321. /**
  23322. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23323. * @param matrix the transforming matrix
  23324. * @returns the VertexData
  23325. */
  23326. transform(matrix: Matrix): VertexData;
  23327. /**
  23328. * Merges the passed VertexData into the current one
  23329. * @param other the VertexData to be merged into the current one
  23330. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23331. * @returns the modified VertexData
  23332. */
  23333. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23334. private _mergeElement;
  23335. private _validate;
  23336. /**
  23337. * Serializes the VertexData
  23338. * @returns a serialized object
  23339. */
  23340. serialize(): any;
  23341. /**
  23342. * Extracts the vertexData from a mesh
  23343. * @param mesh the mesh from which to extract the VertexData
  23344. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23345. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23346. * @returns the object VertexData associated to the passed mesh
  23347. */
  23348. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23349. /**
  23350. * Extracts the vertexData from the geometry
  23351. * @param geometry the geometry from which to extract the VertexData
  23352. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23353. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23354. * @returns the object VertexData associated to the passed mesh
  23355. */
  23356. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23357. private static _ExtractFrom;
  23358. /**
  23359. * Creates the VertexData for a Ribbon
  23360. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23361. * * pathArray array of paths, each of which an array of successive Vector3
  23362. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23363. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23364. * * 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
  23365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23366. * * 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)
  23367. * * 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)
  23368. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23369. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23370. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23371. * @returns the VertexData of the ribbon
  23372. */
  23373. static CreateRibbon(options: {
  23374. pathArray: Vector3[][];
  23375. closeArray?: boolean;
  23376. closePath?: boolean;
  23377. offset?: number;
  23378. sideOrientation?: number;
  23379. frontUVs?: Vector4;
  23380. backUVs?: Vector4;
  23381. invertUV?: boolean;
  23382. uvs?: Vector2[];
  23383. colors?: Color4[];
  23384. }): VertexData;
  23385. /**
  23386. * Creates the VertexData for a box
  23387. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23388. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23389. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23390. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23391. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23392. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23393. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23395. * * 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)
  23396. * * 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)
  23397. * @returns the VertexData of the box
  23398. */
  23399. static CreateBox(options: {
  23400. size?: number;
  23401. width?: number;
  23402. height?: number;
  23403. depth?: number;
  23404. faceUV?: Vector4[];
  23405. faceColors?: Color4[];
  23406. sideOrientation?: number;
  23407. frontUVs?: Vector4;
  23408. backUVs?: Vector4;
  23409. }): VertexData;
  23410. /**
  23411. * Creates the VertexData for a tiled box
  23412. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23413. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23414. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23415. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23417. * @returns the VertexData of the box
  23418. */
  23419. static CreateTiledBox(options: {
  23420. pattern?: number;
  23421. width?: number;
  23422. height?: number;
  23423. depth?: number;
  23424. tileSize?: number;
  23425. tileWidth?: number;
  23426. tileHeight?: number;
  23427. alignHorizontal?: number;
  23428. alignVertical?: number;
  23429. faceUV?: Vector4[];
  23430. faceColors?: Color4[];
  23431. sideOrientation?: number;
  23432. }): VertexData;
  23433. /**
  23434. * Creates the VertexData for a tiled plane
  23435. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23436. * * pattern a limited pattern arrangement depending on the number
  23437. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23438. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23439. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23441. * * 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)
  23442. * * 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)
  23443. * @returns the VertexData of the tiled plane
  23444. */
  23445. static CreateTiledPlane(options: {
  23446. pattern?: number;
  23447. tileSize?: number;
  23448. tileWidth?: number;
  23449. tileHeight?: number;
  23450. size?: number;
  23451. width?: number;
  23452. height?: number;
  23453. alignHorizontal?: number;
  23454. alignVertical?: number;
  23455. sideOrientation?: number;
  23456. frontUVs?: Vector4;
  23457. backUVs?: Vector4;
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23461. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23462. * * segments sets the number of horizontal strips optional, default 32
  23463. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23464. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23465. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23466. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23467. * * 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
  23468. * * 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
  23469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23470. * * 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)
  23471. * * 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)
  23472. * @returns the VertexData of the ellipsoid
  23473. */
  23474. static CreateSphere(options: {
  23475. segments?: number;
  23476. diameter?: number;
  23477. diameterX?: number;
  23478. diameterY?: number;
  23479. diameterZ?: number;
  23480. arc?: number;
  23481. slice?: number;
  23482. sideOrientation?: number;
  23483. frontUVs?: Vector4;
  23484. backUVs?: Vector4;
  23485. }): VertexData;
  23486. /**
  23487. * Creates the VertexData for a cylinder, cone or prism
  23488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23489. * * height sets the height (y direction) of the cylinder, optional, default 2
  23490. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23491. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23492. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23493. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23494. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23495. * * 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
  23496. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23497. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23498. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23499. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23501. * * 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)
  23502. * * 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)
  23503. * @returns the VertexData of the cylinder, cone or prism
  23504. */
  23505. static CreateCylinder(options: {
  23506. height?: number;
  23507. diameterTop?: number;
  23508. diameterBottom?: number;
  23509. diameter?: number;
  23510. tessellation?: number;
  23511. subdivisions?: number;
  23512. arc?: number;
  23513. faceColors?: Color4[];
  23514. faceUV?: Vector4[];
  23515. hasRings?: boolean;
  23516. enclose?: boolean;
  23517. sideOrientation?: number;
  23518. frontUVs?: Vector4;
  23519. backUVs?: Vector4;
  23520. }): VertexData;
  23521. /**
  23522. * Creates the VertexData for a torus
  23523. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23524. * * diameter the diameter of the torus, optional default 1
  23525. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23526. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23528. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23529. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23530. * @returns the VertexData of the torus
  23531. */
  23532. static CreateTorus(options: {
  23533. diameter?: number;
  23534. thickness?: number;
  23535. tessellation?: number;
  23536. sideOrientation?: number;
  23537. frontUVs?: Vector4;
  23538. backUVs?: Vector4;
  23539. }): VertexData;
  23540. /**
  23541. * Creates the VertexData of the LineSystem
  23542. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23543. * - lines an array of lines, each line being an array of successive Vector3
  23544. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23545. * @returns the VertexData of the LineSystem
  23546. */
  23547. static CreateLineSystem(options: {
  23548. lines: Vector3[][];
  23549. colors?: Nullable<Color4[][]>;
  23550. }): VertexData;
  23551. /**
  23552. * Create the VertexData for a DashedLines
  23553. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23554. * - points an array successive Vector3
  23555. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23556. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23557. * - dashNb the intended total number of dashes, optional, default 200
  23558. * @returns the VertexData for the DashedLines
  23559. */
  23560. static CreateDashedLines(options: {
  23561. points: Vector3[];
  23562. dashSize?: number;
  23563. gapSize?: number;
  23564. dashNb?: number;
  23565. }): VertexData;
  23566. /**
  23567. * Creates the VertexData for a Ground
  23568. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23569. * - width the width (x direction) of the ground, optional, default 1
  23570. * - height the height (z direction) of the ground, optional, default 1
  23571. * - subdivisions the number of subdivisions per side, optional, default 1
  23572. * @returns the VertexData of the Ground
  23573. */
  23574. static CreateGround(options: {
  23575. width?: number;
  23576. height?: number;
  23577. subdivisions?: number;
  23578. subdivisionsX?: number;
  23579. subdivisionsY?: number;
  23580. }): VertexData;
  23581. /**
  23582. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23583. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23584. * * xmin the ground minimum X coordinate, optional, default -1
  23585. * * zmin the ground minimum Z coordinate, optional, default -1
  23586. * * xmax the ground maximum X coordinate, optional, default 1
  23587. * * zmax the ground maximum Z coordinate, optional, default 1
  23588. * * 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}
  23589. * * 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}
  23590. * @returns the VertexData of the TiledGround
  23591. */
  23592. static CreateTiledGround(options: {
  23593. xmin: number;
  23594. zmin: number;
  23595. xmax: number;
  23596. zmax: number;
  23597. subdivisions?: {
  23598. w: number;
  23599. h: number;
  23600. };
  23601. precision?: {
  23602. w: number;
  23603. h: number;
  23604. };
  23605. }): VertexData;
  23606. /**
  23607. * Creates the VertexData of the Ground designed from a heightmap
  23608. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23609. * * width the width (x direction) of the ground
  23610. * * height the height (z direction) of the ground
  23611. * * subdivisions the number of subdivisions per side
  23612. * * minHeight the minimum altitude on the ground, optional, default 0
  23613. * * maxHeight the maximum altitude on the ground, optional default 1
  23614. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23615. * * buffer the array holding the image color data
  23616. * * bufferWidth the width of image
  23617. * * bufferHeight the height of image
  23618. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23619. * @returns the VertexData of the Ground designed from a heightmap
  23620. */
  23621. static CreateGroundFromHeightMap(options: {
  23622. width: number;
  23623. height: number;
  23624. subdivisions: number;
  23625. minHeight: number;
  23626. maxHeight: number;
  23627. colorFilter: Color3;
  23628. buffer: Uint8Array;
  23629. bufferWidth: number;
  23630. bufferHeight: number;
  23631. alphaFilter: number;
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData for a Plane
  23635. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23636. * * size sets the width and height of the plane to the value of size, optional default 1
  23637. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23638. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23640. * * 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)
  23641. * * 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)
  23642. * @returns the VertexData of the box
  23643. */
  23644. static CreatePlane(options: {
  23645. size?: number;
  23646. width?: number;
  23647. height?: number;
  23648. sideOrientation?: number;
  23649. frontUVs?: Vector4;
  23650. backUVs?: Vector4;
  23651. }): VertexData;
  23652. /**
  23653. * Creates the VertexData of the Disc or regular Polygon
  23654. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23655. * * radius the radius of the disc, optional default 0.5
  23656. * * tessellation the number of polygon sides, optional, default 64
  23657. * * 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
  23658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23659. * * 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)
  23660. * * 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)
  23661. * @returns the VertexData of the box
  23662. */
  23663. static CreateDisc(options: {
  23664. radius?: number;
  23665. tessellation?: number;
  23666. arc?: number;
  23667. sideOrientation?: number;
  23668. frontUVs?: Vector4;
  23669. backUVs?: Vector4;
  23670. }): VertexData;
  23671. /**
  23672. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23673. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23674. * @param polygon a mesh built from polygonTriangulation.build()
  23675. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23676. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23677. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23678. * @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)
  23679. * @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)
  23680. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23681. * @returns the VertexData of the Polygon
  23682. */
  23683. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23684. /**
  23685. * Creates the VertexData of the IcoSphere
  23686. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23687. * * radius the radius of the IcoSphere, optional default 1
  23688. * * radiusX allows stretching in the x direction, optional, default radius
  23689. * * radiusY allows stretching in the y direction, optional, default radius
  23690. * * radiusZ allows stretching in the z direction, optional, default radius
  23691. * * flat when true creates a flat shaded mesh, optional, default true
  23692. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23694. * * 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)
  23695. * * 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)
  23696. * @returns the VertexData of the IcoSphere
  23697. */
  23698. static CreateIcoSphere(options: {
  23699. radius?: number;
  23700. radiusX?: number;
  23701. radiusY?: number;
  23702. radiusZ?: number;
  23703. flat?: boolean;
  23704. subdivisions?: number;
  23705. sideOrientation?: number;
  23706. frontUVs?: Vector4;
  23707. backUVs?: Vector4;
  23708. }): VertexData;
  23709. /**
  23710. * Creates the VertexData for a Polyhedron
  23711. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23712. * * type provided types are:
  23713. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23714. * * 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)
  23715. * * size the size of the IcoSphere, optional default 1
  23716. * * sizeX allows stretching in the x direction, optional, default size
  23717. * * sizeY allows stretching in the y direction, optional, default size
  23718. * * sizeZ allows stretching in the z direction, optional, default size
  23719. * * 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
  23720. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23721. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23722. * * flat when true creates a flat shaded mesh, optional, default true
  23723. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23724. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23725. * * 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)
  23726. * * 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)
  23727. * @returns the VertexData of the Polyhedron
  23728. */
  23729. static CreatePolyhedron(options: {
  23730. type?: number;
  23731. size?: number;
  23732. sizeX?: number;
  23733. sizeY?: number;
  23734. sizeZ?: number;
  23735. custom?: any;
  23736. faceUV?: Vector4[];
  23737. faceColors?: Color4[];
  23738. flat?: boolean;
  23739. sideOrientation?: number;
  23740. frontUVs?: Vector4;
  23741. backUVs?: Vector4;
  23742. }): VertexData;
  23743. /**
  23744. * Creates the VertexData for a TorusKnot
  23745. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23746. * * radius the radius of the torus knot, optional, default 2
  23747. * * tube the thickness of the tube, optional, default 0.5
  23748. * * radialSegments the number of sides on each tube segments, optional, default 32
  23749. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23750. * * p the number of windings around the z axis, optional, default 2
  23751. * * q the number of windings around the x axis, optional, default 3
  23752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23753. * * 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)
  23754. * * 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)
  23755. * @returns the VertexData of the Torus Knot
  23756. */
  23757. static CreateTorusKnot(options: {
  23758. radius?: number;
  23759. tube?: number;
  23760. radialSegments?: number;
  23761. tubularSegments?: number;
  23762. p?: number;
  23763. q?: number;
  23764. sideOrientation?: number;
  23765. frontUVs?: Vector4;
  23766. backUVs?: Vector4;
  23767. }): VertexData;
  23768. /**
  23769. * Compute normals for given positions and indices
  23770. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23771. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23772. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23773. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23774. * * facetNormals : optional array of facet normals (vector3)
  23775. * * facetPositions : optional array of facet positions (vector3)
  23776. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23777. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23778. * * bInfo : optional bounding info, required for facetPartitioning computation
  23779. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23780. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23781. * * useRightHandedSystem: optional boolean to for right handed system computation
  23782. * * depthSort : optional boolean to enable the facet depth sort computation
  23783. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23784. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23785. */
  23786. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23787. facetNormals?: any;
  23788. facetPositions?: any;
  23789. facetPartitioning?: any;
  23790. ratio?: number;
  23791. bInfo?: any;
  23792. bbSize?: Vector3;
  23793. subDiv?: any;
  23794. useRightHandedSystem?: boolean;
  23795. depthSort?: boolean;
  23796. distanceTo?: Vector3;
  23797. depthSortedFacets?: any;
  23798. }): void;
  23799. /** @hidden */
  23800. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23801. /**
  23802. * Applies VertexData created from the imported parameters to the geometry
  23803. * @param parsedVertexData the parsed data from an imported file
  23804. * @param geometry the geometry to apply the VertexData to
  23805. */
  23806. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23807. }
  23808. }
  23809. declare module "babylonjs/Morph/morphTarget" {
  23810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23811. import { Observable } from "babylonjs/Misc/observable";
  23812. import { Nullable, FloatArray } from "babylonjs/types";
  23813. import { Scene } from "babylonjs/scene";
  23814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23815. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23816. /**
  23817. * Defines a target to use with MorphTargetManager
  23818. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23819. */
  23820. export class MorphTarget implements IAnimatable {
  23821. /** defines the name of the target */
  23822. name: string;
  23823. /**
  23824. * Gets or sets the list of animations
  23825. */
  23826. animations: import("babylonjs/Animations/animation").Animation[];
  23827. private _scene;
  23828. private _positions;
  23829. private _normals;
  23830. private _tangents;
  23831. private _uvs;
  23832. private _influence;
  23833. private _uniqueId;
  23834. /**
  23835. * Observable raised when the influence changes
  23836. */
  23837. onInfluenceChanged: Observable<boolean>;
  23838. /** @hidden */
  23839. _onDataLayoutChanged: Observable<void>;
  23840. /**
  23841. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23842. */
  23843. get influence(): number;
  23844. set influence(influence: number);
  23845. /**
  23846. * Gets or sets the id of the morph Target
  23847. */
  23848. id: string;
  23849. private _animationPropertiesOverride;
  23850. /**
  23851. * Gets or sets the animation properties override
  23852. */
  23853. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23854. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23855. /**
  23856. * Creates a new MorphTarget
  23857. * @param name defines the name of the target
  23858. * @param influence defines the influence to use
  23859. * @param scene defines the scene the morphtarget belongs to
  23860. */
  23861. constructor(
  23862. /** defines the name of the target */
  23863. name: string, influence?: number, scene?: Nullable<Scene>);
  23864. /**
  23865. * Gets the unique ID of this manager
  23866. */
  23867. get uniqueId(): number;
  23868. /**
  23869. * Gets a boolean defining if the target contains position data
  23870. */
  23871. get hasPositions(): boolean;
  23872. /**
  23873. * Gets a boolean defining if the target contains normal data
  23874. */
  23875. get hasNormals(): boolean;
  23876. /**
  23877. * Gets a boolean defining if the target contains tangent data
  23878. */
  23879. get hasTangents(): boolean;
  23880. /**
  23881. * Gets a boolean defining if the target contains texture coordinates data
  23882. */
  23883. get hasUVs(): boolean;
  23884. /**
  23885. * Affects position data to this target
  23886. * @param data defines the position data to use
  23887. */
  23888. setPositions(data: Nullable<FloatArray>): void;
  23889. /**
  23890. * Gets the position data stored in this target
  23891. * @returns a FloatArray containing the position data (or null if not present)
  23892. */
  23893. getPositions(): Nullable<FloatArray>;
  23894. /**
  23895. * Affects normal data to this target
  23896. * @param data defines the normal data to use
  23897. */
  23898. setNormals(data: Nullable<FloatArray>): void;
  23899. /**
  23900. * Gets the normal data stored in this target
  23901. * @returns a FloatArray containing the normal data (or null if not present)
  23902. */
  23903. getNormals(): Nullable<FloatArray>;
  23904. /**
  23905. * Affects tangent data to this target
  23906. * @param data defines the tangent data to use
  23907. */
  23908. setTangents(data: Nullable<FloatArray>): void;
  23909. /**
  23910. * Gets the tangent data stored in this target
  23911. * @returns a FloatArray containing the tangent data (or null if not present)
  23912. */
  23913. getTangents(): Nullable<FloatArray>;
  23914. /**
  23915. * Affects texture coordinates data to this target
  23916. * @param data defines the texture coordinates data to use
  23917. */
  23918. setUVs(data: Nullable<FloatArray>): void;
  23919. /**
  23920. * Gets the texture coordinates data stored in this target
  23921. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23922. */
  23923. getUVs(): Nullable<FloatArray>;
  23924. /**
  23925. * Clone the current target
  23926. * @returns a new MorphTarget
  23927. */
  23928. clone(): MorphTarget;
  23929. /**
  23930. * Serializes the current target into a Serialization object
  23931. * @returns the serialized object
  23932. */
  23933. serialize(): any;
  23934. /**
  23935. * Returns the string "MorphTarget"
  23936. * @returns "MorphTarget"
  23937. */
  23938. getClassName(): string;
  23939. /**
  23940. * Creates a new target from serialized data
  23941. * @param serializationObject defines the serialized data to use
  23942. * @returns a new MorphTarget
  23943. */
  23944. static Parse(serializationObject: any): MorphTarget;
  23945. /**
  23946. * Creates a MorphTarget from mesh data
  23947. * @param mesh defines the source mesh
  23948. * @param name defines the name to use for the new target
  23949. * @param influence defines the influence to attach to the target
  23950. * @returns a new MorphTarget
  23951. */
  23952. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23953. }
  23954. }
  23955. declare module "babylonjs/Morph/morphTargetManager" {
  23956. import { Nullable } from "babylonjs/types";
  23957. import { Scene } from "babylonjs/scene";
  23958. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23959. /**
  23960. * This class is used to deform meshes using morphing between different targets
  23961. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23962. */
  23963. export class MorphTargetManager {
  23964. private _targets;
  23965. private _targetInfluenceChangedObservers;
  23966. private _targetDataLayoutChangedObservers;
  23967. private _activeTargets;
  23968. private _scene;
  23969. private _influences;
  23970. private _supportsNormals;
  23971. private _supportsTangents;
  23972. private _supportsUVs;
  23973. private _vertexCount;
  23974. private _uniqueId;
  23975. private _tempInfluences;
  23976. /**
  23977. * Gets or sets a boolean indicating if normals must be morphed
  23978. */
  23979. enableNormalMorphing: boolean;
  23980. /**
  23981. * Gets or sets a boolean indicating if tangents must be morphed
  23982. */
  23983. enableTangentMorphing: boolean;
  23984. /**
  23985. * Gets or sets a boolean indicating if UV must be morphed
  23986. */
  23987. enableUVMorphing: boolean;
  23988. /**
  23989. * Creates a new MorphTargetManager
  23990. * @param scene defines the current scene
  23991. */
  23992. constructor(scene?: Nullable<Scene>);
  23993. /**
  23994. * Gets the unique ID of this manager
  23995. */
  23996. get uniqueId(): number;
  23997. /**
  23998. * Gets the number of vertices handled by this manager
  23999. */
  24000. get vertexCount(): number;
  24001. /**
  24002. * Gets a boolean indicating if this manager supports morphing of normals
  24003. */
  24004. get supportsNormals(): boolean;
  24005. /**
  24006. * Gets a boolean indicating if this manager supports morphing of tangents
  24007. */
  24008. get supportsTangents(): boolean;
  24009. /**
  24010. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  24011. */
  24012. get supportsUVs(): boolean;
  24013. /**
  24014. * Gets the number of targets stored in this manager
  24015. */
  24016. get numTargets(): number;
  24017. /**
  24018. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24019. */
  24020. get numInfluencers(): number;
  24021. /**
  24022. * Gets the list of influences (one per target)
  24023. */
  24024. get influences(): Float32Array;
  24025. /**
  24026. * Gets the active target at specified index. An active target is a target with an influence > 0
  24027. * @param index defines the index to check
  24028. * @returns the requested target
  24029. */
  24030. getActiveTarget(index: number): MorphTarget;
  24031. /**
  24032. * Gets the target at specified index
  24033. * @param index defines the index to check
  24034. * @returns the requested target
  24035. */
  24036. getTarget(index: number): MorphTarget;
  24037. /**
  24038. * Add a new target to this manager
  24039. * @param target defines the target to add
  24040. */
  24041. addTarget(target: MorphTarget): void;
  24042. /**
  24043. * Removes a target from the manager
  24044. * @param target defines the target to remove
  24045. */
  24046. removeTarget(target: MorphTarget): void;
  24047. /**
  24048. * Clone the current manager
  24049. * @returns a new MorphTargetManager
  24050. */
  24051. clone(): MorphTargetManager;
  24052. /**
  24053. * Serializes the current manager into a Serialization object
  24054. * @returns the serialized object
  24055. */
  24056. serialize(): any;
  24057. private _syncActiveTargets;
  24058. /**
  24059. * Syncrhonize the targets with all the meshes using this morph target manager
  24060. */
  24061. synchronize(): void;
  24062. /**
  24063. * Creates a new MorphTargetManager from serialized data
  24064. * @param serializationObject defines the serialized data
  24065. * @param scene defines the hosting scene
  24066. * @returns the new MorphTargetManager
  24067. */
  24068. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24069. }
  24070. }
  24071. declare module "babylonjs/Meshes/meshLODLevel" {
  24072. import { Mesh } from "babylonjs/Meshes/mesh";
  24073. import { Nullable } from "babylonjs/types";
  24074. /**
  24075. * Class used to represent a specific level of detail of a mesh
  24076. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24077. */
  24078. export class MeshLODLevel {
  24079. /** Defines the distance where this level should start being displayed */
  24080. distance: number;
  24081. /** Defines the mesh to use to render this level */
  24082. mesh: Nullable<Mesh>;
  24083. /**
  24084. * Creates a new LOD level
  24085. * @param distance defines the distance where this level should star being displayed
  24086. * @param mesh defines the mesh to use to render this level
  24087. */
  24088. constructor(
  24089. /** Defines the distance where this level should start being displayed */
  24090. distance: number,
  24091. /** Defines the mesh to use to render this level */
  24092. mesh: Nullable<Mesh>);
  24093. }
  24094. }
  24095. declare module "babylonjs/Meshes/groundMesh" {
  24096. import { Scene } from "babylonjs/scene";
  24097. import { Vector3 } from "babylonjs/Maths/math.vector";
  24098. import { Mesh } from "babylonjs/Meshes/mesh";
  24099. /**
  24100. * Mesh representing the gorund
  24101. */
  24102. export class GroundMesh extends Mesh {
  24103. /** If octree should be generated */
  24104. generateOctree: boolean;
  24105. private _heightQuads;
  24106. /** @hidden */
  24107. _subdivisionsX: number;
  24108. /** @hidden */
  24109. _subdivisionsY: number;
  24110. /** @hidden */
  24111. _width: number;
  24112. /** @hidden */
  24113. _height: number;
  24114. /** @hidden */
  24115. _minX: number;
  24116. /** @hidden */
  24117. _maxX: number;
  24118. /** @hidden */
  24119. _minZ: number;
  24120. /** @hidden */
  24121. _maxZ: number;
  24122. constructor(name: string, scene: Scene);
  24123. /**
  24124. * "GroundMesh"
  24125. * @returns "GroundMesh"
  24126. */
  24127. getClassName(): string;
  24128. /**
  24129. * The minimum of x and y subdivisions
  24130. */
  24131. get subdivisions(): number;
  24132. /**
  24133. * X subdivisions
  24134. */
  24135. get subdivisionsX(): number;
  24136. /**
  24137. * Y subdivisions
  24138. */
  24139. get subdivisionsY(): number;
  24140. /**
  24141. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24142. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24143. * @param chunksCount the number of subdivisions for x and y
  24144. * @param octreeBlocksSize (Default: 32)
  24145. */
  24146. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24147. /**
  24148. * Returns a height (y) value in the Worl system :
  24149. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24150. * @param x x coordinate
  24151. * @param z z coordinate
  24152. * @returns the ground y position if (x, z) are outside the ground surface.
  24153. */
  24154. getHeightAtCoordinates(x: number, z: number): number;
  24155. /**
  24156. * Returns a normalized vector (Vector3) orthogonal to the ground
  24157. * at the ground coordinates (x, z) expressed in the World system.
  24158. * @param x x coordinate
  24159. * @param z z coordinate
  24160. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24161. */
  24162. getNormalAtCoordinates(x: number, z: number): Vector3;
  24163. /**
  24164. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24165. * at the ground coordinates (x, z) expressed in the World system.
  24166. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24167. * @param x x coordinate
  24168. * @param z z coordinate
  24169. * @param ref vector to store the result
  24170. * @returns the GroundMesh.
  24171. */
  24172. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24173. /**
  24174. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24175. * if the ground has been updated.
  24176. * This can be used in the render loop.
  24177. * @returns the GroundMesh.
  24178. */
  24179. updateCoordinateHeights(): GroundMesh;
  24180. private _getFacetAt;
  24181. private _initHeightQuads;
  24182. private _computeHeightQuads;
  24183. /**
  24184. * Serializes this ground mesh
  24185. * @param serializationObject object to write serialization to
  24186. */
  24187. serialize(serializationObject: any): void;
  24188. /**
  24189. * Parses a serialized ground mesh
  24190. * @param parsedMesh the serialized mesh
  24191. * @param scene the scene to create the ground mesh in
  24192. * @returns the created ground mesh
  24193. */
  24194. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24195. }
  24196. }
  24197. declare module "babylonjs/Physics/physicsJoint" {
  24198. import { Vector3 } from "babylonjs/Maths/math.vector";
  24199. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24200. /**
  24201. * Interface for Physics-Joint data
  24202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24203. */
  24204. export interface PhysicsJointData {
  24205. /**
  24206. * The main pivot of the joint
  24207. */
  24208. mainPivot?: Vector3;
  24209. /**
  24210. * The connected pivot of the joint
  24211. */
  24212. connectedPivot?: Vector3;
  24213. /**
  24214. * The main axis of the joint
  24215. */
  24216. mainAxis?: Vector3;
  24217. /**
  24218. * The connected axis of the joint
  24219. */
  24220. connectedAxis?: Vector3;
  24221. /**
  24222. * The collision of the joint
  24223. */
  24224. collision?: boolean;
  24225. /**
  24226. * Native Oimo/Cannon/Energy data
  24227. */
  24228. nativeParams?: any;
  24229. }
  24230. /**
  24231. * This is a holder class for the physics joint created by the physics plugin
  24232. * It holds a set of functions to control the underlying joint
  24233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24234. */
  24235. export class PhysicsJoint {
  24236. /**
  24237. * The type of the physics joint
  24238. */
  24239. type: number;
  24240. /**
  24241. * The data for the physics joint
  24242. */
  24243. jointData: PhysicsJointData;
  24244. private _physicsJoint;
  24245. protected _physicsPlugin: IPhysicsEnginePlugin;
  24246. /**
  24247. * Initializes the physics joint
  24248. * @param type The type of the physics joint
  24249. * @param jointData The data for the physics joint
  24250. */
  24251. constructor(
  24252. /**
  24253. * The type of the physics joint
  24254. */
  24255. type: number,
  24256. /**
  24257. * The data for the physics joint
  24258. */
  24259. jointData: PhysicsJointData);
  24260. /**
  24261. * Gets the physics joint
  24262. */
  24263. get physicsJoint(): any;
  24264. /**
  24265. * Sets the physics joint
  24266. */
  24267. set physicsJoint(newJoint: any);
  24268. /**
  24269. * Sets the physics plugin
  24270. */
  24271. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24272. /**
  24273. * Execute a function that is physics-plugin specific.
  24274. * @param {Function} func the function that will be executed.
  24275. * It accepts two parameters: the physics world and the physics joint
  24276. */
  24277. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24278. /**
  24279. * Distance-Joint type
  24280. */
  24281. static DistanceJoint: number;
  24282. /**
  24283. * Hinge-Joint type
  24284. */
  24285. static HingeJoint: number;
  24286. /**
  24287. * Ball-and-Socket joint type
  24288. */
  24289. static BallAndSocketJoint: number;
  24290. /**
  24291. * Wheel-Joint type
  24292. */
  24293. static WheelJoint: number;
  24294. /**
  24295. * Slider-Joint type
  24296. */
  24297. static SliderJoint: number;
  24298. /**
  24299. * Prismatic-Joint type
  24300. */
  24301. static PrismaticJoint: number;
  24302. /**
  24303. * Universal-Joint type
  24304. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24305. */
  24306. static UniversalJoint: number;
  24307. /**
  24308. * Hinge-Joint 2 type
  24309. */
  24310. static Hinge2Joint: number;
  24311. /**
  24312. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24313. */
  24314. static PointToPointJoint: number;
  24315. /**
  24316. * Spring-Joint type
  24317. */
  24318. static SpringJoint: number;
  24319. /**
  24320. * Lock-Joint type
  24321. */
  24322. static LockJoint: number;
  24323. }
  24324. /**
  24325. * A class representing a physics distance joint
  24326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24327. */
  24328. export class DistanceJoint extends PhysicsJoint {
  24329. /**
  24330. *
  24331. * @param jointData The data for the Distance-Joint
  24332. */
  24333. constructor(jointData: DistanceJointData);
  24334. /**
  24335. * Update the predefined distance.
  24336. * @param maxDistance The maximum preferred distance
  24337. * @param minDistance The minimum preferred distance
  24338. */
  24339. updateDistance(maxDistance: number, minDistance?: number): void;
  24340. }
  24341. /**
  24342. * Represents a Motor-Enabled Joint
  24343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24344. */
  24345. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24346. /**
  24347. * Initializes the Motor-Enabled Joint
  24348. * @param type The type of the joint
  24349. * @param jointData The physica joint data for the joint
  24350. */
  24351. constructor(type: number, jointData: PhysicsJointData);
  24352. /**
  24353. * Set the motor values.
  24354. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24355. * @param force the force to apply
  24356. * @param maxForce max force for this motor.
  24357. */
  24358. setMotor(force?: number, maxForce?: number): void;
  24359. /**
  24360. * Set the motor's limits.
  24361. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24362. * @param upperLimit The upper limit of the motor
  24363. * @param lowerLimit The lower limit of the motor
  24364. */
  24365. setLimit(upperLimit: number, lowerLimit?: number): void;
  24366. }
  24367. /**
  24368. * This class represents a single physics Hinge-Joint
  24369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24370. */
  24371. export class HingeJoint extends MotorEnabledJoint {
  24372. /**
  24373. * Initializes the Hinge-Joint
  24374. * @param jointData The joint data for the Hinge-Joint
  24375. */
  24376. constructor(jointData: PhysicsJointData);
  24377. /**
  24378. * Set the motor values.
  24379. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24380. * @param {number} force the force to apply
  24381. * @param {number} maxForce max force for this motor.
  24382. */
  24383. setMotor(force?: number, maxForce?: number): void;
  24384. /**
  24385. * Set the motor's limits.
  24386. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24387. * @param upperLimit The upper limit of the motor
  24388. * @param lowerLimit The lower limit of the motor
  24389. */
  24390. setLimit(upperLimit: number, lowerLimit?: number): void;
  24391. }
  24392. /**
  24393. * This class represents a dual hinge physics joint (same as wheel joint)
  24394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24395. */
  24396. export class Hinge2Joint extends MotorEnabledJoint {
  24397. /**
  24398. * Initializes the Hinge2-Joint
  24399. * @param jointData The joint data for the Hinge2-Joint
  24400. */
  24401. constructor(jointData: PhysicsJointData);
  24402. /**
  24403. * Set the motor values.
  24404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24405. * @param {number} targetSpeed the speed the motor is to reach
  24406. * @param {number} maxForce max force for this motor.
  24407. * @param {motorIndex} the motor's index, 0 or 1.
  24408. */
  24409. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24410. /**
  24411. * Set the motor limits.
  24412. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24413. * @param {number} upperLimit the upper limit
  24414. * @param {number} lowerLimit lower limit
  24415. * @param {motorIndex} the motor's index, 0 or 1.
  24416. */
  24417. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24418. }
  24419. /**
  24420. * Interface for a motor enabled joint
  24421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24422. */
  24423. export interface IMotorEnabledJoint {
  24424. /**
  24425. * Physics joint
  24426. */
  24427. physicsJoint: any;
  24428. /**
  24429. * Sets the motor of the motor-enabled joint
  24430. * @param force The force of the motor
  24431. * @param maxForce The maximum force of the motor
  24432. * @param motorIndex The index of the motor
  24433. */
  24434. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24435. /**
  24436. * Sets the limit of the motor
  24437. * @param upperLimit The upper limit of the motor
  24438. * @param lowerLimit The lower limit of the motor
  24439. * @param motorIndex The index of the motor
  24440. */
  24441. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24442. }
  24443. /**
  24444. * Joint data for a Distance-Joint
  24445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24446. */
  24447. export interface DistanceJointData extends PhysicsJointData {
  24448. /**
  24449. * Max distance the 2 joint objects can be apart
  24450. */
  24451. maxDistance: number;
  24452. }
  24453. /**
  24454. * Joint data from a spring joint
  24455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24456. */
  24457. export interface SpringJointData extends PhysicsJointData {
  24458. /**
  24459. * Length of the spring
  24460. */
  24461. length: number;
  24462. /**
  24463. * Stiffness of the spring
  24464. */
  24465. stiffness: number;
  24466. /**
  24467. * Damping of the spring
  24468. */
  24469. damping: number;
  24470. /** this callback will be called when applying the force to the impostors. */
  24471. forceApplicationCallback: () => void;
  24472. }
  24473. }
  24474. declare module "babylonjs/Physics/physicsRaycastResult" {
  24475. import { Vector3 } from "babylonjs/Maths/math.vector";
  24476. /**
  24477. * Holds the data for the raycast result
  24478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24479. */
  24480. export class PhysicsRaycastResult {
  24481. private _hasHit;
  24482. private _hitDistance;
  24483. private _hitNormalWorld;
  24484. private _hitPointWorld;
  24485. private _rayFromWorld;
  24486. private _rayToWorld;
  24487. /**
  24488. * Gets if there was a hit
  24489. */
  24490. get hasHit(): boolean;
  24491. /**
  24492. * Gets the distance from the hit
  24493. */
  24494. get hitDistance(): number;
  24495. /**
  24496. * Gets the hit normal/direction in the world
  24497. */
  24498. get hitNormalWorld(): Vector3;
  24499. /**
  24500. * Gets the hit point in the world
  24501. */
  24502. get hitPointWorld(): Vector3;
  24503. /**
  24504. * Gets the ray "start point" of the ray in the world
  24505. */
  24506. get rayFromWorld(): Vector3;
  24507. /**
  24508. * Gets the ray "end point" of the ray in the world
  24509. */
  24510. get rayToWorld(): Vector3;
  24511. /**
  24512. * Sets the hit data (normal & point in world space)
  24513. * @param hitNormalWorld defines the normal in world space
  24514. * @param hitPointWorld defines the point in world space
  24515. */
  24516. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24517. /**
  24518. * Sets the distance from the start point to the hit point
  24519. * @param distance
  24520. */
  24521. setHitDistance(distance: number): void;
  24522. /**
  24523. * Calculates the distance manually
  24524. */
  24525. calculateHitDistance(): void;
  24526. /**
  24527. * Resets all the values to default
  24528. * @param from The from point on world space
  24529. * @param to The to point on world space
  24530. */
  24531. reset(from?: Vector3, to?: Vector3): void;
  24532. }
  24533. /**
  24534. * Interface for the size containing width and height
  24535. */
  24536. interface IXYZ {
  24537. /**
  24538. * X
  24539. */
  24540. x: number;
  24541. /**
  24542. * Y
  24543. */
  24544. y: number;
  24545. /**
  24546. * Z
  24547. */
  24548. z: number;
  24549. }
  24550. }
  24551. declare module "babylonjs/Physics/IPhysicsEngine" {
  24552. import { Nullable } from "babylonjs/types";
  24553. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24555. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24556. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24557. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24558. /**
  24559. * Interface used to describe a physics joint
  24560. */
  24561. export interface PhysicsImpostorJoint {
  24562. /** Defines the main impostor to which the joint is linked */
  24563. mainImpostor: PhysicsImpostor;
  24564. /** Defines the impostor that is connected to the main impostor using this joint */
  24565. connectedImpostor: PhysicsImpostor;
  24566. /** Defines the joint itself */
  24567. joint: PhysicsJoint;
  24568. }
  24569. /** @hidden */
  24570. export interface IPhysicsEnginePlugin {
  24571. world: any;
  24572. name: string;
  24573. setGravity(gravity: Vector3): void;
  24574. setTimeStep(timeStep: number): void;
  24575. getTimeStep(): number;
  24576. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24577. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24578. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24579. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24580. removePhysicsBody(impostor: PhysicsImpostor): void;
  24581. generateJoint(joint: PhysicsImpostorJoint): void;
  24582. removeJoint(joint: PhysicsImpostorJoint): void;
  24583. isSupported(): boolean;
  24584. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24585. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24587. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24588. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24589. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24590. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24591. getBodyMass(impostor: PhysicsImpostor): number;
  24592. getBodyFriction(impostor: PhysicsImpostor): number;
  24593. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24594. getBodyRestitution(impostor: PhysicsImpostor): number;
  24595. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24596. getBodyPressure?(impostor: PhysicsImpostor): number;
  24597. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24598. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24599. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24600. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24601. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24602. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24603. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24604. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24605. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24606. sleepBody(impostor: PhysicsImpostor): void;
  24607. wakeUpBody(impostor: PhysicsImpostor): void;
  24608. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24609. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24610. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24611. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24612. getRadius(impostor: PhysicsImpostor): number;
  24613. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24614. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24615. dispose(): void;
  24616. }
  24617. /**
  24618. * Interface used to define a physics engine
  24619. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24620. */
  24621. export interface IPhysicsEngine {
  24622. /**
  24623. * Gets the gravity vector used by the simulation
  24624. */
  24625. gravity: Vector3;
  24626. /**
  24627. * Sets the gravity vector used by the simulation
  24628. * @param gravity defines the gravity vector to use
  24629. */
  24630. setGravity(gravity: Vector3): void;
  24631. /**
  24632. * Set the time step of the physics engine.
  24633. * Default is 1/60.
  24634. * To slow it down, enter 1/600 for example.
  24635. * To speed it up, 1/30
  24636. * @param newTimeStep the new timestep to apply to this world.
  24637. */
  24638. setTimeStep(newTimeStep: number): void;
  24639. /**
  24640. * Get the time step of the physics engine.
  24641. * @returns the current time step
  24642. */
  24643. getTimeStep(): number;
  24644. /**
  24645. * Set the sub time step of the physics engine.
  24646. * Default is 0 meaning there is no sub steps
  24647. * To increase physics resolution precision, set a small value (like 1 ms)
  24648. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24649. */
  24650. setSubTimeStep(subTimeStep: number): void;
  24651. /**
  24652. * Get the sub time step of the physics engine.
  24653. * @returns the current sub time step
  24654. */
  24655. getSubTimeStep(): number;
  24656. /**
  24657. * Release all resources
  24658. */
  24659. dispose(): void;
  24660. /**
  24661. * Gets the name of the current physics plugin
  24662. * @returns the name of the plugin
  24663. */
  24664. getPhysicsPluginName(): string;
  24665. /**
  24666. * Adding a new impostor for the impostor tracking.
  24667. * This will be done by the impostor itself.
  24668. * @param impostor the impostor to add
  24669. */
  24670. addImpostor(impostor: PhysicsImpostor): void;
  24671. /**
  24672. * Remove an impostor from the engine.
  24673. * This impostor and its mesh will not longer be updated by the physics engine.
  24674. * @param impostor the impostor to remove
  24675. */
  24676. removeImpostor(impostor: PhysicsImpostor): void;
  24677. /**
  24678. * Add a joint to the physics engine
  24679. * @param mainImpostor defines the main impostor to which the joint is added.
  24680. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24681. * @param joint defines the joint that will connect both impostors.
  24682. */
  24683. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24684. /**
  24685. * Removes a joint from the simulation
  24686. * @param mainImpostor defines the impostor used with the joint
  24687. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24688. * @param joint defines the joint to remove
  24689. */
  24690. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24691. /**
  24692. * Gets the current plugin used to run the simulation
  24693. * @returns current plugin
  24694. */
  24695. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24696. /**
  24697. * Gets the list of physic impostors
  24698. * @returns an array of PhysicsImpostor
  24699. */
  24700. getImpostors(): Array<PhysicsImpostor>;
  24701. /**
  24702. * Gets the impostor for a physics enabled object
  24703. * @param object defines the object impersonated by the impostor
  24704. * @returns the PhysicsImpostor or null if not found
  24705. */
  24706. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24707. /**
  24708. * Gets the impostor for a physics body object
  24709. * @param body defines physics body used by the impostor
  24710. * @returns the PhysicsImpostor or null if not found
  24711. */
  24712. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24713. /**
  24714. * Does a raycast in the physics world
  24715. * @param from when should the ray start?
  24716. * @param to when should the ray end?
  24717. * @returns PhysicsRaycastResult
  24718. */
  24719. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24720. /**
  24721. * Called by the scene. No need to call it.
  24722. * @param delta defines the timespam between frames
  24723. */
  24724. _step(delta: number): void;
  24725. }
  24726. }
  24727. declare module "babylonjs/Physics/physicsImpostor" {
  24728. import { Nullable, IndicesArray } from "babylonjs/types";
  24729. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24730. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24732. import { Scene } from "babylonjs/scene";
  24733. import { Bone } from "babylonjs/Bones/bone";
  24734. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24735. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24736. import { Space } from "babylonjs/Maths/math.axis";
  24737. /**
  24738. * The interface for the physics imposter parameters
  24739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24740. */
  24741. export interface PhysicsImpostorParameters {
  24742. /**
  24743. * The mass of the physics imposter
  24744. */
  24745. mass: number;
  24746. /**
  24747. * The friction of the physics imposter
  24748. */
  24749. friction?: number;
  24750. /**
  24751. * The coefficient of restitution of the physics imposter
  24752. */
  24753. restitution?: number;
  24754. /**
  24755. * The native options of the physics imposter
  24756. */
  24757. nativeOptions?: any;
  24758. /**
  24759. * Specifies if the parent should be ignored
  24760. */
  24761. ignoreParent?: boolean;
  24762. /**
  24763. * Specifies if bi-directional transformations should be disabled
  24764. */
  24765. disableBidirectionalTransformation?: boolean;
  24766. /**
  24767. * The pressure inside the physics imposter, soft object only
  24768. */
  24769. pressure?: number;
  24770. /**
  24771. * The stiffness the physics imposter, soft object only
  24772. */
  24773. stiffness?: number;
  24774. /**
  24775. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24776. */
  24777. velocityIterations?: number;
  24778. /**
  24779. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24780. */
  24781. positionIterations?: number;
  24782. /**
  24783. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24784. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24785. * Add to fix multiple points
  24786. */
  24787. fixedPoints?: number;
  24788. /**
  24789. * The collision margin around a soft object
  24790. */
  24791. margin?: number;
  24792. /**
  24793. * The collision margin around a soft object
  24794. */
  24795. damping?: number;
  24796. /**
  24797. * The path for a rope based on an extrusion
  24798. */
  24799. path?: any;
  24800. /**
  24801. * The shape of an extrusion used for a rope based on an extrusion
  24802. */
  24803. shape?: any;
  24804. }
  24805. /**
  24806. * Interface for a physics-enabled object
  24807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24808. */
  24809. export interface IPhysicsEnabledObject {
  24810. /**
  24811. * The position of the physics-enabled object
  24812. */
  24813. position: Vector3;
  24814. /**
  24815. * The rotation of the physics-enabled object
  24816. */
  24817. rotationQuaternion: Nullable<Quaternion>;
  24818. /**
  24819. * The scale of the physics-enabled object
  24820. */
  24821. scaling: Vector3;
  24822. /**
  24823. * The rotation of the physics-enabled object
  24824. */
  24825. rotation?: Vector3;
  24826. /**
  24827. * The parent of the physics-enabled object
  24828. */
  24829. parent?: any;
  24830. /**
  24831. * The bounding info of the physics-enabled object
  24832. * @returns The bounding info of the physics-enabled object
  24833. */
  24834. getBoundingInfo(): BoundingInfo;
  24835. /**
  24836. * Computes the world matrix
  24837. * @param force Specifies if the world matrix should be computed by force
  24838. * @returns A world matrix
  24839. */
  24840. computeWorldMatrix(force: boolean): Matrix;
  24841. /**
  24842. * Gets the world matrix
  24843. * @returns A world matrix
  24844. */
  24845. getWorldMatrix?(): Matrix;
  24846. /**
  24847. * Gets the child meshes
  24848. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24849. * @returns An array of abstract meshes
  24850. */
  24851. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24852. /**
  24853. * Gets the vertex data
  24854. * @param kind The type of vertex data
  24855. * @returns A nullable array of numbers, or a float32 array
  24856. */
  24857. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24858. /**
  24859. * Gets the indices from the mesh
  24860. * @returns A nullable array of index arrays
  24861. */
  24862. getIndices?(): Nullable<IndicesArray>;
  24863. /**
  24864. * Gets the scene from the mesh
  24865. * @returns the indices array or null
  24866. */
  24867. getScene?(): Scene;
  24868. /**
  24869. * Gets the absolute position from the mesh
  24870. * @returns the absolute position
  24871. */
  24872. getAbsolutePosition(): Vector3;
  24873. /**
  24874. * Gets the absolute pivot point from the mesh
  24875. * @returns the absolute pivot point
  24876. */
  24877. getAbsolutePivotPoint(): Vector3;
  24878. /**
  24879. * Rotates the mesh
  24880. * @param axis The axis of rotation
  24881. * @param amount The amount of rotation
  24882. * @param space The space of the rotation
  24883. * @returns The rotation transform node
  24884. */
  24885. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24886. /**
  24887. * Translates the mesh
  24888. * @param axis The axis of translation
  24889. * @param distance The distance of translation
  24890. * @param space The space of the translation
  24891. * @returns The transform node
  24892. */
  24893. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24894. /**
  24895. * Sets the absolute position of the mesh
  24896. * @param absolutePosition The absolute position of the mesh
  24897. * @returns The transform node
  24898. */
  24899. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24900. /**
  24901. * Gets the class name of the mesh
  24902. * @returns The class name
  24903. */
  24904. getClassName(): string;
  24905. }
  24906. /**
  24907. * Represents a physics imposter
  24908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24909. */
  24910. export class PhysicsImpostor {
  24911. /**
  24912. * The physics-enabled object used as the physics imposter
  24913. */
  24914. object: IPhysicsEnabledObject;
  24915. /**
  24916. * The type of the physics imposter
  24917. */
  24918. type: number;
  24919. private _options;
  24920. private _scene?;
  24921. /**
  24922. * The default object size of the imposter
  24923. */
  24924. static DEFAULT_OBJECT_SIZE: Vector3;
  24925. /**
  24926. * The identity quaternion of the imposter
  24927. */
  24928. static IDENTITY_QUATERNION: Quaternion;
  24929. /** @hidden */
  24930. _pluginData: any;
  24931. private _physicsEngine;
  24932. private _physicsBody;
  24933. private _bodyUpdateRequired;
  24934. private _onBeforePhysicsStepCallbacks;
  24935. private _onAfterPhysicsStepCallbacks;
  24936. /** @hidden */
  24937. _onPhysicsCollideCallbacks: Array<{
  24938. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24939. otherImpostors: Array<PhysicsImpostor>;
  24940. }>;
  24941. private _deltaPosition;
  24942. private _deltaRotation;
  24943. private _deltaRotationConjugated;
  24944. /** @hidden */
  24945. _isFromLine: boolean;
  24946. private _parent;
  24947. private _isDisposed;
  24948. private static _tmpVecs;
  24949. private static _tmpQuat;
  24950. /**
  24951. * Specifies if the physics imposter is disposed
  24952. */
  24953. get isDisposed(): boolean;
  24954. /**
  24955. * Gets the mass of the physics imposter
  24956. */
  24957. get mass(): number;
  24958. set mass(value: number);
  24959. /**
  24960. * Gets the coefficient of friction
  24961. */
  24962. get friction(): number;
  24963. /**
  24964. * Sets the coefficient of friction
  24965. */
  24966. set friction(value: number);
  24967. /**
  24968. * Gets the coefficient of restitution
  24969. */
  24970. get restitution(): number;
  24971. /**
  24972. * Sets the coefficient of restitution
  24973. */
  24974. set restitution(value: number);
  24975. /**
  24976. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24977. */
  24978. get pressure(): number;
  24979. /**
  24980. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24981. */
  24982. set pressure(value: number);
  24983. /**
  24984. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24985. */
  24986. get stiffness(): number;
  24987. /**
  24988. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24989. */
  24990. set stiffness(value: number);
  24991. /**
  24992. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24993. */
  24994. get velocityIterations(): number;
  24995. /**
  24996. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24997. */
  24998. set velocityIterations(value: number);
  24999. /**
  25000. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25001. */
  25002. get positionIterations(): number;
  25003. /**
  25004. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  25005. */
  25006. set positionIterations(value: number);
  25007. /**
  25008. * The unique id of the physics imposter
  25009. * set by the physics engine when adding this impostor to the array
  25010. */
  25011. uniqueId: number;
  25012. /**
  25013. * @hidden
  25014. */
  25015. soft: boolean;
  25016. /**
  25017. * @hidden
  25018. */
  25019. segments: number;
  25020. private _joints;
  25021. /**
  25022. * Initializes the physics imposter
  25023. * @param object The physics-enabled object used as the physics imposter
  25024. * @param type The type of the physics imposter
  25025. * @param _options The options for the physics imposter
  25026. * @param _scene The Babylon scene
  25027. */
  25028. constructor(
  25029. /**
  25030. * The physics-enabled object used as the physics imposter
  25031. */
  25032. object: IPhysicsEnabledObject,
  25033. /**
  25034. * The type of the physics imposter
  25035. */
  25036. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25037. /**
  25038. * This function will completly initialize this impostor.
  25039. * It will create a new body - but only if this mesh has no parent.
  25040. * If it has, this impostor will not be used other than to define the impostor
  25041. * of the child mesh.
  25042. * @hidden
  25043. */
  25044. _init(): void;
  25045. private _getPhysicsParent;
  25046. /**
  25047. * Should a new body be generated.
  25048. * @returns boolean specifying if body initialization is required
  25049. */
  25050. isBodyInitRequired(): boolean;
  25051. /**
  25052. * Sets the updated scaling
  25053. * @param updated Specifies if the scaling is updated
  25054. */
  25055. setScalingUpdated(): void;
  25056. /**
  25057. * Force a regeneration of this or the parent's impostor's body.
  25058. * Use under cautious - This will remove all joints already implemented.
  25059. */
  25060. forceUpdate(): void;
  25061. /**
  25062. * Gets the body that holds this impostor. Either its own, or its parent.
  25063. */
  25064. get physicsBody(): any;
  25065. /**
  25066. * Get the parent of the physics imposter
  25067. * @returns Physics imposter or null
  25068. */
  25069. get parent(): Nullable<PhysicsImpostor>;
  25070. /**
  25071. * Sets the parent of the physics imposter
  25072. */
  25073. set parent(value: Nullable<PhysicsImpostor>);
  25074. /**
  25075. * Set the physics body. Used mainly by the physics engine/plugin
  25076. */
  25077. set physicsBody(physicsBody: any);
  25078. /**
  25079. * Resets the update flags
  25080. */
  25081. resetUpdateFlags(): void;
  25082. /**
  25083. * Gets the object extend size
  25084. * @returns the object extend size
  25085. */
  25086. getObjectExtendSize(): Vector3;
  25087. /**
  25088. * Gets the object center
  25089. * @returns The object center
  25090. */
  25091. getObjectCenter(): Vector3;
  25092. /**
  25093. * Get a specific parameter from the options parameters
  25094. * @param paramName The object parameter name
  25095. * @returns The object parameter
  25096. */
  25097. getParam(paramName: string): any;
  25098. /**
  25099. * Sets a specific parameter in the options given to the physics plugin
  25100. * @param paramName The parameter name
  25101. * @param value The value of the parameter
  25102. */
  25103. setParam(paramName: string, value: number): void;
  25104. /**
  25105. * Specifically change the body's mass option. Won't recreate the physics body object
  25106. * @param mass The mass of the physics imposter
  25107. */
  25108. setMass(mass: number): void;
  25109. /**
  25110. * Gets the linear velocity
  25111. * @returns linear velocity or null
  25112. */
  25113. getLinearVelocity(): Nullable<Vector3>;
  25114. /**
  25115. * Sets the linear velocity
  25116. * @param velocity linear velocity or null
  25117. */
  25118. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25119. /**
  25120. * Gets the angular velocity
  25121. * @returns angular velocity or null
  25122. */
  25123. getAngularVelocity(): Nullable<Vector3>;
  25124. /**
  25125. * Sets the angular velocity
  25126. * @param velocity The velocity or null
  25127. */
  25128. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25129. /**
  25130. * Execute a function with the physics plugin native code
  25131. * Provide a function the will have two variables - the world object and the physics body object
  25132. * @param func The function to execute with the physics plugin native code
  25133. */
  25134. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25135. /**
  25136. * Register a function that will be executed before the physics world is stepping forward
  25137. * @param func The function to execute before the physics world is stepped forward
  25138. */
  25139. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25140. /**
  25141. * Unregister a function that will be executed before the physics world is stepping forward
  25142. * @param func The function to execute before the physics world is stepped forward
  25143. */
  25144. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25145. /**
  25146. * Register a function that will be executed after the physics step
  25147. * @param func The function to execute after physics step
  25148. */
  25149. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25150. /**
  25151. * Unregisters a function that will be executed after the physics step
  25152. * @param func The function to execute after physics step
  25153. */
  25154. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25155. /**
  25156. * register a function that will be executed when this impostor collides against a different body
  25157. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25158. * @param func Callback that is executed on collision
  25159. */
  25160. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25161. /**
  25162. * Unregisters the physics imposter on contact
  25163. * @param collideAgainst The physics object to collide against
  25164. * @param func Callback to execute on collision
  25165. */
  25166. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25167. private _tmpQuat;
  25168. private _tmpQuat2;
  25169. /**
  25170. * Get the parent rotation
  25171. * @returns The parent rotation
  25172. */
  25173. getParentsRotation(): Quaternion;
  25174. /**
  25175. * this function is executed by the physics engine.
  25176. */
  25177. beforeStep: () => void;
  25178. /**
  25179. * this function is executed by the physics engine
  25180. */
  25181. afterStep: () => void;
  25182. /**
  25183. * Legacy collision detection event support
  25184. */
  25185. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25186. /**
  25187. * event and body object due to cannon's event-based architecture.
  25188. */
  25189. onCollide: (e: {
  25190. body: any;
  25191. }) => void;
  25192. /**
  25193. * Apply a force
  25194. * @param force The force to apply
  25195. * @param contactPoint The contact point for the force
  25196. * @returns The physics imposter
  25197. */
  25198. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25199. /**
  25200. * Apply an impulse
  25201. * @param force The impulse force
  25202. * @param contactPoint The contact point for the impulse force
  25203. * @returns The physics imposter
  25204. */
  25205. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25206. /**
  25207. * A help function to create a joint
  25208. * @param otherImpostor A physics imposter used to create a joint
  25209. * @param jointType The type of joint
  25210. * @param jointData The data for the joint
  25211. * @returns The physics imposter
  25212. */
  25213. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25214. /**
  25215. * Add a joint to this impostor with a different impostor
  25216. * @param otherImpostor A physics imposter used to add a joint
  25217. * @param joint The joint to add
  25218. * @returns The physics imposter
  25219. */
  25220. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25221. /**
  25222. * Add an anchor to a cloth impostor
  25223. * @param otherImpostor rigid impostor to anchor to
  25224. * @param width ratio across width from 0 to 1
  25225. * @param height ratio up height from 0 to 1
  25226. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25227. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25228. * @returns impostor the soft imposter
  25229. */
  25230. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25231. /**
  25232. * Add a hook to a rope impostor
  25233. * @param otherImpostor rigid impostor to anchor to
  25234. * @param length ratio across rope from 0 to 1
  25235. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25236. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25237. * @returns impostor the rope imposter
  25238. */
  25239. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25240. /**
  25241. * Will keep this body still, in a sleep mode.
  25242. * @returns the physics imposter
  25243. */
  25244. sleep(): PhysicsImpostor;
  25245. /**
  25246. * Wake the body up.
  25247. * @returns The physics imposter
  25248. */
  25249. wakeUp(): PhysicsImpostor;
  25250. /**
  25251. * Clones the physics imposter
  25252. * @param newObject The physics imposter clones to this physics-enabled object
  25253. * @returns A nullable physics imposter
  25254. */
  25255. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25256. /**
  25257. * Disposes the physics imposter
  25258. */
  25259. dispose(): void;
  25260. /**
  25261. * Sets the delta position
  25262. * @param position The delta position amount
  25263. */
  25264. setDeltaPosition(position: Vector3): void;
  25265. /**
  25266. * Sets the delta rotation
  25267. * @param rotation The delta rotation amount
  25268. */
  25269. setDeltaRotation(rotation: Quaternion): void;
  25270. /**
  25271. * Gets the box size of the physics imposter and stores the result in the input parameter
  25272. * @param result Stores the box size
  25273. * @returns The physics imposter
  25274. */
  25275. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25276. /**
  25277. * Gets the radius of the physics imposter
  25278. * @returns Radius of the physics imposter
  25279. */
  25280. getRadius(): number;
  25281. /**
  25282. * Sync a bone with this impostor
  25283. * @param bone The bone to sync to the impostor.
  25284. * @param boneMesh The mesh that the bone is influencing.
  25285. * @param jointPivot The pivot of the joint / bone in local space.
  25286. * @param distToJoint Optional distance from the impostor to the joint.
  25287. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25288. */
  25289. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25290. /**
  25291. * Sync impostor to a bone
  25292. * @param bone The bone that the impostor will be synced to.
  25293. * @param boneMesh The mesh that the bone is influencing.
  25294. * @param jointPivot The pivot of the joint / bone in local space.
  25295. * @param distToJoint Optional distance from the impostor to the joint.
  25296. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25297. * @param boneAxis Optional vector3 axis the bone is aligned with
  25298. */
  25299. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25300. /**
  25301. * No-Imposter type
  25302. */
  25303. static NoImpostor: number;
  25304. /**
  25305. * Sphere-Imposter type
  25306. */
  25307. static SphereImpostor: number;
  25308. /**
  25309. * Box-Imposter type
  25310. */
  25311. static BoxImpostor: number;
  25312. /**
  25313. * Plane-Imposter type
  25314. */
  25315. static PlaneImpostor: number;
  25316. /**
  25317. * Mesh-imposter type
  25318. */
  25319. static MeshImpostor: number;
  25320. /**
  25321. * Capsule-Impostor type (Ammo.js plugin only)
  25322. */
  25323. static CapsuleImpostor: number;
  25324. /**
  25325. * Cylinder-Imposter type
  25326. */
  25327. static CylinderImpostor: number;
  25328. /**
  25329. * Particle-Imposter type
  25330. */
  25331. static ParticleImpostor: number;
  25332. /**
  25333. * Heightmap-Imposter type
  25334. */
  25335. static HeightmapImpostor: number;
  25336. /**
  25337. * ConvexHull-Impostor type (Ammo.js plugin only)
  25338. */
  25339. static ConvexHullImpostor: number;
  25340. /**
  25341. * Custom-Imposter type (Ammo.js plugin only)
  25342. */
  25343. static CustomImpostor: number;
  25344. /**
  25345. * Rope-Imposter type
  25346. */
  25347. static RopeImpostor: number;
  25348. /**
  25349. * Cloth-Imposter type
  25350. */
  25351. static ClothImpostor: number;
  25352. /**
  25353. * Softbody-Imposter type
  25354. */
  25355. static SoftbodyImpostor: number;
  25356. }
  25357. }
  25358. declare module "babylonjs/Meshes/mesh" {
  25359. import { Observable } from "babylonjs/Misc/observable";
  25360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25361. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25362. import { Camera } from "babylonjs/Cameras/camera";
  25363. import { Scene } from "babylonjs/scene";
  25364. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25365. import { Color4 } from "babylonjs/Maths/math.color";
  25366. import { Engine } from "babylonjs/Engines/engine";
  25367. import { Node } from "babylonjs/node";
  25368. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25369. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25370. import { Buffer } from "babylonjs/Meshes/buffer";
  25371. import { Geometry } from "babylonjs/Meshes/geometry";
  25372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25374. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25375. import { Effect } from "babylonjs/Materials/effect";
  25376. import { Material } from "babylonjs/Materials/material";
  25377. import { Skeleton } from "babylonjs/Bones/skeleton";
  25378. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25379. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25380. import { Path3D } from "babylonjs/Maths/math.path";
  25381. import { Plane } from "babylonjs/Maths/math.plane";
  25382. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25383. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25384. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25385. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25386. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25387. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25388. /**
  25389. * @hidden
  25390. **/
  25391. export class _CreationDataStorage {
  25392. closePath?: boolean;
  25393. closeArray?: boolean;
  25394. idx: number[];
  25395. dashSize: number;
  25396. gapSize: number;
  25397. path3D: Path3D;
  25398. pathArray: Vector3[][];
  25399. arc: number;
  25400. radius: number;
  25401. cap: number;
  25402. tessellation: number;
  25403. }
  25404. /**
  25405. * @hidden
  25406. **/
  25407. class _InstanceDataStorage {
  25408. visibleInstances: any;
  25409. batchCache: _InstancesBatch;
  25410. instancesBufferSize: number;
  25411. instancesBuffer: Nullable<Buffer>;
  25412. instancesData: Float32Array;
  25413. overridenInstanceCount: number;
  25414. isFrozen: boolean;
  25415. previousBatch: Nullable<_InstancesBatch>;
  25416. hardwareInstancedRendering: boolean;
  25417. sideOrientation: number;
  25418. manualUpdate: boolean;
  25419. }
  25420. /**
  25421. * @hidden
  25422. **/
  25423. export class _InstancesBatch {
  25424. mustReturn: boolean;
  25425. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25426. renderSelf: boolean[];
  25427. hardwareInstancedRendering: boolean[];
  25428. }
  25429. /**
  25430. * Class used to represent renderable models
  25431. */
  25432. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25433. /**
  25434. * Mesh side orientation : usually the external or front surface
  25435. */
  25436. static readonly FRONTSIDE: number;
  25437. /**
  25438. * Mesh side orientation : usually the internal or back surface
  25439. */
  25440. static readonly BACKSIDE: number;
  25441. /**
  25442. * Mesh side orientation : both internal and external or front and back surfaces
  25443. */
  25444. static readonly DOUBLESIDE: number;
  25445. /**
  25446. * Mesh side orientation : by default, `FRONTSIDE`
  25447. */
  25448. static readonly DEFAULTSIDE: number;
  25449. /**
  25450. * Mesh cap setting : no cap
  25451. */
  25452. static readonly NO_CAP: number;
  25453. /**
  25454. * Mesh cap setting : one cap at the beginning of the mesh
  25455. */
  25456. static readonly CAP_START: number;
  25457. /**
  25458. * Mesh cap setting : one cap at the end of the mesh
  25459. */
  25460. static readonly CAP_END: number;
  25461. /**
  25462. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25463. */
  25464. static readonly CAP_ALL: number;
  25465. /**
  25466. * Mesh pattern setting : no flip or rotate
  25467. */
  25468. static readonly NO_FLIP: number;
  25469. /**
  25470. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25471. */
  25472. static readonly FLIP_TILE: number;
  25473. /**
  25474. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25475. */
  25476. static readonly ROTATE_TILE: number;
  25477. /**
  25478. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25479. */
  25480. static readonly FLIP_ROW: number;
  25481. /**
  25482. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25483. */
  25484. static readonly ROTATE_ROW: number;
  25485. /**
  25486. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25487. */
  25488. static readonly FLIP_N_ROTATE_TILE: number;
  25489. /**
  25490. * Mesh pattern setting : rotate pattern and rotate
  25491. */
  25492. static readonly FLIP_N_ROTATE_ROW: number;
  25493. /**
  25494. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25495. */
  25496. static readonly CENTER: number;
  25497. /**
  25498. * Mesh tile positioning : part tiles on left
  25499. */
  25500. static readonly LEFT: number;
  25501. /**
  25502. * Mesh tile positioning : part tiles on right
  25503. */
  25504. static readonly RIGHT: number;
  25505. /**
  25506. * Mesh tile positioning : part tiles on top
  25507. */
  25508. static readonly TOP: number;
  25509. /**
  25510. * Mesh tile positioning : part tiles on bottom
  25511. */
  25512. static readonly BOTTOM: number;
  25513. /**
  25514. * Gets the default side orientation.
  25515. * @param orientation the orientation to value to attempt to get
  25516. * @returns the default orientation
  25517. * @hidden
  25518. */
  25519. static _GetDefaultSideOrientation(orientation?: number): number;
  25520. private _internalMeshDataInfo;
  25521. /**
  25522. * An event triggered before rendering the mesh
  25523. */
  25524. get onBeforeRenderObservable(): Observable<Mesh>;
  25525. /**
  25526. * An event triggered before binding the mesh
  25527. */
  25528. get onBeforeBindObservable(): Observable<Mesh>;
  25529. /**
  25530. * An event triggered after rendering the mesh
  25531. */
  25532. get onAfterRenderObservable(): Observable<Mesh>;
  25533. /**
  25534. * An event triggered before drawing the mesh
  25535. */
  25536. get onBeforeDrawObservable(): Observable<Mesh>;
  25537. private _onBeforeDrawObserver;
  25538. /**
  25539. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25540. */
  25541. set onBeforeDraw(callback: () => void);
  25542. get hasInstances(): boolean;
  25543. /**
  25544. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25545. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25546. */
  25547. delayLoadState: number;
  25548. /**
  25549. * Gets the list of instances created from this mesh
  25550. * it is not supposed to be modified manually.
  25551. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25552. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25553. */
  25554. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25555. /**
  25556. * Gets the file containing delay loading data for this mesh
  25557. */
  25558. delayLoadingFile: string;
  25559. /** @hidden */
  25560. _binaryInfo: any;
  25561. /**
  25562. * User defined function used to change how LOD level selection is done
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25564. */
  25565. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25566. /**
  25567. * Gets or sets the morph target manager
  25568. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25569. */
  25570. get morphTargetManager(): Nullable<MorphTargetManager>;
  25571. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25572. /** @hidden */
  25573. _creationDataStorage: Nullable<_CreationDataStorage>;
  25574. /** @hidden */
  25575. _geometry: Nullable<Geometry>;
  25576. /** @hidden */
  25577. _delayInfo: Array<string>;
  25578. /** @hidden */
  25579. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25580. /** @hidden */
  25581. _instanceDataStorage: _InstanceDataStorage;
  25582. private _effectiveMaterial;
  25583. /** @hidden */
  25584. _shouldGenerateFlatShading: boolean;
  25585. /** @hidden */
  25586. _originalBuilderSideOrientation: number;
  25587. /**
  25588. * Use this property to change the original side orientation defined at construction time
  25589. */
  25590. overrideMaterialSideOrientation: Nullable<number>;
  25591. /**
  25592. * Gets the source mesh (the one used to clone this one from)
  25593. */
  25594. get source(): Nullable<Mesh>;
  25595. /**
  25596. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25597. */
  25598. get isUnIndexed(): boolean;
  25599. set isUnIndexed(value: boolean);
  25600. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25601. get worldMatrixInstancedBuffer(): Float32Array;
  25602. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25603. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25604. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25605. /**
  25606. * @constructor
  25607. * @param name The value used by scene.getMeshByName() to do a lookup.
  25608. * @param scene The scene to add this mesh to.
  25609. * @param parent The parent of this mesh, if it has one
  25610. * @param source An optional Mesh from which geometry is shared, cloned.
  25611. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25612. * When false, achieved by calling a clone(), also passing False.
  25613. * This will make creation of children, recursive.
  25614. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25615. */
  25616. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25617. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25618. doNotInstantiate: boolean;
  25619. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25620. /**
  25621. * Gets the class name
  25622. * @returns the string "Mesh".
  25623. */
  25624. getClassName(): string;
  25625. /** @hidden */
  25626. get _isMesh(): boolean;
  25627. /**
  25628. * Returns a description of this mesh
  25629. * @param fullDetails define if full details about this mesh must be used
  25630. * @returns a descriptive string representing this mesh
  25631. */
  25632. toString(fullDetails?: boolean): string;
  25633. /** @hidden */
  25634. _unBindEffect(): void;
  25635. /**
  25636. * Gets a boolean indicating if this mesh has LOD
  25637. */
  25638. get hasLODLevels(): boolean;
  25639. /**
  25640. * Gets the list of MeshLODLevel associated with the current mesh
  25641. * @returns an array of MeshLODLevel
  25642. */
  25643. getLODLevels(): MeshLODLevel[];
  25644. private _sortLODLevels;
  25645. /**
  25646. * Add a mesh as LOD level triggered at the given distance.
  25647. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25648. * @param distance The distance from the center of the object to show this level
  25649. * @param mesh The mesh to be added as LOD level (can be null)
  25650. * @return This mesh (for chaining)
  25651. */
  25652. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25653. /**
  25654. * Returns the LOD level mesh at the passed distance or null if not found.
  25655. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25656. * @param distance The distance from the center of the object to show this level
  25657. * @returns a Mesh or `null`
  25658. */
  25659. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25660. /**
  25661. * Remove a mesh from the LOD array
  25662. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25663. * @param mesh defines the mesh to be removed
  25664. * @return This mesh (for chaining)
  25665. */
  25666. removeLODLevel(mesh: Mesh): Mesh;
  25667. /**
  25668. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25670. * @param camera defines the camera to use to compute distance
  25671. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25672. * @return This mesh (for chaining)
  25673. */
  25674. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25675. /**
  25676. * Gets the mesh internal Geometry object
  25677. */
  25678. get geometry(): Nullable<Geometry>;
  25679. /**
  25680. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25681. * @returns the total number of vertices
  25682. */
  25683. getTotalVertices(): number;
  25684. /**
  25685. * Returns the content of an associated vertex buffer
  25686. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25687. * - VertexBuffer.PositionKind
  25688. * - VertexBuffer.UVKind
  25689. * - VertexBuffer.UV2Kind
  25690. * - VertexBuffer.UV3Kind
  25691. * - VertexBuffer.UV4Kind
  25692. * - VertexBuffer.UV5Kind
  25693. * - VertexBuffer.UV6Kind
  25694. * - VertexBuffer.ColorKind
  25695. * - VertexBuffer.MatricesIndicesKind
  25696. * - VertexBuffer.MatricesIndicesExtraKind
  25697. * - VertexBuffer.MatricesWeightsKind
  25698. * - VertexBuffer.MatricesWeightsExtraKind
  25699. * @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
  25700. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25701. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25702. */
  25703. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25704. /**
  25705. * Returns the mesh VertexBuffer object from the requested `kind`
  25706. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25707. * - VertexBuffer.PositionKind
  25708. * - VertexBuffer.NormalKind
  25709. * - VertexBuffer.UVKind
  25710. * - VertexBuffer.UV2Kind
  25711. * - VertexBuffer.UV3Kind
  25712. * - VertexBuffer.UV4Kind
  25713. * - VertexBuffer.UV5Kind
  25714. * - VertexBuffer.UV6Kind
  25715. * - VertexBuffer.ColorKind
  25716. * - VertexBuffer.MatricesIndicesKind
  25717. * - VertexBuffer.MatricesIndicesExtraKind
  25718. * - VertexBuffer.MatricesWeightsKind
  25719. * - VertexBuffer.MatricesWeightsExtraKind
  25720. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25721. */
  25722. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25723. /**
  25724. * Tests if a specific vertex buffer is associated with this mesh
  25725. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25726. * - VertexBuffer.PositionKind
  25727. * - VertexBuffer.NormalKind
  25728. * - VertexBuffer.UVKind
  25729. * - VertexBuffer.UV2Kind
  25730. * - VertexBuffer.UV3Kind
  25731. * - VertexBuffer.UV4Kind
  25732. * - VertexBuffer.UV5Kind
  25733. * - VertexBuffer.UV6Kind
  25734. * - VertexBuffer.ColorKind
  25735. * - VertexBuffer.MatricesIndicesKind
  25736. * - VertexBuffer.MatricesIndicesExtraKind
  25737. * - VertexBuffer.MatricesWeightsKind
  25738. * - VertexBuffer.MatricesWeightsExtraKind
  25739. * @returns a boolean
  25740. */
  25741. isVerticesDataPresent(kind: string): boolean;
  25742. /**
  25743. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25744. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25745. * - VertexBuffer.PositionKind
  25746. * - VertexBuffer.UVKind
  25747. * - VertexBuffer.UV2Kind
  25748. * - VertexBuffer.UV3Kind
  25749. * - VertexBuffer.UV4Kind
  25750. * - VertexBuffer.UV5Kind
  25751. * - VertexBuffer.UV6Kind
  25752. * - VertexBuffer.ColorKind
  25753. * - VertexBuffer.MatricesIndicesKind
  25754. * - VertexBuffer.MatricesIndicesExtraKind
  25755. * - VertexBuffer.MatricesWeightsKind
  25756. * - VertexBuffer.MatricesWeightsExtraKind
  25757. * @returns a boolean
  25758. */
  25759. isVertexBufferUpdatable(kind: string): boolean;
  25760. /**
  25761. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25762. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25763. * - VertexBuffer.PositionKind
  25764. * - VertexBuffer.NormalKind
  25765. * - VertexBuffer.UVKind
  25766. * - VertexBuffer.UV2Kind
  25767. * - VertexBuffer.UV3Kind
  25768. * - VertexBuffer.UV4Kind
  25769. * - VertexBuffer.UV5Kind
  25770. * - VertexBuffer.UV6Kind
  25771. * - VertexBuffer.ColorKind
  25772. * - VertexBuffer.MatricesIndicesKind
  25773. * - VertexBuffer.MatricesIndicesExtraKind
  25774. * - VertexBuffer.MatricesWeightsKind
  25775. * - VertexBuffer.MatricesWeightsExtraKind
  25776. * @returns an array of strings
  25777. */
  25778. getVerticesDataKinds(): string[];
  25779. /**
  25780. * Returns a positive integer : the total number of indices in this mesh geometry.
  25781. * @returns the numner of indices or zero if the mesh has no geometry.
  25782. */
  25783. getTotalIndices(): number;
  25784. /**
  25785. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25786. * @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.
  25787. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25788. * @returns the indices array or an empty array if the mesh has no geometry
  25789. */
  25790. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25791. get isBlocked(): boolean;
  25792. /**
  25793. * Determine if the current mesh is ready to be rendered
  25794. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25795. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25796. * @returns true if all associated assets are ready (material, textures, shaders)
  25797. */
  25798. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25799. /**
  25800. * 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.
  25801. */
  25802. get areNormalsFrozen(): boolean;
  25803. /**
  25804. * 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.
  25805. * @returns the current mesh
  25806. */
  25807. freezeNormals(): Mesh;
  25808. /**
  25809. * 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
  25810. * @returns the current mesh
  25811. */
  25812. unfreezeNormals(): Mesh;
  25813. /**
  25814. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25815. */
  25816. set overridenInstanceCount(count: number);
  25817. /** @hidden */
  25818. _preActivate(): Mesh;
  25819. /** @hidden */
  25820. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25821. /** @hidden */
  25822. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25823. /**
  25824. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25825. * This means the mesh underlying bounding box and sphere are recomputed.
  25826. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25827. * @returns the current mesh
  25828. */
  25829. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25830. /** @hidden */
  25831. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25832. /**
  25833. * This function will subdivide the mesh into multiple submeshes
  25834. * @param count defines the expected number of submeshes
  25835. */
  25836. subdivide(count: number): void;
  25837. /**
  25838. * Copy a FloatArray into a specific associated vertex buffer
  25839. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25840. * - VertexBuffer.PositionKind
  25841. * - VertexBuffer.UVKind
  25842. * - VertexBuffer.UV2Kind
  25843. * - VertexBuffer.UV3Kind
  25844. * - VertexBuffer.UV4Kind
  25845. * - VertexBuffer.UV5Kind
  25846. * - VertexBuffer.UV6Kind
  25847. * - VertexBuffer.ColorKind
  25848. * - VertexBuffer.MatricesIndicesKind
  25849. * - VertexBuffer.MatricesIndicesExtraKind
  25850. * - VertexBuffer.MatricesWeightsKind
  25851. * - VertexBuffer.MatricesWeightsExtraKind
  25852. * @param data defines the data source
  25853. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25854. * @param stride defines the data stride size (can be null)
  25855. * @returns the current mesh
  25856. */
  25857. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25858. /**
  25859. * Delete a vertex buffer associated with this mesh
  25860. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25861. * - VertexBuffer.PositionKind
  25862. * - VertexBuffer.UVKind
  25863. * - VertexBuffer.UV2Kind
  25864. * - VertexBuffer.UV3Kind
  25865. * - VertexBuffer.UV4Kind
  25866. * - VertexBuffer.UV5Kind
  25867. * - VertexBuffer.UV6Kind
  25868. * - VertexBuffer.ColorKind
  25869. * - VertexBuffer.MatricesIndicesKind
  25870. * - VertexBuffer.MatricesIndicesExtraKind
  25871. * - VertexBuffer.MatricesWeightsKind
  25872. * - VertexBuffer.MatricesWeightsExtraKind
  25873. */
  25874. removeVerticesData(kind: string): void;
  25875. /**
  25876. * Flags an associated vertex buffer as updatable
  25877. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25878. * - VertexBuffer.PositionKind
  25879. * - VertexBuffer.UVKind
  25880. * - VertexBuffer.UV2Kind
  25881. * - VertexBuffer.UV3Kind
  25882. * - VertexBuffer.UV4Kind
  25883. * - VertexBuffer.UV5Kind
  25884. * - VertexBuffer.UV6Kind
  25885. * - VertexBuffer.ColorKind
  25886. * - VertexBuffer.MatricesIndicesKind
  25887. * - VertexBuffer.MatricesIndicesExtraKind
  25888. * - VertexBuffer.MatricesWeightsKind
  25889. * - VertexBuffer.MatricesWeightsExtraKind
  25890. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25891. */
  25892. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25893. /**
  25894. * Sets the mesh global Vertex Buffer
  25895. * @param buffer defines the buffer to use
  25896. * @returns the current mesh
  25897. */
  25898. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25899. /**
  25900. * Update a specific associated vertex buffer
  25901. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25902. * - VertexBuffer.PositionKind
  25903. * - VertexBuffer.UVKind
  25904. * - VertexBuffer.UV2Kind
  25905. * - VertexBuffer.UV3Kind
  25906. * - VertexBuffer.UV4Kind
  25907. * - VertexBuffer.UV5Kind
  25908. * - VertexBuffer.UV6Kind
  25909. * - VertexBuffer.ColorKind
  25910. * - VertexBuffer.MatricesIndicesKind
  25911. * - VertexBuffer.MatricesIndicesExtraKind
  25912. * - VertexBuffer.MatricesWeightsKind
  25913. * - VertexBuffer.MatricesWeightsExtraKind
  25914. * @param data defines the data source
  25915. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25916. * @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)
  25917. * @returns the current mesh
  25918. */
  25919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25920. /**
  25921. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25922. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25923. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25924. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25925. * @returns the current mesh
  25926. */
  25927. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25928. /**
  25929. * Creates a un-shared specific occurence of the geometry for the mesh.
  25930. * @returns the current mesh
  25931. */
  25932. makeGeometryUnique(): Mesh;
  25933. /**
  25934. * Set the index buffer of this mesh
  25935. * @param indices defines the source data
  25936. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25937. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25938. * @returns the current mesh
  25939. */
  25940. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25941. /**
  25942. * Update the current index buffer
  25943. * @param indices defines the source data
  25944. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25945. * @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)
  25946. * @returns the current mesh
  25947. */
  25948. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25949. /**
  25950. * Invert the geometry to move from a right handed system to a left handed one.
  25951. * @returns the current mesh
  25952. */
  25953. toLeftHanded(): Mesh;
  25954. /** @hidden */
  25955. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25956. /** @hidden */
  25957. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25958. /**
  25959. * Registers for this mesh a javascript function called just before the rendering process
  25960. * @param func defines the function to call before rendering this mesh
  25961. * @returns the current mesh
  25962. */
  25963. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25964. /**
  25965. * Disposes a previously registered javascript function called before the rendering
  25966. * @param func defines the function to remove
  25967. * @returns the current mesh
  25968. */
  25969. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25970. /**
  25971. * Registers for this mesh a javascript function called just after the rendering is complete
  25972. * @param func defines the function to call after rendering this mesh
  25973. * @returns the current mesh
  25974. */
  25975. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25976. /**
  25977. * Disposes a previously registered javascript function called after the rendering.
  25978. * @param func defines the function to remove
  25979. * @returns the current mesh
  25980. */
  25981. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25982. /** @hidden */
  25983. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25984. /** @hidden */
  25985. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25986. /** @hidden */
  25987. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25988. /** @hidden */
  25989. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25990. /** @hidden */
  25991. _rebuild(): void;
  25992. /** @hidden */
  25993. _freeze(): void;
  25994. /** @hidden */
  25995. _unFreeze(): void;
  25996. /**
  25997. * 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
  25998. * @param subMesh defines the subMesh to render
  25999. * @param enableAlphaMode defines if alpha mode can be changed
  26000. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  26001. * @returns the current mesh
  26002. */
  26003. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  26004. private _onBeforeDraw;
  26005. /**
  26006. * Renormalize the mesh and patch it up if there are no weights
  26007. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26008. * However in the case of zero weights then we set just a single influence to 1.
  26009. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26010. */
  26011. cleanMatrixWeights(): void;
  26012. private normalizeSkinFourWeights;
  26013. private normalizeSkinWeightsAndExtra;
  26014. /**
  26015. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26016. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26017. * the user know there was an issue with importing the mesh
  26018. * @returns a validation object with skinned, valid and report string
  26019. */
  26020. validateSkinning(): {
  26021. skinned: boolean;
  26022. valid: boolean;
  26023. report: string;
  26024. };
  26025. /** @hidden */
  26026. _checkDelayState(): Mesh;
  26027. private _queueLoad;
  26028. /**
  26029. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26030. * A mesh is in the frustum if its bounding box intersects the frustum
  26031. * @param frustumPlanes defines the frustum to test
  26032. * @returns true if the mesh is in the frustum planes
  26033. */
  26034. isInFrustum(frustumPlanes: Plane[]): boolean;
  26035. /**
  26036. * Sets the mesh material by the material or multiMaterial `id` property
  26037. * @param id is a string identifying the material or the multiMaterial
  26038. * @returns the current mesh
  26039. */
  26040. setMaterialByID(id: string): Mesh;
  26041. /**
  26042. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26043. * @returns an array of IAnimatable
  26044. */
  26045. getAnimatables(): IAnimatable[];
  26046. /**
  26047. * Modifies the mesh geometry according to the passed transformation matrix.
  26048. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26049. * The mesh normals are modified using the same transformation.
  26050. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26051. * @param transform defines the transform matrix to use
  26052. * @see http://doc.babylonjs.com/resources/baking_transformations
  26053. * @returns the current mesh
  26054. */
  26055. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26056. /**
  26057. * Modifies the mesh geometry according to its own current World Matrix.
  26058. * The mesh World Matrix is then reset.
  26059. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26060. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26061. * @see http://doc.babylonjs.com/resources/baking_transformations
  26062. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26063. * @returns the current mesh
  26064. */
  26065. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26066. /** @hidden */
  26067. get _positions(): Nullable<Vector3[]>;
  26068. /** @hidden */
  26069. _resetPointsArrayCache(): Mesh;
  26070. /** @hidden */
  26071. _generatePointsArray(): boolean;
  26072. /**
  26073. * Returns a new Mesh object generated from the current mesh properties.
  26074. * This method must not get confused with createInstance()
  26075. * @param name is a string, the name given to the new mesh
  26076. * @param newParent can be any Node object (default `null`)
  26077. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26078. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26079. * @returns a new mesh
  26080. */
  26081. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26082. /**
  26083. * Releases resources associated with this mesh.
  26084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26086. */
  26087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26088. /** @hidden */
  26089. _disposeInstanceSpecificData(): void;
  26090. /**
  26091. * Modifies the mesh geometry according to a displacement map.
  26092. * 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.
  26093. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26094. * @param url is a string, the URL from the image file is to be downloaded.
  26095. * @param minHeight is the lower limit of the displacement.
  26096. * @param maxHeight is the upper limit of the displacement.
  26097. * @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.
  26098. * @param uvOffset is an optional vector2 used to offset UV.
  26099. * @param uvScale is an optional vector2 used to scale UV.
  26100. * @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.
  26101. * @returns the Mesh.
  26102. */
  26103. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26104. /**
  26105. * Modifies the mesh geometry according to a displacementMap buffer.
  26106. * 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.
  26107. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26108. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26109. * @param heightMapWidth is the width of the buffer image.
  26110. * @param heightMapHeight is the height of the buffer image.
  26111. * @param minHeight is the lower limit of the displacement.
  26112. * @param maxHeight is the upper limit of the displacement.
  26113. * @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.
  26114. * @param uvOffset is an optional vector2 used to offset UV.
  26115. * @param uvScale is an optional vector2 used to scale UV.
  26116. * @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.
  26117. * @returns the Mesh.
  26118. */
  26119. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26120. /**
  26121. * Modify the mesh to get a flat shading rendering.
  26122. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26123. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26124. * @returns current mesh
  26125. */
  26126. convertToFlatShadedMesh(): Mesh;
  26127. /**
  26128. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26129. * In other words, more vertices, no more indices and a single bigger VBO.
  26130. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26131. * @returns current mesh
  26132. */
  26133. convertToUnIndexedMesh(): Mesh;
  26134. /**
  26135. * Inverses facet orientations.
  26136. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26137. * @param flipNormals will also inverts the normals
  26138. * @returns current mesh
  26139. */
  26140. flipFaces(flipNormals?: boolean): Mesh;
  26141. /**
  26142. * Increase the number of facets and hence vertices in a mesh
  26143. * Vertex normals are interpolated from existing vertex normals
  26144. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26145. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26146. */
  26147. increaseVertices(numberPerEdge: number): void;
  26148. /**
  26149. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26150. * This will undo any application of covertToFlatShadedMesh
  26151. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26152. */
  26153. forceSharedVertices(): void;
  26154. /** @hidden */
  26155. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26156. /** @hidden */
  26157. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26158. /**
  26159. * Creates a new InstancedMesh object from the mesh model.
  26160. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26161. * @param name defines the name of the new instance
  26162. * @returns a new InstancedMesh
  26163. */
  26164. createInstance(name: string): InstancedMesh;
  26165. /**
  26166. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26167. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26168. * @returns the current mesh
  26169. */
  26170. synchronizeInstances(): Mesh;
  26171. /**
  26172. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26173. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26174. * This should be used together with the simplification to avoid disappearing triangles.
  26175. * @param successCallback an optional success callback to be called after the optimization finished.
  26176. * @returns the current mesh
  26177. */
  26178. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26179. /**
  26180. * Serialize current mesh
  26181. * @param serializationObject defines the object which will receive the serialization data
  26182. */
  26183. serialize(serializationObject: any): void;
  26184. /** @hidden */
  26185. _syncGeometryWithMorphTargetManager(): void;
  26186. /** @hidden */
  26187. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26188. /**
  26189. * Returns a new Mesh object parsed from the source provided.
  26190. * @param parsedMesh is the source
  26191. * @param scene defines the hosting scene
  26192. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26193. * @returns a new Mesh
  26194. */
  26195. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26196. /**
  26197. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26198. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26199. * @param name defines the name of the mesh to create
  26200. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26201. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26202. * @param closePath creates a seam between the first and the last points of each path of the path array
  26203. * @param offset is taken in account only if the `pathArray` is containing a single path
  26204. * @param scene defines the hosting scene
  26205. * @param updatable defines if the mesh must be flagged as updatable
  26206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26207. * @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)
  26208. * @returns a new Mesh
  26209. */
  26210. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26211. /**
  26212. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26213. * @param name defines the name of the mesh to create
  26214. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26215. * @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
  26216. * @param scene defines the hosting scene
  26217. * @param updatable defines if the mesh must be flagged as updatable
  26218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26219. * @returns a new Mesh
  26220. */
  26221. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26222. /**
  26223. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26224. * @param name defines the name of the mesh to create
  26225. * @param size sets the size (float) of each box side (default 1)
  26226. * @param scene defines the hosting scene
  26227. * @param updatable defines if the mesh must be flagged as updatable
  26228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26229. * @returns a new Mesh
  26230. */
  26231. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26232. /**
  26233. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26234. * @param name defines the name of the mesh to create
  26235. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26236. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26237. * @param scene defines the hosting scene
  26238. * @param updatable defines if the mesh must be flagged as updatable
  26239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26240. * @returns a new Mesh
  26241. */
  26242. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26243. /**
  26244. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26245. * @param name defines the name of the mesh to create
  26246. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26247. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26248. * @param scene defines the hosting scene
  26249. * @returns a new Mesh
  26250. */
  26251. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26252. /**
  26253. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26254. * @param name defines the name of the mesh to create
  26255. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26256. * @param diameterTop set the top cap diameter (floats, default 1)
  26257. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26258. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26259. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26260. * @param scene defines the hosting scene
  26261. * @param updatable defines if the mesh must be flagged as updatable
  26262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26263. * @returns a new Mesh
  26264. */
  26265. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26266. /**
  26267. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26268. * @param name defines the name of the mesh to create
  26269. * @param diameter sets the diameter size (float) of the torus (default 1)
  26270. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26271. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26272. * @param scene defines the hosting scene
  26273. * @param updatable defines if the mesh must be flagged as updatable
  26274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26275. * @returns a new Mesh
  26276. */
  26277. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26278. /**
  26279. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26280. * @param name defines the name of the mesh to create
  26281. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26282. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26283. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26284. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26285. * @param p the number of windings on X axis (positive integers, default 2)
  26286. * @param q the number of windings on Y axis (positive integers, default 3)
  26287. * @param scene defines the hosting scene
  26288. * @param updatable defines if the mesh must be flagged as updatable
  26289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26290. * @returns a new Mesh
  26291. */
  26292. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26293. /**
  26294. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26295. * @param name defines the name of the mesh to create
  26296. * @param points is an array successive Vector3
  26297. * @param scene defines the hosting scene
  26298. * @param updatable defines if the mesh must be flagged as updatable
  26299. * @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).
  26300. * @returns a new Mesh
  26301. */
  26302. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26303. /**
  26304. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26305. * @param name defines the name of the mesh to create
  26306. * @param points is an array successive Vector3
  26307. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26308. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26309. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26310. * @param scene defines the hosting scene
  26311. * @param updatable defines if the mesh must be flagged as updatable
  26312. * @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)
  26313. * @returns a new Mesh
  26314. */
  26315. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26316. /**
  26317. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26318. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26319. * 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.
  26320. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26321. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26322. * Remember you can only change the shape positions, not their number when updating a polygon.
  26323. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26324. * @param name defines the name of the mesh to create
  26325. * @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
  26326. * @param scene defines the hosting scene
  26327. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26328. * @param updatable defines if the mesh must be flagged as updatable
  26329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26330. * @param earcutInjection can be used to inject your own earcut reference
  26331. * @returns a new Mesh
  26332. */
  26333. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26334. /**
  26335. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26336. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26337. * @param name defines the name of the mesh to create
  26338. * @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
  26339. * @param depth defines the height of extrusion
  26340. * @param scene defines the hosting scene
  26341. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26342. * @param updatable defines if the mesh must be flagged as updatable
  26343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26344. * @param earcutInjection can be used to inject your own earcut reference
  26345. * @returns a new Mesh
  26346. */
  26347. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26348. /**
  26349. * Creates an extruded shape mesh.
  26350. * 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
  26351. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26353. * @param name defines the name of the mesh to create
  26354. * @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
  26355. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26356. * @param scale is the value to scale the shape
  26357. * @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
  26358. * @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
  26359. * @param scene defines the hosting scene
  26360. * @param updatable defines if the mesh must be flagged as updatable
  26361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26362. * @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)
  26363. * @returns a new Mesh
  26364. */
  26365. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26366. /**
  26367. * Creates an custom extruded shape mesh.
  26368. * The custom extrusion is a parametric shape.
  26369. * It has no predefined shape. Its final shape will depend on the input parameters.
  26370. * Please consider using the same method from the MeshBuilder class instead
  26371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26372. * @param name defines the name of the mesh to create
  26373. * @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
  26374. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26375. * @param scaleFunction is a custom Javascript function called on each path point
  26376. * @param rotationFunction is a custom Javascript function called on each path point
  26377. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26378. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26379. * @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
  26380. * @param scene defines the hosting scene
  26381. * @param updatable defines if the mesh must be flagged as updatable
  26382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26383. * @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)
  26384. * @returns a new Mesh
  26385. */
  26386. 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;
  26387. /**
  26388. * Creates lathe mesh.
  26389. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26390. * Please consider using the same method from the MeshBuilder class instead
  26391. * @param name defines the name of the mesh to create
  26392. * @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
  26393. * @param radius is the radius value of the lathe
  26394. * @param tessellation is the side number of the lathe.
  26395. * @param scene defines the hosting scene
  26396. * @param updatable defines if the mesh must be flagged as updatable
  26397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26398. * @returns a new Mesh
  26399. */
  26400. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26401. /**
  26402. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26403. * @param name defines the name of the mesh to create
  26404. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26405. * @param scene defines the hosting scene
  26406. * @param updatable defines if the mesh must be flagged as updatable
  26407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26408. * @returns a new Mesh
  26409. */
  26410. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26411. /**
  26412. * Creates a ground mesh.
  26413. * Please consider using the same method from the MeshBuilder class instead
  26414. * @param name defines the name of the mesh to create
  26415. * @param width set the width of the ground
  26416. * @param height set the height of the ground
  26417. * @param subdivisions sets the number of subdivisions per side
  26418. * @param scene defines the hosting scene
  26419. * @param updatable defines if the mesh must be flagged as updatable
  26420. * @returns a new Mesh
  26421. */
  26422. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26423. /**
  26424. * Creates a tiled ground mesh.
  26425. * Please consider using the same method from the MeshBuilder class instead
  26426. * @param name defines the name of the mesh to create
  26427. * @param xmin set the ground minimum X coordinate
  26428. * @param zmin set the ground minimum Y coordinate
  26429. * @param xmax set the ground maximum X coordinate
  26430. * @param zmax set the ground maximum Z coordinate
  26431. * @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
  26432. * @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
  26433. * @param scene defines the hosting scene
  26434. * @param updatable defines if the mesh must be flagged as updatable
  26435. * @returns a new Mesh
  26436. */
  26437. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26438. w: number;
  26439. h: number;
  26440. }, precision: {
  26441. w: number;
  26442. h: number;
  26443. }, scene: Scene, updatable?: boolean): Mesh;
  26444. /**
  26445. * Creates a ground mesh from a height map.
  26446. * Please consider using the same method from the MeshBuilder class instead
  26447. * @see http://doc.babylonjs.com/babylon101/height_map
  26448. * @param name defines the name of the mesh to create
  26449. * @param url sets the URL of the height map image resource
  26450. * @param width set the ground width size
  26451. * @param height set the ground height size
  26452. * @param subdivisions sets the number of subdivision per side
  26453. * @param minHeight is the minimum altitude on the ground
  26454. * @param maxHeight is the maximum altitude on the ground
  26455. * @param scene defines the hosting scene
  26456. * @param updatable defines if the mesh must be flagged as updatable
  26457. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26458. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26459. * @returns a new Mesh
  26460. */
  26461. 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;
  26462. /**
  26463. * Creates a tube mesh.
  26464. * The tube is a parametric shape.
  26465. * It has no predefined shape. Its final shape will depend on the input parameters.
  26466. * Please consider using the same method from the MeshBuilder class instead
  26467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26468. * @param name defines the name of the mesh to create
  26469. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26470. * @param radius sets the tube radius size
  26471. * @param tessellation is the number of sides on the tubular surface
  26472. * @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
  26473. * @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
  26474. * @param scene defines the hosting scene
  26475. * @param updatable defines if the mesh must be flagged as updatable
  26476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26477. * @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)
  26478. * @returns a new Mesh
  26479. */
  26480. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26481. (i: number, distance: number): number;
  26482. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26483. /**
  26484. * Creates a polyhedron mesh.
  26485. * Please consider using the same method from the MeshBuilder class instead.
  26486. * * 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
  26487. * * The parameter `size` (positive float, default 1) sets the polygon size
  26488. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26489. * * 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`
  26490. * * 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
  26491. * * 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)`)
  26492. * * 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
  26493. * * 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
  26494. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26495. * * If you create a double-sided mesh, you can choose what parts of 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
  26496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26497. * @param name defines the name of the mesh to create
  26498. * @param options defines the options used to create the mesh
  26499. * @param scene defines the hosting scene
  26500. * @returns a new Mesh
  26501. */
  26502. static CreatePolyhedron(name: string, options: {
  26503. type?: number;
  26504. size?: number;
  26505. sizeX?: number;
  26506. sizeY?: number;
  26507. sizeZ?: number;
  26508. custom?: any;
  26509. faceUV?: Vector4[];
  26510. faceColors?: Color4[];
  26511. updatable?: boolean;
  26512. sideOrientation?: number;
  26513. }, scene: Scene): Mesh;
  26514. /**
  26515. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26516. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26517. * * 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`)
  26518. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26519. * * 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
  26520. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26521. * * If you create a double-sided mesh, you can choose what parts of 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
  26522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26523. * @param name defines the name of the mesh
  26524. * @param options defines the options used to create the mesh
  26525. * @param scene defines the hosting scene
  26526. * @returns a new Mesh
  26527. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26528. */
  26529. static CreateIcoSphere(name: string, options: {
  26530. radius?: number;
  26531. flat?: boolean;
  26532. subdivisions?: number;
  26533. sideOrientation?: number;
  26534. updatable?: boolean;
  26535. }, scene: Scene): Mesh;
  26536. /**
  26537. * Creates a decal mesh.
  26538. * Please consider using the same method from the MeshBuilder class instead.
  26539. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26540. * @param name defines the name of the mesh
  26541. * @param sourceMesh defines the mesh receiving the decal
  26542. * @param position sets the position of the decal in world coordinates
  26543. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26544. * @param size sets the decal scaling
  26545. * @param angle sets the angle to rotate the decal
  26546. * @returns a new Mesh
  26547. */
  26548. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26549. /**
  26550. * Prepare internal position array for software CPU skinning
  26551. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26552. */
  26553. setPositionsForCPUSkinning(): Float32Array;
  26554. /**
  26555. * Prepare internal normal array for software CPU skinning
  26556. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26557. */
  26558. setNormalsForCPUSkinning(): Float32Array;
  26559. /**
  26560. * Updates the vertex buffer by applying transformation from the bones
  26561. * @param skeleton defines the skeleton to apply to current mesh
  26562. * @returns the current mesh
  26563. */
  26564. applySkeleton(skeleton: Skeleton): Mesh;
  26565. /**
  26566. * 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
  26567. * @param meshes defines the list of meshes to scan
  26568. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26569. */
  26570. static MinMax(meshes: AbstractMesh[]): {
  26571. min: Vector3;
  26572. max: Vector3;
  26573. };
  26574. /**
  26575. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26576. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26577. * @returns a vector3
  26578. */
  26579. static Center(meshesOrMinMaxVector: {
  26580. min: Vector3;
  26581. max: Vector3;
  26582. } | AbstractMesh[]): Vector3;
  26583. /**
  26584. * Merge the array of meshes into a single mesh for performance reasons.
  26585. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26586. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26587. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26588. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26589. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26590. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26591. * @returns a new mesh
  26592. */
  26593. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26594. /** @hidden */
  26595. addInstance(instance: InstancedMesh): void;
  26596. /** @hidden */
  26597. removeInstance(instance: InstancedMesh): void;
  26598. }
  26599. }
  26600. declare module "babylonjs/Cameras/camera" {
  26601. import { SmartArray } from "babylonjs/Misc/smartArray";
  26602. import { Observable } from "babylonjs/Misc/observable";
  26603. import { Nullable } from "babylonjs/types";
  26604. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26605. import { Scene } from "babylonjs/scene";
  26606. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26607. import { Node } from "babylonjs/node";
  26608. import { Mesh } from "babylonjs/Meshes/mesh";
  26609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26610. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26611. import { Viewport } from "babylonjs/Maths/math.viewport";
  26612. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26614. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26615. import { Ray } from "babylonjs/Culling/ray";
  26616. /**
  26617. * This is the base class of all the camera used in the application.
  26618. * @see http://doc.babylonjs.com/features/cameras
  26619. */
  26620. export class Camera extends Node {
  26621. /** @hidden */
  26622. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26623. /**
  26624. * This is the default projection mode used by the cameras.
  26625. * It helps recreating a feeling of perspective and better appreciate depth.
  26626. * This is the best way to simulate real life cameras.
  26627. */
  26628. static readonly PERSPECTIVE_CAMERA: number;
  26629. /**
  26630. * This helps creating camera with an orthographic mode.
  26631. * 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.
  26632. */
  26633. static readonly ORTHOGRAPHIC_CAMERA: number;
  26634. /**
  26635. * This is the default FOV mode for perspective cameras.
  26636. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26637. */
  26638. static readonly FOVMODE_VERTICAL_FIXED: number;
  26639. /**
  26640. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26641. */
  26642. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26643. /**
  26644. * This specifies ther is no need for a camera rig.
  26645. * Basically only one eye is rendered corresponding to the camera.
  26646. */
  26647. static readonly RIG_MODE_NONE: number;
  26648. /**
  26649. * Simulates a camera Rig with one blue eye and one red eye.
  26650. * This can be use with 3d blue and red glasses.
  26651. */
  26652. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26653. /**
  26654. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26655. */
  26656. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26657. /**
  26658. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26659. */
  26660. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26661. /**
  26662. * Defines that both eyes of the camera will be rendered over under each other.
  26663. */
  26664. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26665. /**
  26666. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26667. */
  26668. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26669. /**
  26670. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26671. */
  26672. static readonly RIG_MODE_VR: number;
  26673. /**
  26674. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26675. */
  26676. static readonly RIG_MODE_WEBVR: number;
  26677. /**
  26678. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26679. */
  26680. static readonly RIG_MODE_CUSTOM: number;
  26681. /**
  26682. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26683. */
  26684. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26685. /**
  26686. * Define the input manager associated with the camera.
  26687. */
  26688. inputs: CameraInputsManager<Camera>;
  26689. /** @hidden */
  26690. _position: Vector3;
  26691. /**
  26692. * Define the current local position of the camera in the scene
  26693. */
  26694. get position(): Vector3;
  26695. set position(newPosition: Vector3);
  26696. /**
  26697. * The vector the camera should consider as up.
  26698. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26699. */
  26700. upVector: Vector3;
  26701. /**
  26702. * Define the current limit on the left side for an orthographic camera
  26703. * In scene unit
  26704. */
  26705. orthoLeft: Nullable<number>;
  26706. /**
  26707. * Define the current limit on the right side for an orthographic camera
  26708. * In scene unit
  26709. */
  26710. orthoRight: Nullable<number>;
  26711. /**
  26712. * Define the current limit on the bottom side for an orthographic camera
  26713. * In scene unit
  26714. */
  26715. orthoBottom: Nullable<number>;
  26716. /**
  26717. * Define the current limit on the top side for an orthographic camera
  26718. * In scene unit
  26719. */
  26720. orthoTop: Nullable<number>;
  26721. /**
  26722. * Field Of View is set in Radians. (default is 0.8)
  26723. */
  26724. fov: number;
  26725. /**
  26726. * Define the minimum distance the camera can see from.
  26727. * This is important to note that the depth buffer are not infinite and the closer it starts
  26728. * the more your scene might encounter depth fighting issue.
  26729. */
  26730. minZ: number;
  26731. /**
  26732. * Define the maximum distance the camera can see to.
  26733. * This is important to note that the depth buffer are not infinite and the further it end
  26734. * the more your scene might encounter depth fighting issue.
  26735. */
  26736. maxZ: number;
  26737. /**
  26738. * Define the default inertia of the camera.
  26739. * This helps giving a smooth feeling to the camera movement.
  26740. */
  26741. inertia: number;
  26742. /**
  26743. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26744. */
  26745. mode: number;
  26746. /**
  26747. * Define whether the camera is intermediate.
  26748. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26749. */
  26750. isIntermediate: boolean;
  26751. /**
  26752. * Define the viewport of the camera.
  26753. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26754. */
  26755. viewport: Viewport;
  26756. /**
  26757. * Restricts the camera to viewing objects with the same layerMask.
  26758. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26759. */
  26760. layerMask: number;
  26761. /**
  26762. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26763. */
  26764. fovMode: number;
  26765. /**
  26766. * Rig mode of the camera.
  26767. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26768. * This is normally controlled byt the camera themselves as internal use.
  26769. */
  26770. cameraRigMode: number;
  26771. /**
  26772. * Defines the distance between both "eyes" in case of a RIG
  26773. */
  26774. interaxialDistance: number;
  26775. /**
  26776. * Defines if stereoscopic rendering is done side by side or over under.
  26777. */
  26778. isStereoscopicSideBySide: boolean;
  26779. /**
  26780. * 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
  26781. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26782. * else in the scene. (Eg. security camera)
  26783. *
  26784. * 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)
  26785. */
  26786. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26787. /**
  26788. * When set, the camera will render to this render target instead of the default canvas
  26789. *
  26790. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26791. */
  26792. outputRenderTarget: Nullable<RenderTargetTexture>;
  26793. /**
  26794. * Observable triggered when the camera view matrix has changed.
  26795. */
  26796. onViewMatrixChangedObservable: Observable<Camera>;
  26797. /**
  26798. * Observable triggered when the camera Projection matrix has changed.
  26799. */
  26800. onProjectionMatrixChangedObservable: Observable<Camera>;
  26801. /**
  26802. * Observable triggered when the inputs have been processed.
  26803. */
  26804. onAfterCheckInputsObservable: Observable<Camera>;
  26805. /**
  26806. * Observable triggered when reset has been called and applied to the camera.
  26807. */
  26808. onRestoreStateObservable: Observable<Camera>;
  26809. /**
  26810. * Is this camera a part of a rig system?
  26811. */
  26812. isRigCamera: boolean;
  26813. /**
  26814. * If isRigCamera set to true this will be set with the parent camera.
  26815. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26816. */
  26817. rigParent?: Camera;
  26818. /** @hidden */
  26819. _cameraRigParams: any;
  26820. /** @hidden */
  26821. _rigCameras: Camera[];
  26822. /** @hidden */
  26823. _rigPostProcess: Nullable<PostProcess>;
  26824. protected _webvrViewMatrix: Matrix;
  26825. /** @hidden */
  26826. _skipRendering: boolean;
  26827. /** @hidden */
  26828. _projectionMatrix: Matrix;
  26829. /** @hidden */
  26830. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26831. /** @hidden */
  26832. _activeMeshes: SmartArray<AbstractMesh>;
  26833. protected _globalPosition: Vector3;
  26834. /** @hidden */
  26835. _computedViewMatrix: Matrix;
  26836. private _doNotComputeProjectionMatrix;
  26837. private _transformMatrix;
  26838. private _frustumPlanes;
  26839. private _refreshFrustumPlanes;
  26840. private _storedFov;
  26841. private _stateStored;
  26842. /**
  26843. * Instantiates a new camera object.
  26844. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26845. * @see http://doc.babylonjs.com/features/cameras
  26846. * @param name Defines the name of the camera in the scene
  26847. * @param position Defines the position of the camera
  26848. * @param scene Defines the scene the camera belongs too
  26849. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26850. */
  26851. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26852. /**
  26853. * Store current camera state (fov, position, etc..)
  26854. * @returns the camera
  26855. */
  26856. storeState(): Camera;
  26857. /**
  26858. * Restores the camera state values if it has been stored. You must call storeState() first
  26859. */
  26860. protected _restoreStateValues(): boolean;
  26861. /**
  26862. * Restored camera state. You must call storeState() first.
  26863. * @returns true if restored and false otherwise
  26864. */
  26865. restoreState(): boolean;
  26866. /**
  26867. * Gets the class name of the camera.
  26868. * @returns the class name
  26869. */
  26870. getClassName(): string;
  26871. /** @hidden */
  26872. readonly _isCamera: boolean;
  26873. /**
  26874. * Gets a string representation of the camera useful for debug purpose.
  26875. * @param fullDetails Defines that a more verboe level of logging is required
  26876. * @returns the string representation
  26877. */
  26878. toString(fullDetails?: boolean): string;
  26879. /**
  26880. * Gets the current world space position of the camera.
  26881. */
  26882. get globalPosition(): Vector3;
  26883. /**
  26884. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26885. * @returns the active meshe list
  26886. */
  26887. getActiveMeshes(): SmartArray<AbstractMesh>;
  26888. /**
  26889. * Check whether a mesh is part of the current active mesh list of the camera
  26890. * @param mesh Defines the mesh to check
  26891. * @returns true if active, false otherwise
  26892. */
  26893. isActiveMesh(mesh: Mesh): boolean;
  26894. /**
  26895. * Is this camera ready to be used/rendered
  26896. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26897. * @return true if the camera is ready
  26898. */
  26899. isReady(completeCheck?: boolean): boolean;
  26900. /** @hidden */
  26901. _initCache(): void;
  26902. /** @hidden */
  26903. _updateCache(ignoreParentClass?: boolean): void;
  26904. /** @hidden */
  26905. _isSynchronized(): boolean;
  26906. /** @hidden */
  26907. _isSynchronizedViewMatrix(): boolean;
  26908. /** @hidden */
  26909. _isSynchronizedProjectionMatrix(): boolean;
  26910. /**
  26911. * Attach the input controls to a specific dom element to get the input from.
  26912. * @param element Defines the element the controls should be listened from
  26913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26914. */
  26915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26916. /**
  26917. * Detach the current controls from the specified dom element.
  26918. * @param element Defines the element to stop listening the inputs from
  26919. */
  26920. detachControl(element: HTMLElement): void;
  26921. /**
  26922. * Update the camera state according to the different inputs gathered during the frame.
  26923. */
  26924. update(): void;
  26925. /** @hidden */
  26926. _checkInputs(): void;
  26927. /** @hidden */
  26928. get rigCameras(): Camera[];
  26929. /**
  26930. * Gets the post process used by the rig cameras
  26931. */
  26932. get rigPostProcess(): Nullable<PostProcess>;
  26933. /**
  26934. * Internal, gets the first post proces.
  26935. * @returns the first post process to be run on this camera.
  26936. */
  26937. _getFirstPostProcess(): Nullable<PostProcess>;
  26938. private _cascadePostProcessesToRigCams;
  26939. /**
  26940. * Attach a post process to the camera.
  26941. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26942. * @param postProcess The post process to attach to the camera
  26943. * @param insertAt The position of the post process in case several of them are in use in the scene
  26944. * @returns the position the post process has been inserted at
  26945. */
  26946. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26947. /**
  26948. * Detach a post process to the camera.
  26949. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26950. * @param postProcess The post process to detach from the camera
  26951. */
  26952. detachPostProcess(postProcess: PostProcess): void;
  26953. /**
  26954. * Gets the current world matrix of the camera
  26955. */
  26956. getWorldMatrix(): Matrix;
  26957. /** @hidden */
  26958. _getViewMatrix(): Matrix;
  26959. /**
  26960. * Gets the current view matrix of the camera.
  26961. * @param force forces the camera to recompute the matrix without looking at the cached state
  26962. * @returns the view matrix
  26963. */
  26964. getViewMatrix(force?: boolean): Matrix;
  26965. /**
  26966. * Freeze the projection matrix.
  26967. * It will prevent the cache check of the camera projection compute and can speed up perf
  26968. * if no parameter of the camera are meant to change
  26969. * @param projection Defines manually a projection if necessary
  26970. */
  26971. freezeProjectionMatrix(projection?: Matrix): void;
  26972. /**
  26973. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26974. */
  26975. unfreezeProjectionMatrix(): void;
  26976. /**
  26977. * Gets the current projection matrix of the camera.
  26978. * @param force forces the camera to recompute the matrix without looking at the cached state
  26979. * @returns the projection matrix
  26980. */
  26981. getProjectionMatrix(force?: boolean): Matrix;
  26982. /**
  26983. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26984. * @returns a Matrix
  26985. */
  26986. getTransformationMatrix(): Matrix;
  26987. private _updateFrustumPlanes;
  26988. /**
  26989. * Checks if a cullable object (mesh...) is in the camera frustum
  26990. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26991. * @param target The object to check
  26992. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26993. * @returns true if the object is in frustum otherwise false
  26994. */
  26995. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26996. /**
  26997. * Checks if a cullable object (mesh...) is in the camera frustum
  26998. * Unlike isInFrustum this cheks the full bounding box
  26999. * @param target The object to check
  27000. * @returns true if the object is in frustum otherwise false
  27001. */
  27002. isCompletelyInFrustum(target: ICullable): boolean;
  27003. /**
  27004. * Gets a ray in the forward direction from the camera.
  27005. * @param length Defines the length of the ray to create
  27006. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  27007. * @param origin Defines the start point of the ray which defaults to the camera position
  27008. * @returns the forward ray
  27009. */
  27010. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  27011. /**
  27012. * Releases resources associated with this node.
  27013. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27014. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27015. */
  27016. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27017. /** @hidden */
  27018. _isLeftCamera: boolean;
  27019. /**
  27020. * Gets the left camera of a rig setup in case of Rigged Camera
  27021. */
  27022. get isLeftCamera(): boolean;
  27023. /** @hidden */
  27024. _isRightCamera: boolean;
  27025. /**
  27026. * Gets the right camera of a rig setup in case of Rigged Camera
  27027. */
  27028. get isRightCamera(): boolean;
  27029. /**
  27030. * Gets the left camera of a rig setup in case of Rigged Camera
  27031. */
  27032. get leftCamera(): Nullable<FreeCamera>;
  27033. /**
  27034. * Gets the right camera of a rig setup in case of Rigged Camera
  27035. */
  27036. get rightCamera(): Nullable<FreeCamera>;
  27037. /**
  27038. * Gets the left camera target of a rig setup in case of Rigged Camera
  27039. * @returns the target position
  27040. */
  27041. getLeftTarget(): Nullable<Vector3>;
  27042. /**
  27043. * Gets the right camera target of a rig setup in case of Rigged Camera
  27044. * @returns the target position
  27045. */
  27046. getRightTarget(): Nullable<Vector3>;
  27047. /**
  27048. * @hidden
  27049. */
  27050. setCameraRigMode(mode: number, rigParams: any): void;
  27051. /** @hidden */
  27052. static _setStereoscopicRigMode(camera: Camera): void;
  27053. /** @hidden */
  27054. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27055. /** @hidden */
  27056. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27057. /** @hidden */
  27058. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27059. /** @hidden */
  27060. _getVRProjectionMatrix(): Matrix;
  27061. protected _updateCameraRotationMatrix(): void;
  27062. protected _updateWebVRCameraRotationMatrix(): void;
  27063. /**
  27064. * This function MUST be overwritten by the different WebVR cameras available.
  27065. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27066. * @hidden
  27067. */
  27068. _getWebVRProjectionMatrix(): Matrix;
  27069. /**
  27070. * This function MUST be overwritten by the different WebVR cameras available.
  27071. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27072. * @hidden
  27073. */
  27074. _getWebVRViewMatrix(): Matrix;
  27075. /** @hidden */
  27076. setCameraRigParameter(name: string, value: any): void;
  27077. /**
  27078. * needs to be overridden by children so sub has required properties to be copied
  27079. * @hidden
  27080. */
  27081. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27082. /**
  27083. * May need to be overridden by children
  27084. * @hidden
  27085. */
  27086. _updateRigCameras(): void;
  27087. /** @hidden */
  27088. _setupInputs(): void;
  27089. /**
  27090. * Serialiaze the camera setup to a json represention
  27091. * @returns the JSON representation
  27092. */
  27093. serialize(): any;
  27094. /**
  27095. * Clones the current camera.
  27096. * @param name The cloned camera name
  27097. * @returns the cloned camera
  27098. */
  27099. clone(name: string): Camera;
  27100. /**
  27101. * Gets the direction of the camera relative to a given local axis.
  27102. * @param localAxis Defines the reference axis to provide a relative direction.
  27103. * @return the direction
  27104. */
  27105. getDirection(localAxis: Vector3): Vector3;
  27106. /**
  27107. * Returns the current camera absolute rotation
  27108. */
  27109. get absoluteRotation(): Quaternion;
  27110. /**
  27111. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27112. * @param localAxis Defines the reference axis to provide a relative direction.
  27113. * @param result Defines the vector to store the result in
  27114. */
  27115. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27116. /**
  27117. * Gets a camera constructor for a given camera type
  27118. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27119. * @param name The name of the camera the result will be able to instantiate
  27120. * @param scene The scene the result will construct the camera in
  27121. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27122. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27123. * @returns a factory method to construc the camera
  27124. */
  27125. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27126. /**
  27127. * Compute the world matrix of the camera.
  27128. * @returns the camera world matrix
  27129. */
  27130. computeWorldMatrix(): Matrix;
  27131. /**
  27132. * Parse a JSON and creates the camera from the parsed information
  27133. * @param parsedCamera The JSON to parse
  27134. * @param scene The scene to instantiate the camera in
  27135. * @returns the newly constructed camera
  27136. */
  27137. static Parse(parsedCamera: any, scene: Scene): Camera;
  27138. }
  27139. }
  27140. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27141. import { Nullable } from "babylonjs/types";
  27142. import { Scene } from "babylonjs/scene";
  27143. import { Vector4 } from "babylonjs/Maths/math.vector";
  27144. import { Mesh } from "babylonjs/Meshes/mesh";
  27145. /**
  27146. * Class containing static functions to help procedurally build meshes
  27147. */
  27148. export class DiscBuilder {
  27149. /**
  27150. * Creates a plane polygonal mesh. By default, this is a disc
  27151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27152. * * 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
  27153. * * 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
  27154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27157. * @param name defines the name of the mesh
  27158. * @param options defines the options used to create the mesh
  27159. * @param scene defines the hosting scene
  27160. * @returns the plane polygonal mesh
  27161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27162. */
  27163. static CreateDisc(name: string, options: {
  27164. radius?: number;
  27165. tessellation?: number;
  27166. arc?: number;
  27167. updatable?: boolean;
  27168. sideOrientation?: number;
  27169. frontUVs?: Vector4;
  27170. backUVs?: Vector4;
  27171. }, scene?: Nullable<Scene>): Mesh;
  27172. }
  27173. }
  27174. declare module "babylonjs/Materials/fresnelParameters" {
  27175. import { DeepImmutable } from "babylonjs/types";
  27176. import { Color3 } from "babylonjs/Maths/math.color";
  27177. /**
  27178. * Options to be used when creating a FresnelParameters.
  27179. */
  27180. export type IFresnelParametersCreationOptions = {
  27181. /**
  27182. * Define the color used on edges (grazing angle)
  27183. */
  27184. leftColor?: Color3;
  27185. /**
  27186. * Define the color used on center
  27187. */
  27188. rightColor?: Color3;
  27189. /**
  27190. * Define bias applied to computed fresnel term
  27191. */
  27192. bias?: number;
  27193. /**
  27194. * Defined the power exponent applied to fresnel term
  27195. */
  27196. power?: number;
  27197. /**
  27198. * Define if the fresnel effect is enable or not.
  27199. */
  27200. isEnabled?: boolean;
  27201. };
  27202. /**
  27203. * Serialized format for FresnelParameters.
  27204. */
  27205. export type IFresnelParametersSerialized = {
  27206. /**
  27207. * Define the color used on edges (grazing angle) [as an array]
  27208. */
  27209. leftColor: number[];
  27210. /**
  27211. * Define the color used on center [as an array]
  27212. */
  27213. rightColor: number[];
  27214. /**
  27215. * Define bias applied to computed fresnel term
  27216. */
  27217. bias: number;
  27218. /**
  27219. * Defined the power exponent applied to fresnel term
  27220. */
  27221. power?: number;
  27222. /**
  27223. * Define if the fresnel effect is enable or not.
  27224. */
  27225. isEnabled: boolean;
  27226. };
  27227. /**
  27228. * This represents all the required information to add a fresnel effect on a material:
  27229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27230. */
  27231. export class FresnelParameters {
  27232. private _isEnabled;
  27233. /**
  27234. * Define if the fresnel effect is enable or not.
  27235. */
  27236. get isEnabled(): boolean;
  27237. set isEnabled(value: boolean);
  27238. /**
  27239. * Define the color used on edges (grazing angle)
  27240. */
  27241. leftColor: Color3;
  27242. /**
  27243. * Define the color used on center
  27244. */
  27245. rightColor: Color3;
  27246. /**
  27247. * Define bias applied to computed fresnel term
  27248. */
  27249. bias: number;
  27250. /**
  27251. * Defined the power exponent applied to fresnel term
  27252. */
  27253. power: number;
  27254. /**
  27255. * Creates a new FresnelParameters object.
  27256. *
  27257. * @param options provide your own settings to optionally to override defaults
  27258. */
  27259. constructor(options?: IFresnelParametersCreationOptions);
  27260. /**
  27261. * Clones the current fresnel and its valuues
  27262. * @returns a clone fresnel configuration
  27263. */
  27264. clone(): FresnelParameters;
  27265. /**
  27266. * Determines equality between FresnelParameters objects
  27267. * @param otherFresnelParameters defines the second operand
  27268. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27269. */
  27270. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27271. /**
  27272. * Serializes the current fresnel parameters to a JSON representation.
  27273. * @return the JSON serialization
  27274. */
  27275. serialize(): IFresnelParametersSerialized;
  27276. /**
  27277. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27278. * @param parsedFresnelParameters Define the JSON representation
  27279. * @returns the parsed parameters
  27280. */
  27281. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27282. }
  27283. }
  27284. declare module "babylonjs/Materials/pushMaterial" {
  27285. import { Nullable } from "babylonjs/types";
  27286. import { Scene } from "babylonjs/scene";
  27287. import { Matrix } from "babylonjs/Maths/math.vector";
  27288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27289. import { Mesh } from "babylonjs/Meshes/mesh";
  27290. import { Material } from "babylonjs/Materials/material";
  27291. import { Effect } from "babylonjs/Materials/effect";
  27292. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27293. /**
  27294. * Base class of materials working in push mode in babylon JS
  27295. * @hidden
  27296. */
  27297. export class PushMaterial extends Material {
  27298. protected _activeEffect: Effect;
  27299. protected _normalMatrix: Matrix;
  27300. /**
  27301. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27302. * This means that the material can keep using a previous shader while a new one is being compiled.
  27303. * This is mostly used when shader parallel compilation is supported (true by default)
  27304. */
  27305. allowShaderHotSwapping: boolean;
  27306. constructor(name: string, scene: Scene);
  27307. getEffect(): Effect;
  27308. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27309. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27310. /**
  27311. * Binds the given world matrix to the active effect
  27312. *
  27313. * @param world the matrix to bind
  27314. */
  27315. bindOnlyWorldMatrix(world: Matrix): void;
  27316. /**
  27317. * Binds the given normal matrix to the active effect
  27318. *
  27319. * @param normalMatrix the matrix to bind
  27320. */
  27321. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27322. bind(world: Matrix, mesh?: Mesh): void;
  27323. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27324. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27325. }
  27326. }
  27327. declare module "babylonjs/Materials/materialFlags" {
  27328. /**
  27329. * This groups all the flags used to control the materials channel.
  27330. */
  27331. export class MaterialFlags {
  27332. private static _DiffuseTextureEnabled;
  27333. /**
  27334. * Are diffuse textures enabled in the application.
  27335. */
  27336. static get DiffuseTextureEnabled(): boolean;
  27337. static set DiffuseTextureEnabled(value: boolean);
  27338. private static _AmbientTextureEnabled;
  27339. /**
  27340. * Are ambient textures enabled in the application.
  27341. */
  27342. static get AmbientTextureEnabled(): boolean;
  27343. static set AmbientTextureEnabled(value: boolean);
  27344. private static _OpacityTextureEnabled;
  27345. /**
  27346. * Are opacity textures enabled in the application.
  27347. */
  27348. static get OpacityTextureEnabled(): boolean;
  27349. static set OpacityTextureEnabled(value: boolean);
  27350. private static _ReflectionTextureEnabled;
  27351. /**
  27352. * Are reflection textures enabled in the application.
  27353. */
  27354. static get ReflectionTextureEnabled(): boolean;
  27355. static set ReflectionTextureEnabled(value: boolean);
  27356. private static _EmissiveTextureEnabled;
  27357. /**
  27358. * Are emissive textures enabled in the application.
  27359. */
  27360. static get EmissiveTextureEnabled(): boolean;
  27361. static set EmissiveTextureEnabled(value: boolean);
  27362. private static _SpecularTextureEnabled;
  27363. /**
  27364. * Are specular textures enabled in the application.
  27365. */
  27366. static get SpecularTextureEnabled(): boolean;
  27367. static set SpecularTextureEnabled(value: boolean);
  27368. private static _BumpTextureEnabled;
  27369. /**
  27370. * Are bump textures enabled in the application.
  27371. */
  27372. static get BumpTextureEnabled(): boolean;
  27373. static set BumpTextureEnabled(value: boolean);
  27374. private static _LightmapTextureEnabled;
  27375. /**
  27376. * Are lightmap textures enabled in the application.
  27377. */
  27378. static get LightmapTextureEnabled(): boolean;
  27379. static set LightmapTextureEnabled(value: boolean);
  27380. private static _RefractionTextureEnabled;
  27381. /**
  27382. * Are refraction textures enabled in the application.
  27383. */
  27384. static get RefractionTextureEnabled(): boolean;
  27385. static set RefractionTextureEnabled(value: boolean);
  27386. private static _ColorGradingTextureEnabled;
  27387. /**
  27388. * Are color grading textures enabled in the application.
  27389. */
  27390. static get ColorGradingTextureEnabled(): boolean;
  27391. static set ColorGradingTextureEnabled(value: boolean);
  27392. private static _FresnelEnabled;
  27393. /**
  27394. * Are fresnels enabled in the application.
  27395. */
  27396. static get FresnelEnabled(): boolean;
  27397. static set FresnelEnabled(value: boolean);
  27398. private static _ClearCoatTextureEnabled;
  27399. /**
  27400. * Are clear coat textures enabled in the application.
  27401. */
  27402. static get ClearCoatTextureEnabled(): boolean;
  27403. static set ClearCoatTextureEnabled(value: boolean);
  27404. private static _ClearCoatBumpTextureEnabled;
  27405. /**
  27406. * Are clear coat bump textures enabled in the application.
  27407. */
  27408. static get ClearCoatBumpTextureEnabled(): boolean;
  27409. static set ClearCoatBumpTextureEnabled(value: boolean);
  27410. private static _ClearCoatTintTextureEnabled;
  27411. /**
  27412. * Are clear coat tint textures enabled in the application.
  27413. */
  27414. static get ClearCoatTintTextureEnabled(): boolean;
  27415. static set ClearCoatTintTextureEnabled(value: boolean);
  27416. private static _SheenTextureEnabled;
  27417. /**
  27418. * Are sheen textures enabled in the application.
  27419. */
  27420. static get SheenTextureEnabled(): boolean;
  27421. static set SheenTextureEnabled(value: boolean);
  27422. private static _AnisotropicTextureEnabled;
  27423. /**
  27424. * Are anisotropic textures enabled in the application.
  27425. */
  27426. static get AnisotropicTextureEnabled(): boolean;
  27427. static set AnisotropicTextureEnabled(value: boolean);
  27428. private static _ThicknessTextureEnabled;
  27429. /**
  27430. * Are thickness textures enabled in the application.
  27431. */
  27432. static get ThicknessTextureEnabled(): boolean;
  27433. static set ThicknessTextureEnabled(value: boolean);
  27434. }
  27435. }
  27436. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27437. /** @hidden */
  27438. export var defaultFragmentDeclaration: {
  27439. name: string;
  27440. shader: string;
  27441. };
  27442. }
  27443. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27444. /** @hidden */
  27445. export var defaultUboDeclaration: {
  27446. name: string;
  27447. shader: string;
  27448. };
  27449. }
  27450. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27451. /** @hidden */
  27452. export var lightFragmentDeclaration: {
  27453. name: string;
  27454. shader: string;
  27455. };
  27456. }
  27457. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27458. /** @hidden */
  27459. export var lightUboDeclaration: {
  27460. name: string;
  27461. shader: string;
  27462. };
  27463. }
  27464. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27465. /** @hidden */
  27466. export var lightsFragmentFunctions: {
  27467. name: string;
  27468. shader: string;
  27469. };
  27470. }
  27471. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27472. /** @hidden */
  27473. export var shadowsFragmentFunctions: {
  27474. name: string;
  27475. shader: string;
  27476. };
  27477. }
  27478. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27479. /** @hidden */
  27480. export var fresnelFunction: {
  27481. name: string;
  27482. shader: string;
  27483. };
  27484. }
  27485. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27486. /** @hidden */
  27487. export var reflectionFunction: {
  27488. name: string;
  27489. shader: string;
  27490. };
  27491. }
  27492. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27493. /** @hidden */
  27494. export var bumpFragmentMainFunctions: {
  27495. name: string;
  27496. shader: string;
  27497. };
  27498. }
  27499. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27500. /** @hidden */
  27501. export var bumpFragmentFunctions: {
  27502. name: string;
  27503. shader: string;
  27504. };
  27505. }
  27506. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27507. /** @hidden */
  27508. export var logDepthDeclaration: {
  27509. name: string;
  27510. shader: string;
  27511. };
  27512. }
  27513. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27514. /** @hidden */
  27515. export var bumpFragment: {
  27516. name: string;
  27517. shader: string;
  27518. };
  27519. }
  27520. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27521. /** @hidden */
  27522. export var depthPrePass: {
  27523. name: string;
  27524. shader: string;
  27525. };
  27526. }
  27527. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27528. /** @hidden */
  27529. export var lightFragment: {
  27530. name: string;
  27531. shader: string;
  27532. };
  27533. }
  27534. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27535. /** @hidden */
  27536. export var logDepthFragment: {
  27537. name: string;
  27538. shader: string;
  27539. };
  27540. }
  27541. declare module "babylonjs/Shaders/default.fragment" {
  27542. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27543. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27544. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27545. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27546. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27547. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27548. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27549. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27550. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27551. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27552. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27553. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27554. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27555. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27556. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27557. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27558. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27559. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27560. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27561. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27562. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27563. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27564. /** @hidden */
  27565. export var defaultPixelShader: {
  27566. name: string;
  27567. shader: string;
  27568. };
  27569. }
  27570. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27571. /** @hidden */
  27572. export var defaultVertexDeclaration: {
  27573. name: string;
  27574. shader: string;
  27575. };
  27576. }
  27577. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27578. /** @hidden */
  27579. export var bumpVertexDeclaration: {
  27580. name: string;
  27581. shader: string;
  27582. };
  27583. }
  27584. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27585. /** @hidden */
  27586. export var bumpVertex: {
  27587. name: string;
  27588. shader: string;
  27589. };
  27590. }
  27591. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27592. /** @hidden */
  27593. export var fogVertex: {
  27594. name: string;
  27595. shader: string;
  27596. };
  27597. }
  27598. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27599. /** @hidden */
  27600. export var shadowsVertex: {
  27601. name: string;
  27602. shader: string;
  27603. };
  27604. }
  27605. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27606. /** @hidden */
  27607. export var pointCloudVertex: {
  27608. name: string;
  27609. shader: string;
  27610. };
  27611. }
  27612. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27613. /** @hidden */
  27614. export var logDepthVertex: {
  27615. name: string;
  27616. shader: string;
  27617. };
  27618. }
  27619. declare module "babylonjs/Shaders/default.vertex" {
  27620. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27621. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27622. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27624. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27625. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27626. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27627. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27628. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27629. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27632. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27634. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27635. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27636. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27638. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27639. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27640. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27641. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27642. /** @hidden */
  27643. export var defaultVertexShader: {
  27644. name: string;
  27645. shader: string;
  27646. };
  27647. }
  27648. declare module "babylonjs/Materials/standardMaterial" {
  27649. import { SmartArray } from "babylonjs/Misc/smartArray";
  27650. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27651. import { Nullable } from "babylonjs/types";
  27652. import { Scene } from "babylonjs/scene";
  27653. import { Matrix } from "babylonjs/Maths/math.vector";
  27654. import { Color3 } from "babylonjs/Maths/math.color";
  27655. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27657. import { Mesh } from "babylonjs/Meshes/mesh";
  27658. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27659. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27660. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27661. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27662. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27664. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27665. import "babylonjs/Shaders/default.fragment";
  27666. import "babylonjs/Shaders/default.vertex";
  27667. /** @hidden */
  27668. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27669. MAINUV1: boolean;
  27670. MAINUV2: boolean;
  27671. DIFFUSE: boolean;
  27672. DIFFUSEDIRECTUV: number;
  27673. AMBIENT: boolean;
  27674. AMBIENTDIRECTUV: number;
  27675. OPACITY: boolean;
  27676. OPACITYDIRECTUV: number;
  27677. OPACITYRGB: boolean;
  27678. REFLECTION: boolean;
  27679. EMISSIVE: boolean;
  27680. EMISSIVEDIRECTUV: number;
  27681. SPECULAR: boolean;
  27682. SPECULARDIRECTUV: number;
  27683. BUMP: boolean;
  27684. BUMPDIRECTUV: number;
  27685. PARALLAX: boolean;
  27686. PARALLAXOCCLUSION: boolean;
  27687. SPECULAROVERALPHA: boolean;
  27688. CLIPPLANE: boolean;
  27689. CLIPPLANE2: boolean;
  27690. CLIPPLANE3: boolean;
  27691. CLIPPLANE4: boolean;
  27692. CLIPPLANE5: boolean;
  27693. CLIPPLANE6: boolean;
  27694. ALPHATEST: boolean;
  27695. DEPTHPREPASS: boolean;
  27696. ALPHAFROMDIFFUSE: boolean;
  27697. POINTSIZE: boolean;
  27698. FOG: boolean;
  27699. SPECULARTERM: boolean;
  27700. DIFFUSEFRESNEL: boolean;
  27701. OPACITYFRESNEL: boolean;
  27702. REFLECTIONFRESNEL: boolean;
  27703. REFRACTIONFRESNEL: boolean;
  27704. EMISSIVEFRESNEL: boolean;
  27705. FRESNEL: boolean;
  27706. NORMAL: boolean;
  27707. UV1: boolean;
  27708. UV2: boolean;
  27709. VERTEXCOLOR: boolean;
  27710. VERTEXALPHA: boolean;
  27711. NUM_BONE_INFLUENCERS: number;
  27712. BonesPerMesh: number;
  27713. BONETEXTURE: boolean;
  27714. INSTANCES: boolean;
  27715. GLOSSINESS: boolean;
  27716. ROUGHNESS: boolean;
  27717. EMISSIVEASILLUMINATION: boolean;
  27718. LINKEMISSIVEWITHDIFFUSE: boolean;
  27719. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27720. LIGHTMAP: boolean;
  27721. LIGHTMAPDIRECTUV: number;
  27722. OBJECTSPACE_NORMALMAP: boolean;
  27723. USELIGHTMAPASSHADOWMAP: boolean;
  27724. REFLECTIONMAP_3D: boolean;
  27725. REFLECTIONMAP_SPHERICAL: boolean;
  27726. REFLECTIONMAP_PLANAR: boolean;
  27727. REFLECTIONMAP_CUBIC: boolean;
  27728. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27729. REFLECTIONMAP_PROJECTION: boolean;
  27730. REFLECTIONMAP_SKYBOX: boolean;
  27731. REFLECTIONMAP_EXPLICIT: boolean;
  27732. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27733. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27734. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27735. INVERTCUBICMAP: boolean;
  27736. LOGARITHMICDEPTH: boolean;
  27737. REFRACTION: boolean;
  27738. REFRACTIONMAP_3D: boolean;
  27739. REFLECTIONOVERALPHA: boolean;
  27740. TWOSIDEDLIGHTING: boolean;
  27741. SHADOWFLOAT: boolean;
  27742. MORPHTARGETS: boolean;
  27743. MORPHTARGETS_NORMAL: boolean;
  27744. MORPHTARGETS_TANGENT: boolean;
  27745. MORPHTARGETS_UV: boolean;
  27746. NUM_MORPH_INFLUENCERS: number;
  27747. NONUNIFORMSCALING: boolean;
  27748. PREMULTIPLYALPHA: boolean;
  27749. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27750. ALPHABLEND: boolean;
  27751. IMAGEPROCESSING: boolean;
  27752. VIGNETTE: boolean;
  27753. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27754. VIGNETTEBLENDMODEOPAQUE: boolean;
  27755. TONEMAPPING: boolean;
  27756. TONEMAPPING_ACES: boolean;
  27757. CONTRAST: boolean;
  27758. COLORCURVES: boolean;
  27759. COLORGRADING: boolean;
  27760. COLORGRADING3D: boolean;
  27761. SAMPLER3DGREENDEPTH: boolean;
  27762. SAMPLER3DBGRMAP: boolean;
  27763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27764. MULTIVIEW: boolean;
  27765. /**
  27766. * If the reflection texture on this material is in linear color space
  27767. * @hidden
  27768. */
  27769. IS_REFLECTION_LINEAR: boolean;
  27770. /**
  27771. * If the refraction texture on this material is in linear color space
  27772. * @hidden
  27773. */
  27774. IS_REFRACTION_LINEAR: boolean;
  27775. EXPOSURE: boolean;
  27776. constructor();
  27777. setReflectionMode(modeToEnable: string): void;
  27778. }
  27779. /**
  27780. * This is the default material used in Babylon. It is the best trade off between quality
  27781. * and performances.
  27782. * @see http://doc.babylonjs.com/babylon101/materials
  27783. */
  27784. export class StandardMaterial extends PushMaterial {
  27785. private _diffuseTexture;
  27786. /**
  27787. * The basic texture of the material as viewed under a light.
  27788. */
  27789. diffuseTexture: Nullable<BaseTexture>;
  27790. private _ambientTexture;
  27791. /**
  27792. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27793. */
  27794. ambientTexture: Nullable<BaseTexture>;
  27795. private _opacityTexture;
  27796. /**
  27797. * Define the transparency of the material from a texture.
  27798. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27799. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27800. */
  27801. opacityTexture: Nullable<BaseTexture>;
  27802. private _reflectionTexture;
  27803. /**
  27804. * Define the texture used to display the reflection.
  27805. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27806. */
  27807. reflectionTexture: Nullable<BaseTexture>;
  27808. private _emissiveTexture;
  27809. /**
  27810. * Define texture of the material as if self lit.
  27811. * This will be mixed in the final result even in the absence of light.
  27812. */
  27813. emissiveTexture: Nullable<BaseTexture>;
  27814. private _specularTexture;
  27815. /**
  27816. * Define how the color and intensity of the highlight given by the light in the material.
  27817. */
  27818. specularTexture: Nullable<BaseTexture>;
  27819. private _bumpTexture;
  27820. /**
  27821. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27822. * 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.
  27823. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27824. */
  27825. bumpTexture: Nullable<BaseTexture>;
  27826. private _lightmapTexture;
  27827. /**
  27828. * Complex lighting can be computationally expensive to compute at runtime.
  27829. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27830. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27831. */
  27832. lightmapTexture: Nullable<BaseTexture>;
  27833. private _refractionTexture;
  27834. /**
  27835. * Define the texture used to display the refraction.
  27836. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27837. */
  27838. refractionTexture: Nullable<BaseTexture>;
  27839. /**
  27840. * The color of the material lit by the environmental background lighting.
  27841. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27842. */
  27843. ambientColor: Color3;
  27844. /**
  27845. * The basic color of the material as viewed under a light.
  27846. */
  27847. diffuseColor: Color3;
  27848. /**
  27849. * Define how the color and intensity of the highlight given by the light in the material.
  27850. */
  27851. specularColor: Color3;
  27852. /**
  27853. * Define the color of the material as if self lit.
  27854. * This will be mixed in the final result even in the absence of light.
  27855. */
  27856. emissiveColor: Color3;
  27857. /**
  27858. * Defines how sharp are the highlights in the material.
  27859. * The bigger the value the sharper giving a more glossy feeling to the result.
  27860. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27861. */
  27862. specularPower: number;
  27863. private _useAlphaFromDiffuseTexture;
  27864. /**
  27865. * Does the transparency come from the diffuse texture alpha channel.
  27866. */
  27867. useAlphaFromDiffuseTexture: boolean;
  27868. private _useEmissiveAsIllumination;
  27869. /**
  27870. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27871. */
  27872. useEmissiveAsIllumination: boolean;
  27873. private _linkEmissiveWithDiffuse;
  27874. /**
  27875. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27876. * the emissive level when the final color is close to one.
  27877. */
  27878. linkEmissiveWithDiffuse: boolean;
  27879. private _useSpecularOverAlpha;
  27880. /**
  27881. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27882. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27883. */
  27884. useSpecularOverAlpha: boolean;
  27885. private _useReflectionOverAlpha;
  27886. /**
  27887. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27888. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27889. */
  27890. useReflectionOverAlpha: boolean;
  27891. private _disableLighting;
  27892. /**
  27893. * Does lights from the scene impacts this material.
  27894. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27895. */
  27896. disableLighting: boolean;
  27897. private _useObjectSpaceNormalMap;
  27898. /**
  27899. * Allows using an object space normal map (instead of tangent space).
  27900. */
  27901. useObjectSpaceNormalMap: boolean;
  27902. private _useParallax;
  27903. /**
  27904. * Is parallax enabled or not.
  27905. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27906. */
  27907. useParallax: boolean;
  27908. private _useParallaxOcclusion;
  27909. /**
  27910. * Is parallax occlusion enabled or not.
  27911. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27912. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27913. */
  27914. useParallaxOcclusion: boolean;
  27915. /**
  27916. * 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.
  27917. */
  27918. parallaxScaleBias: number;
  27919. private _roughness;
  27920. /**
  27921. * Helps to define how blurry the reflections should appears in the material.
  27922. */
  27923. roughness: number;
  27924. /**
  27925. * In case of refraction, define the value of the index of refraction.
  27926. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27927. */
  27928. indexOfRefraction: number;
  27929. /**
  27930. * Invert the refraction texture alongside the y axis.
  27931. * It can be useful with procedural textures or probe for instance.
  27932. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27933. */
  27934. invertRefractionY: boolean;
  27935. /**
  27936. * Defines the alpha limits in alpha test mode.
  27937. */
  27938. alphaCutOff: number;
  27939. private _useLightmapAsShadowmap;
  27940. /**
  27941. * In case of light mapping, define whether the map contains light or shadow informations.
  27942. */
  27943. useLightmapAsShadowmap: boolean;
  27944. private _diffuseFresnelParameters;
  27945. /**
  27946. * Define the diffuse fresnel parameters of the material.
  27947. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27948. */
  27949. diffuseFresnelParameters: FresnelParameters;
  27950. private _opacityFresnelParameters;
  27951. /**
  27952. * Define the opacity fresnel parameters of the material.
  27953. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27954. */
  27955. opacityFresnelParameters: FresnelParameters;
  27956. private _reflectionFresnelParameters;
  27957. /**
  27958. * Define the reflection fresnel parameters of the material.
  27959. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27960. */
  27961. reflectionFresnelParameters: FresnelParameters;
  27962. private _refractionFresnelParameters;
  27963. /**
  27964. * Define the refraction fresnel parameters of the material.
  27965. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27966. */
  27967. refractionFresnelParameters: FresnelParameters;
  27968. private _emissiveFresnelParameters;
  27969. /**
  27970. * Define the emissive fresnel parameters of the material.
  27971. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27972. */
  27973. emissiveFresnelParameters: FresnelParameters;
  27974. private _useReflectionFresnelFromSpecular;
  27975. /**
  27976. * If true automatically deducts the fresnels values from the material specularity.
  27977. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27978. */
  27979. useReflectionFresnelFromSpecular: boolean;
  27980. private _useGlossinessFromSpecularMapAlpha;
  27981. /**
  27982. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27983. */
  27984. useGlossinessFromSpecularMapAlpha: boolean;
  27985. private _maxSimultaneousLights;
  27986. /**
  27987. * Defines the maximum number of lights that can be used in the material
  27988. */
  27989. maxSimultaneousLights: number;
  27990. private _invertNormalMapX;
  27991. /**
  27992. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27993. */
  27994. invertNormalMapX: boolean;
  27995. private _invertNormalMapY;
  27996. /**
  27997. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27998. */
  27999. invertNormalMapY: boolean;
  28000. private _twoSidedLighting;
  28001. /**
  28002. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28003. */
  28004. twoSidedLighting: boolean;
  28005. /**
  28006. * Default configuration related to image processing available in the standard Material.
  28007. */
  28008. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28009. /**
  28010. * Gets the image processing configuration used either in this material.
  28011. */
  28012. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28013. /**
  28014. * Sets the Default image processing configuration used either in the this material.
  28015. *
  28016. * If sets to null, the scene one is in use.
  28017. */
  28018. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28019. /**
  28020. * Keep track of the image processing observer to allow dispose and replace.
  28021. */
  28022. private _imageProcessingObserver;
  28023. /**
  28024. * Attaches a new image processing configuration to the Standard Material.
  28025. * @param configuration
  28026. */
  28027. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28028. /**
  28029. * Gets wether the color curves effect is enabled.
  28030. */
  28031. get cameraColorCurvesEnabled(): boolean;
  28032. /**
  28033. * Sets wether the color curves effect is enabled.
  28034. */
  28035. set cameraColorCurvesEnabled(value: boolean);
  28036. /**
  28037. * Gets wether the color grading effect is enabled.
  28038. */
  28039. get cameraColorGradingEnabled(): boolean;
  28040. /**
  28041. * Gets wether the color grading effect is enabled.
  28042. */
  28043. set cameraColorGradingEnabled(value: boolean);
  28044. /**
  28045. * Gets wether tonemapping is enabled or not.
  28046. */
  28047. get cameraToneMappingEnabled(): boolean;
  28048. /**
  28049. * Sets wether tonemapping is enabled or not
  28050. */
  28051. set cameraToneMappingEnabled(value: boolean);
  28052. /**
  28053. * The camera exposure used on this material.
  28054. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28055. * This corresponds to a photographic exposure.
  28056. */
  28057. get cameraExposure(): number;
  28058. /**
  28059. * The camera exposure used on this material.
  28060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28061. * This corresponds to a photographic exposure.
  28062. */
  28063. set cameraExposure(value: number);
  28064. /**
  28065. * Gets The camera contrast used on this material.
  28066. */
  28067. get cameraContrast(): number;
  28068. /**
  28069. * Sets The camera contrast used on this material.
  28070. */
  28071. set cameraContrast(value: number);
  28072. /**
  28073. * Gets the Color Grading 2D Lookup Texture.
  28074. */
  28075. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28076. /**
  28077. * Sets the Color Grading 2D Lookup Texture.
  28078. */
  28079. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28080. /**
  28081. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28082. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28083. * 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;
  28084. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28085. */
  28086. get cameraColorCurves(): Nullable<ColorCurves>;
  28087. /**
  28088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28090. * 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;
  28091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28092. */
  28093. set cameraColorCurves(value: Nullable<ColorCurves>);
  28094. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28095. protected _worldViewProjectionMatrix: Matrix;
  28096. protected _globalAmbientColor: Color3;
  28097. protected _useLogarithmicDepth: boolean;
  28098. protected _rebuildInParallel: boolean;
  28099. /**
  28100. * Instantiates a new standard material.
  28101. * This is the default material used in Babylon. It is the best trade off between quality
  28102. * and performances.
  28103. * @see http://doc.babylonjs.com/babylon101/materials
  28104. * @param name Define the name of the material in the scene
  28105. * @param scene Define the scene the material belong to
  28106. */
  28107. constructor(name: string, scene: Scene);
  28108. /**
  28109. * Gets a boolean indicating that current material needs to register RTT
  28110. */
  28111. get hasRenderTargetTextures(): boolean;
  28112. /**
  28113. * Gets the current class name of the material e.g. "StandardMaterial"
  28114. * Mainly use in serialization.
  28115. * @returns the class name
  28116. */
  28117. getClassName(): string;
  28118. /**
  28119. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28120. * You can try switching to logarithmic depth.
  28121. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28122. */
  28123. get useLogarithmicDepth(): boolean;
  28124. set useLogarithmicDepth(value: boolean);
  28125. /**
  28126. * Specifies if the material will require alpha blending
  28127. * @returns a boolean specifying if alpha blending is needed
  28128. */
  28129. needAlphaBlending(): boolean;
  28130. /**
  28131. * Specifies if this material should be rendered in alpha test mode
  28132. * @returns a boolean specifying if an alpha test is needed.
  28133. */
  28134. needAlphaTesting(): boolean;
  28135. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28136. /**
  28137. * Get the texture used for alpha test purpose.
  28138. * @returns the diffuse texture in case of the standard material.
  28139. */
  28140. getAlphaTestTexture(): Nullable<BaseTexture>;
  28141. /**
  28142. * Get if the submesh is ready to be used and all its information available.
  28143. * Child classes can use it to update shaders
  28144. * @param mesh defines the mesh to check
  28145. * @param subMesh defines which submesh to check
  28146. * @param useInstances specifies that instances should be used
  28147. * @returns a boolean indicating that the submesh is ready or not
  28148. */
  28149. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28150. /**
  28151. * Builds the material UBO layouts.
  28152. * Used internally during the effect preparation.
  28153. */
  28154. buildUniformLayout(): void;
  28155. /**
  28156. * Unbinds the material from the mesh
  28157. */
  28158. unbind(): void;
  28159. /**
  28160. * Binds the submesh to this material by preparing the effect and shader to draw
  28161. * @param world defines the world transformation matrix
  28162. * @param mesh defines the mesh containing the submesh
  28163. * @param subMesh defines the submesh to bind the material to
  28164. */
  28165. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28166. /**
  28167. * Get the list of animatables in the material.
  28168. * @returns the list of animatables object used in the material
  28169. */
  28170. getAnimatables(): IAnimatable[];
  28171. /**
  28172. * Gets the active textures from the material
  28173. * @returns an array of textures
  28174. */
  28175. getActiveTextures(): BaseTexture[];
  28176. /**
  28177. * Specifies if the material uses a texture
  28178. * @param texture defines the texture to check against the material
  28179. * @returns a boolean specifying if the material uses the texture
  28180. */
  28181. hasTexture(texture: BaseTexture): boolean;
  28182. /**
  28183. * Disposes the material
  28184. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28185. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28186. */
  28187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28188. /**
  28189. * Makes a duplicate of the material, and gives it a new name
  28190. * @param name defines the new name for the duplicated material
  28191. * @returns the cloned material
  28192. */
  28193. clone(name: string): StandardMaterial;
  28194. /**
  28195. * Serializes this material in a JSON representation
  28196. * @returns the serialized material object
  28197. */
  28198. serialize(): any;
  28199. /**
  28200. * Creates a standard material from parsed material data
  28201. * @param source defines the JSON representation of the material
  28202. * @param scene defines the hosting scene
  28203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28204. * @returns a new standard material
  28205. */
  28206. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28207. /**
  28208. * Are diffuse textures enabled in the application.
  28209. */
  28210. static get DiffuseTextureEnabled(): boolean;
  28211. static set DiffuseTextureEnabled(value: boolean);
  28212. /**
  28213. * Are ambient textures enabled in the application.
  28214. */
  28215. static get AmbientTextureEnabled(): boolean;
  28216. static set AmbientTextureEnabled(value: boolean);
  28217. /**
  28218. * Are opacity textures enabled in the application.
  28219. */
  28220. static get OpacityTextureEnabled(): boolean;
  28221. static set OpacityTextureEnabled(value: boolean);
  28222. /**
  28223. * Are reflection textures enabled in the application.
  28224. */
  28225. static get ReflectionTextureEnabled(): boolean;
  28226. static set ReflectionTextureEnabled(value: boolean);
  28227. /**
  28228. * Are emissive textures enabled in the application.
  28229. */
  28230. static get EmissiveTextureEnabled(): boolean;
  28231. static set EmissiveTextureEnabled(value: boolean);
  28232. /**
  28233. * Are specular textures enabled in the application.
  28234. */
  28235. static get SpecularTextureEnabled(): boolean;
  28236. static set SpecularTextureEnabled(value: boolean);
  28237. /**
  28238. * Are bump textures enabled in the application.
  28239. */
  28240. static get BumpTextureEnabled(): boolean;
  28241. static set BumpTextureEnabled(value: boolean);
  28242. /**
  28243. * Are lightmap textures enabled in the application.
  28244. */
  28245. static get LightmapTextureEnabled(): boolean;
  28246. static set LightmapTextureEnabled(value: boolean);
  28247. /**
  28248. * Are refraction textures enabled in the application.
  28249. */
  28250. static get RefractionTextureEnabled(): boolean;
  28251. static set RefractionTextureEnabled(value: boolean);
  28252. /**
  28253. * Are color grading textures enabled in the application.
  28254. */
  28255. static get ColorGradingTextureEnabled(): boolean;
  28256. static set ColorGradingTextureEnabled(value: boolean);
  28257. /**
  28258. * Are fresnels enabled in the application.
  28259. */
  28260. static get FresnelEnabled(): boolean;
  28261. static set FresnelEnabled(value: boolean);
  28262. }
  28263. }
  28264. declare module "babylonjs/Particles/solidParticleSystem" {
  28265. import { Nullable } from "babylonjs/types";
  28266. import { Mesh } from "babylonjs/Meshes/mesh";
  28267. import { Scene, IDisposable } from "babylonjs/scene";
  28268. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28269. import { Material } from "babylonjs/Materials/material";
  28270. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28271. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28272. /**
  28273. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28274. *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.
  28275. * The SPS is also a particle system. It provides some methods to manage the particles.
  28276. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28277. *
  28278. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28279. */
  28280. export class SolidParticleSystem implements IDisposable {
  28281. /**
  28282. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28283. * Example : var p = SPS.particles[i];
  28284. */
  28285. particles: SolidParticle[];
  28286. /**
  28287. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28288. */
  28289. nbParticles: number;
  28290. /**
  28291. * If the particles must ever face the camera (default false). Useful for planar particles.
  28292. */
  28293. billboard: boolean;
  28294. /**
  28295. * Recompute normals when adding a shape
  28296. */
  28297. recomputeNormals: boolean;
  28298. /**
  28299. * This a counter ofr your own usage. It's not set by any SPS functions.
  28300. */
  28301. counter: number;
  28302. /**
  28303. * The SPS name. This name is also given to the underlying mesh.
  28304. */
  28305. name: string;
  28306. /**
  28307. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28308. */
  28309. mesh: Mesh;
  28310. /**
  28311. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28312. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28313. */
  28314. vars: any;
  28315. /**
  28316. * This array is populated when the SPS is set as 'pickable'.
  28317. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28318. * Each element of this array is an object `{idx: int, faceId: int}`.
  28319. * `idx` is the picked particle index in the `SPS.particles` array
  28320. * `faceId` is the picked face index counted within this particle.
  28321. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28322. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28323. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28324. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28325. */
  28326. pickedParticles: {
  28327. idx: number;
  28328. faceId: number;
  28329. }[];
  28330. /**
  28331. * This array is populated when the SPS is set as 'pickable'
  28332. * Each key of this array is a submesh index.
  28333. * Each element of this array is a second array defined like this :
  28334. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28335. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28336. * `idx` is the picked particle index in the `SPS.particles` array
  28337. * `faceId` is the picked face index counted within this particle.
  28338. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28339. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28340. */
  28341. pickedBySubMesh: {
  28342. idx: number;
  28343. faceId: number;
  28344. }[][];
  28345. /**
  28346. * This array is populated when `enableDepthSort` is set to true.
  28347. * Each element of this array is an instance of the class DepthSortedParticle.
  28348. */
  28349. depthSortedParticles: DepthSortedParticle[];
  28350. /**
  28351. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28352. * @hidden
  28353. */
  28354. _bSphereOnly: boolean;
  28355. /**
  28356. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28357. * @hidden
  28358. */
  28359. _bSphereRadiusFactor: number;
  28360. private _scene;
  28361. private _positions;
  28362. private _indices;
  28363. private _normals;
  28364. private _colors;
  28365. private _uvs;
  28366. private _indices32;
  28367. private _positions32;
  28368. private _normals32;
  28369. private _fixedNormal32;
  28370. private _colors32;
  28371. private _uvs32;
  28372. private _index;
  28373. private _updatable;
  28374. private _pickable;
  28375. private _isVisibilityBoxLocked;
  28376. private _alwaysVisible;
  28377. private _depthSort;
  28378. private _expandable;
  28379. private _shapeCounter;
  28380. private _copy;
  28381. private _color;
  28382. private _computeParticleColor;
  28383. private _computeParticleTexture;
  28384. private _computeParticleRotation;
  28385. private _computeParticleVertex;
  28386. private _computeBoundingBox;
  28387. private _depthSortParticles;
  28388. private _camera;
  28389. private _mustUnrotateFixedNormals;
  28390. private _particlesIntersect;
  28391. private _needs32Bits;
  28392. private _isNotBuilt;
  28393. private _lastParticleId;
  28394. private _idxOfId;
  28395. private _multimaterialEnabled;
  28396. private _useModelMaterial;
  28397. private _indicesByMaterial;
  28398. private _materialIndexes;
  28399. private _depthSortFunction;
  28400. private _materialSortFunction;
  28401. private _materials;
  28402. private _multimaterial;
  28403. private _materialIndexesById;
  28404. private _defaultMaterial;
  28405. private _autoUpdateSubMeshes;
  28406. private _tmpVertex;
  28407. /**
  28408. * Creates a SPS (Solid Particle System) object.
  28409. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28410. * @param scene (Scene) is the scene in which the SPS is added.
  28411. * @param options defines the options of the sps e.g.
  28412. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28413. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28414. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28415. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  28416. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28417. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28418. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28419. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28420. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28421. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28422. */
  28423. constructor(name: string, scene: Scene, options?: {
  28424. updatable?: boolean;
  28425. isPickable?: boolean;
  28426. enableDepthSort?: boolean;
  28427. particleIntersection?: boolean;
  28428. boundingSphereOnly?: boolean;
  28429. bSphereRadiusFactor?: number;
  28430. expandable?: boolean;
  28431. useModelMaterial?: boolean;
  28432. enableMultiMaterial?: boolean;
  28433. });
  28434. /**
  28435. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28436. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28437. * @returns the created mesh
  28438. */
  28439. buildMesh(): Mesh;
  28440. /**
  28441. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28442. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28443. * Thus the particles generated from `digest()` have their property `position` set yet.
  28444. * @param mesh ( Mesh ) is the mesh to be digested
  28445. * @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
  28446. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28447. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28448. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28449. * @returns the current SPS
  28450. */
  28451. digest(mesh: Mesh, options?: {
  28452. facetNb?: number;
  28453. number?: number;
  28454. delta?: number;
  28455. storage?: [];
  28456. }): SolidParticleSystem;
  28457. /**
  28458. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28459. * @hidden
  28460. */
  28461. private _unrotateFixedNormals;
  28462. /**
  28463. * Resets the temporary working copy particle
  28464. * @hidden
  28465. */
  28466. private _resetCopy;
  28467. /**
  28468. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28469. * @param p the current index in the positions array to be updated
  28470. * @param ind the current index in the indices array
  28471. * @param shape a Vector3 array, the shape geometry
  28472. * @param positions the positions array to be updated
  28473. * @param meshInd the shape indices array
  28474. * @param indices the indices array to be updated
  28475. * @param meshUV the shape uv array
  28476. * @param uvs the uv array to be updated
  28477. * @param meshCol the shape color array
  28478. * @param colors the color array to be updated
  28479. * @param meshNor the shape normals array
  28480. * @param normals the normals array to be updated
  28481. * @param idx the particle index
  28482. * @param idxInShape the particle index in its shape
  28483. * @param options the addShape() method passed options
  28484. * @model the particle model
  28485. * @hidden
  28486. */
  28487. private _meshBuilder;
  28488. /**
  28489. * Returns a shape Vector3 array from positions float array
  28490. * @param positions float array
  28491. * @returns a vector3 array
  28492. * @hidden
  28493. */
  28494. private _posToShape;
  28495. /**
  28496. * Returns a shapeUV array from a float uvs (array deep copy)
  28497. * @param uvs as a float array
  28498. * @returns a shapeUV array
  28499. * @hidden
  28500. */
  28501. private _uvsToShapeUV;
  28502. /**
  28503. * Adds a new particle object in the particles array
  28504. * @param idx particle index in particles array
  28505. * @param id particle id
  28506. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28507. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28508. * @param model particle ModelShape object
  28509. * @param shapeId model shape identifier
  28510. * @param idxInShape index of the particle in the current model
  28511. * @param bInfo model bounding info object
  28512. * @param storage target storage array, if any
  28513. * @hidden
  28514. */
  28515. private _addParticle;
  28516. /**
  28517. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28518. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28519. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28520. * @param nb (positive integer) the number of particles to be created from this model
  28521. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28522. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28523. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28524. * @returns the number of shapes in the system
  28525. */
  28526. addShape(mesh: Mesh, nb: number, options?: {
  28527. positionFunction?: any;
  28528. vertexFunction?: any;
  28529. storage?: [];
  28530. }): number;
  28531. /**
  28532. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28533. * @hidden
  28534. */
  28535. private _rebuildParticle;
  28536. /**
  28537. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28538. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  28539. * @returns the SPS.
  28540. */
  28541. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28542. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28543. * Returns an array with the removed particles.
  28544. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28545. * The SPS can't be empty so at least one particle needs to remain in place.
  28546. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28547. * @param start index of the first particle to remove
  28548. * @param end index of the last particle to remove (included)
  28549. * @returns an array populated with the removed particles
  28550. */
  28551. removeParticles(start: number, end: number): SolidParticle[];
  28552. /**
  28553. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28554. * @param solidParticleArray an array populated with Solid Particles objects
  28555. * @returns the SPS
  28556. */
  28557. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28558. /**
  28559. * Creates a new particle and modifies the SPS mesh geometry :
  28560. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28561. * - calls _addParticle() to populate the particle array
  28562. * factorized code from addShape() and insertParticlesFromArray()
  28563. * @param idx particle index in the particles array
  28564. * @param i particle index in its shape
  28565. * @param modelShape particle ModelShape object
  28566. * @param shape shape vertex array
  28567. * @param meshInd shape indices array
  28568. * @param meshUV shape uv array
  28569. * @param meshCol shape color array
  28570. * @param meshNor shape normals array
  28571. * @param bbInfo shape bounding info
  28572. * @param storage target particle storage
  28573. * @options addShape() passed options
  28574. * @hidden
  28575. */
  28576. private _insertNewParticle;
  28577. /**
  28578. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28579. * This method calls `updateParticle()` for each particle of the SPS.
  28580. * For an animated SPS, it is usually called within the render loop.
  28581. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28582. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28583. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28584. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28585. * @returns the SPS.
  28586. */
  28587. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28588. /**
  28589. * Disposes the SPS.
  28590. */
  28591. dispose(): void;
  28592. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28593. * idx is the particle index in the SPS
  28594. * faceId is the picked face index counted within this particle.
  28595. * Returns null if the pickInfo can't identify a picked particle.
  28596. * @param pickingInfo (PickingInfo object)
  28597. * @returns {idx: number, faceId: number} or null
  28598. */
  28599. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28600. idx: number;
  28601. faceId: number;
  28602. }>;
  28603. /**
  28604. * Returns a SolidParticle object from its identifier : particle.id
  28605. * @param id (integer) the particle Id
  28606. * @returns the searched particle or null if not found in the SPS.
  28607. */
  28608. getParticleById(id: number): Nullable<SolidParticle>;
  28609. /**
  28610. * Returns a new array populated with the particles having the passed shapeId.
  28611. * @param shapeId (integer) the shape identifier
  28612. * @returns a new solid particle array
  28613. */
  28614. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28615. /**
  28616. * Populates the passed array "ref" with the particles having the passed shapeId.
  28617. * @param shapeId the shape identifier
  28618. * @returns the SPS
  28619. * @param ref
  28620. */
  28621. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28622. /**
  28623. * Computes the required SubMeshes according the materials assigned to the particles.
  28624. * @returns the solid particle system.
  28625. * Does nothing if called before the SPS mesh is built.
  28626. */
  28627. computeSubMeshes(): SolidParticleSystem;
  28628. /**
  28629. * Sorts the solid particles by material when MultiMaterial is enabled.
  28630. * Updates the indices32 array.
  28631. * Updates the indicesByMaterial array.
  28632. * Updates the mesh indices array.
  28633. * @returns the SPS
  28634. * @hidden
  28635. */
  28636. private _sortParticlesByMaterial;
  28637. /**
  28638. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28639. * @hidden
  28640. */
  28641. private _setMaterialIndexesById;
  28642. /**
  28643. * Returns an array with unique values of Materials from the passed array
  28644. * @param array the material array to be checked and filtered
  28645. * @hidden
  28646. */
  28647. private _filterUniqueMaterialId;
  28648. /**
  28649. * Sets a new Standard Material as _defaultMaterial if not already set.
  28650. * @hidden
  28651. */
  28652. private _setDefaultMaterial;
  28653. /**
  28654. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28655. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28656. * @returns the SPS.
  28657. */
  28658. refreshVisibleSize(): SolidParticleSystem;
  28659. /**
  28660. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28661. * @param size the size (float) of the visibility box
  28662. * note : this doesn't lock the SPS mesh bounding box.
  28663. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28664. */
  28665. setVisibilityBox(size: number): void;
  28666. /**
  28667. * Gets whether the SPS as always visible or not
  28668. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28669. */
  28670. get isAlwaysVisible(): boolean;
  28671. /**
  28672. * Sets the SPS as always visible or not
  28673. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28674. */
  28675. set isAlwaysVisible(val: boolean);
  28676. /**
  28677. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28678. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28679. */
  28680. set isVisibilityBoxLocked(val: boolean);
  28681. /**
  28682. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28683. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28684. */
  28685. get isVisibilityBoxLocked(): boolean;
  28686. /**
  28687. * Tells to `setParticles()` to compute the particle rotations or not.
  28688. * Default value : true. The SPS is faster when it's set to false.
  28689. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28690. */
  28691. set computeParticleRotation(val: boolean);
  28692. /**
  28693. * Tells to `setParticles()` to compute the particle colors or not.
  28694. * Default value : true. The SPS is faster when it's set to false.
  28695. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28696. */
  28697. set computeParticleColor(val: boolean);
  28698. set computeParticleTexture(val: boolean);
  28699. /**
  28700. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28701. * Default value : false. The SPS is faster when it's set to false.
  28702. * Note : the particle custom vertex positions aren't stored values.
  28703. */
  28704. set computeParticleVertex(val: boolean);
  28705. /**
  28706. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28707. */
  28708. set computeBoundingBox(val: boolean);
  28709. /**
  28710. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28711. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28712. * Default : `true`
  28713. */
  28714. set depthSortParticles(val: boolean);
  28715. /**
  28716. * Gets if `setParticles()` computes the particle rotations or not.
  28717. * Default value : true. The SPS is faster when it's set to false.
  28718. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28719. */
  28720. get computeParticleRotation(): boolean;
  28721. /**
  28722. * Gets if `setParticles()` computes the particle colors or not.
  28723. * Default value : true. The SPS is faster when it's set to false.
  28724. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28725. */
  28726. get computeParticleColor(): boolean;
  28727. /**
  28728. * Gets if `setParticles()` computes the particle textures or not.
  28729. * Default value : true. The SPS is faster when it's set to false.
  28730. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28731. */
  28732. get computeParticleTexture(): boolean;
  28733. /**
  28734. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28735. * Default value : false. The SPS is faster when it's set to false.
  28736. * Note : the particle custom vertex positions aren't stored values.
  28737. */
  28738. get computeParticleVertex(): boolean;
  28739. /**
  28740. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28741. */
  28742. get computeBoundingBox(): boolean;
  28743. /**
  28744. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28745. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28746. * Default : `true`
  28747. */
  28748. get depthSortParticles(): boolean;
  28749. /**
  28750. * Gets if the SPS is created as expandable at construction time.
  28751. * Default : `false`
  28752. */
  28753. get expandable(): boolean;
  28754. /**
  28755. * Gets if the SPS supports the Multi Materials
  28756. */
  28757. get multimaterialEnabled(): boolean;
  28758. /**
  28759. * Gets if the SPS uses the model materials for its own multimaterial.
  28760. */
  28761. get useModelMaterial(): boolean;
  28762. /**
  28763. * The SPS used material array.
  28764. */
  28765. get materials(): Material[];
  28766. /**
  28767. * Sets the SPS MultiMaterial from the passed materials.
  28768. * Note : the passed array is internally copied and not used then by reference.
  28769. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28770. */
  28771. setMultiMaterial(materials: Material[]): void;
  28772. /**
  28773. * The SPS computed multimaterial object
  28774. */
  28775. get multimaterial(): MultiMaterial;
  28776. set multimaterial(mm: MultiMaterial);
  28777. /**
  28778. * If the subMeshes must be updated on the next call to setParticles()
  28779. */
  28780. get autoUpdateSubMeshes(): boolean;
  28781. set autoUpdateSubMeshes(val: boolean);
  28782. /**
  28783. * This function does nothing. It may be overwritten to set all the particle first values.
  28784. * The SPS doesn't call this function, you may have to call it by your own.
  28785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28786. */
  28787. initParticles(): void;
  28788. /**
  28789. * This function does nothing. It may be overwritten to recycle a particle.
  28790. * The SPS doesn't call this function, you may have to call it by your own.
  28791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28792. * @param particle The particle to recycle
  28793. * @returns the recycled particle
  28794. */
  28795. recycleParticle(particle: SolidParticle): SolidParticle;
  28796. /**
  28797. * Updates a particle : this function should be overwritten by the user.
  28798. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28799. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28800. * @example : just set a particle position or velocity and recycle conditions
  28801. * @param particle The particle to update
  28802. * @returns the updated particle
  28803. */
  28804. updateParticle(particle: SolidParticle): SolidParticle;
  28805. /**
  28806. * Updates a vertex of a particle : it can be overwritten by the user.
  28807. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28808. * @param particle the current particle
  28809. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28810. * @param pt the index of the current vertex in the particle shape
  28811. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28812. * @example : just set a vertex particle position or color
  28813. * @returns the sps
  28814. */
  28815. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28816. /**
  28817. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28818. * This does nothing and may be overwritten by the user.
  28819. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28820. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28821. * @param update the boolean update value actually passed to setParticles()
  28822. */
  28823. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28824. /**
  28825. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28826. * This will be passed three parameters.
  28827. * This does nothing and may be overwritten by the user.
  28828. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28829. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28830. * @param update the boolean update value actually passed to setParticles()
  28831. */
  28832. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28833. }
  28834. }
  28835. declare module "babylonjs/Particles/solidParticle" {
  28836. import { Nullable } from "babylonjs/types";
  28837. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28838. import { Color4 } from "babylonjs/Maths/math.color";
  28839. import { Mesh } from "babylonjs/Meshes/mesh";
  28840. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28841. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28842. import { Plane } from "babylonjs/Maths/math.plane";
  28843. import { Material } from "babylonjs/Materials/material";
  28844. /**
  28845. * Represents one particle of a solid particle system.
  28846. */
  28847. export class SolidParticle {
  28848. /**
  28849. * particle global index
  28850. */
  28851. idx: number;
  28852. /**
  28853. * particle identifier
  28854. */
  28855. id: number;
  28856. /**
  28857. * The color of the particle
  28858. */
  28859. color: Nullable<Color4>;
  28860. /**
  28861. * The world space position of the particle.
  28862. */
  28863. position: Vector3;
  28864. /**
  28865. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28866. */
  28867. rotation: Vector3;
  28868. /**
  28869. * The world space rotation quaternion of the particle.
  28870. */
  28871. rotationQuaternion: Nullable<Quaternion>;
  28872. /**
  28873. * The scaling of the particle.
  28874. */
  28875. scaling: Vector3;
  28876. /**
  28877. * The uvs of the particle.
  28878. */
  28879. uvs: Vector4;
  28880. /**
  28881. * The current speed of the particle.
  28882. */
  28883. velocity: Vector3;
  28884. /**
  28885. * The pivot point in the particle local space.
  28886. */
  28887. pivot: Vector3;
  28888. /**
  28889. * Must the particle be translated from its pivot point in its local space ?
  28890. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28891. * Default : false
  28892. */
  28893. translateFromPivot: boolean;
  28894. /**
  28895. * Is the particle active or not ?
  28896. */
  28897. alive: boolean;
  28898. /**
  28899. * Is the particle visible or not ?
  28900. */
  28901. isVisible: boolean;
  28902. /**
  28903. * Index of this particle in the global "positions" array (Internal use)
  28904. * @hidden
  28905. */
  28906. _pos: number;
  28907. /**
  28908. * @hidden Index of this particle in the global "indices" array (Internal use)
  28909. */
  28910. _ind: number;
  28911. /**
  28912. * @hidden ModelShape of this particle (Internal use)
  28913. */
  28914. _model: ModelShape;
  28915. /**
  28916. * ModelShape id of this particle
  28917. */
  28918. shapeId: number;
  28919. /**
  28920. * Index of the particle in its shape id
  28921. */
  28922. idxInShape: number;
  28923. /**
  28924. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28925. */
  28926. _modelBoundingInfo: BoundingInfo;
  28927. /**
  28928. * @hidden Particle BoundingInfo object (Internal use)
  28929. */
  28930. _boundingInfo: BoundingInfo;
  28931. /**
  28932. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28933. */
  28934. _sps: SolidParticleSystem;
  28935. /**
  28936. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28937. */
  28938. _stillInvisible: boolean;
  28939. /**
  28940. * @hidden Last computed particle rotation matrix
  28941. */
  28942. _rotationMatrix: number[];
  28943. /**
  28944. * Parent particle Id, if any.
  28945. * Default null.
  28946. */
  28947. parentId: Nullable<number>;
  28948. /**
  28949. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28950. */
  28951. materialIndex: Nullable<number>;
  28952. /**
  28953. * Custom object or properties.
  28954. */
  28955. props: Nullable<any>;
  28956. /**
  28957. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28958. * The possible values are :
  28959. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28960. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28961. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28962. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28963. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28964. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28965. * */
  28966. cullingStrategy: number;
  28967. /**
  28968. * @hidden Internal global position in the SPS.
  28969. */
  28970. _globalPosition: Vector3;
  28971. /**
  28972. * Creates a Solid Particle object.
  28973. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28974. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28975. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28976. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28977. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28978. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28979. * @param shapeId (integer) is the model shape identifier in the SPS.
  28980. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28981. * @param sps defines the sps it is associated to
  28982. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28983. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28984. */
  28985. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28986. /**
  28987. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28988. * @param target the particle target
  28989. * @returns the current particle
  28990. */
  28991. copyToRef(target: SolidParticle): SolidParticle;
  28992. /**
  28993. * Legacy support, changed scale to scaling
  28994. */
  28995. get scale(): Vector3;
  28996. /**
  28997. * Legacy support, changed scale to scaling
  28998. */
  28999. set scale(scale: Vector3);
  29000. /**
  29001. * Legacy support, changed quaternion to rotationQuaternion
  29002. */
  29003. get quaternion(): Nullable<Quaternion>;
  29004. /**
  29005. * Legacy support, changed quaternion to rotationQuaternion
  29006. */
  29007. set quaternion(q: Nullable<Quaternion>);
  29008. /**
  29009. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  29010. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  29011. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  29012. * @returns true if it intersects
  29013. */
  29014. intersectsMesh(target: Mesh | SolidParticle): boolean;
  29015. /**
  29016. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  29017. * A particle is in the frustum if its bounding box intersects the frustum
  29018. * @param frustumPlanes defines the frustum to test
  29019. * @returns true if the particle is in the frustum planes
  29020. */
  29021. isInFrustum(frustumPlanes: Plane[]): boolean;
  29022. /**
  29023. * get the rotation matrix of the particle
  29024. * @hidden
  29025. */
  29026. getRotationMatrix(m: Matrix): void;
  29027. }
  29028. /**
  29029. * Represents the shape of the model used by one particle of a solid particle system.
  29030. * SPS internal tool, don't use it manually.
  29031. */
  29032. export class ModelShape {
  29033. /**
  29034. * The shape id
  29035. * @hidden
  29036. */
  29037. shapeID: number;
  29038. /**
  29039. * flat array of model positions (internal use)
  29040. * @hidden
  29041. */
  29042. _shape: Vector3[];
  29043. /**
  29044. * flat array of model UVs (internal use)
  29045. * @hidden
  29046. */
  29047. _shapeUV: number[];
  29048. /**
  29049. * color array of the model
  29050. * @hidden
  29051. */
  29052. _shapeColors: number[];
  29053. /**
  29054. * indices array of the model
  29055. * @hidden
  29056. */
  29057. _indices: number[];
  29058. /**
  29059. * normals array of the model
  29060. * @hidden
  29061. */
  29062. _normals: number[];
  29063. /**
  29064. * length of the shape in the model indices array (internal use)
  29065. * @hidden
  29066. */
  29067. _indicesLength: number;
  29068. /**
  29069. * Custom position function (internal use)
  29070. * @hidden
  29071. */
  29072. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29073. /**
  29074. * Custom vertex function (internal use)
  29075. * @hidden
  29076. */
  29077. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29078. /**
  29079. * Model material (internal use)
  29080. * @hidden
  29081. */
  29082. _material: Nullable<Material>;
  29083. /**
  29084. * 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.
  29085. * SPS internal tool, don't use it manually.
  29086. * @hidden
  29087. */
  29088. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  29089. }
  29090. /**
  29091. * Represents a Depth Sorted Particle in the solid particle system.
  29092. * @hidden
  29093. */
  29094. export class DepthSortedParticle {
  29095. /**
  29096. * Particle index
  29097. */
  29098. idx: number;
  29099. /**
  29100. * Index of the particle in the "indices" array
  29101. */
  29102. ind: number;
  29103. /**
  29104. * Length of the particle shape in the "indices" array
  29105. */
  29106. indicesLength: number;
  29107. /**
  29108. * Squared distance from the particle to the camera
  29109. */
  29110. sqDistance: number;
  29111. /**
  29112. * Material index when used with MultiMaterials
  29113. */
  29114. materialIndex: number;
  29115. /**
  29116. * Creates a new sorted particle
  29117. * @param materialIndex
  29118. */
  29119. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29120. }
  29121. /**
  29122. * Represents a solid particle vertex
  29123. */
  29124. export class SolidParticleVertex {
  29125. /**
  29126. * Vertex position
  29127. */
  29128. position: Vector3;
  29129. /**
  29130. * Vertex color
  29131. */
  29132. color: Color4;
  29133. /**
  29134. * Vertex UV
  29135. */
  29136. uv: Vector2;
  29137. /**
  29138. * Creates a new solid particle vertex
  29139. */
  29140. constructor();
  29141. /** Vertex x coordinate */
  29142. get x(): number;
  29143. set x(val: number);
  29144. /** Vertex y coordinate */
  29145. get y(): number;
  29146. set y(val: number);
  29147. /** Vertex z coordinate */
  29148. get z(): number;
  29149. set z(val: number);
  29150. }
  29151. }
  29152. declare module "babylonjs/Collisions/meshCollisionData" {
  29153. import { Collider } from "babylonjs/Collisions/collider";
  29154. import { Vector3 } from "babylonjs/Maths/math.vector";
  29155. import { Nullable } from "babylonjs/types";
  29156. import { Observer } from "babylonjs/Misc/observable";
  29157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29158. /**
  29159. * @hidden
  29160. */
  29161. export class _MeshCollisionData {
  29162. _checkCollisions: boolean;
  29163. _collisionMask: number;
  29164. _collisionGroup: number;
  29165. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29166. _collider: Nullable<Collider>;
  29167. _oldPositionForCollisions: Vector3;
  29168. _diffPositionForCollisions: Vector3;
  29169. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29170. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29171. }
  29172. }
  29173. declare module "babylonjs/Meshes/abstractMesh" {
  29174. import { Observable } from "babylonjs/Misc/observable";
  29175. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29176. import { Camera } from "babylonjs/Cameras/camera";
  29177. import { Scene, IDisposable } from "babylonjs/scene";
  29178. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29179. import { Node } from "babylonjs/node";
  29180. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29182. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29183. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29184. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29185. import { Material } from "babylonjs/Materials/material";
  29186. import { Light } from "babylonjs/Lights/light";
  29187. import { Skeleton } from "babylonjs/Bones/skeleton";
  29188. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29189. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29190. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29191. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29192. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29193. import { Plane } from "babylonjs/Maths/math.plane";
  29194. import { Ray } from "babylonjs/Culling/ray";
  29195. import { Collider } from "babylonjs/Collisions/collider";
  29196. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29197. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29198. /** @hidden */
  29199. class _FacetDataStorage {
  29200. facetPositions: Vector3[];
  29201. facetNormals: Vector3[];
  29202. facetPartitioning: number[][];
  29203. facetNb: number;
  29204. partitioningSubdivisions: number;
  29205. partitioningBBoxRatio: number;
  29206. facetDataEnabled: boolean;
  29207. facetParameters: any;
  29208. bbSize: Vector3;
  29209. subDiv: {
  29210. max: number;
  29211. X: number;
  29212. Y: number;
  29213. Z: number;
  29214. };
  29215. facetDepthSort: boolean;
  29216. facetDepthSortEnabled: boolean;
  29217. depthSortedIndices: IndicesArray;
  29218. depthSortedFacets: {
  29219. ind: number;
  29220. sqDistance: number;
  29221. }[];
  29222. facetDepthSortFunction: (f1: {
  29223. ind: number;
  29224. sqDistance: number;
  29225. }, f2: {
  29226. ind: number;
  29227. sqDistance: number;
  29228. }) => number;
  29229. facetDepthSortFrom: Vector3;
  29230. facetDepthSortOrigin: Vector3;
  29231. invertedMatrix: Matrix;
  29232. }
  29233. /**
  29234. * @hidden
  29235. **/
  29236. class _InternalAbstractMeshDataInfo {
  29237. _hasVertexAlpha: boolean;
  29238. _useVertexColors: boolean;
  29239. _numBoneInfluencers: number;
  29240. _applyFog: boolean;
  29241. _receiveShadows: boolean;
  29242. _facetData: _FacetDataStorage;
  29243. _visibility: number;
  29244. _skeleton: Nullable<Skeleton>;
  29245. _layerMask: number;
  29246. _computeBonesUsingShaders: boolean;
  29247. _isActive: boolean;
  29248. _onlyForInstances: boolean;
  29249. _isActiveIntermediate: boolean;
  29250. _onlyForInstancesIntermediate: boolean;
  29251. _actAsRegularMesh: boolean;
  29252. }
  29253. /**
  29254. * Class used to store all common mesh properties
  29255. */
  29256. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29257. /** No occlusion */
  29258. static OCCLUSION_TYPE_NONE: number;
  29259. /** Occlusion set to optimisitic */
  29260. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29261. /** Occlusion set to strict */
  29262. static OCCLUSION_TYPE_STRICT: number;
  29263. /** Use an accurante occlusion algorithm */
  29264. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29265. /** Use a conservative occlusion algorithm */
  29266. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29267. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29268. * Test order :
  29269. * Is the bounding sphere outside the frustum ?
  29270. * If not, are the bounding box vertices outside the frustum ?
  29271. * It not, then the cullable object is in the frustum.
  29272. */
  29273. static readonly CULLINGSTRATEGY_STANDARD: number;
  29274. /** Culling strategy : Bounding Sphere Only.
  29275. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29276. * It's also less accurate than the standard because some not visible objects can still be selected.
  29277. * Test : is the bounding sphere outside the frustum ?
  29278. * If not, then the cullable object is in the frustum.
  29279. */
  29280. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29281. /** Culling strategy : Optimistic Inclusion.
  29282. * This in an inclusion test first, then the standard exclusion test.
  29283. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29284. * 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.
  29285. * Anyway, it's as accurate as the standard strategy.
  29286. * Test :
  29287. * Is the cullable object bounding sphere center in the frustum ?
  29288. * If not, apply the default culling strategy.
  29289. */
  29290. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29291. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29292. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29293. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29294. * 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.
  29295. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29296. * Test :
  29297. * Is the cullable object bounding sphere center in the frustum ?
  29298. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29299. */
  29300. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29301. /**
  29302. * No billboard
  29303. */
  29304. static get BILLBOARDMODE_NONE(): number;
  29305. /** Billboard on X axis */
  29306. static get BILLBOARDMODE_X(): number;
  29307. /** Billboard on Y axis */
  29308. static get BILLBOARDMODE_Y(): number;
  29309. /** Billboard on Z axis */
  29310. static get BILLBOARDMODE_Z(): number;
  29311. /** Billboard on all axes */
  29312. static get BILLBOARDMODE_ALL(): number;
  29313. /** Billboard on using position instead of orientation */
  29314. static get BILLBOARDMODE_USE_POSITION(): number;
  29315. /** @hidden */
  29316. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29317. /**
  29318. * The culling strategy to use to check whether the mesh must be rendered or not.
  29319. * This value can be changed at any time and will be used on the next render mesh selection.
  29320. * The possible values are :
  29321. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29322. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29323. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29324. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29325. * Please read each static variable documentation to get details about the culling process.
  29326. * */
  29327. cullingStrategy: number;
  29328. /**
  29329. * Gets the number of facets in the mesh
  29330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29331. */
  29332. get facetNb(): number;
  29333. /**
  29334. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29336. */
  29337. get partitioningSubdivisions(): number;
  29338. set partitioningSubdivisions(nb: number);
  29339. /**
  29340. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29341. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29343. */
  29344. get partitioningBBoxRatio(): number;
  29345. set partitioningBBoxRatio(ratio: number);
  29346. /**
  29347. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29348. * Works only for updatable meshes.
  29349. * Doesn't work with multi-materials
  29350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29351. */
  29352. get mustDepthSortFacets(): boolean;
  29353. set mustDepthSortFacets(sort: boolean);
  29354. /**
  29355. * The location (Vector3) where the facet depth sort must be computed from.
  29356. * By default, the active camera position.
  29357. * Used only when facet depth sort is enabled
  29358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29359. */
  29360. get facetDepthSortFrom(): Vector3;
  29361. set facetDepthSortFrom(location: Vector3);
  29362. /**
  29363. * gets a boolean indicating if facetData is enabled
  29364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29365. */
  29366. get isFacetDataEnabled(): boolean;
  29367. /** @hidden */
  29368. _updateNonUniformScalingState(value: boolean): boolean;
  29369. /**
  29370. * An event triggered when this mesh collides with another one
  29371. */
  29372. onCollideObservable: Observable<AbstractMesh>;
  29373. /** Set a function to call when this mesh collides with another one */
  29374. set onCollide(callback: () => void);
  29375. /**
  29376. * An event triggered when the collision's position changes
  29377. */
  29378. onCollisionPositionChangeObservable: Observable<Vector3>;
  29379. /** Set a function to call when the collision's position changes */
  29380. set onCollisionPositionChange(callback: () => void);
  29381. /**
  29382. * An event triggered when material is changed
  29383. */
  29384. onMaterialChangedObservable: Observable<AbstractMesh>;
  29385. /**
  29386. * Gets or sets the orientation for POV movement & rotation
  29387. */
  29388. definedFacingForward: boolean;
  29389. /** @hidden */
  29390. _occlusionQuery: Nullable<WebGLQuery>;
  29391. /** @hidden */
  29392. _renderingGroup: Nullable<RenderingGroup>;
  29393. /**
  29394. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29395. */
  29396. get visibility(): number;
  29397. /**
  29398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29399. */
  29400. set visibility(value: number);
  29401. /** Gets or sets the alpha index used to sort transparent meshes
  29402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29403. */
  29404. alphaIndex: number;
  29405. /**
  29406. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29407. */
  29408. isVisible: boolean;
  29409. /**
  29410. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29411. */
  29412. isPickable: boolean;
  29413. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29414. showSubMeshesBoundingBox: boolean;
  29415. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29417. */
  29418. isBlocker: boolean;
  29419. /**
  29420. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29421. */
  29422. enablePointerMoveEvents: boolean;
  29423. /**
  29424. * Specifies the rendering group id for this mesh (0 by default)
  29425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29426. */
  29427. renderingGroupId: number;
  29428. private _material;
  29429. /** Gets or sets current material */
  29430. get material(): Nullable<Material>;
  29431. set material(value: Nullable<Material>);
  29432. /**
  29433. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29434. * @see http://doc.babylonjs.com/babylon101/shadows
  29435. */
  29436. get receiveShadows(): boolean;
  29437. set receiveShadows(value: boolean);
  29438. /** Defines color to use when rendering outline */
  29439. outlineColor: Color3;
  29440. /** Define width to use when rendering outline */
  29441. outlineWidth: number;
  29442. /** Defines color to use when rendering overlay */
  29443. overlayColor: Color3;
  29444. /** Defines alpha to use when rendering overlay */
  29445. overlayAlpha: number;
  29446. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29447. get hasVertexAlpha(): boolean;
  29448. set hasVertexAlpha(value: boolean);
  29449. /** 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) */
  29450. get useVertexColors(): boolean;
  29451. set useVertexColors(value: boolean);
  29452. /**
  29453. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29454. */
  29455. get computeBonesUsingShaders(): boolean;
  29456. set computeBonesUsingShaders(value: boolean);
  29457. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29458. get numBoneInfluencers(): number;
  29459. set numBoneInfluencers(value: number);
  29460. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29461. get applyFog(): boolean;
  29462. set applyFog(value: boolean);
  29463. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29464. useOctreeForRenderingSelection: boolean;
  29465. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29466. useOctreeForPicking: boolean;
  29467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29468. useOctreeForCollisions: boolean;
  29469. /**
  29470. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29471. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29472. */
  29473. get layerMask(): number;
  29474. set layerMask(value: number);
  29475. /**
  29476. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29477. */
  29478. alwaysSelectAsActiveMesh: boolean;
  29479. /**
  29480. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29481. */
  29482. doNotSyncBoundingInfo: boolean;
  29483. /**
  29484. * Gets or sets the current action manager
  29485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29486. */
  29487. actionManager: Nullable<AbstractActionManager>;
  29488. private _meshCollisionData;
  29489. /**
  29490. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29492. */
  29493. ellipsoid: Vector3;
  29494. /**
  29495. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29497. */
  29498. ellipsoidOffset: Vector3;
  29499. /**
  29500. * Gets or sets a collision mask used to mask collisions (default is -1).
  29501. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29502. */
  29503. get collisionMask(): number;
  29504. set collisionMask(mask: number);
  29505. /**
  29506. * Gets or sets the current collision group mask (-1 by default).
  29507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29508. */
  29509. get collisionGroup(): number;
  29510. set collisionGroup(mask: number);
  29511. /**
  29512. * Gets or sets current surrounding meshes (null by default).
  29513. *
  29514. * By default collision detection is tested against every mesh in the scene.
  29515. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29516. * meshes will be tested for the collision.
  29517. *
  29518. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29519. */
  29520. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29521. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29522. /**
  29523. * Defines edge width used when edgesRenderer is enabled
  29524. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29525. */
  29526. edgesWidth: number;
  29527. /**
  29528. * Defines edge color used when edgesRenderer is enabled
  29529. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29530. */
  29531. edgesColor: Color4;
  29532. /** @hidden */
  29533. _edgesRenderer: Nullable<IEdgesRenderer>;
  29534. /** @hidden */
  29535. _masterMesh: Nullable<AbstractMesh>;
  29536. /** @hidden */
  29537. _boundingInfo: Nullable<BoundingInfo>;
  29538. /** @hidden */
  29539. _renderId: number;
  29540. /**
  29541. * Gets or sets the list of subMeshes
  29542. * @see http://doc.babylonjs.com/how_to/multi_materials
  29543. */
  29544. subMeshes: SubMesh[];
  29545. /** @hidden */
  29546. _intersectionsInProgress: AbstractMesh[];
  29547. /** @hidden */
  29548. _unIndexed: boolean;
  29549. /** @hidden */
  29550. _lightSources: Light[];
  29551. /** Gets the list of lights affecting that mesh */
  29552. get lightSources(): Light[];
  29553. /** @hidden */
  29554. get _positions(): Nullable<Vector3[]>;
  29555. /** @hidden */
  29556. _waitingData: {
  29557. lods: Nullable<any>;
  29558. actions: Nullable<any>;
  29559. freezeWorldMatrix: Nullable<boolean>;
  29560. };
  29561. /** @hidden */
  29562. _bonesTransformMatrices: Nullable<Float32Array>;
  29563. /** @hidden */
  29564. _transformMatrixTexture: Nullable<RawTexture>;
  29565. /**
  29566. * Gets or sets a skeleton to apply skining transformations
  29567. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29568. */
  29569. set skeleton(value: Nullable<Skeleton>);
  29570. get skeleton(): Nullable<Skeleton>;
  29571. /**
  29572. * An event triggered when the mesh is rebuilt.
  29573. */
  29574. onRebuildObservable: Observable<AbstractMesh>;
  29575. /**
  29576. * Creates a new AbstractMesh
  29577. * @param name defines the name of the mesh
  29578. * @param scene defines the hosting scene
  29579. */
  29580. constructor(name: string, scene?: Nullable<Scene>);
  29581. /**
  29582. * Returns the string "AbstractMesh"
  29583. * @returns "AbstractMesh"
  29584. */
  29585. getClassName(): string;
  29586. /**
  29587. * Gets a string representation of the current mesh
  29588. * @param fullDetails defines a boolean indicating if full details must be included
  29589. * @returns a string representation of the current mesh
  29590. */
  29591. toString(fullDetails?: boolean): string;
  29592. /**
  29593. * @hidden
  29594. */
  29595. protected _getEffectiveParent(): Nullable<Node>;
  29596. /** @hidden */
  29597. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29598. /** @hidden */
  29599. _rebuild(): void;
  29600. /** @hidden */
  29601. _resyncLightSources(): void;
  29602. /** @hidden */
  29603. _resyncLightSource(light: Light): void;
  29604. /** @hidden */
  29605. _unBindEffect(): void;
  29606. /** @hidden */
  29607. _removeLightSource(light: Light, dispose: boolean): void;
  29608. private _markSubMeshesAsDirty;
  29609. /** @hidden */
  29610. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29611. /** @hidden */
  29612. _markSubMeshesAsAttributesDirty(): void;
  29613. /** @hidden */
  29614. _markSubMeshesAsMiscDirty(): void;
  29615. /**
  29616. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29617. */
  29618. get scaling(): Vector3;
  29619. set scaling(newScaling: Vector3);
  29620. /**
  29621. * Returns true if the mesh is blocked. Implemented by child classes
  29622. */
  29623. get isBlocked(): boolean;
  29624. /**
  29625. * Returns the mesh itself by default. Implemented by child classes
  29626. * @param camera defines the camera to use to pick the right LOD level
  29627. * @returns the currentAbstractMesh
  29628. */
  29629. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29630. /**
  29631. * Returns 0 by default. Implemented by child classes
  29632. * @returns an integer
  29633. */
  29634. getTotalVertices(): number;
  29635. /**
  29636. * Returns a positive integer : the total number of indices in this mesh geometry.
  29637. * @returns the numner of indices or zero if the mesh has no geometry.
  29638. */
  29639. getTotalIndices(): number;
  29640. /**
  29641. * Returns null by default. Implemented by child classes
  29642. * @returns null
  29643. */
  29644. getIndices(): Nullable<IndicesArray>;
  29645. /**
  29646. * Returns the array of the requested vertex data kind. Implemented by child classes
  29647. * @param kind defines the vertex data kind to use
  29648. * @returns null
  29649. */
  29650. getVerticesData(kind: string): Nullable<FloatArray>;
  29651. /**
  29652. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29653. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29654. * Note that a new underlying VertexBuffer object is created each call.
  29655. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29656. * @param kind defines vertex data kind:
  29657. * * VertexBuffer.PositionKind
  29658. * * VertexBuffer.UVKind
  29659. * * VertexBuffer.UV2Kind
  29660. * * VertexBuffer.UV3Kind
  29661. * * VertexBuffer.UV4Kind
  29662. * * VertexBuffer.UV5Kind
  29663. * * VertexBuffer.UV6Kind
  29664. * * VertexBuffer.ColorKind
  29665. * * VertexBuffer.MatricesIndicesKind
  29666. * * VertexBuffer.MatricesIndicesExtraKind
  29667. * * VertexBuffer.MatricesWeightsKind
  29668. * * VertexBuffer.MatricesWeightsExtraKind
  29669. * @param data defines the data source
  29670. * @param updatable defines if the data must be flagged as updatable (or static)
  29671. * @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
  29672. * @returns the current mesh
  29673. */
  29674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29675. /**
  29676. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29677. * If the mesh has no geometry, it is simply returned as it is.
  29678. * @param kind defines vertex data kind:
  29679. * * VertexBuffer.PositionKind
  29680. * * VertexBuffer.UVKind
  29681. * * VertexBuffer.UV2Kind
  29682. * * VertexBuffer.UV3Kind
  29683. * * VertexBuffer.UV4Kind
  29684. * * VertexBuffer.UV5Kind
  29685. * * VertexBuffer.UV6Kind
  29686. * * VertexBuffer.ColorKind
  29687. * * VertexBuffer.MatricesIndicesKind
  29688. * * VertexBuffer.MatricesIndicesExtraKind
  29689. * * VertexBuffer.MatricesWeightsKind
  29690. * * VertexBuffer.MatricesWeightsExtraKind
  29691. * @param data defines the data source
  29692. * @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
  29693. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29694. * @returns the current mesh
  29695. */
  29696. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29697. /**
  29698. * Sets the mesh indices,
  29699. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29700. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29701. * @param totalVertices Defines the total number of vertices
  29702. * @returns the current mesh
  29703. */
  29704. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29705. /**
  29706. * Gets a boolean indicating if specific vertex data is present
  29707. * @param kind defines the vertex data kind to use
  29708. * @returns true is data kind is present
  29709. */
  29710. isVerticesDataPresent(kind: string): boolean;
  29711. /**
  29712. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29713. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29714. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29715. * @returns a BoundingInfo
  29716. */
  29717. getBoundingInfo(): BoundingInfo;
  29718. /**
  29719. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29720. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29721. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29722. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29723. * @returns the current mesh
  29724. */
  29725. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29726. /**
  29727. * Overwrite the current bounding info
  29728. * @param boundingInfo defines the new bounding info
  29729. * @returns the current mesh
  29730. */
  29731. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29732. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29733. get useBones(): boolean;
  29734. /** @hidden */
  29735. _preActivate(): void;
  29736. /** @hidden */
  29737. _preActivateForIntermediateRendering(renderId: number): void;
  29738. /** @hidden */
  29739. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29740. /** @hidden */
  29741. _postActivate(): void;
  29742. /** @hidden */
  29743. _freeze(): void;
  29744. /** @hidden */
  29745. _unFreeze(): void;
  29746. /**
  29747. * Gets the current world matrix
  29748. * @returns a Matrix
  29749. */
  29750. getWorldMatrix(): Matrix;
  29751. /** @hidden */
  29752. _getWorldMatrixDeterminant(): number;
  29753. /**
  29754. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29755. */
  29756. get isAnInstance(): boolean;
  29757. /**
  29758. * Gets a boolean indicating if this mesh has instances
  29759. */
  29760. get hasInstances(): boolean;
  29761. /**
  29762. * Perform relative position change from the point of view of behind the front of the mesh.
  29763. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29764. * Supports definition of mesh facing forward or backward
  29765. * @param amountRight defines the distance on the right axis
  29766. * @param amountUp defines the distance on the up axis
  29767. * @param amountForward defines the distance on the forward axis
  29768. * @returns the current mesh
  29769. */
  29770. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29771. /**
  29772. * Calculate relative position change from the point of view of behind the front of the mesh.
  29773. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29774. * Supports definition of mesh facing forward or backward
  29775. * @param amountRight defines the distance on the right axis
  29776. * @param amountUp defines the distance on the up axis
  29777. * @param amountForward defines the distance on the forward axis
  29778. * @returns the new displacement vector
  29779. */
  29780. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29781. /**
  29782. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29783. * Supports definition of mesh facing forward or backward
  29784. * @param flipBack defines the flip
  29785. * @param twirlClockwise defines the twirl
  29786. * @param tiltRight defines the tilt
  29787. * @returns the current mesh
  29788. */
  29789. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29790. /**
  29791. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29792. * Supports definition of mesh facing forward or backward.
  29793. * @param flipBack defines the flip
  29794. * @param twirlClockwise defines the twirl
  29795. * @param tiltRight defines the tilt
  29796. * @returns the new rotation vector
  29797. */
  29798. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29799. /**
  29800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29801. * This means the mesh underlying bounding box and sphere are recomputed.
  29802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29803. * @returns the current mesh
  29804. */
  29805. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29806. /** @hidden */
  29807. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29808. /** @hidden */
  29809. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29810. /** @hidden */
  29811. _updateBoundingInfo(): AbstractMesh;
  29812. /** @hidden */
  29813. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29814. /** @hidden */
  29815. protected _afterComputeWorldMatrix(): void;
  29816. /** @hidden */
  29817. get _effectiveMesh(): AbstractMesh;
  29818. /**
  29819. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29820. * A mesh is in the frustum if its bounding box intersects the frustum
  29821. * @param frustumPlanes defines the frustum to test
  29822. * @returns true if the mesh is in the frustum planes
  29823. */
  29824. isInFrustum(frustumPlanes: Plane[]): boolean;
  29825. /**
  29826. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29827. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29828. * @param frustumPlanes defines the frustum to test
  29829. * @returns true if the mesh is completely in the frustum planes
  29830. */
  29831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29832. /**
  29833. * True if the mesh intersects another mesh or a SolidParticle object
  29834. * @param mesh defines a target mesh or SolidParticle to test
  29835. * @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)
  29836. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29837. * @returns true if there is an intersection
  29838. */
  29839. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29840. /**
  29841. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29842. * @param point defines the point to test
  29843. * @returns true if there is an intersection
  29844. */
  29845. intersectsPoint(point: Vector3): boolean;
  29846. /**
  29847. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29849. */
  29850. get checkCollisions(): boolean;
  29851. set checkCollisions(collisionEnabled: boolean);
  29852. /**
  29853. * Gets Collider object used to compute collisions (not physics)
  29854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29855. */
  29856. get collider(): Nullable<Collider>;
  29857. /**
  29858. * Move the mesh using collision engine
  29859. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29860. * @param displacement defines the requested displacement vector
  29861. * @returns the current mesh
  29862. */
  29863. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29864. private _onCollisionPositionChange;
  29865. /** @hidden */
  29866. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29867. /** @hidden */
  29868. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29869. /** @hidden */
  29870. _checkCollision(collider: Collider): AbstractMesh;
  29871. /** @hidden */
  29872. _generatePointsArray(): boolean;
  29873. /**
  29874. * Checks if the passed Ray intersects with the mesh
  29875. * @param ray defines the ray to use
  29876. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29877. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29878. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29879. * @returns the picking info
  29880. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29881. */
  29882. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29883. /**
  29884. * Clones the current mesh
  29885. * @param name defines the mesh name
  29886. * @param newParent defines the new mesh parent
  29887. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29888. * @returns the new mesh
  29889. */
  29890. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29891. /**
  29892. * Disposes all the submeshes of the current meshnp
  29893. * @returns the current mesh
  29894. */
  29895. releaseSubMeshes(): AbstractMesh;
  29896. /**
  29897. * Releases resources associated with this abstract mesh.
  29898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29900. */
  29901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29902. /**
  29903. * Adds the passed mesh as a child to the current mesh
  29904. * @param mesh defines the child mesh
  29905. * @returns the current mesh
  29906. */
  29907. addChild(mesh: AbstractMesh): AbstractMesh;
  29908. /**
  29909. * Removes the passed mesh from the current mesh children list
  29910. * @param mesh defines the child mesh
  29911. * @returns the current mesh
  29912. */
  29913. removeChild(mesh: AbstractMesh): AbstractMesh;
  29914. /** @hidden */
  29915. private _initFacetData;
  29916. /**
  29917. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29918. * This method can be called within the render loop.
  29919. * 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
  29920. * @returns the current mesh
  29921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29922. */
  29923. updateFacetData(): AbstractMesh;
  29924. /**
  29925. * Returns the facetLocalNormals array.
  29926. * The normals are expressed in the mesh local spac
  29927. * @returns an array of Vector3
  29928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29929. */
  29930. getFacetLocalNormals(): Vector3[];
  29931. /**
  29932. * Returns the facetLocalPositions array.
  29933. * The facet positions are expressed in the mesh local space
  29934. * @returns an array of Vector3
  29935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29936. */
  29937. getFacetLocalPositions(): Vector3[];
  29938. /**
  29939. * Returns the facetLocalPartioning array
  29940. * @returns an array of array of numbers
  29941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29942. */
  29943. getFacetLocalPartitioning(): number[][];
  29944. /**
  29945. * Returns the i-th facet position in the world system.
  29946. * This method allocates a new Vector3 per call
  29947. * @param i defines the facet index
  29948. * @returns a new Vector3
  29949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29950. */
  29951. getFacetPosition(i: number): Vector3;
  29952. /**
  29953. * Sets the reference Vector3 with the i-th facet position in the world system
  29954. * @param i defines the facet index
  29955. * @param ref defines the target vector
  29956. * @returns the current mesh
  29957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29958. */
  29959. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29960. /**
  29961. * Returns the i-th facet normal in the world system.
  29962. * This method allocates a new Vector3 per call
  29963. * @param i defines the facet index
  29964. * @returns a new Vector3
  29965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29966. */
  29967. getFacetNormal(i: number): Vector3;
  29968. /**
  29969. * Sets the reference Vector3 with the i-th facet normal in the world system
  29970. * @param i defines the facet index
  29971. * @param ref defines the target vector
  29972. * @returns the current mesh
  29973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29974. */
  29975. getFacetNormalToRef(i: number, ref: Vector3): this;
  29976. /**
  29977. * 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)
  29978. * @param x defines x coordinate
  29979. * @param y defines y coordinate
  29980. * @param z defines z coordinate
  29981. * @returns the array of facet indexes
  29982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29983. */
  29984. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29985. /**
  29986. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29987. * @param projected sets as the (x,y,z) world projection on the facet
  29988. * @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
  29989. * @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
  29990. * @param x defines x coordinate
  29991. * @param y defines y coordinate
  29992. * @param z defines z coordinate
  29993. * @returns the face index if found (or null instead)
  29994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29995. */
  29996. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29997. /**
  29998. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29999. * @param projected sets as the (x,y,z) local projection on the facet
  30000. * @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
  30001. * @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
  30002. * @param x defines x coordinate
  30003. * @param y defines y coordinate
  30004. * @param z defines z coordinate
  30005. * @returns the face index if found (or null instead)
  30006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30007. */
  30008. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  30009. /**
  30010. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  30011. * @returns the parameters
  30012. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30013. */
  30014. getFacetDataParameters(): any;
  30015. /**
  30016. * Disables the feature FacetData and frees the related memory
  30017. * @returns the current mesh
  30018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  30019. */
  30020. disableFacetData(): AbstractMesh;
  30021. /**
  30022. * Updates the AbstractMesh indices array
  30023. * @param indices defines the data source
  30024. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  30025. * @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)
  30026. * @returns the current mesh
  30027. */
  30028. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  30029. /**
  30030. * Creates new normals data for the mesh
  30031. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30032. * @returns the current mesh
  30033. */
  30034. createNormals(updatable: boolean): AbstractMesh;
  30035. /**
  30036. * Align the mesh with a normal
  30037. * @param normal defines the normal to use
  30038. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30039. * @returns the current mesh
  30040. */
  30041. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30042. /** @hidden */
  30043. _checkOcclusionQuery(): boolean;
  30044. /**
  30045. * Disables the mesh edge rendering mode
  30046. * @returns the currentAbstractMesh
  30047. */
  30048. disableEdgesRendering(): AbstractMesh;
  30049. /**
  30050. * Enables the edge rendering mode on the mesh.
  30051. * This mode makes the mesh edges visible
  30052. * @param epsilon defines the maximal distance between two angles to detect a face
  30053. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30054. * @returns the currentAbstractMesh
  30055. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30056. */
  30057. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30058. }
  30059. }
  30060. declare module "babylonjs/Actions/actionEvent" {
  30061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30062. import { Nullable } from "babylonjs/types";
  30063. import { Sprite } from "babylonjs/Sprites/sprite";
  30064. import { Scene } from "babylonjs/scene";
  30065. import { Vector2 } from "babylonjs/Maths/math.vector";
  30066. /**
  30067. * Interface used to define ActionEvent
  30068. */
  30069. export interface IActionEvent {
  30070. /** The mesh or sprite that triggered the action */
  30071. source: any;
  30072. /** The X mouse cursor position at the time of the event */
  30073. pointerX: number;
  30074. /** The Y mouse cursor position at the time of the event */
  30075. pointerY: number;
  30076. /** The mesh that is currently pointed at (can be null) */
  30077. meshUnderPointer: Nullable<AbstractMesh>;
  30078. /** the original (browser) event that triggered the ActionEvent */
  30079. sourceEvent?: any;
  30080. /** additional data for the event */
  30081. additionalData?: any;
  30082. }
  30083. /**
  30084. * ActionEvent is the event being sent when an action is triggered.
  30085. */
  30086. export class ActionEvent implements IActionEvent {
  30087. /** The mesh or sprite that triggered the action */
  30088. source: any;
  30089. /** The X mouse cursor position at the time of the event */
  30090. pointerX: number;
  30091. /** The Y mouse cursor position at the time of the event */
  30092. pointerY: number;
  30093. /** The mesh that is currently pointed at (can be null) */
  30094. meshUnderPointer: Nullable<AbstractMesh>;
  30095. /** the original (browser) event that triggered the ActionEvent */
  30096. sourceEvent?: any;
  30097. /** additional data for the event */
  30098. additionalData?: any;
  30099. /**
  30100. * Creates a new ActionEvent
  30101. * @param source The mesh or sprite that triggered the action
  30102. * @param pointerX The X mouse cursor position at the time of the event
  30103. * @param pointerY The Y mouse cursor position at the time of the event
  30104. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30105. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30106. * @param additionalData additional data for the event
  30107. */
  30108. constructor(
  30109. /** The mesh or sprite that triggered the action */
  30110. source: any,
  30111. /** The X mouse cursor position at the time of the event */
  30112. pointerX: number,
  30113. /** The Y mouse cursor position at the time of the event */
  30114. pointerY: number,
  30115. /** The mesh that is currently pointed at (can be null) */
  30116. meshUnderPointer: Nullable<AbstractMesh>,
  30117. /** the original (browser) event that triggered the ActionEvent */
  30118. sourceEvent?: any,
  30119. /** additional data for the event */
  30120. additionalData?: any);
  30121. /**
  30122. * Helper function to auto-create an ActionEvent from a source mesh.
  30123. * @param source The source mesh that triggered the event
  30124. * @param evt The original (browser) event
  30125. * @param additionalData additional data for the event
  30126. * @returns the new ActionEvent
  30127. */
  30128. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30129. /**
  30130. * Helper function to auto-create an ActionEvent from a source sprite
  30131. * @param source The source sprite that triggered the event
  30132. * @param scene Scene associated with the sprite
  30133. * @param evt The original (browser) event
  30134. * @param additionalData additional data for the event
  30135. * @returns the new ActionEvent
  30136. */
  30137. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30138. /**
  30139. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30140. * @param scene the scene where the event occurred
  30141. * @param evt The original (browser) event
  30142. * @returns the new ActionEvent
  30143. */
  30144. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30145. /**
  30146. * Helper function to auto-create an ActionEvent from a primitive
  30147. * @param prim defines the target primitive
  30148. * @param pointerPos defines the pointer position
  30149. * @param evt The original (browser) event
  30150. * @param additionalData additional data for the event
  30151. * @returns the new ActionEvent
  30152. */
  30153. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30154. }
  30155. }
  30156. declare module "babylonjs/Actions/abstractActionManager" {
  30157. import { IDisposable } from "babylonjs/scene";
  30158. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30159. import { IAction } from "babylonjs/Actions/action";
  30160. import { Nullable } from "babylonjs/types";
  30161. /**
  30162. * Abstract class used to decouple action Manager from scene and meshes.
  30163. * Do not instantiate.
  30164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30165. */
  30166. export abstract class AbstractActionManager implements IDisposable {
  30167. /** Gets the list of active triggers */
  30168. static Triggers: {
  30169. [key: string]: number;
  30170. };
  30171. /** Gets the cursor to use when hovering items */
  30172. hoverCursor: string;
  30173. /** Gets the list of actions */
  30174. actions: IAction[];
  30175. /**
  30176. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30177. */
  30178. isRecursive: boolean;
  30179. /**
  30180. * Releases all associated resources
  30181. */
  30182. abstract dispose(): void;
  30183. /**
  30184. * Does this action manager has pointer triggers
  30185. */
  30186. abstract get hasPointerTriggers(): boolean;
  30187. /**
  30188. * Does this action manager has pick triggers
  30189. */
  30190. abstract get hasPickTriggers(): boolean;
  30191. /**
  30192. * Process a specific trigger
  30193. * @param trigger defines the trigger to process
  30194. * @param evt defines the event details to be processed
  30195. */
  30196. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30197. /**
  30198. * Does this action manager handles actions of any of the given triggers
  30199. * @param triggers defines the triggers to be tested
  30200. * @return a boolean indicating whether one (or more) of the triggers is handled
  30201. */
  30202. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30203. /**
  30204. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30205. * speed.
  30206. * @param triggerA defines the trigger to be tested
  30207. * @param triggerB defines the trigger to be tested
  30208. * @return a boolean indicating whether one (or more) of the triggers is handled
  30209. */
  30210. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30211. /**
  30212. * Does this action manager handles actions of a given trigger
  30213. * @param trigger defines the trigger to be tested
  30214. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30215. * @return whether the trigger is handled
  30216. */
  30217. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30218. /**
  30219. * Serialize this manager to a JSON object
  30220. * @param name defines the property name to store this manager
  30221. * @returns a JSON representation of this manager
  30222. */
  30223. abstract serialize(name: string): any;
  30224. /**
  30225. * Registers an action to this action manager
  30226. * @param action defines the action to be registered
  30227. * @return the action amended (prepared) after registration
  30228. */
  30229. abstract registerAction(action: IAction): Nullable<IAction>;
  30230. /**
  30231. * Unregisters an action to this action manager
  30232. * @param action defines the action to be unregistered
  30233. * @return a boolean indicating whether the action has been unregistered
  30234. */
  30235. abstract unregisterAction(action: IAction): Boolean;
  30236. /**
  30237. * Does exist one action manager with at least one trigger
  30238. **/
  30239. static get HasTriggers(): boolean;
  30240. /**
  30241. * Does exist one action manager with at least one pick trigger
  30242. **/
  30243. static get HasPickTriggers(): boolean;
  30244. /**
  30245. * Does exist one action manager that handles actions of a given trigger
  30246. * @param trigger defines the trigger to be tested
  30247. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30248. **/
  30249. static HasSpecificTrigger(trigger: number): boolean;
  30250. }
  30251. }
  30252. declare module "babylonjs/node" {
  30253. import { Scene } from "babylonjs/scene";
  30254. import { Nullable } from "babylonjs/types";
  30255. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30256. import { Engine } from "babylonjs/Engines/engine";
  30257. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30258. import { Observable } from "babylonjs/Misc/observable";
  30259. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30260. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30261. import { Animatable } from "babylonjs/Animations/animatable";
  30262. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30263. import { Animation } from "babylonjs/Animations/animation";
  30264. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30266. /**
  30267. * Defines how a node can be built from a string name.
  30268. */
  30269. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30270. /**
  30271. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30272. */
  30273. export class Node implements IBehaviorAware<Node> {
  30274. /** @hidden */
  30275. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30276. private static _NodeConstructors;
  30277. /**
  30278. * Add a new node constructor
  30279. * @param type defines the type name of the node to construct
  30280. * @param constructorFunc defines the constructor function
  30281. */
  30282. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30283. /**
  30284. * Returns a node constructor based on type name
  30285. * @param type defines the type name
  30286. * @param name defines the new node name
  30287. * @param scene defines the hosting scene
  30288. * @param options defines optional options to transmit to constructors
  30289. * @returns the new constructor or null
  30290. */
  30291. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30292. /**
  30293. * Gets or sets the name of the node
  30294. */
  30295. name: string;
  30296. /**
  30297. * Gets or sets the id of the node
  30298. */
  30299. id: string;
  30300. /**
  30301. * Gets or sets the unique id of the node
  30302. */
  30303. uniqueId: number;
  30304. /**
  30305. * Gets or sets a string used to store user defined state for the node
  30306. */
  30307. state: string;
  30308. /**
  30309. * Gets or sets an object used to store user defined information for the node
  30310. */
  30311. metadata: any;
  30312. /**
  30313. * For internal use only. Please do not use.
  30314. */
  30315. reservedDataStore: any;
  30316. /**
  30317. * List of inspectable custom properties (used by the Inspector)
  30318. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30319. */
  30320. inspectableCustomProperties: IInspectable[];
  30321. private _doNotSerialize;
  30322. /**
  30323. * Gets or sets a boolean used to define if the node must be serialized
  30324. */
  30325. get doNotSerialize(): boolean;
  30326. set doNotSerialize(value: boolean);
  30327. /** @hidden */
  30328. _isDisposed: boolean;
  30329. /**
  30330. * Gets a list of Animations associated with the node
  30331. */
  30332. animations: import("babylonjs/Animations/animation").Animation[];
  30333. protected _ranges: {
  30334. [name: string]: Nullable<AnimationRange>;
  30335. };
  30336. /**
  30337. * Callback raised when the node is ready to be used
  30338. */
  30339. onReady: Nullable<(node: Node) => void>;
  30340. private _isEnabled;
  30341. private _isParentEnabled;
  30342. private _isReady;
  30343. /** @hidden */
  30344. _currentRenderId: number;
  30345. private _parentUpdateId;
  30346. /** @hidden */
  30347. _childUpdateId: number;
  30348. /** @hidden */
  30349. _waitingParentId: Nullable<string>;
  30350. /** @hidden */
  30351. _scene: Scene;
  30352. /** @hidden */
  30353. _cache: any;
  30354. private _parentNode;
  30355. private _children;
  30356. /** @hidden */
  30357. _worldMatrix: Matrix;
  30358. /** @hidden */
  30359. _worldMatrixDeterminant: number;
  30360. /** @hidden */
  30361. _worldMatrixDeterminantIsDirty: boolean;
  30362. /** @hidden */
  30363. private _sceneRootNodesIndex;
  30364. /**
  30365. * Gets a boolean indicating if the node has been disposed
  30366. * @returns true if the node was disposed
  30367. */
  30368. isDisposed(): boolean;
  30369. /**
  30370. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30371. * @see https://doc.babylonjs.com/how_to/parenting
  30372. */
  30373. set parent(parent: Nullable<Node>);
  30374. get parent(): Nullable<Node>;
  30375. /** @hidden */
  30376. _addToSceneRootNodes(): void;
  30377. /** @hidden */
  30378. _removeFromSceneRootNodes(): void;
  30379. private _animationPropertiesOverride;
  30380. /**
  30381. * Gets or sets the animation properties override
  30382. */
  30383. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30384. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30385. /**
  30386. * Gets a string idenfifying the name of the class
  30387. * @returns "Node" string
  30388. */
  30389. getClassName(): string;
  30390. /** @hidden */
  30391. readonly _isNode: boolean;
  30392. /**
  30393. * An event triggered when the mesh is disposed
  30394. */
  30395. onDisposeObservable: Observable<Node>;
  30396. private _onDisposeObserver;
  30397. /**
  30398. * Sets a callback that will be raised when the node will be disposed
  30399. */
  30400. set onDispose(callback: () => void);
  30401. /**
  30402. * Creates a new Node
  30403. * @param name the name and id to be given to this node
  30404. * @param scene the scene this node will be added to
  30405. */
  30406. constructor(name: string, scene?: Nullable<Scene>);
  30407. /**
  30408. * Gets the scene of the node
  30409. * @returns a scene
  30410. */
  30411. getScene(): Scene;
  30412. /**
  30413. * Gets the engine of the node
  30414. * @returns a Engine
  30415. */
  30416. getEngine(): Engine;
  30417. private _behaviors;
  30418. /**
  30419. * Attach a behavior to the node
  30420. * @see http://doc.babylonjs.com/features/behaviour
  30421. * @param behavior defines the behavior to attach
  30422. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30423. * @returns the current Node
  30424. */
  30425. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30426. /**
  30427. * Remove an attached behavior
  30428. * @see http://doc.babylonjs.com/features/behaviour
  30429. * @param behavior defines the behavior to attach
  30430. * @returns the current Node
  30431. */
  30432. removeBehavior(behavior: Behavior<Node>): Node;
  30433. /**
  30434. * Gets the list of attached behaviors
  30435. * @see http://doc.babylonjs.com/features/behaviour
  30436. */
  30437. get behaviors(): Behavior<Node>[];
  30438. /**
  30439. * Gets an attached behavior by name
  30440. * @param name defines the name of the behavior to look for
  30441. * @see http://doc.babylonjs.com/features/behaviour
  30442. * @returns null if behavior was not found else the requested behavior
  30443. */
  30444. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30445. /**
  30446. * Returns the latest update of the World matrix
  30447. * @returns a Matrix
  30448. */
  30449. getWorldMatrix(): Matrix;
  30450. /** @hidden */
  30451. _getWorldMatrixDeterminant(): number;
  30452. /**
  30453. * Returns directly the latest state of the mesh World matrix.
  30454. * A Matrix is returned.
  30455. */
  30456. get worldMatrixFromCache(): Matrix;
  30457. /** @hidden */
  30458. _initCache(): void;
  30459. /** @hidden */
  30460. updateCache(force?: boolean): void;
  30461. /** @hidden */
  30462. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30463. /** @hidden */
  30464. _updateCache(ignoreParentClass?: boolean): void;
  30465. /** @hidden */
  30466. _isSynchronized(): boolean;
  30467. /** @hidden */
  30468. _markSyncedWithParent(): void;
  30469. /** @hidden */
  30470. isSynchronizedWithParent(): boolean;
  30471. /** @hidden */
  30472. isSynchronized(): boolean;
  30473. /**
  30474. * Is this node ready to be used/rendered
  30475. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30476. * @return true if the node is ready
  30477. */
  30478. isReady(completeCheck?: boolean): boolean;
  30479. /**
  30480. * Is this node enabled?
  30481. * 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
  30482. * @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
  30483. * @return whether this node (and its parent) is enabled
  30484. */
  30485. isEnabled(checkAncestors?: boolean): boolean;
  30486. /** @hidden */
  30487. protected _syncParentEnabledState(): void;
  30488. /**
  30489. * Set the enabled state of this node
  30490. * @param value defines the new enabled state
  30491. */
  30492. setEnabled(value: boolean): void;
  30493. /**
  30494. * Is this node a descendant of the given node?
  30495. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30496. * @param ancestor defines the parent node to inspect
  30497. * @returns a boolean indicating if this node is a descendant of the given node
  30498. */
  30499. isDescendantOf(ancestor: Node): boolean;
  30500. /** @hidden */
  30501. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30502. /**
  30503. * Will return all nodes that have this node as ascendant
  30504. * @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
  30505. * @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
  30506. * @return all children nodes of all types
  30507. */
  30508. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30509. /**
  30510. * Get all child-meshes of this node
  30511. * @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)
  30512. * @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
  30513. * @returns an array of AbstractMesh
  30514. */
  30515. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30516. /**
  30517. * Get all direct children of this node
  30518. * @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
  30519. * @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)
  30520. * @returns an array of Node
  30521. */
  30522. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30523. /** @hidden */
  30524. _setReady(state: boolean): void;
  30525. /**
  30526. * Get an animation by name
  30527. * @param name defines the name of the animation to look for
  30528. * @returns null if not found else the requested animation
  30529. */
  30530. getAnimationByName(name: string): Nullable<Animation>;
  30531. /**
  30532. * Creates an animation range for this node
  30533. * @param name defines the name of the range
  30534. * @param from defines the starting key
  30535. * @param to defines the end key
  30536. */
  30537. createAnimationRange(name: string, from: number, to: number): void;
  30538. /**
  30539. * Delete a specific animation range
  30540. * @param name defines the name of the range to delete
  30541. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30542. */
  30543. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30544. /**
  30545. * Get an animation range by name
  30546. * @param name defines the name of the animation range to look for
  30547. * @returns null if not found else the requested animation range
  30548. */
  30549. getAnimationRange(name: string): Nullable<AnimationRange>;
  30550. /**
  30551. * Gets the list of all animation ranges defined on this node
  30552. * @returns an array
  30553. */
  30554. getAnimationRanges(): Nullable<AnimationRange>[];
  30555. /**
  30556. * Will start the animation sequence
  30557. * @param name defines the range frames for animation sequence
  30558. * @param loop defines if the animation should loop (false by default)
  30559. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30560. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30561. * @returns the object created for this animation. If range does not exist, it will return null
  30562. */
  30563. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30564. /**
  30565. * Serialize animation ranges into a JSON compatible object
  30566. * @returns serialization object
  30567. */
  30568. serializeAnimationRanges(): any;
  30569. /**
  30570. * Computes the world matrix of the node
  30571. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30572. * @returns the world matrix
  30573. */
  30574. computeWorldMatrix(force?: boolean): Matrix;
  30575. /**
  30576. * Releases resources associated with this node.
  30577. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30578. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30579. */
  30580. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30581. /**
  30582. * Parse animation range data from a serialization object and store them into a given node
  30583. * @param node defines where to store the animation ranges
  30584. * @param parsedNode defines the serialization object to read data from
  30585. * @param scene defines the hosting scene
  30586. */
  30587. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30588. /**
  30589. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30590. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30591. * @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
  30592. * @returns the new bounding vectors
  30593. */
  30594. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30595. min: Vector3;
  30596. max: Vector3;
  30597. };
  30598. }
  30599. }
  30600. declare module "babylonjs/Animations/animation" {
  30601. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30602. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30603. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30604. import { Nullable } from "babylonjs/types";
  30605. import { Scene } from "babylonjs/scene";
  30606. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30607. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30608. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30609. import { Node } from "babylonjs/node";
  30610. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30611. import { Size } from "babylonjs/Maths/math.size";
  30612. import { Animatable } from "babylonjs/Animations/animatable";
  30613. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30614. /**
  30615. * @hidden
  30616. */
  30617. export class _IAnimationState {
  30618. key: number;
  30619. repeatCount: number;
  30620. workValue?: any;
  30621. loopMode?: number;
  30622. offsetValue?: any;
  30623. highLimitValue?: any;
  30624. }
  30625. /**
  30626. * Class used to store any kind of animation
  30627. */
  30628. export class Animation {
  30629. /**Name of the animation */
  30630. name: string;
  30631. /**Property to animate */
  30632. targetProperty: string;
  30633. /**The frames per second of the animation */
  30634. framePerSecond: number;
  30635. /**The data type of the animation */
  30636. dataType: number;
  30637. /**The loop mode of the animation */
  30638. loopMode?: number | undefined;
  30639. /**Specifies if blending should be enabled */
  30640. enableBlending?: boolean | undefined;
  30641. /**
  30642. * Use matrix interpolation instead of using direct key value when animating matrices
  30643. */
  30644. static AllowMatricesInterpolation: boolean;
  30645. /**
  30646. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30647. */
  30648. static AllowMatrixDecomposeForInterpolation: boolean;
  30649. /**
  30650. * Stores the key frames of the animation
  30651. */
  30652. private _keys;
  30653. /**
  30654. * Stores the easing function of the animation
  30655. */
  30656. private _easingFunction;
  30657. /**
  30658. * @hidden Internal use only
  30659. */
  30660. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30661. /**
  30662. * The set of event that will be linked to this animation
  30663. */
  30664. private _events;
  30665. /**
  30666. * Stores an array of target property paths
  30667. */
  30668. targetPropertyPath: string[];
  30669. /**
  30670. * Stores the blending speed of the animation
  30671. */
  30672. blendingSpeed: number;
  30673. /**
  30674. * Stores the animation ranges for the animation
  30675. */
  30676. private _ranges;
  30677. /**
  30678. * @hidden Internal use
  30679. */
  30680. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30681. /**
  30682. * Sets up an animation
  30683. * @param property The property to animate
  30684. * @param animationType The animation type to apply
  30685. * @param framePerSecond The frames per second of the animation
  30686. * @param easingFunction The easing function used in the animation
  30687. * @returns The created animation
  30688. */
  30689. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30690. /**
  30691. * Create and start an animation on a node
  30692. * @param name defines the name of the global animation that will be run on all nodes
  30693. * @param node defines the root node where the animation will take place
  30694. * @param targetProperty defines property to animate
  30695. * @param framePerSecond defines the number of frame per second yo use
  30696. * @param totalFrame defines the number of frames in total
  30697. * @param from defines the initial value
  30698. * @param to defines the final value
  30699. * @param loopMode defines which loop mode you want to use (off by default)
  30700. * @param easingFunction defines the easing function to use (linear by default)
  30701. * @param onAnimationEnd defines the callback to call when animation end
  30702. * @returns the animatable created for this animation
  30703. */
  30704. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30705. /**
  30706. * Create and start an animation on a node and its descendants
  30707. * @param name defines the name of the global animation that will be run on all nodes
  30708. * @param node defines the root node where the animation will take place
  30709. * @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
  30710. * @param targetProperty defines property to animate
  30711. * @param framePerSecond defines the number of frame per second to use
  30712. * @param totalFrame defines the number of frames in total
  30713. * @param from defines the initial value
  30714. * @param to defines the final value
  30715. * @param loopMode defines which loop mode you want to use (off by default)
  30716. * @param easingFunction defines the easing function to use (linear by default)
  30717. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30718. * @returns the list of animatables created for all nodes
  30719. * @example https://www.babylonjs-playground.com/#MH0VLI
  30720. */
  30721. 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[]>;
  30722. /**
  30723. * Creates a new animation, merges it with the existing animations and starts it
  30724. * @param name Name of the animation
  30725. * @param node Node which contains the scene that begins the animations
  30726. * @param targetProperty Specifies which property to animate
  30727. * @param framePerSecond The frames per second of the animation
  30728. * @param totalFrame The total number of frames
  30729. * @param from The frame at the beginning of the animation
  30730. * @param to The frame at the end of the animation
  30731. * @param loopMode Specifies the loop mode of the animation
  30732. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30733. * @param onAnimationEnd Callback to run once the animation is complete
  30734. * @returns Nullable animation
  30735. */
  30736. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30737. /**
  30738. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30739. * @param sourceAnimation defines the Animation containing keyframes to convert
  30740. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30741. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30742. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30743. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30744. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30745. */
  30746. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30747. /**
  30748. * Transition property of an host to the target Value
  30749. * @param property The property to transition
  30750. * @param targetValue The target Value of the property
  30751. * @param host The object where the property to animate belongs
  30752. * @param scene Scene used to run the animation
  30753. * @param frameRate Framerate (in frame/s) to use
  30754. * @param transition The transition type we want to use
  30755. * @param duration The duration of the animation, in milliseconds
  30756. * @param onAnimationEnd Callback trigger at the end of the animation
  30757. * @returns Nullable animation
  30758. */
  30759. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30760. /**
  30761. * Return the array of runtime animations currently using this animation
  30762. */
  30763. get runtimeAnimations(): RuntimeAnimation[];
  30764. /**
  30765. * Specifies if any of the runtime animations are currently running
  30766. */
  30767. get hasRunningRuntimeAnimations(): boolean;
  30768. /**
  30769. * Initializes the animation
  30770. * @param name Name of the animation
  30771. * @param targetProperty Property to animate
  30772. * @param framePerSecond The frames per second of the animation
  30773. * @param dataType The data type of the animation
  30774. * @param loopMode The loop mode of the animation
  30775. * @param enableBlending Specifies if blending should be enabled
  30776. */
  30777. constructor(
  30778. /**Name of the animation */
  30779. name: string,
  30780. /**Property to animate */
  30781. targetProperty: string,
  30782. /**The frames per second of the animation */
  30783. framePerSecond: number,
  30784. /**The data type of the animation */
  30785. dataType: number,
  30786. /**The loop mode of the animation */
  30787. loopMode?: number | undefined,
  30788. /**Specifies if blending should be enabled */
  30789. enableBlending?: boolean | undefined);
  30790. /**
  30791. * Converts the animation to a string
  30792. * @param fullDetails support for multiple levels of logging within scene loading
  30793. * @returns String form of the animation
  30794. */
  30795. toString(fullDetails?: boolean): string;
  30796. /**
  30797. * Add an event to this animation
  30798. * @param event Event to add
  30799. */
  30800. addEvent(event: AnimationEvent): void;
  30801. /**
  30802. * Remove all events found at the given frame
  30803. * @param frame The frame to remove events from
  30804. */
  30805. removeEvents(frame: number): void;
  30806. /**
  30807. * Retrieves all the events from the animation
  30808. * @returns Events from the animation
  30809. */
  30810. getEvents(): AnimationEvent[];
  30811. /**
  30812. * Creates an animation range
  30813. * @param name Name of the animation range
  30814. * @param from Starting frame of the animation range
  30815. * @param to Ending frame of the animation
  30816. */
  30817. createRange(name: string, from: number, to: number): void;
  30818. /**
  30819. * Deletes an animation range by name
  30820. * @param name Name of the animation range to delete
  30821. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30822. */
  30823. deleteRange(name: string, deleteFrames?: boolean): void;
  30824. /**
  30825. * Gets the animation range by name, or null if not defined
  30826. * @param name Name of the animation range
  30827. * @returns Nullable animation range
  30828. */
  30829. getRange(name: string): Nullable<AnimationRange>;
  30830. /**
  30831. * Gets the key frames from the animation
  30832. * @returns The key frames of the animation
  30833. */
  30834. getKeys(): Array<IAnimationKey>;
  30835. /**
  30836. * Gets the highest frame rate of the animation
  30837. * @returns Highest frame rate of the animation
  30838. */
  30839. getHighestFrame(): number;
  30840. /**
  30841. * Gets the easing function of the animation
  30842. * @returns Easing function of the animation
  30843. */
  30844. getEasingFunction(): IEasingFunction;
  30845. /**
  30846. * Sets the easing function of the animation
  30847. * @param easingFunction A custom mathematical formula for animation
  30848. */
  30849. setEasingFunction(easingFunction: EasingFunction): void;
  30850. /**
  30851. * Interpolates a scalar linearly
  30852. * @param startValue Start value of the animation curve
  30853. * @param endValue End value of the animation curve
  30854. * @param gradient Scalar amount to interpolate
  30855. * @returns Interpolated scalar value
  30856. */
  30857. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30858. /**
  30859. * Interpolates a scalar cubically
  30860. * @param startValue Start value of the animation curve
  30861. * @param outTangent End tangent of the animation
  30862. * @param endValue End value of the animation curve
  30863. * @param inTangent Start tangent of the animation curve
  30864. * @param gradient Scalar amount to interpolate
  30865. * @returns Interpolated scalar value
  30866. */
  30867. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30868. /**
  30869. * Interpolates a quaternion using a spherical linear interpolation
  30870. * @param startValue Start value of the animation curve
  30871. * @param endValue End value of the animation curve
  30872. * @param gradient Scalar amount to interpolate
  30873. * @returns Interpolated quaternion value
  30874. */
  30875. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30876. /**
  30877. * Interpolates a quaternion cubically
  30878. * @param startValue Start value of the animation curve
  30879. * @param outTangent End tangent of the animation curve
  30880. * @param endValue End value of the animation curve
  30881. * @param inTangent Start tangent of the animation curve
  30882. * @param gradient Scalar amount to interpolate
  30883. * @returns Interpolated quaternion value
  30884. */
  30885. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30886. /**
  30887. * Interpolates a Vector3 linearl
  30888. * @param startValue Start value of the animation curve
  30889. * @param endValue End value of the animation curve
  30890. * @param gradient Scalar amount to interpolate
  30891. * @returns Interpolated scalar value
  30892. */
  30893. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30894. /**
  30895. * Interpolates a Vector3 cubically
  30896. * @param startValue Start value of the animation curve
  30897. * @param outTangent End tangent of the animation
  30898. * @param endValue End value of the animation curve
  30899. * @param inTangent Start tangent of the animation curve
  30900. * @param gradient Scalar amount to interpolate
  30901. * @returns InterpolatedVector3 value
  30902. */
  30903. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30904. /**
  30905. * Interpolates a Vector2 linearly
  30906. * @param startValue Start value of the animation curve
  30907. * @param endValue End value of the animation curve
  30908. * @param gradient Scalar amount to interpolate
  30909. * @returns Interpolated Vector2 value
  30910. */
  30911. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30912. /**
  30913. * Interpolates a Vector2 cubically
  30914. * @param startValue Start value of the animation curve
  30915. * @param outTangent End tangent of the animation
  30916. * @param endValue End value of the animation curve
  30917. * @param inTangent Start tangent of the animation curve
  30918. * @param gradient Scalar amount to interpolate
  30919. * @returns Interpolated Vector2 value
  30920. */
  30921. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30922. /**
  30923. * Interpolates a size linearly
  30924. * @param startValue Start value of the animation curve
  30925. * @param endValue End value of the animation curve
  30926. * @param gradient Scalar amount to interpolate
  30927. * @returns Interpolated Size value
  30928. */
  30929. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30930. /**
  30931. * Interpolates a Color3 linearly
  30932. * @param startValue Start value of the animation curve
  30933. * @param endValue End value of the animation curve
  30934. * @param gradient Scalar amount to interpolate
  30935. * @returns Interpolated Color3 value
  30936. */
  30937. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30938. /**
  30939. * Interpolates a Color4 linearly
  30940. * @param startValue Start value of the animation curve
  30941. * @param endValue End value of the animation curve
  30942. * @param gradient Scalar amount to interpolate
  30943. * @returns Interpolated Color3 value
  30944. */
  30945. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30946. /**
  30947. * @hidden Internal use only
  30948. */
  30949. _getKeyValue(value: any): any;
  30950. /**
  30951. * @hidden Internal use only
  30952. */
  30953. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30954. /**
  30955. * Defines the function to use to interpolate matrices
  30956. * @param startValue defines the start matrix
  30957. * @param endValue defines the end matrix
  30958. * @param gradient defines the gradient between both matrices
  30959. * @param result defines an optional target matrix where to store the interpolation
  30960. * @returns the interpolated matrix
  30961. */
  30962. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30963. /**
  30964. * Makes a copy of the animation
  30965. * @returns Cloned animation
  30966. */
  30967. clone(): Animation;
  30968. /**
  30969. * Sets the key frames of the animation
  30970. * @param values The animation key frames to set
  30971. */
  30972. setKeys(values: Array<IAnimationKey>): void;
  30973. /**
  30974. * Serializes the animation to an object
  30975. * @returns Serialized object
  30976. */
  30977. serialize(): any;
  30978. /**
  30979. * Float animation type
  30980. */
  30981. static readonly ANIMATIONTYPE_FLOAT: number;
  30982. /**
  30983. * Vector3 animation type
  30984. */
  30985. static readonly ANIMATIONTYPE_VECTOR3: number;
  30986. /**
  30987. * Quaternion animation type
  30988. */
  30989. static readonly ANIMATIONTYPE_QUATERNION: number;
  30990. /**
  30991. * Matrix animation type
  30992. */
  30993. static readonly ANIMATIONTYPE_MATRIX: number;
  30994. /**
  30995. * Color3 animation type
  30996. */
  30997. static readonly ANIMATIONTYPE_COLOR3: number;
  30998. /**
  30999. * Color3 animation type
  31000. */
  31001. static readonly ANIMATIONTYPE_COLOR4: number;
  31002. /**
  31003. * Vector2 animation type
  31004. */
  31005. static readonly ANIMATIONTYPE_VECTOR2: number;
  31006. /**
  31007. * Size animation type
  31008. */
  31009. static readonly ANIMATIONTYPE_SIZE: number;
  31010. /**
  31011. * Relative Loop Mode
  31012. */
  31013. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  31014. /**
  31015. * Cycle Loop Mode
  31016. */
  31017. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  31018. /**
  31019. * Constant Loop Mode
  31020. */
  31021. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  31022. /** @hidden */
  31023. static _UniversalLerp(left: any, right: any, amount: number): any;
  31024. /**
  31025. * Parses an animation object and creates an animation
  31026. * @param parsedAnimation Parsed animation object
  31027. * @returns Animation object
  31028. */
  31029. static Parse(parsedAnimation: any): Animation;
  31030. /**
  31031. * Appends the serialized animations from the source animations
  31032. * @param source Source containing the animations
  31033. * @param destination Target to store the animations
  31034. */
  31035. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31036. }
  31037. }
  31038. declare module "babylonjs/Animations/animatable.interface" {
  31039. import { Nullable } from "babylonjs/types";
  31040. import { Animation } from "babylonjs/Animations/animation";
  31041. /**
  31042. * Interface containing an array of animations
  31043. */
  31044. export interface IAnimatable {
  31045. /**
  31046. * Array of animations
  31047. */
  31048. animations: Nullable<Array<Animation>>;
  31049. }
  31050. }
  31051. declare module "babylonjs/Misc/decorators" {
  31052. import { Nullable } from "babylonjs/types";
  31053. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31054. import { Scene } from "babylonjs/scene";
  31055. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31056. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31057. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31058. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31059. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31060. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31061. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31062. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31063. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31064. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31065. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31066. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31067. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31068. /**
  31069. * Decorator used to define property that can be serialized as reference to a camera
  31070. * @param sourceName defines the name of the property to decorate
  31071. */
  31072. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31073. /**
  31074. * Class used to help serialization objects
  31075. */
  31076. export class SerializationHelper {
  31077. /** @hidden */
  31078. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31079. /** @hidden */
  31080. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31081. /** @hidden */
  31082. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31083. /** @hidden */
  31084. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31085. /**
  31086. * Appends the serialized animations from the source animations
  31087. * @param source Source containing the animations
  31088. * @param destination Target to store the animations
  31089. */
  31090. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31091. /**
  31092. * Static function used to serialized a specific entity
  31093. * @param entity defines the entity to serialize
  31094. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31095. * @returns a JSON compatible object representing the serialization of the entity
  31096. */
  31097. static Serialize<T>(entity: T, serializationObject?: any): any;
  31098. /**
  31099. * Creates a new entity from a serialization data object
  31100. * @param creationFunction defines a function used to instanciated the new entity
  31101. * @param source defines the source serialization data
  31102. * @param scene defines the hosting scene
  31103. * @param rootUrl defines the root url for resources
  31104. * @returns a new entity
  31105. */
  31106. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31107. /**
  31108. * Clones an object
  31109. * @param creationFunction defines the function used to instanciate the new object
  31110. * @param source defines the source object
  31111. * @returns the cloned object
  31112. */
  31113. static Clone<T>(creationFunction: () => T, source: T): T;
  31114. /**
  31115. * Instanciates a new object based on a source one (some data will be shared between both object)
  31116. * @param creationFunction defines the function used to instanciate the new object
  31117. * @param source defines the source object
  31118. * @returns the new object
  31119. */
  31120. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31121. }
  31122. }
  31123. declare module "babylonjs/Materials/Textures/baseTexture" {
  31124. import { Observable } from "babylonjs/Misc/observable";
  31125. import { Nullable } from "babylonjs/types";
  31126. import { Scene } from "babylonjs/scene";
  31127. import { Matrix } from "babylonjs/Maths/math.vector";
  31128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31129. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31130. import { ISize } from "babylonjs/Maths/math.size";
  31131. import "babylonjs/Misc/fileTools";
  31132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31133. /**
  31134. * Base class of all the textures in babylon.
  31135. * It groups all the common properties the materials, post process, lights... might need
  31136. * in order to make a correct use of the texture.
  31137. */
  31138. export class BaseTexture implements IAnimatable {
  31139. /**
  31140. * Default anisotropic filtering level for the application.
  31141. * It is set to 4 as a good tradeoff between perf and quality.
  31142. */
  31143. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31144. /**
  31145. * Gets or sets the unique id of the texture
  31146. */
  31147. uniqueId: number;
  31148. /**
  31149. * Define the name of the texture.
  31150. */
  31151. name: string;
  31152. /**
  31153. * Gets or sets an object used to store user defined information.
  31154. */
  31155. metadata: any;
  31156. /**
  31157. * For internal use only. Please do not use.
  31158. */
  31159. reservedDataStore: any;
  31160. private _hasAlpha;
  31161. /**
  31162. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31163. */
  31164. set hasAlpha(value: boolean);
  31165. get hasAlpha(): boolean;
  31166. /**
  31167. * Defines if the alpha value should be determined via the rgb values.
  31168. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31169. */
  31170. getAlphaFromRGB: boolean;
  31171. /**
  31172. * Intensity or strength of the texture.
  31173. * It is commonly used by materials to fine tune the intensity of the texture
  31174. */
  31175. level: number;
  31176. /**
  31177. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31178. * This is part of the texture as textures usually maps to one uv set.
  31179. */
  31180. coordinatesIndex: number;
  31181. private _coordinatesMode;
  31182. /**
  31183. * How a texture is mapped.
  31184. *
  31185. * | Value | Type | Description |
  31186. * | ----- | ----------------------------------- | ----------- |
  31187. * | 0 | EXPLICIT_MODE | |
  31188. * | 1 | SPHERICAL_MODE | |
  31189. * | 2 | PLANAR_MODE | |
  31190. * | 3 | CUBIC_MODE | |
  31191. * | 4 | PROJECTION_MODE | |
  31192. * | 5 | SKYBOX_MODE | |
  31193. * | 6 | INVCUBIC_MODE | |
  31194. * | 7 | EQUIRECTANGULAR_MODE | |
  31195. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31196. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31197. */
  31198. set coordinatesMode(value: number);
  31199. get coordinatesMode(): number;
  31200. /**
  31201. * | Value | Type | Description |
  31202. * | ----- | ------------------ | ----------- |
  31203. * | 0 | CLAMP_ADDRESSMODE | |
  31204. * | 1 | WRAP_ADDRESSMODE | |
  31205. * | 2 | MIRROR_ADDRESSMODE | |
  31206. */
  31207. wrapU: number;
  31208. /**
  31209. * | Value | Type | Description |
  31210. * | ----- | ------------------ | ----------- |
  31211. * | 0 | CLAMP_ADDRESSMODE | |
  31212. * | 1 | WRAP_ADDRESSMODE | |
  31213. * | 2 | MIRROR_ADDRESSMODE | |
  31214. */
  31215. wrapV: number;
  31216. /**
  31217. * | Value | Type | Description |
  31218. * | ----- | ------------------ | ----------- |
  31219. * | 0 | CLAMP_ADDRESSMODE | |
  31220. * | 1 | WRAP_ADDRESSMODE | |
  31221. * | 2 | MIRROR_ADDRESSMODE | |
  31222. */
  31223. wrapR: number;
  31224. /**
  31225. * With compliant hardware and browser (supporting anisotropic filtering)
  31226. * this defines the level of anisotropic filtering in the texture.
  31227. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31228. */
  31229. anisotropicFilteringLevel: number;
  31230. /**
  31231. * Define if the texture is a cube texture or if false a 2d texture.
  31232. */
  31233. get isCube(): boolean;
  31234. set isCube(value: boolean);
  31235. /**
  31236. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31237. */
  31238. get is3D(): boolean;
  31239. set is3D(value: boolean);
  31240. /**
  31241. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31242. */
  31243. get is2DArray(): boolean;
  31244. set is2DArray(value: boolean);
  31245. /**
  31246. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31247. * HDR texture are usually stored in linear space.
  31248. * This only impacts the PBR and Background materials
  31249. */
  31250. gammaSpace: boolean;
  31251. /**
  31252. * Gets or sets whether or not the texture contains RGBD data.
  31253. */
  31254. get isRGBD(): boolean;
  31255. set isRGBD(value: boolean);
  31256. /**
  31257. * Is Z inverted in the texture (useful in a cube texture).
  31258. */
  31259. invertZ: boolean;
  31260. /**
  31261. * Are mip maps generated for this texture or not.
  31262. */
  31263. get noMipmap(): boolean;
  31264. /**
  31265. * @hidden
  31266. */
  31267. lodLevelInAlpha: boolean;
  31268. /**
  31269. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31270. */
  31271. get lodGenerationOffset(): number;
  31272. set lodGenerationOffset(value: number);
  31273. /**
  31274. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31275. */
  31276. get lodGenerationScale(): number;
  31277. set lodGenerationScale(value: number);
  31278. /**
  31279. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31280. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31281. * average roughness values.
  31282. */
  31283. get linearSpecularLOD(): boolean;
  31284. set linearSpecularLOD(value: boolean);
  31285. /**
  31286. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31287. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31288. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31289. */
  31290. get irradianceTexture(): Nullable<BaseTexture>;
  31291. set irradianceTexture(value: Nullable<BaseTexture>);
  31292. /**
  31293. * Define if the texture is a render target.
  31294. */
  31295. isRenderTarget: boolean;
  31296. /**
  31297. * Define the unique id of the texture in the scene.
  31298. */
  31299. get uid(): string;
  31300. /**
  31301. * Return a string representation of the texture.
  31302. * @returns the texture as a string
  31303. */
  31304. toString(): string;
  31305. /**
  31306. * Get the class name of the texture.
  31307. * @returns "BaseTexture"
  31308. */
  31309. getClassName(): string;
  31310. /**
  31311. * Define the list of animation attached to the texture.
  31312. */
  31313. animations: import("babylonjs/Animations/animation").Animation[];
  31314. /**
  31315. * An event triggered when the texture is disposed.
  31316. */
  31317. onDisposeObservable: Observable<BaseTexture>;
  31318. private _onDisposeObserver;
  31319. /**
  31320. * Callback triggered when the texture has been disposed.
  31321. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31322. */
  31323. set onDispose(callback: () => void);
  31324. /**
  31325. * Define the current state of the loading sequence when in delayed load mode.
  31326. */
  31327. delayLoadState: number;
  31328. private _scene;
  31329. private _engine;
  31330. /** @hidden */
  31331. _texture: Nullable<InternalTexture>;
  31332. private _uid;
  31333. /**
  31334. * Define if the texture is preventinga material to render or not.
  31335. * If not and the texture is not ready, the engine will use a default black texture instead.
  31336. */
  31337. get isBlocking(): boolean;
  31338. /**
  31339. * Instantiates a new BaseTexture.
  31340. * Base class of all the textures in babylon.
  31341. * It groups all the common properties the materials, post process, lights... might need
  31342. * in order to make a correct use of the texture.
  31343. * @param sceneOrEngine Define the scene or engine the texture blongs to
  31344. */
  31345. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  31346. /**
  31347. * Get the scene the texture belongs to.
  31348. * @returns the scene or null if undefined
  31349. */
  31350. getScene(): Nullable<Scene>;
  31351. /** @hidden */
  31352. protected _getEngine(): Nullable<ThinEngine>;
  31353. /**
  31354. * Get the texture transform matrix used to offset tile the texture for istance.
  31355. * @returns the transformation matrix
  31356. */
  31357. getTextureMatrix(): Matrix;
  31358. /**
  31359. * Get the texture reflection matrix used to rotate/transform the reflection.
  31360. * @returns the reflection matrix
  31361. */
  31362. getReflectionTextureMatrix(): Matrix;
  31363. /**
  31364. * Get the underlying lower level texture from Babylon.
  31365. * @returns the insternal texture
  31366. */
  31367. getInternalTexture(): Nullable<InternalTexture>;
  31368. /**
  31369. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31370. * @returns true if ready or not blocking
  31371. */
  31372. isReadyOrNotBlocking(): boolean;
  31373. /**
  31374. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31375. * @returns true if fully ready
  31376. */
  31377. isReady(): boolean;
  31378. private _cachedSize;
  31379. /**
  31380. * Get the size of the texture.
  31381. * @returns the texture size.
  31382. */
  31383. getSize(): ISize;
  31384. /**
  31385. * Get the base size of the texture.
  31386. * It can be different from the size if the texture has been resized for POT for instance
  31387. * @returns the base size
  31388. */
  31389. getBaseSize(): ISize;
  31390. /**
  31391. * Update the sampling mode of the texture.
  31392. * Default is Trilinear mode.
  31393. *
  31394. * | Value | Type | Description |
  31395. * | ----- | ------------------ | ----------- |
  31396. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31397. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31398. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31399. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31400. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31401. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31402. * | 7 | NEAREST_LINEAR | |
  31403. * | 8 | NEAREST_NEAREST | |
  31404. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31405. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31406. * | 11 | LINEAR_LINEAR | |
  31407. * | 12 | LINEAR_NEAREST | |
  31408. *
  31409. * > _mag_: magnification filter (close to the viewer)
  31410. * > _min_: minification filter (far from the viewer)
  31411. * > _mip_: filter used between mip map levels
  31412. *@param samplingMode Define the new sampling mode of the texture
  31413. */
  31414. updateSamplingMode(samplingMode: number): void;
  31415. /**
  31416. * Scales the texture if is `canRescale()`
  31417. * @param ratio the resize factor we want to use to rescale
  31418. */
  31419. scale(ratio: number): void;
  31420. /**
  31421. * Get if the texture can rescale.
  31422. */
  31423. get canRescale(): boolean;
  31424. /** @hidden */
  31425. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31426. /** @hidden */
  31427. _rebuild(): void;
  31428. /**
  31429. * Triggers the load sequence in delayed load mode.
  31430. */
  31431. delayLoad(): void;
  31432. /**
  31433. * Clones the texture.
  31434. * @returns the cloned texture
  31435. */
  31436. clone(): Nullable<BaseTexture>;
  31437. /**
  31438. * Get the texture underlying type (INT, FLOAT...)
  31439. */
  31440. get textureType(): number;
  31441. /**
  31442. * Get the texture underlying format (RGB, RGBA...)
  31443. */
  31444. get textureFormat(): number;
  31445. /**
  31446. * Indicates that textures need to be re-calculated for all materials
  31447. */
  31448. protected _markAllSubMeshesAsTexturesDirty(): void;
  31449. /**
  31450. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31451. * This will returns an RGBA array buffer containing either in values (0-255) or
  31452. * float values (0-1) depending of the underlying buffer type.
  31453. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31454. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31455. * @param buffer defines a user defined buffer to fill with data (can be null)
  31456. * @returns The Array buffer containing the pixels data.
  31457. */
  31458. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31459. /**
  31460. * Release and destroy the underlying lower level texture aka internalTexture.
  31461. */
  31462. releaseInternalTexture(): void;
  31463. /** @hidden */
  31464. get _lodTextureHigh(): Nullable<BaseTexture>;
  31465. /** @hidden */
  31466. get _lodTextureMid(): Nullable<BaseTexture>;
  31467. /** @hidden */
  31468. get _lodTextureLow(): Nullable<BaseTexture>;
  31469. /**
  31470. * Dispose the texture and release its associated resources.
  31471. */
  31472. dispose(): void;
  31473. /**
  31474. * Serialize the texture into a JSON representation that can be parsed later on.
  31475. * @returns the JSON representation of the texture
  31476. */
  31477. serialize(): any;
  31478. /**
  31479. * Helper function to be called back once a list of texture contains only ready textures.
  31480. * @param textures Define the list of textures to wait for
  31481. * @param callback Define the callback triggered once the entire list will be ready
  31482. */
  31483. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31484. private static _isScene;
  31485. }
  31486. }
  31487. declare module "babylonjs/Materials/effect" {
  31488. import { Observable } from "babylonjs/Misc/observable";
  31489. import { Nullable } from "babylonjs/types";
  31490. import { IDisposable } from "babylonjs/scene";
  31491. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31492. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31493. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31494. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31495. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31496. import { Engine } from "babylonjs/Engines/engine";
  31497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31500. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31501. /**
  31502. * Options to be used when creating an effect.
  31503. */
  31504. export interface IEffectCreationOptions {
  31505. /**
  31506. * Atrributes that will be used in the shader.
  31507. */
  31508. attributes: string[];
  31509. /**
  31510. * Uniform varible names that will be set in the shader.
  31511. */
  31512. uniformsNames: string[];
  31513. /**
  31514. * Uniform buffer variable names that will be set in the shader.
  31515. */
  31516. uniformBuffersNames: string[];
  31517. /**
  31518. * Sampler texture variable names that will be set in the shader.
  31519. */
  31520. samplers: string[];
  31521. /**
  31522. * Define statements that will be set in the shader.
  31523. */
  31524. defines: any;
  31525. /**
  31526. * Possible fallbacks for this effect to improve performance when needed.
  31527. */
  31528. fallbacks: Nullable<IEffectFallbacks>;
  31529. /**
  31530. * Callback that will be called when the shader is compiled.
  31531. */
  31532. onCompiled: Nullable<(effect: Effect) => void>;
  31533. /**
  31534. * Callback that will be called if an error occurs during shader compilation.
  31535. */
  31536. onError: Nullable<(effect: Effect, errors: string) => void>;
  31537. /**
  31538. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31539. */
  31540. indexParameters?: any;
  31541. /**
  31542. * Max number of lights that can be used in the shader.
  31543. */
  31544. maxSimultaneousLights?: number;
  31545. /**
  31546. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31547. */
  31548. transformFeedbackVaryings?: Nullable<string[]>;
  31549. }
  31550. /**
  31551. * Effect containing vertex and fragment shader that can be executed on an object.
  31552. */
  31553. export class Effect implements IDisposable {
  31554. /**
  31555. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31556. */
  31557. static ShadersRepository: string;
  31558. /**
  31559. * Enable logging of the shader code when a compilation error occurs
  31560. */
  31561. static LogShaderCodeOnCompilationError: boolean;
  31562. /**
  31563. * Name of the effect.
  31564. */
  31565. name: any;
  31566. /**
  31567. * String container all the define statements that should be set on the shader.
  31568. */
  31569. defines: string;
  31570. /**
  31571. * Callback that will be called when the shader is compiled.
  31572. */
  31573. onCompiled: Nullable<(effect: Effect) => void>;
  31574. /**
  31575. * Callback that will be called if an error occurs during shader compilation.
  31576. */
  31577. onError: Nullable<(effect: Effect, errors: string) => void>;
  31578. /**
  31579. * Callback that will be called when effect is bound.
  31580. */
  31581. onBind: Nullable<(effect: Effect) => void>;
  31582. /**
  31583. * Unique ID of the effect.
  31584. */
  31585. uniqueId: number;
  31586. /**
  31587. * Observable that will be called when the shader is compiled.
  31588. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31589. */
  31590. onCompileObservable: Observable<Effect>;
  31591. /**
  31592. * Observable that will be called if an error occurs during shader compilation.
  31593. */
  31594. onErrorObservable: Observable<Effect>;
  31595. /** @hidden */
  31596. _onBindObservable: Nullable<Observable<Effect>>;
  31597. /**
  31598. * @hidden
  31599. * Specifies if the effect was previously ready
  31600. */
  31601. _wasPreviouslyReady: boolean;
  31602. /**
  31603. * Observable that will be called when effect is bound.
  31604. */
  31605. get onBindObservable(): Observable<Effect>;
  31606. /** @hidden */
  31607. _bonesComputationForcedToCPU: boolean;
  31608. private static _uniqueIdSeed;
  31609. private _engine;
  31610. private _uniformBuffersNames;
  31611. private _uniformBuffersNamesList;
  31612. private _uniformsNames;
  31613. private _samplerList;
  31614. private _samplers;
  31615. private _isReady;
  31616. private _compilationError;
  31617. private _allFallbacksProcessed;
  31618. private _attributesNames;
  31619. private _attributes;
  31620. private _attributeLocationByName;
  31621. private _uniforms;
  31622. /**
  31623. * Key for the effect.
  31624. * @hidden
  31625. */
  31626. _key: string;
  31627. private _indexParameters;
  31628. private _fallbacks;
  31629. private _vertexSourceCode;
  31630. private _fragmentSourceCode;
  31631. private _vertexSourceCodeOverride;
  31632. private _fragmentSourceCodeOverride;
  31633. private _transformFeedbackVaryings;
  31634. /**
  31635. * Compiled shader to webGL program.
  31636. * @hidden
  31637. */
  31638. _pipelineContext: Nullable<IPipelineContext>;
  31639. private _valueCache;
  31640. private static _baseCache;
  31641. /**
  31642. * Instantiates an effect.
  31643. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31644. * @param baseName Name of the effect.
  31645. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31646. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31647. * @param samplers List of sampler variables that will be passed to the shader.
  31648. * @param engine Engine to be used to render the effect
  31649. * @param defines Define statements to be added to the shader.
  31650. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31651. * @param onCompiled Callback that will be called when the shader is compiled.
  31652. * @param onError Callback that will be called if an error occurs during shader compilation.
  31653. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31654. */
  31655. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31656. private _useFinalCode;
  31657. /**
  31658. * Unique key for this effect
  31659. */
  31660. get key(): string;
  31661. /**
  31662. * If the effect has been compiled and prepared.
  31663. * @returns if the effect is compiled and prepared.
  31664. */
  31665. isReady(): boolean;
  31666. private _isReadyInternal;
  31667. /**
  31668. * The engine the effect was initialized with.
  31669. * @returns the engine.
  31670. */
  31671. getEngine(): Engine;
  31672. /**
  31673. * The pipeline context for this effect
  31674. * @returns the associated pipeline context
  31675. */
  31676. getPipelineContext(): Nullable<IPipelineContext>;
  31677. /**
  31678. * The set of names of attribute variables for the shader.
  31679. * @returns An array of attribute names.
  31680. */
  31681. getAttributesNames(): string[];
  31682. /**
  31683. * Returns the attribute at the given index.
  31684. * @param index The index of the attribute.
  31685. * @returns The location of the attribute.
  31686. */
  31687. getAttributeLocation(index: number): number;
  31688. /**
  31689. * Returns the attribute based on the name of the variable.
  31690. * @param name of the attribute to look up.
  31691. * @returns the attribute location.
  31692. */
  31693. getAttributeLocationByName(name: string): number;
  31694. /**
  31695. * The number of attributes.
  31696. * @returns the numnber of attributes.
  31697. */
  31698. getAttributesCount(): number;
  31699. /**
  31700. * Gets the index of a uniform variable.
  31701. * @param uniformName of the uniform to look up.
  31702. * @returns the index.
  31703. */
  31704. getUniformIndex(uniformName: string): number;
  31705. /**
  31706. * Returns the attribute based on the name of the variable.
  31707. * @param uniformName of the uniform to look up.
  31708. * @returns the location of the uniform.
  31709. */
  31710. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31711. /**
  31712. * Returns an array of sampler variable names
  31713. * @returns The array of sampler variable names.
  31714. */
  31715. getSamplers(): string[];
  31716. /**
  31717. * Returns an array of uniform variable names
  31718. * @returns The array of uniform variable names.
  31719. */
  31720. getUniformNames(): string[];
  31721. /**
  31722. * Returns an array of uniform buffer variable names
  31723. * @returns The array of uniform buffer variable names.
  31724. */
  31725. getUniformBuffersNames(): string[];
  31726. /**
  31727. * Returns the index parameters used to create the effect
  31728. * @returns The index parameters object
  31729. */
  31730. getIndexParameters(): any;
  31731. /**
  31732. * The error from the last compilation.
  31733. * @returns the error string.
  31734. */
  31735. getCompilationError(): string;
  31736. /**
  31737. * Gets a boolean indicating that all fallbacks were used during compilation
  31738. * @returns true if all fallbacks were used
  31739. */
  31740. allFallbacksProcessed(): boolean;
  31741. /**
  31742. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31743. * @param func The callback to be used.
  31744. */
  31745. executeWhenCompiled(func: (effect: Effect) => void): void;
  31746. private _checkIsReady;
  31747. private _loadShader;
  31748. /**
  31749. * Gets the vertex shader source code of this effect
  31750. */
  31751. get vertexSourceCode(): string;
  31752. /**
  31753. * Gets the fragment shader source code of this effect
  31754. */
  31755. get fragmentSourceCode(): string;
  31756. /**
  31757. * Recompiles the webGL program
  31758. * @param vertexSourceCode The source code for the vertex shader.
  31759. * @param fragmentSourceCode The source code for the fragment shader.
  31760. * @param onCompiled Callback called when completed.
  31761. * @param onError Callback called on error.
  31762. * @hidden
  31763. */
  31764. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31765. /**
  31766. * Prepares the effect
  31767. * @hidden
  31768. */
  31769. _prepareEffect(): void;
  31770. private _getShaderCodeAndErrorLine;
  31771. private _processCompilationErrors;
  31772. /**
  31773. * Checks if the effect is supported. (Must be called after compilation)
  31774. */
  31775. get isSupported(): boolean;
  31776. /**
  31777. * Binds a texture to the engine to be used as output of the shader.
  31778. * @param channel Name of the output variable.
  31779. * @param texture Texture to bind.
  31780. * @hidden
  31781. */
  31782. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31783. /**
  31784. * Sets a texture on the engine to be used in the shader.
  31785. * @param channel Name of the sampler variable.
  31786. * @param texture Texture to set.
  31787. */
  31788. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31789. /**
  31790. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31791. * @param channel Name of the sampler variable.
  31792. * @param texture Texture to set.
  31793. */
  31794. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31795. /**
  31796. * Sets an array of textures on the engine to be used in the shader.
  31797. * @param channel Name of the variable.
  31798. * @param textures Textures to set.
  31799. */
  31800. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31801. /**
  31802. * 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)
  31803. * @param channel Name of the sampler variable.
  31804. * @param postProcess Post process to get the input texture from.
  31805. */
  31806. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31807. /**
  31808. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31809. * 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)
  31810. * @param channel Name of the sampler variable.
  31811. * @param postProcess Post process to get the output texture from.
  31812. */
  31813. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31814. /** @hidden */
  31815. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31816. /** @hidden */
  31817. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31818. /** @hidden */
  31819. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31820. /** @hidden */
  31821. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31822. /**
  31823. * Binds a buffer to a uniform.
  31824. * @param buffer Buffer to bind.
  31825. * @param name Name of the uniform variable to bind to.
  31826. */
  31827. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31828. /**
  31829. * Binds block to a uniform.
  31830. * @param blockName Name of the block to bind.
  31831. * @param index Index to bind.
  31832. */
  31833. bindUniformBlock(blockName: string, index: number): void;
  31834. /**
  31835. * Sets an interger value on a uniform variable.
  31836. * @param uniformName Name of the variable.
  31837. * @param value Value to be set.
  31838. * @returns this effect.
  31839. */
  31840. setInt(uniformName: string, value: number): Effect;
  31841. /**
  31842. * Sets an int array on a uniform variable.
  31843. * @param uniformName Name of the variable.
  31844. * @param array array to be set.
  31845. * @returns this effect.
  31846. */
  31847. setIntArray(uniformName: string, array: Int32Array): Effect;
  31848. /**
  31849. * 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)
  31850. * @param uniformName Name of the variable.
  31851. * @param array array to be set.
  31852. * @returns this effect.
  31853. */
  31854. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31855. /**
  31856. * 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)
  31857. * @param uniformName Name of the variable.
  31858. * @param array array to be set.
  31859. * @returns this effect.
  31860. */
  31861. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31862. /**
  31863. * 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)
  31864. * @param uniformName Name of the variable.
  31865. * @param array array to be set.
  31866. * @returns this effect.
  31867. */
  31868. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31869. /**
  31870. * Sets an float array on a uniform variable.
  31871. * @param uniformName Name of the variable.
  31872. * @param array array to be set.
  31873. * @returns this effect.
  31874. */
  31875. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31876. /**
  31877. * 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)
  31878. * @param uniformName Name of the variable.
  31879. * @param array array to be set.
  31880. * @returns this effect.
  31881. */
  31882. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31883. /**
  31884. * 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)
  31885. * @param uniformName Name of the variable.
  31886. * @param array array to be set.
  31887. * @returns this effect.
  31888. */
  31889. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31890. /**
  31891. * 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)
  31892. * @param uniformName Name of the variable.
  31893. * @param array array to be set.
  31894. * @returns this effect.
  31895. */
  31896. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31897. /**
  31898. * Sets an array on a uniform variable.
  31899. * @param uniformName Name of the variable.
  31900. * @param array array to be set.
  31901. * @returns this effect.
  31902. */
  31903. setArray(uniformName: string, array: number[]): Effect;
  31904. /**
  31905. * 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)
  31906. * @param uniformName Name of the variable.
  31907. * @param array array to be set.
  31908. * @returns this effect.
  31909. */
  31910. setArray2(uniformName: string, array: number[]): Effect;
  31911. /**
  31912. * 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)
  31913. * @param uniformName Name of the variable.
  31914. * @param array array to be set.
  31915. * @returns this effect.
  31916. */
  31917. setArray3(uniformName: string, array: number[]): Effect;
  31918. /**
  31919. * 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)
  31920. * @param uniformName Name of the variable.
  31921. * @param array array to be set.
  31922. * @returns this effect.
  31923. */
  31924. setArray4(uniformName: string, array: number[]): Effect;
  31925. /**
  31926. * Sets matrices on a uniform variable.
  31927. * @param uniformName Name of the variable.
  31928. * @param matrices matrices to be set.
  31929. * @returns this effect.
  31930. */
  31931. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31932. /**
  31933. * Sets matrix on a uniform variable.
  31934. * @param uniformName Name of the variable.
  31935. * @param matrix matrix to be set.
  31936. * @returns this effect.
  31937. */
  31938. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31939. /**
  31940. * 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)
  31941. * @param uniformName Name of the variable.
  31942. * @param matrix matrix to be set.
  31943. * @returns this effect.
  31944. */
  31945. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31946. /**
  31947. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31948. * @param uniformName Name of the variable.
  31949. * @param matrix matrix to be set.
  31950. * @returns this effect.
  31951. */
  31952. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31953. /**
  31954. * Sets a float on a uniform variable.
  31955. * @param uniformName Name of the variable.
  31956. * @param value value to be set.
  31957. * @returns this effect.
  31958. */
  31959. setFloat(uniformName: string, value: number): Effect;
  31960. /**
  31961. * Sets a boolean on a uniform variable.
  31962. * @param uniformName Name of the variable.
  31963. * @param bool value to be set.
  31964. * @returns this effect.
  31965. */
  31966. setBool(uniformName: string, bool: boolean): Effect;
  31967. /**
  31968. * Sets a Vector2 on a uniform variable.
  31969. * @param uniformName Name of the variable.
  31970. * @param vector2 vector2 to be set.
  31971. * @returns this effect.
  31972. */
  31973. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31974. /**
  31975. * Sets a float2 on a uniform variable.
  31976. * @param uniformName Name of the variable.
  31977. * @param x First float in float2.
  31978. * @param y Second float in float2.
  31979. * @returns this effect.
  31980. */
  31981. setFloat2(uniformName: string, x: number, y: number): Effect;
  31982. /**
  31983. * Sets a Vector3 on a uniform variable.
  31984. * @param uniformName Name of the variable.
  31985. * @param vector3 Value to be set.
  31986. * @returns this effect.
  31987. */
  31988. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31989. /**
  31990. * Sets a float3 on a uniform variable.
  31991. * @param uniformName Name of the variable.
  31992. * @param x First float in float3.
  31993. * @param y Second float in float3.
  31994. * @param z Third float in float3.
  31995. * @returns this effect.
  31996. */
  31997. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31998. /**
  31999. * Sets a Vector4 on a uniform variable.
  32000. * @param uniformName Name of the variable.
  32001. * @param vector4 Value to be set.
  32002. * @returns this effect.
  32003. */
  32004. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  32005. /**
  32006. * Sets a float4 on a uniform variable.
  32007. * @param uniformName Name of the variable.
  32008. * @param x First float in float4.
  32009. * @param y Second float in float4.
  32010. * @param z Third float in float4.
  32011. * @param w Fourth float in float4.
  32012. * @returns this effect.
  32013. */
  32014. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  32015. /**
  32016. * Sets a Color3 on a uniform variable.
  32017. * @param uniformName Name of the variable.
  32018. * @param color3 Value to be set.
  32019. * @returns this effect.
  32020. */
  32021. setColor3(uniformName: string, color3: IColor3Like): Effect;
  32022. /**
  32023. * Sets a Color4 on a uniform variable.
  32024. * @param uniformName Name of the variable.
  32025. * @param color3 Value to be set.
  32026. * @param alpha Alpha value to be set.
  32027. * @returns this effect.
  32028. */
  32029. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  32030. /**
  32031. * Sets a Color4 on a uniform variable
  32032. * @param uniformName defines the name of the variable
  32033. * @param color4 defines the value to be set
  32034. * @returns this effect.
  32035. */
  32036. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32037. /** Release all associated resources */
  32038. dispose(): void;
  32039. /**
  32040. * This function will add a new shader to the shader store
  32041. * @param name the name of the shader
  32042. * @param pixelShader optional pixel shader content
  32043. * @param vertexShader optional vertex shader content
  32044. */
  32045. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32046. /**
  32047. * Store of each shader (The can be looked up using effect.key)
  32048. */
  32049. static ShadersStore: {
  32050. [key: string]: string;
  32051. };
  32052. /**
  32053. * Store of each included file for a shader (The can be looked up using effect.key)
  32054. */
  32055. static IncludesShadersStore: {
  32056. [key: string]: string;
  32057. };
  32058. /**
  32059. * Resets the cache of effects.
  32060. */
  32061. static ResetCache(): void;
  32062. }
  32063. }
  32064. declare module "babylonjs/Engines/engineCapabilities" {
  32065. /**
  32066. * Interface used to describe the capabilities of the engine relatively to the current browser
  32067. */
  32068. export interface EngineCapabilities {
  32069. /** Maximum textures units per fragment shader */
  32070. maxTexturesImageUnits: number;
  32071. /** Maximum texture units per vertex shader */
  32072. maxVertexTextureImageUnits: number;
  32073. /** Maximum textures units in the entire pipeline */
  32074. maxCombinedTexturesImageUnits: number;
  32075. /** Maximum texture size */
  32076. maxTextureSize: number;
  32077. /** Maximum texture samples */
  32078. maxSamples?: number;
  32079. /** Maximum cube texture size */
  32080. maxCubemapTextureSize: number;
  32081. /** Maximum render texture size */
  32082. maxRenderTextureSize: number;
  32083. /** Maximum number of vertex attributes */
  32084. maxVertexAttribs: number;
  32085. /** Maximum number of varyings */
  32086. maxVaryingVectors: number;
  32087. /** Maximum number of uniforms per vertex shader */
  32088. maxVertexUniformVectors: number;
  32089. /** Maximum number of uniforms per fragment shader */
  32090. maxFragmentUniformVectors: number;
  32091. /** Defines if standard derivates (dx/dy) are supported */
  32092. standardDerivatives: boolean;
  32093. /** Defines if s3tc texture compression is supported */
  32094. s3tc?: WEBGL_compressed_texture_s3tc;
  32095. /** Defines if pvrtc texture compression is supported */
  32096. pvrtc: any;
  32097. /** Defines if etc1 texture compression is supported */
  32098. etc1: any;
  32099. /** Defines if etc2 texture compression is supported */
  32100. etc2: any;
  32101. /** Defines if astc texture compression is supported */
  32102. astc: any;
  32103. /** Defines if float textures are supported */
  32104. textureFloat: boolean;
  32105. /** Defines if vertex array objects are supported */
  32106. vertexArrayObject: boolean;
  32107. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32108. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32109. /** Gets the maximum level of anisotropy supported */
  32110. maxAnisotropy: number;
  32111. /** Defines if instancing is supported */
  32112. instancedArrays: boolean;
  32113. /** Defines if 32 bits indices are supported */
  32114. uintIndices: boolean;
  32115. /** Defines if high precision shaders are supported */
  32116. highPrecisionShaderSupported: boolean;
  32117. /** Defines if depth reading in the fragment shader is supported */
  32118. fragmentDepthSupported: boolean;
  32119. /** Defines if float texture linear filtering is supported*/
  32120. textureFloatLinearFiltering: boolean;
  32121. /** Defines if rendering to float textures is supported */
  32122. textureFloatRender: boolean;
  32123. /** Defines if half float textures are supported*/
  32124. textureHalfFloat: boolean;
  32125. /** Defines if half float texture linear filtering is supported*/
  32126. textureHalfFloatLinearFiltering: boolean;
  32127. /** Defines if rendering to half float textures is supported */
  32128. textureHalfFloatRender: boolean;
  32129. /** Defines if textureLOD shader command is supported */
  32130. textureLOD: boolean;
  32131. /** Defines if draw buffers extension is supported */
  32132. drawBuffersExtension: boolean;
  32133. /** Defines if depth textures are supported */
  32134. depthTextureExtension: boolean;
  32135. /** Defines if float color buffer are supported */
  32136. colorBufferFloat: boolean;
  32137. /** Gets disjoint timer query extension (null if not supported) */
  32138. timerQuery?: EXT_disjoint_timer_query;
  32139. /** Defines if timestamp can be used with timer query */
  32140. canUseTimestampForTimerQuery: boolean;
  32141. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32142. multiview?: any;
  32143. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32144. oculusMultiview?: any;
  32145. /** Function used to let the system compiles shaders in background */
  32146. parallelShaderCompile?: {
  32147. COMPLETION_STATUS_KHR: number;
  32148. };
  32149. /** Max number of texture samples for MSAA */
  32150. maxMSAASamples: number;
  32151. /** Defines if the blend min max extension is supported */
  32152. blendMinMax: boolean;
  32153. }
  32154. }
  32155. declare module "babylonjs/States/depthCullingState" {
  32156. import { Nullable } from "babylonjs/types";
  32157. /**
  32158. * @hidden
  32159. **/
  32160. export class DepthCullingState {
  32161. private _isDepthTestDirty;
  32162. private _isDepthMaskDirty;
  32163. private _isDepthFuncDirty;
  32164. private _isCullFaceDirty;
  32165. private _isCullDirty;
  32166. private _isZOffsetDirty;
  32167. private _isFrontFaceDirty;
  32168. private _depthTest;
  32169. private _depthMask;
  32170. private _depthFunc;
  32171. private _cull;
  32172. private _cullFace;
  32173. private _zOffset;
  32174. private _frontFace;
  32175. /**
  32176. * Initializes the state.
  32177. */
  32178. constructor();
  32179. get isDirty(): boolean;
  32180. get zOffset(): number;
  32181. set zOffset(value: number);
  32182. get cullFace(): Nullable<number>;
  32183. set cullFace(value: Nullable<number>);
  32184. get cull(): Nullable<boolean>;
  32185. set cull(value: Nullable<boolean>);
  32186. get depthFunc(): Nullable<number>;
  32187. set depthFunc(value: Nullable<number>);
  32188. get depthMask(): boolean;
  32189. set depthMask(value: boolean);
  32190. get depthTest(): boolean;
  32191. set depthTest(value: boolean);
  32192. get frontFace(): Nullable<number>;
  32193. set frontFace(value: Nullable<number>);
  32194. reset(): void;
  32195. apply(gl: WebGLRenderingContext): void;
  32196. }
  32197. }
  32198. declare module "babylonjs/States/stencilState" {
  32199. /**
  32200. * @hidden
  32201. **/
  32202. export class StencilState {
  32203. /** 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 */
  32204. static readonly ALWAYS: number;
  32205. /** Passed to stencilOperation to specify that stencil value must be kept */
  32206. static readonly KEEP: number;
  32207. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32208. static readonly REPLACE: number;
  32209. private _isStencilTestDirty;
  32210. private _isStencilMaskDirty;
  32211. private _isStencilFuncDirty;
  32212. private _isStencilOpDirty;
  32213. private _stencilTest;
  32214. private _stencilMask;
  32215. private _stencilFunc;
  32216. private _stencilFuncRef;
  32217. private _stencilFuncMask;
  32218. private _stencilOpStencilFail;
  32219. private _stencilOpDepthFail;
  32220. private _stencilOpStencilDepthPass;
  32221. get isDirty(): boolean;
  32222. get stencilFunc(): number;
  32223. set stencilFunc(value: number);
  32224. get stencilFuncRef(): number;
  32225. set stencilFuncRef(value: number);
  32226. get stencilFuncMask(): number;
  32227. set stencilFuncMask(value: number);
  32228. get stencilOpStencilFail(): number;
  32229. set stencilOpStencilFail(value: number);
  32230. get stencilOpDepthFail(): number;
  32231. set stencilOpDepthFail(value: number);
  32232. get stencilOpStencilDepthPass(): number;
  32233. set stencilOpStencilDepthPass(value: number);
  32234. get stencilMask(): number;
  32235. set stencilMask(value: number);
  32236. get stencilTest(): boolean;
  32237. set stencilTest(value: boolean);
  32238. constructor();
  32239. reset(): void;
  32240. apply(gl: WebGLRenderingContext): void;
  32241. }
  32242. }
  32243. declare module "babylonjs/States/alphaCullingState" {
  32244. /**
  32245. * @hidden
  32246. **/
  32247. export class AlphaState {
  32248. private _isAlphaBlendDirty;
  32249. private _isBlendFunctionParametersDirty;
  32250. private _isBlendEquationParametersDirty;
  32251. private _isBlendConstantsDirty;
  32252. private _alphaBlend;
  32253. private _blendFunctionParameters;
  32254. private _blendEquationParameters;
  32255. private _blendConstants;
  32256. /**
  32257. * Initializes the state.
  32258. */
  32259. constructor();
  32260. get isDirty(): boolean;
  32261. get alphaBlend(): boolean;
  32262. set alphaBlend(value: boolean);
  32263. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32264. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32265. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32266. reset(): void;
  32267. apply(gl: WebGLRenderingContext): void;
  32268. }
  32269. }
  32270. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32271. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32272. /** @hidden */
  32273. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32274. attributeProcessor(attribute: string): string;
  32275. varyingProcessor(varying: string, isFragment: boolean): string;
  32276. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32277. }
  32278. }
  32279. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32280. /**
  32281. * Interface for attribute information associated with buffer instanciation
  32282. */
  32283. export interface InstancingAttributeInfo {
  32284. /**
  32285. * Name of the GLSL attribute
  32286. * if attribute index is not specified, this is used to retrieve the index from the effect
  32287. */
  32288. attributeName: string;
  32289. /**
  32290. * Index/offset of the attribute in the vertex shader
  32291. * if not specified, this will be computes from the name.
  32292. */
  32293. index?: number;
  32294. /**
  32295. * size of the attribute, 1, 2, 3 or 4
  32296. */
  32297. attributeSize: number;
  32298. /**
  32299. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32300. */
  32301. offset: number;
  32302. /**
  32303. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32304. * default to 1
  32305. */
  32306. divisor?: number;
  32307. /**
  32308. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32309. * default is FLOAT
  32310. */
  32311. attributeType?: number;
  32312. /**
  32313. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32314. */
  32315. normalized?: boolean;
  32316. }
  32317. }
  32318. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32319. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32320. import { Nullable } from "babylonjs/types";
  32321. module "babylonjs/Engines/thinEngine" {
  32322. interface ThinEngine {
  32323. /**
  32324. * Update a video texture
  32325. * @param texture defines the texture to update
  32326. * @param video defines the video element to use
  32327. * @param invertY defines if data must be stored with Y axis inverted
  32328. */
  32329. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32330. }
  32331. }
  32332. }
  32333. declare module "babylonjs/Materials/Textures/videoTexture" {
  32334. import { Observable } from "babylonjs/Misc/observable";
  32335. import { Nullable } from "babylonjs/types";
  32336. import { Scene } from "babylonjs/scene";
  32337. import { Texture } from "babylonjs/Materials/Textures/texture";
  32338. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32339. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32340. /**
  32341. * Settings for finer control over video usage
  32342. */
  32343. export interface VideoTextureSettings {
  32344. /**
  32345. * Applies `autoplay` to video, if specified
  32346. */
  32347. autoPlay?: boolean;
  32348. /**
  32349. * Applies `loop` to video, if specified
  32350. */
  32351. loop?: boolean;
  32352. /**
  32353. * Automatically updates internal texture from video at every frame in the render loop
  32354. */
  32355. autoUpdateTexture: boolean;
  32356. /**
  32357. * Image src displayed during the video loading or until the user interacts with the video.
  32358. */
  32359. poster?: string;
  32360. }
  32361. /**
  32362. * If you want to display a video in your scene, this is the special texture for that.
  32363. * This special texture works similar to other textures, with the exception of a few parameters.
  32364. * @see https://doc.babylonjs.com/how_to/video_texture
  32365. */
  32366. export class VideoTexture extends Texture {
  32367. /**
  32368. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32369. */
  32370. readonly autoUpdateTexture: boolean;
  32371. /**
  32372. * The video instance used by the texture internally
  32373. */
  32374. readonly video: HTMLVideoElement;
  32375. private _onUserActionRequestedObservable;
  32376. /**
  32377. * Event triggerd when a dom action is required by the user to play the video.
  32378. * This happens due to recent changes in browser policies preventing video to auto start.
  32379. */
  32380. get onUserActionRequestedObservable(): Observable<Texture>;
  32381. private _generateMipMaps;
  32382. private _stillImageCaptured;
  32383. private _displayingPosterTexture;
  32384. private _settings;
  32385. private _createInternalTextureOnEvent;
  32386. private _frameId;
  32387. private _currentSrc;
  32388. /**
  32389. * Creates a video texture.
  32390. * If you want to display a video in your scene, this is the special texture for that.
  32391. * This special texture works similar to other textures, with the exception of a few parameters.
  32392. * @see https://doc.babylonjs.com/how_to/video_texture
  32393. * @param name optional name, will detect from video source, if not defined
  32394. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32395. * @param scene is obviously the current scene.
  32396. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32397. * @param invertY is false by default but can be used to invert video on Y axis
  32398. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32399. * @param settings allows finer control over video usage
  32400. */
  32401. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32402. private _getName;
  32403. private _getVideo;
  32404. private _createInternalTexture;
  32405. private reset;
  32406. /**
  32407. * @hidden Internal method to initiate `update`.
  32408. */
  32409. _rebuild(): void;
  32410. /**
  32411. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32412. */
  32413. update(): void;
  32414. /**
  32415. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32416. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32417. */
  32418. updateTexture(isVisible: boolean): void;
  32419. protected _updateInternalTexture: () => void;
  32420. /**
  32421. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32422. * @param url New url.
  32423. */
  32424. updateURL(url: string): void;
  32425. /**
  32426. * Clones the texture.
  32427. * @returns the cloned texture
  32428. */
  32429. clone(): VideoTexture;
  32430. /**
  32431. * Dispose the texture and release its associated resources.
  32432. */
  32433. dispose(): void;
  32434. /**
  32435. * Creates a video texture straight from a stream.
  32436. * @param scene Define the scene the texture should be created in
  32437. * @param stream Define the stream the texture should be created from
  32438. * @returns The created video texture as a promise
  32439. */
  32440. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32441. /**
  32442. * Creates a video texture straight from your WebCam video feed.
  32443. * @param scene Define the scene the texture should be created in
  32444. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32445. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32446. * @returns The created video texture as a promise
  32447. */
  32448. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32449. minWidth: number;
  32450. maxWidth: number;
  32451. minHeight: number;
  32452. maxHeight: number;
  32453. deviceId: string;
  32454. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32455. /**
  32456. * Creates a video texture straight from your WebCam video feed.
  32457. * @param scene Define the scene the texture should be created in
  32458. * @param onReady Define a callback to triggered once the texture will be ready
  32459. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32460. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32461. */
  32462. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32463. minWidth: number;
  32464. maxWidth: number;
  32465. minHeight: number;
  32466. maxHeight: number;
  32467. deviceId: string;
  32468. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32469. }
  32470. }
  32471. declare module "babylonjs/Engines/thinEngine" {
  32472. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32473. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32474. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32475. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32476. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32477. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32478. import { Observable } from "babylonjs/Misc/observable";
  32479. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32480. import { StencilState } from "babylonjs/States/stencilState";
  32481. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32483. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32484. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32485. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32486. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32487. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32488. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32489. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32491. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32493. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32494. import { WebRequest } from "babylonjs/Misc/webRequest";
  32495. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32496. /**
  32497. * Defines the interface used by objects working like Scene
  32498. * @hidden
  32499. */
  32500. export interface ISceneLike {
  32501. _addPendingData(data: any): void;
  32502. _removePendingData(data: any): void;
  32503. offlineProvider: IOfflineProvider;
  32504. }
  32505. /** Interface defining initialization parameters for Engine class */
  32506. export interface EngineOptions extends WebGLContextAttributes {
  32507. /**
  32508. * Defines if the engine should no exceed a specified device ratio
  32509. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32510. */
  32511. limitDeviceRatio?: number;
  32512. /**
  32513. * Defines if webvr should be enabled automatically
  32514. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32515. */
  32516. autoEnableWebVR?: boolean;
  32517. /**
  32518. * Defines if webgl2 should be turned off even if supported
  32519. * @see http://doc.babylonjs.com/features/webgl2
  32520. */
  32521. disableWebGL2Support?: boolean;
  32522. /**
  32523. * Defines if webaudio should be initialized as well
  32524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32525. */
  32526. audioEngine?: boolean;
  32527. /**
  32528. * Defines if animations should run using a deterministic lock step
  32529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32530. */
  32531. deterministicLockstep?: boolean;
  32532. /** Defines the maximum steps to use with deterministic lock step mode */
  32533. lockstepMaxSteps?: number;
  32534. /** Defines the seconds between each deterministic lock step */
  32535. timeStep?: number;
  32536. /**
  32537. * Defines that engine should ignore context lost events
  32538. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32539. */
  32540. doNotHandleContextLost?: boolean;
  32541. /**
  32542. * Defines that engine should ignore modifying touch action attribute and style
  32543. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32544. */
  32545. doNotHandleTouchAction?: boolean;
  32546. /**
  32547. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32548. */
  32549. useHighPrecisionFloats?: boolean;
  32550. }
  32551. /**
  32552. * The base engine class (root of all engines)
  32553. */
  32554. export class ThinEngine {
  32555. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32556. static ExceptionList: ({
  32557. key: string;
  32558. capture: string;
  32559. captureConstraint: number;
  32560. targets: string[];
  32561. } | {
  32562. key: string;
  32563. capture: null;
  32564. captureConstraint: null;
  32565. targets: string[];
  32566. })[];
  32567. /** @hidden */
  32568. static _TextureLoaders: IInternalTextureLoader[];
  32569. /**
  32570. * Returns the current npm package of the sdk
  32571. */
  32572. static get NpmPackage(): string;
  32573. /**
  32574. * Returns the current version of the framework
  32575. */
  32576. static get Version(): string;
  32577. /**
  32578. * Returns a string describing the current engine
  32579. */
  32580. get description(): string;
  32581. /**
  32582. * Gets or sets the epsilon value used by collision engine
  32583. */
  32584. static CollisionsEpsilon: number;
  32585. /**
  32586. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32587. */
  32588. static get ShadersRepository(): string;
  32589. static set ShadersRepository(value: string);
  32590. /** @hidden */
  32591. _shaderProcessor: IShaderProcessor;
  32592. /**
  32593. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32594. */
  32595. forcePOTTextures: boolean;
  32596. /**
  32597. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32598. */
  32599. isFullscreen: boolean;
  32600. /**
  32601. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32602. */
  32603. cullBackFaces: boolean;
  32604. /**
  32605. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32606. */
  32607. renderEvenInBackground: boolean;
  32608. /**
  32609. * Gets or sets a boolean indicating that cache can be kept between frames
  32610. */
  32611. preventCacheWipeBetweenFrames: boolean;
  32612. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32613. validateShaderPrograms: boolean;
  32614. /**
  32615. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32616. * This can provide greater z depth for distant objects.
  32617. */
  32618. useReverseDepthBuffer: boolean;
  32619. /**
  32620. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32621. */
  32622. disableUniformBuffers: boolean;
  32623. /** @hidden */
  32624. _uniformBuffers: UniformBuffer[];
  32625. /**
  32626. * Gets a boolean indicating that the engine supports uniform buffers
  32627. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32628. */
  32629. get supportsUniformBuffers(): boolean;
  32630. /** @hidden */
  32631. _gl: WebGLRenderingContext;
  32632. /** @hidden */
  32633. _webGLVersion: number;
  32634. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32635. protected _windowIsBackground: boolean;
  32636. protected _creationOptions: EngineOptions;
  32637. protected _highPrecisionShadersAllowed: boolean;
  32638. /** @hidden */
  32639. get _shouldUseHighPrecisionShader(): boolean;
  32640. /**
  32641. * Gets a boolean indicating that only power of 2 textures are supported
  32642. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32643. */
  32644. get needPOTTextures(): boolean;
  32645. /** @hidden */
  32646. _badOS: boolean;
  32647. /** @hidden */
  32648. _badDesktopOS: boolean;
  32649. private _hardwareScalingLevel;
  32650. /** @hidden */
  32651. _caps: EngineCapabilities;
  32652. private _isStencilEnable;
  32653. private _glVersion;
  32654. private _glRenderer;
  32655. private _glVendor;
  32656. /** @hidden */
  32657. _videoTextureSupported: boolean;
  32658. protected _renderingQueueLaunched: boolean;
  32659. protected _activeRenderLoops: (() => void)[];
  32660. /**
  32661. * Observable signaled when a context lost event is raised
  32662. */
  32663. onContextLostObservable: Observable<ThinEngine>;
  32664. /**
  32665. * Observable signaled when a context restored event is raised
  32666. */
  32667. onContextRestoredObservable: Observable<ThinEngine>;
  32668. private _onContextLost;
  32669. private _onContextRestored;
  32670. protected _contextWasLost: boolean;
  32671. /** @hidden */
  32672. _doNotHandleContextLost: boolean;
  32673. /**
  32674. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32676. */
  32677. get doNotHandleContextLost(): boolean;
  32678. set doNotHandleContextLost(value: boolean);
  32679. /**
  32680. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32681. */
  32682. disableVertexArrayObjects: boolean;
  32683. /** @hidden */
  32684. protected _colorWrite: boolean;
  32685. /** @hidden */
  32686. protected _colorWriteChanged: boolean;
  32687. /** @hidden */
  32688. protected _depthCullingState: DepthCullingState;
  32689. /** @hidden */
  32690. protected _stencilState: StencilState;
  32691. /** @hidden */
  32692. _alphaState: AlphaState;
  32693. /** @hidden */
  32694. _alphaMode: number;
  32695. /** @hidden */
  32696. _alphaEquation: number;
  32697. /** @hidden */
  32698. _internalTexturesCache: InternalTexture[];
  32699. /** @hidden */
  32700. protected _activeChannel: number;
  32701. private _currentTextureChannel;
  32702. /** @hidden */
  32703. protected _boundTexturesCache: {
  32704. [key: string]: Nullable<InternalTexture>;
  32705. };
  32706. /** @hidden */
  32707. protected _currentEffect: Nullable<Effect>;
  32708. /** @hidden */
  32709. protected _currentProgram: Nullable<WebGLProgram>;
  32710. private _compiledEffects;
  32711. private _vertexAttribArraysEnabled;
  32712. /** @hidden */
  32713. protected _cachedViewport: Nullable<IViewportLike>;
  32714. private _cachedVertexArrayObject;
  32715. /** @hidden */
  32716. protected _cachedVertexBuffers: any;
  32717. /** @hidden */
  32718. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32719. /** @hidden */
  32720. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32721. /** @hidden */
  32722. _currentRenderTarget: Nullable<InternalTexture>;
  32723. private _uintIndicesCurrentlySet;
  32724. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32725. /** @hidden */
  32726. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32727. /** @hidden */
  32728. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  32729. private _currentBufferPointers;
  32730. private _currentInstanceLocations;
  32731. private _currentInstanceBuffers;
  32732. private _textureUnits;
  32733. /** @hidden */
  32734. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32735. /** @hidden */
  32736. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32737. /** @hidden */
  32738. _boundRenderFunction: any;
  32739. private _vaoRecordInProgress;
  32740. private _mustWipeVertexAttributes;
  32741. private _emptyTexture;
  32742. private _emptyCubeTexture;
  32743. private _emptyTexture3D;
  32744. private _emptyTexture2DArray;
  32745. /** @hidden */
  32746. _frameHandler: number;
  32747. private _nextFreeTextureSlots;
  32748. private _maxSimultaneousTextures;
  32749. private _activeRequests;
  32750. /** @hidden */
  32751. _transformTextureUrl: Nullable<(url: string) => string>;
  32752. protected get _supportsHardwareTextureRescaling(): boolean;
  32753. private _framebufferDimensionsObject;
  32754. /**
  32755. * sets the object from which width and height will be taken from when getting render width and height
  32756. * Will fallback to the gl object
  32757. * @param dimensions the framebuffer width and height that will be used.
  32758. */
  32759. set framebufferDimensionsObject(dimensions: Nullable<{
  32760. framebufferWidth: number;
  32761. framebufferHeight: number;
  32762. }>);
  32763. /**
  32764. * Gets the current viewport
  32765. */
  32766. get currentViewport(): Nullable<IViewportLike>;
  32767. /**
  32768. * Gets the default empty texture
  32769. */
  32770. get emptyTexture(): InternalTexture;
  32771. /**
  32772. * Gets the default empty 3D texture
  32773. */
  32774. get emptyTexture3D(): InternalTexture;
  32775. /**
  32776. * Gets the default empty 2D array texture
  32777. */
  32778. get emptyTexture2DArray(): InternalTexture;
  32779. /**
  32780. * Gets the default empty cube texture
  32781. */
  32782. get emptyCubeTexture(): InternalTexture;
  32783. /**
  32784. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32785. */
  32786. readonly premultipliedAlpha: boolean;
  32787. /**
  32788. * Observable event triggered before each texture is initialized
  32789. */
  32790. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32791. /**
  32792. * Creates a new engine
  32793. * @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
  32794. * @param antialias defines enable antialiasing (default: false)
  32795. * @param options defines further options to be sent to the getContext() function
  32796. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32797. */
  32798. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32799. private _rebuildInternalTextures;
  32800. private _rebuildEffects;
  32801. /**
  32802. * Gets a boolean indicating if all created effects are ready
  32803. * @returns true if all effects are ready
  32804. */
  32805. areAllEffectsReady(): boolean;
  32806. protected _rebuildBuffers(): void;
  32807. protected _initGLContext(): void;
  32808. /**
  32809. * Gets version of the current webGL context
  32810. */
  32811. get webGLVersion(): number;
  32812. /**
  32813. * Gets a string idenfifying the name of the class
  32814. * @returns "Engine" string
  32815. */
  32816. getClassName(): string;
  32817. /**
  32818. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32819. */
  32820. get isStencilEnable(): boolean;
  32821. /** @hidden */
  32822. _prepareWorkingCanvas(): void;
  32823. /**
  32824. * Reset the texture cache to empty state
  32825. */
  32826. resetTextureCache(): void;
  32827. /**
  32828. * Gets an object containing information about the current webGL context
  32829. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32830. */
  32831. getGlInfo(): {
  32832. vendor: string;
  32833. renderer: string;
  32834. version: string;
  32835. };
  32836. /**
  32837. * Defines the hardware scaling level.
  32838. * By default the hardware scaling level is computed from the window device ratio.
  32839. * 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.
  32840. * @param level defines the level to use
  32841. */
  32842. setHardwareScalingLevel(level: number): void;
  32843. /**
  32844. * Gets the current hardware scaling level.
  32845. * By default the hardware scaling level is computed from the window device ratio.
  32846. * 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.
  32847. * @returns a number indicating the current hardware scaling level
  32848. */
  32849. getHardwareScalingLevel(): number;
  32850. /**
  32851. * Gets the list of loaded textures
  32852. * @returns an array containing all loaded textures
  32853. */
  32854. getLoadedTexturesCache(): InternalTexture[];
  32855. /**
  32856. * Gets the object containing all engine capabilities
  32857. * @returns the EngineCapabilities object
  32858. */
  32859. getCaps(): EngineCapabilities;
  32860. /**
  32861. * stop executing a render loop function and remove it from the execution array
  32862. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32863. */
  32864. stopRenderLoop(renderFunction?: () => void): void;
  32865. /** @hidden */
  32866. _renderLoop(): void;
  32867. /**
  32868. * Gets the HTML canvas attached with the current webGL context
  32869. * @returns a HTML canvas
  32870. */
  32871. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32872. /**
  32873. * Gets host window
  32874. * @returns the host window object
  32875. */
  32876. getHostWindow(): Nullable<Window>;
  32877. /**
  32878. * Gets the current render width
  32879. * @param useScreen defines if screen size must be used (or the current render target if any)
  32880. * @returns a number defining the current render width
  32881. */
  32882. getRenderWidth(useScreen?: boolean): number;
  32883. /**
  32884. * Gets the current render height
  32885. * @param useScreen defines if screen size must be used (or the current render target if any)
  32886. * @returns a number defining the current render height
  32887. */
  32888. getRenderHeight(useScreen?: boolean): number;
  32889. /**
  32890. * Can be used to override the current requestAnimationFrame requester.
  32891. * @hidden
  32892. */
  32893. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32894. /**
  32895. * Register and execute a render loop. The engine can have more than one render function
  32896. * @param renderFunction defines the function to continuously execute
  32897. */
  32898. runRenderLoop(renderFunction: () => void): void;
  32899. /**
  32900. * Clear the current render buffer or the current render target (if any is set up)
  32901. * @param color defines the color to use
  32902. * @param backBuffer defines if the back buffer must be cleared
  32903. * @param depth defines if the depth buffer must be cleared
  32904. * @param stencil defines if the stencil buffer must be cleared
  32905. */
  32906. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32907. private _viewportCached;
  32908. /** @hidden */
  32909. _viewport(x: number, y: number, width: number, height: number): void;
  32910. /**
  32911. * Set the WebGL's viewport
  32912. * @param viewport defines the viewport element to be used
  32913. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32914. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32915. */
  32916. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32917. /**
  32918. * Begin a new frame
  32919. */
  32920. beginFrame(): void;
  32921. /**
  32922. * Enf the current frame
  32923. */
  32924. endFrame(): void;
  32925. /**
  32926. * Resize the view according to the canvas' size
  32927. */
  32928. resize(): void;
  32929. /**
  32930. * Force a specific size of the canvas
  32931. * @param width defines the new canvas' width
  32932. * @param height defines the new canvas' height
  32933. */
  32934. setSize(width: number, height: number): void;
  32935. /**
  32936. * Binds the frame buffer to the specified texture.
  32937. * @param texture The texture to render to or null for the default canvas
  32938. * @param faceIndex The face of the texture to render to in case of cube texture
  32939. * @param requiredWidth The width of the target to render to
  32940. * @param requiredHeight The height of the target to render to
  32941. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32942. * @param lodLevel defines the lod level to bind to the frame buffer
  32943. * @param layer defines the 2d array index to bind to frame buffer to
  32944. */
  32945. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32946. /** @hidden */
  32947. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32948. /**
  32949. * Unbind the current render target texture from the webGL context
  32950. * @param texture defines the render target texture to unbind
  32951. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32952. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32953. */
  32954. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32955. /**
  32956. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32957. */
  32958. flushFramebuffer(): void;
  32959. /**
  32960. * Unbind the current render target and bind the default framebuffer
  32961. */
  32962. restoreDefaultFramebuffer(): void;
  32963. /** @hidden */
  32964. protected _resetVertexBufferBinding(): void;
  32965. /**
  32966. * Creates a vertex buffer
  32967. * @param data the data for the vertex buffer
  32968. * @returns the new WebGL static buffer
  32969. */
  32970. createVertexBuffer(data: DataArray): DataBuffer;
  32971. private _createVertexBuffer;
  32972. /**
  32973. * Creates a dynamic vertex buffer
  32974. * @param data the data for the dynamic vertex buffer
  32975. * @returns the new WebGL dynamic buffer
  32976. */
  32977. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32978. protected _resetIndexBufferBinding(): void;
  32979. /**
  32980. * Creates a new index buffer
  32981. * @param indices defines the content of the index buffer
  32982. * @param updatable defines if the index buffer must be updatable
  32983. * @returns a new webGL buffer
  32984. */
  32985. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32986. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32987. /**
  32988. * Bind a webGL buffer to the webGL context
  32989. * @param buffer defines the buffer to bind
  32990. */
  32991. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32992. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32993. private bindBuffer;
  32994. /**
  32995. * update the bound buffer with the given data
  32996. * @param data defines the data to update
  32997. */
  32998. updateArrayBuffer(data: Float32Array): void;
  32999. private _vertexAttribPointer;
  33000. /** @hidden */
  33001. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  33002. private _bindVertexBuffersAttributes;
  33003. /**
  33004. * Records a vertex array object
  33005. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33006. * @param vertexBuffers defines the list of vertex buffers to store
  33007. * @param indexBuffer defines the index buffer to store
  33008. * @param effect defines the effect to store
  33009. * @returns the new vertex array object
  33010. */
  33011. recordVertexArrayObject(vertexBuffers: {
  33012. [key: string]: VertexBuffer;
  33013. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  33014. /**
  33015. * Bind a specific vertex array object
  33016. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  33017. * @param vertexArrayObject defines the vertex array object to bind
  33018. * @param indexBuffer defines the index buffer to bind
  33019. */
  33020. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  33021. /**
  33022. * Bind webGl buffers directly to the webGL context
  33023. * @param vertexBuffer defines the vertex buffer to bind
  33024. * @param indexBuffer defines the index buffer to bind
  33025. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  33026. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  33027. * @param effect defines the effect associated with the vertex buffer
  33028. */
  33029. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  33030. private _unbindVertexArrayObject;
  33031. /**
  33032. * Bind a list of vertex buffers to the webGL context
  33033. * @param vertexBuffers defines the list of vertex buffers to bind
  33034. * @param indexBuffer defines the index buffer to bind
  33035. * @param effect defines the effect associated with the vertex buffers
  33036. */
  33037. bindBuffers(vertexBuffers: {
  33038. [key: string]: Nullable<VertexBuffer>;
  33039. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33040. /**
  33041. * Unbind all instance attributes
  33042. */
  33043. unbindInstanceAttributes(): void;
  33044. /**
  33045. * Release and free the memory of a vertex array object
  33046. * @param vao defines the vertex array object to delete
  33047. */
  33048. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33049. /** @hidden */
  33050. _releaseBuffer(buffer: DataBuffer): boolean;
  33051. protected _deleteBuffer(buffer: DataBuffer): void;
  33052. /**
  33053. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33054. * @param instancesBuffer defines the webGL buffer to update and bind
  33055. * @param data defines the data to store in the buffer
  33056. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33057. */
  33058. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33059. /**
  33060. * Bind the content of a webGL buffer used with instantiation
  33061. * @param instancesBuffer defines the webGL buffer to bind
  33062. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33063. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33064. */
  33065. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33066. /**
  33067. * Disable the instance attribute corresponding to the name in parameter
  33068. * @param name defines the name of the attribute to disable
  33069. */
  33070. disableInstanceAttributeByName(name: string): void;
  33071. /**
  33072. * Disable the instance attribute corresponding to the location in parameter
  33073. * @param attributeLocation defines the attribute location of the attribute to disable
  33074. */
  33075. disableInstanceAttribute(attributeLocation: number): void;
  33076. /**
  33077. * Disable the attribute corresponding to the location in parameter
  33078. * @param attributeLocation defines the attribute location of the attribute to disable
  33079. */
  33080. disableAttributeByIndex(attributeLocation: number): void;
  33081. /**
  33082. * Send a draw order
  33083. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33084. * @param indexStart defines the starting index
  33085. * @param indexCount defines the number of index to draw
  33086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33087. */
  33088. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33089. /**
  33090. * Draw a list of points
  33091. * @param verticesStart defines the index of first vertex to draw
  33092. * @param verticesCount defines the count of vertices to draw
  33093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33094. */
  33095. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33096. /**
  33097. * Draw a list of unindexed primitives
  33098. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33099. * @param verticesStart defines the index of first vertex to draw
  33100. * @param verticesCount defines the count of vertices to draw
  33101. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33102. */
  33103. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33104. /**
  33105. * Draw a list of indexed primitives
  33106. * @param fillMode defines the primitive to use
  33107. * @param indexStart defines the starting index
  33108. * @param indexCount defines the number of index to draw
  33109. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33110. */
  33111. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33112. /**
  33113. * Draw a list of unindexed primitives
  33114. * @param fillMode defines the primitive to use
  33115. * @param verticesStart defines the index of first vertex to draw
  33116. * @param verticesCount defines the count of vertices to draw
  33117. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33118. */
  33119. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33120. private _drawMode;
  33121. /** @hidden */
  33122. protected _reportDrawCall(): void;
  33123. /** @hidden */
  33124. _releaseEffect(effect: Effect): void;
  33125. /** @hidden */
  33126. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33127. /**
  33128. * Create a new effect (used to store vertex/fragment shaders)
  33129. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33130. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33131. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33132. * @param samplers defines an array of string used to represent textures
  33133. * @param defines defines the string containing the defines to use to compile the shaders
  33134. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33135. * @param onCompiled defines a function to call when the effect creation is successful
  33136. * @param onError defines a function to call when the effect creation has failed
  33137. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33138. * @returns the new Effect
  33139. */
  33140. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  33141. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33142. private _compileShader;
  33143. private _compileRawShader;
  33144. /** @hidden */
  33145. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33146. /**
  33147. * Directly creates a webGL program
  33148. * @param pipelineContext defines the pipeline context to attach to
  33149. * @param vertexCode defines the vertex shader code to use
  33150. * @param fragmentCode defines the fragment shader code to use
  33151. * @param context defines the webGL context to use (if not set, the current one will be used)
  33152. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33153. * @returns the new webGL program
  33154. */
  33155. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33156. /**
  33157. * Creates a webGL program
  33158. * @param pipelineContext defines the pipeline context to attach to
  33159. * @param vertexCode defines the vertex shader code to use
  33160. * @param fragmentCode defines the fragment shader code to use
  33161. * @param defines defines the string containing the defines to use to compile the shaders
  33162. * @param context defines the webGL context to use (if not set, the current one will be used)
  33163. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33164. * @returns the new webGL program
  33165. */
  33166. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33167. /**
  33168. * Creates a new pipeline context
  33169. * @returns the new pipeline
  33170. */
  33171. createPipelineContext(): IPipelineContext;
  33172. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33173. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33174. /** @hidden */
  33175. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33176. /** @hidden */
  33177. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33178. /** @hidden */
  33179. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33180. /**
  33181. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33182. * @param pipelineContext defines the pipeline context to use
  33183. * @param uniformsNames defines the list of uniform names
  33184. * @returns an array of webGL uniform locations
  33185. */
  33186. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33187. /**
  33188. * Gets the lsit of active attributes for a given webGL program
  33189. * @param pipelineContext defines the pipeline context to use
  33190. * @param attributesNames defines the list of attribute names to get
  33191. * @returns an array of indices indicating the offset of each attribute
  33192. */
  33193. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33194. /**
  33195. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33196. * @param effect defines the effect to activate
  33197. */
  33198. enableEffect(effect: Nullable<Effect>): void;
  33199. /**
  33200. * Set the value of an uniform to a number (int)
  33201. * @param uniform defines the webGL uniform location where to store the value
  33202. * @param value defines the int number to store
  33203. */
  33204. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33205. /**
  33206. * Set the value of an uniform to an array of int32
  33207. * @param uniform defines the webGL uniform location where to store the value
  33208. * @param array defines the array of int32 to store
  33209. */
  33210. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33211. /**
  33212. * Set the value of an uniform to an array of int32 (stored as vec2)
  33213. * @param uniform defines the webGL uniform location where to store the value
  33214. * @param array defines the array of int32 to store
  33215. */
  33216. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33217. /**
  33218. * Set the value of an uniform to an array of int32 (stored as vec3)
  33219. * @param uniform defines the webGL uniform location where to store the value
  33220. * @param array defines the array of int32 to store
  33221. */
  33222. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33223. /**
  33224. * Set the value of an uniform to an array of int32 (stored as vec4)
  33225. * @param uniform defines the webGL uniform location where to store the value
  33226. * @param array defines the array of int32 to store
  33227. */
  33228. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33229. /**
  33230. * Set the value of an uniform to an array of number
  33231. * @param uniform defines the webGL uniform location where to store the value
  33232. * @param array defines the array of number to store
  33233. */
  33234. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33235. /**
  33236. * Set the value of an uniform to an array of number (stored as vec2)
  33237. * @param uniform defines the webGL uniform location where to store the value
  33238. * @param array defines the array of number to store
  33239. */
  33240. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33241. /**
  33242. * Set the value of an uniform to an array of number (stored as vec3)
  33243. * @param uniform defines the webGL uniform location where to store the value
  33244. * @param array defines the array of number to store
  33245. */
  33246. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33247. /**
  33248. * Set the value of an uniform to an array of number (stored as vec4)
  33249. * @param uniform defines the webGL uniform location where to store the value
  33250. * @param array defines the array of number to store
  33251. */
  33252. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33253. /**
  33254. * Set the value of an uniform to an array of float32 (stored as matrices)
  33255. * @param uniform defines the webGL uniform location where to store the value
  33256. * @param matrices defines the array of float32 to store
  33257. */
  33258. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33259. /**
  33260. * Set the value of an uniform to a matrix (3x3)
  33261. * @param uniform defines the webGL uniform location where to store the value
  33262. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33263. */
  33264. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33265. /**
  33266. * Set the value of an uniform to a matrix (2x2)
  33267. * @param uniform defines the webGL uniform location where to store the value
  33268. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33269. */
  33270. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33271. /**
  33272. * Set the value of an uniform to a number (float)
  33273. * @param uniform defines the webGL uniform location where to store the value
  33274. * @param value defines the float number to store
  33275. */
  33276. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33277. /**
  33278. * Set the value of an uniform to a vec2
  33279. * @param uniform defines the webGL uniform location where to store the value
  33280. * @param x defines the 1st component of the value
  33281. * @param y defines the 2nd component of the value
  33282. */
  33283. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33284. /**
  33285. * Set the value of an uniform to a vec3
  33286. * @param uniform defines the webGL uniform location where to store the value
  33287. * @param x defines the 1st component of the value
  33288. * @param y defines the 2nd component of the value
  33289. * @param z defines the 3rd component of the value
  33290. */
  33291. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33292. /**
  33293. * Set the value of an uniform to a vec4
  33294. * @param uniform defines the webGL uniform location where to store the value
  33295. * @param x defines the 1st component of the value
  33296. * @param y defines the 2nd component of the value
  33297. * @param z defines the 3rd component of the value
  33298. * @param w defines the 4th component of the value
  33299. */
  33300. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33301. /**
  33302. * Apply all cached states (depth, culling, stencil and alpha)
  33303. */
  33304. applyStates(): void;
  33305. /**
  33306. * Enable or disable color writing
  33307. * @param enable defines the state to set
  33308. */
  33309. setColorWrite(enable: boolean): void;
  33310. /**
  33311. * Gets a boolean indicating if color writing is enabled
  33312. * @returns the current color writing state
  33313. */
  33314. getColorWrite(): boolean;
  33315. /**
  33316. * Gets the depth culling state manager
  33317. */
  33318. get depthCullingState(): DepthCullingState;
  33319. /**
  33320. * Gets the alpha state manager
  33321. */
  33322. get alphaState(): AlphaState;
  33323. /**
  33324. * Gets the stencil state manager
  33325. */
  33326. get stencilState(): StencilState;
  33327. /**
  33328. * Clears the list of texture accessible through engine.
  33329. * This can help preventing texture load conflict due to name collision.
  33330. */
  33331. clearInternalTexturesCache(): void;
  33332. /**
  33333. * Force the entire cache to be cleared
  33334. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33335. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33336. */
  33337. wipeCaches(bruteForce?: boolean): void;
  33338. /** @hidden */
  33339. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33340. min: number;
  33341. mag: number;
  33342. };
  33343. /** @hidden */
  33344. _createTexture(): WebGLTexture;
  33345. /**
  33346. * Usually called from Texture.ts.
  33347. * Passed information to create a WebGLTexture
  33348. * @param url defines a value which contains one of the following:
  33349. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33350. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33351. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33352. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33353. * @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)
  33354. * @param scene needed for loading to the correct scene
  33355. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33356. * @param onLoad optional callback to be called upon successful completion
  33357. * @param onError optional callback to be called upon failure
  33358. * @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
  33359. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33360. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33361. * @param forcedExtension defines the extension to use to pick the right loader
  33362. * @param mimeType defines an optional mime type
  33363. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33364. */
  33365. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  33366. /**
  33367. * Loads an image as an HTMLImageElement.
  33368. * @param input url string, ArrayBuffer, or Blob to load
  33369. * @param onLoad callback called when the image successfully loads
  33370. * @param onError callback called when the image fails to load
  33371. * @param offlineProvider offline provider for caching
  33372. * @param mimeType optional mime type
  33373. * @returns the HTMLImageElement of the loaded image
  33374. * @hidden
  33375. */
  33376. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33377. /**
  33378. * @hidden
  33379. */
  33380. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33381. private _unpackFlipYCached;
  33382. /**
  33383. * In case you are sharing the context with other applications, it might
  33384. * be interested to not cache the unpack flip y state to ensure a consistent
  33385. * value would be set.
  33386. */
  33387. enableUnpackFlipYCached: boolean;
  33388. /** @hidden */
  33389. _unpackFlipY(value: boolean): void;
  33390. /** @hidden */
  33391. _getUnpackAlignement(): number;
  33392. private _getTextureTarget;
  33393. /**
  33394. * Update the sampling mode of a given texture
  33395. * @param samplingMode defines the required sampling mode
  33396. * @param texture defines the texture to update
  33397. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33398. */
  33399. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33400. /**
  33401. * Update the sampling mode of a given texture
  33402. * @param texture defines the texture to update
  33403. * @param wrapU defines the texture wrap mode of the u coordinates
  33404. * @param wrapV defines the texture wrap mode of the v coordinates
  33405. * @param wrapR defines the texture wrap mode of the r coordinates
  33406. */
  33407. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33408. /** @hidden */
  33409. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33410. width: number;
  33411. height: number;
  33412. layers?: number;
  33413. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33414. /** @hidden */
  33415. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33416. /** @hidden */
  33417. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33418. /**
  33419. * Update a portion of an internal texture
  33420. * @param texture defines the texture to update
  33421. * @param imageData defines the data to store into the texture
  33422. * @param xOffset defines the x coordinates of the update rectangle
  33423. * @param yOffset defines the y coordinates of the update rectangle
  33424. * @param width defines the width of the update rectangle
  33425. * @param height defines the height of the update rectangle
  33426. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33427. * @param lod defines the lod level to update (0 by default)
  33428. */
  33429. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33430. /** @hidden */
  33431. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33432. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33433. private _prepareWebGLTexture;
  33434. /** @hidden */
  33435. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33436. private _getDepthStencilBuffer;
  33437. /** @hidden */
  33438. _releaseFramebufferObjects(texture: InternalTexture): void;
  33439. /** @hidden */
  33440. _releaseTexture(texture: InternalTexture): void;
  33441. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33442. protected _setProgram(program: WebGLProgram): void;
  33443. protected _boundUniforms: {
  33444. [key: number]: WebGLUniformLocation;
  33445. };
  33446. /**
  33447. * Binds an effect to the webGL context
  33448. * @param effect defines the effect to bind
  33449. */
  33450. bindSamplers(effect: Effect): void;
  33451. private _activateCurrentTexture;
  33452. /** @hidden */
  33453. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33454. /** @hidden */
  33455. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33456. /**
  33457. * Unbind all textures from the webGL context
  33458. */
  33459. unbindAllTextures(): void;
  33460. /**
  33461. * Sets a texture to the according uniform.
  33462. * @param channel The texture channel
  33463. * @param uniform The uniform to set
  33464. * @param texture The texture to apply
  33465. */
  33466. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33467. private _bindSamplerUniformToChannel;
  33468. private _getTextureWrapMode;
  33469. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33470. /**
  33471. * Sets an array of texture to the webGL context
  33472. * @param channel defines the channel where the texture array must be set
  33473. * @param uniform defines the associated uniform location
  33474. * @param textures defines the array of textures to bind
  33475. */
  33476. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33477. /** @hidden */
  33478. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33479. private _setTextureParameterFloat;
  33480. private _setTextureParameterInteger;
  33481. /**
  33482. * Unbind all vertex attributes from the webGL context
  33483. */
  33484. unbindAllAttributes(): void;
  33485. /**
  33486. * 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
  33487. */
  33488. releaseEffects(): void;
  33489. /**
  33490. * Dispose and release all associated resources
  33491. */
  33492. dispose(): void;
  33493. /**
  33494. * Attach a new callback raised when context lost event is fired
  33495. * @param callback defines the callback to call
  33496. */
  33497. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33498. /**
  33499. * Attach a new callback raised when context restored event is fired
  33500. * @param callback defines the callback to call
  33501. */
  33502. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33503. /**
  33504. * Get the current error code of the webGL context
  33505. * @returns the error code
  33506. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33507. */
  33508. getError(): number;
  33509. private _canRenderToFloatFramebuffer;
  33510. private _canRenderToHalfFloatFramebuffer;
  33511. private _canRenderToFramebuffer;
  33512. /** @hidden */
  33513. _getWebGLTextureType(type: number): number;
  33514. /** @hidden */
  33515. _getInternalFormat(format: number): number;
  33516. /** @hidden */
  33517. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33518. /** @hidden */
  33519. _getRGBAMultiSampleBufferFormat(type: number): number;
  33520. /** @hidden */
  33521. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  33522. /**
  33523. * Loads a file from a url
  33524. * @param url url to load
  33525. * @param onSuccess callback called when the file successfully loads
  33526. * @param onProgress callback called while file is loading (if the server supports this mode)
  33527. * @param offlineProvider defines the offline provider for caching
  33528. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33529. * @param onError callback called when the file fails to load
  33530. * @returns a file request object
  33531. * @hidden
  33532. */
  33533. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  33534. /**
  33535. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33536. * @param x defines the x coordinate of the rectangle where pixels must be read
  33537. * @param y defines the y coordinate of the rectangle where pixels must be read
  33538. * @param width defines the width of the rectangle where pixels must be read
  33539. * @param height defines the height of the rectangle where pixels must be read
  33540. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33541. * @returns a Uint8Array containing RGBA colors
  33542. */
  33543. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33544. private static _isSupported;
  33545. /**
  33546. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33547. * @returns true if the engine can be created
  33548. * @ignorenaming
  33549. */
  33550. static isSupported(): boolean;
  33551. /**
  33552. * Find the next highest power of two.
  33553. * @param x Number to start search from.
  33554. * @return Next highest power of two.
  33555. */
  33556. static CeilingPOT(x: number): number;
  33557. /**
  33558. * Find the next lowest power of two.
  33559. * @param x Number to start search from.
  33560. * @return Next lowest power of two.
  33561. */
  33562. static FloorPOT(x: number): number;
  33563. /**
  33564. * Find the nearest power of two.
  33565. * @param x Number to start search from.
  33566. * @return Next nearest power of two.
  33567. */
  33568. static NearestPOT(x: number): number;
  33569. /**
  33570. * Get the closest exponent of two
  33571. * @param value defines the value to approximate
  33572. * @param max defines the maximum value to return
  33573. * @param mode defines how to define the closest value
  33574. * @returns closest exponent of two of the given value
  33575. */
  33576. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33577. /**
  33578. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33579. * @param func - the function to be called
  33580. * @param requester - the object that will request the next frame. Falls back to window.
  33581. * @returns frame number
  33582. */
  33583. static QueueNewFrame(func: () => void, requester?: any): number;
  33584. /**
  33585. * Gets host document
  33586. * @returns the host document object
  33587. */
  33588. getHostDocument(): Nullable<Document>;
  33589. }
  33590. }
  33591. declare module "babylonjs/Maths/sphericalPolynomial" {
  33592. import { Vector3 } from "babylonjs/Maths/math.vector";
  33593. import { Color3 } from "babylonjs/Maths/math.color";
  33594. /**
  33595. * Class representing spherical harmonics coefficients to the 3rd degree
  33596. */
  33597. export class SphericalHarmonics {
  33598. /**
  33599. * Defines whether or not the harmonics have been prescaled for rendering.
  33600. */
  33601. preScaled: boolean;
  33602. /**
  33603. * The l0,0 coefficients of the spherical harmonics
  33604. */
  33605. l00: Vector3;
  33606. /**
  33607. * The l1,-1 coefficients of the spherical harmonics
  33608. */
  33609. l1_1: Vector3;
  33610. /**
  33611. * The l1,0 coefficients of the spherical harmonics
  33612. */
  33613. l10: Vector3;
  33614. /**
  33615. * The l1,1 coefficients of the spherical harmonics
  33616. */
  33617. l11: Vector3;
  33618. /**
  33619. * The l2,-2 coefficients of the spherical harmonics
  33620. */
  33621. l2_2: Vector3;
  33622. /**
  33623. * The l2,-1 coefficients of the spherical harmonics
  33624. */
  33625. l2_1: Vector3;
  33626. /**
  33627. * The l2,0 coefficients of the spherical harmonics
  33628. */
  33629. l20: Vector3;
  33630. /**
  33631. * The l2,1 coefficients of the spherical harmonics
  33632. */
  33633. l21: Vector3;
  33634. /**
  33635. * The l2,2 coefficients of the spherical harmonics
  33636. */
  33637. l22: Vector3;
  33638. /**
  33639. * Adds a light to the spherical harmonics
  33640. * @param direction the direction of the light
  33641. * @param color the color of the light
  33642. * @param deltaSolidAngle the delta solid angle of the light
  33643. */
  33644. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33645. /**
  33646. * Scales the spherical harmonics by the given amount
  33647. * @param scale the amount to scale
  33648. */
  33649. scaleInPlace(scale: number): void;
  33650. /**
  33651. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33652. *
  33653. * ```
  33654. * E_lm = A_l * L_lm
  33655. * ```
  33656. *
  33657. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33658. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33659. * the scaling factors are given in equation 9.
  33660. */
  33661. convertIncidentRadianceToIrradiance(): void;
  33662. /**
  33663. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33664. *
  33665. * ```
  33666. * L = (1/pi) * E * rho
  33667. * ```
  33668. *
  33669. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33670. */
  33671. convertIrradianceToLambertianRadiance(): void;
  33672. /**
  33673. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33674. * required operations at run time.
  33675. *
  33676. * This is simply done by scaling back the SH with Ylm constants parameter.
  33677. * The trigonometric part being applied by the shader at run time.
  33678. */
  33679. preScaleForRendering(): void;
  33680. /**
  33681. * Constructs a spherical harmonics from an array.
  33682. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33683. * @returns the spherical harmonics
  33684. */
  33685. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33686. /**
  33687. * Gets the spherical harmonics from polynomial
  33688. * @param polynomial the spherical polynomial
  33689. * @returns the spherical harmonics
  33690. */
  33691. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33692. }
  33693. /**
  33694. * Class representing spherical polynomial coefficients to the 3rd degree
  33695. */
  33696. export class SphericalPolynomial {
  33697. private _harmonics;
  33698. /**
  33699. * The spherical harmonics used to create the polynomials.
  33700. */
  33701. get preScaledHarmonics(): SphericalHarmonics;
  33702. /**
  33703. * The x coefficients of the spherical polynomial
  33704. */
  33705. x: Vector3;
  33706. /**
  33707. * The y coefficients of the spherical polynomial
  33708. */
  33709. y: Vector3;
  33710. /**
  33711. * The z coefficients of the spherical polynomial
  33712. */
  33713. z: Vector3;
  33714. /**
  33715. * The xx coefficients of the spherical polynomial
  33716. */
  33717. xx: Vector3;
  33718. /**
  33719. * The yy coefficients of the spherical polynomial
  33720. */
  33721. yy: Vector3;
  33722. /**
  33723. * The zz coefficients of the spherical polynomial
  33724. */
  33725. zz: Vector3;
  33726. /**
  33727. * The xy coefficients of the spherical polynomial
  33728. */
  33729. xy: Vector3;
  33730. /**
  33731. * The yz coefficients of the spherical polynomial
  33732. */
  33733. yz: Vector3;
  33734. /**
  33735. * The zx coefficients of the spherical polynomial
  33736. */
  33737. zx: Vector3;
  33738. /**
  33739. * Adds an ambient color to the spherical polynomial
  33740. * @param color the color to add
  33741. */
  33742. addAmbient(color: Color3): void;
  33743. /**
  33744. * Scales the spherical polynomial by the given amount
  33745. * @param scale the amount to scale
  33746. */
  33747. scaleInPlace(scale: number): void;
  33748. /**
  33749. * Gets the spherical polynomial from harmonics
  33750. * @param harmonics the spherical harmonics
  33751. * @returns the spherical polynomial
  33752. */
  33753. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33754. /**
  33755. * Constructs a spherical polynomial from an array.
  33756. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33757. * @returns the spherical polynomial
  33758. */
  33759. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33760. }
  33761. }
  33762. declare module "babylonjs/Materials/Textures/internalTexture" {
  33763. import { Observable } from "babylonjs/Misc/observable";
  33764. import { Nullable, int } from "babylonjs/types";
  33765. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33767. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33768. /**
  33769. * Defines the source of the internal texture
  33770. */
  33771. export enum InternalTextureSource {
  33772. /**
  33773. * The source of the texture data is unknown
  33774. */
  33775. Unknown = 0,
  33776. /**
  33777. * Texture data comes from an URL
  33778. */
  33779. Url = 1,
  33780. /**
  33781. * Texture data is only used for temporary storage
  33782. */
  33783. Temp = 2,
  33784. /**
  33785. * Texture data comes from raw data (ArrayBuffer)
  33786. */
  33787. Raw = 3,
  33788. /**
  33789. * Texture content is dynamic (video or dynamic texture)
  33790. */
  33791. Dynamic = 4,
  33792. /**
  33793. * Texture content is generated by rendering to it
  33794. */
  33795. RenderTarget = 5,
  33796. /**
  33797. * Texture content is part of a multi render target process
  33798. */
  33799. MultiRenderTarget = 6,
  33800. /**
  33801. * Texture data comes from a cube data file
  33802. */
  33803. Cube = 7,
  33804. /**
  33805. * Texture data comes from a raw cube data
  33806. */
  33807. CubeRaw = 8,
  33808. /**
  33809. * Texture data come from a prefiltered cube data file
  33810. */
  33811. CubePrefiltered = 9,
  33812. /**
  33813. * Texture content is raw 3D data
  33814. */
  33815. Raw3D = 10,
  33816. /**
  33817. * Texture content is raw 2D array data
  33818. */
  33819. Raw2DArray = 11,
  33820. /**
  33821. * Texture content is a depth texture
  33822. */
  33823. Depth = 12,
  33824. /**
  33825. * Texture data comes from a raw cube data encoded with RGBD
  33826. */
  33827. CubeRawRGBD = 13
  33828. }
  33829. /**
  33830. * Class used to store data associated with WebGL texture data for the engine
  33831. * This class should not be used directly
  33832. */
  33833. export class InternalTexture {
  33834. /** @hidden */
  33835. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33836. /**
  33837. * Defines if the texture is ready
  33838. */
  33839. isReady: boolean;
  33840. /**
  33841. * Defines if the texture is a cube texture
  33842. */
  33843. isCube: boolean;
  33844. /**
  33845. * Defines if the texture contains 3D data
  33846. */
  33847. is3D: boolean;
  33848. /**
  33849. * Defines if the texture contains 2D array data
  33850. */
  33851. is2DArray: boolean;
  33852. /**
  33853. * Defines if the texture contains multiview data
  33854. */
  33855. isMultiview: boolean;
  33856. /**
  33857. * Gets the URL used to load this texture
  33858. */
  33859. url: string;
  33860. /**
  33861. * Gets the sampling mode of the texture
  33862. */
  33863. samplingMode: number;
  33864. /**
  33865. * Gets a boolean indicating if the texture needs mipmaps generation
  33866. */
  33867. generateMipMaps: boolean;
  33868. /**
  33869. * Gets the number of samples used by the texture (WebGL2+ only)
  33870. */
  33871. samples: number;
  33872. /**
  33873. * Gets the type of the texture (int, float...)
  33874. */
  33875. type: number;
  33876. /**
  33877. * Gets the format of the texture (RGB, RGBA...)
  33878. */
  33879. format: number;
  33880. /**
  33881. * Observable called when the texture is loaded
  33882. */
  33883. onLoadedObservable: Observable<InternalTexture>;
  33884. /**
  33885. * Gets the width of the texture
  33886. */
  33887. width: number;
  33888. /**
  33889. * Gets the height of the texture
  33890. */
  33891. height: number;
  33892. /**
  33893. * Gets the depth of the texture
  33894. */
  33895. depth: number;
  33896. /**
  33897. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33898. */
  33899. baseWidth: number;
  33900. /**
  33901. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33902. */
  33903. baseHeight: number;
  33904. /**
  33905. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33906. */
  33907. baseDepth: number;
  33908. /**
  33909. * Gets a boolean indicating if the texture is inverted on Y axis
  33910. */
  33911. invertY: boolean;
  33912. /** @hidden */
  33913. _invertVScale: boolean;
  33914. /** @hidden */
  33915. _associatedChannel: number;
  33916. /** @hidden */
  33917. _source: InternalTextureSource;
  33918. /** @hidden */
  33919. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33920. /** @hidden */
  33921. _bufferView: Nullable<ArrayBufferView>;
  33922. /** @hidden */
  33923. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33924. /** @hidden */
  33925. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33926. /** @hidden */
  33927. _size: number;
  33928. /** @hidden */
  33929. _extension: string;
  33930. /** @hidden */
  33931. _files: Nullable<string[]>;
  33932. /** @hidden */
  33933. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33934. /** @hidden */
  33935. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33936. /** @hidden */
  33937. _framebuffer: Nullable<WebGLFramebuffer>;
  33938. /** @hidden */
  33939. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33940. /** @hidden */
  33941. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33942. /** @hidden */
  33943. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33944. /** @hidden */
  33945. _attachments: Nullable<number[]>;
  33946. /** @hidden */
  33947. _cachedCoordinatesMode: Nullable<number>;
  33948. /** @hidden */
  33949. _cachedWrapU: Nullable<number>;
  33950. /** @hidden */
  33951. _cachedWrapV: Nullable<number>;
  33952. /** @hidden */
  33953. _cachedWrapR: Nullable<number>;
  33954. /** @hidden */
  33955. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33956. /** @hidden */
  33957. _isDisabled: boolean;
  33958. /** @hidden */
  33959. _compression: Nullable<string>;
  33960. /** @hidden */
  33961. _generateStencilBuffer: boolean;
  33962. /** @hidden */
  33963. _generateDepthBuffer: boolean;
  33964. /** @hidden */
  33965. _comparisonFunction: number;
  33966. /** @hidden */
  33967. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33968. /** @hidden */
  33969. _lodGenerationScale: number;
  33970. /** @hidden */
  33971. _lodGenerationOffset: number;
  33972. /** @hidden */
  33973. _depthStencilTexture: Nullable<InternalTexture>;
  33974. /** @hidden */
  33975. _colorTextureArray: Nullable<WebGLTexture>;
  33976. /** @hidden */
  33977. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33978. /** @hidden */
  33979. _lodTextureHigh: Nullable<BaseTexture>;
  33980. /** @hidden */
  33981. _lodTextureMid: Nullable<BaseTexture>;
  33982. /** @hidden */
  33983. _lodTextureLow: Nullable<BaseTexture>;
  33984. /** @hidden */
  33985. _isRGBD: boolean;
  33986. /** @hidden */
  33987. _linearSpecularLOD: boolean;
  33988. /** @hidden */
  33989. _irradianceTexture: Nullable<BaseTexture>;
  33990. /** @hidden */
  33991. _webGLTexture: Nullable<WebGLTexture>;
  33992. /** @hidden */
  33993. _references: number;
  33994. private _engine;
  33995. /**
  33996. * Gets the Engine the texture belongs to.
  33997. * @returns The babylon engine
  33998. */
  33999. getEngine(): ThinEngine;
  34000. /**
  34001. * Gets the data source type of the texture
  34002. */
  34003. get source(): InternalTextureSource;
  34004. /**
  34005. * Creates a new InternalTexture
  34006. * @param engine defines the engine to use
  34007. * @param source defines the type of data that will be used
  34008. * @param delayAllocation if the texture allocation should be delayed (default: false)
  34009. */
  34010. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  34011. /**
  34012. * Increments the number of references (ie. the number of Texture that point to it)
  34013. */
  34014. incrementReferences(): void;
  34015. /**
  34016. * Change the size of the texture (not the size of the content)
  34017. * @param width defines the new width
  34018. * @param height defines the new height
  34019. * @param depth defines the new depth (1 by default)
  34020. */
  34021. updateSize(width: int, height: int, depth?: int): void;
  34022. /** @hidden */
  34023. _rebuild(): void;
  34024. /** @hidden */
  34025. _swapAndDie(target: InternalTexture): void;
  34026. /**
  34027. * Dispose the current allocated resources
  34028. */
  34029. dispose(): void;
  34030. }
  34031. }
  34032. declare module "babylonjs/Audio/analyser" {
  34033. import { Scene } from "babylonjs/scene";
  34034. /**
  34035. * Class used to work with sound analyzer using fast fourier transform (FFT)
  34036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34037. */
  34038. export class Analyser {
  34039. /**
  34040. * Gets or sets the smoothing
  34041. * @ignorenaming
  34042. */
  34043. SMOOTHING: number;
  34044. /**
  34045. * Gets or sets the FFT table size
  34046. * @ignorenaming
  34047. */
  34048. FFT_SIZE: number;
  34049. /**
  34050. * Gets or sets the bar graph amplitude
  34051. * @ignorenaming
  34052. */
  34053. BARGRAPHAMPLITUDE: number;
  34054. /**
  34055. * Gets or sets the position of the debug canvas
  34056. * @ignorenaming
  34057. */
  34058. DEBUGCANVASPOS: {
  34059. x: number;
  34060. y: number;
  34061. };
  34062. /**
  34063. * Gets or sets the debug canvas size
  34064. * @ignorenaming
  34065. */
  34066. DEBUGCANVASSIZE: {
  34067. width: number;
  34068. height: number;
  34069. };
  34070. private _byteFreqs;
  34071. private _byteTime;
  34072. private _floatFreqs;
  34073. private _webAudioAnalyser;
  34074. private _debugCanvas;
  34075. private _debugCanvasContext;
  34076. private _scene;
  34077. private _registerFunc;
  34078. private _audioEngine;
  34079. /**
  34080. * Creates a new analyser
  34081. * @param scene defines hosting scene
  34082. */
  34083. constructor(scene: Scene);
  34084. /**
  34085. * Get the number of data values you will have to play with for the visualization
  34086. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34087. * @returns a number
  34088. */
  34089. getFrequencyBinCount(): number;
  34090. /**
  34091. * Gets the current frequency data as a byte array
  34092. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34093. * @returns a Uint8Array
  34094. */
  34095. getByteFrequencyData(): Uint8Array;
  34096. /**
  34097. * Gets the current waveform as a byte array
  34098. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34099. * @returns a Uint8Array
  34100. */
  34101. getByteTimeDomainData(): Uint8Array;
  34102. /**
  34103. * Gets the current frequency data as a float array
  34104. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34105. * @returns a Float32Array
  34106. */
  34107. getFloatFrequencyData(): Float32Array;
  34108. /**
  34109. * Renders the debug canvas
  34110. */
  34111. drawDebugCanvas(): void;
  34112. /**
  34113. * Stops rendering the debug canvas and removes it
  34114. */
  34115. stopDebugCanvas(): void;
  34116. /**
  34117. * Connects two audio nodes
  34118. * @param inputAudioNode defines first node to connect
  34119. * @param outputAudioNode defines second node to connect
  34120. */
  34121. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34122. /**
  34123. * Releases all associated resources
  34124. */
  34125. dispose(): void;
  34126. }
  34127. }
  34128. declare module "babylonjs/Audio/audioEngine" {
  34129. import { IDisposable } from "babylonjs/scene";
  34130. import { Analyser } from "babylonjs/Audio/analyser";
  34131. import { Nullable } from "babylonjs/types";
  34132. import { Observable } from "babylonjs/Misc/observable";
  34133. /**
  34134. * This represents an audio engine and it is responsible
  34135. * to play, synchronize and analyse sounds throughout the application.
  34136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34137. */
  34138. export interface IAudioEngine extends IDisposable {
  34139. /**
  34140. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34141. */
  34142. readonly canUseWebAudio: boolean;
  34143. /**
  34144. * Gets the current AudioContext if available.
  34145. */
  34146. readonly audioContext: Nullable<AudioContext>;
  34147. /**
  34148. * The master gain node defines the global audio volume of your audio engine.
  34149. */
  34150. readonly masterGain: GainNode;
  34151. /**
  34152. * Gets whether or not mp3 are supported by your browser.
  34153. */
  34154. readonly isMP3supported: boolean;
  34155. /**
  34156. * Gets whether or not ogg are supported by your browser.
  34157. */
  34158. readonly isOGGsupported: boolean;
  34159. /**
  34160. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34161. * @ignoreNaming
  34162. */
  34163. WarnedWebAudioUnsupported: boolean;
  34164. /**
  34165. * Defines if the audio engine relies on a custom unlocked button.
  34166. * In this case, the embedded button will not be displayed.
  34167. */
  34168. useCustomUnlockedButton: boolean;
  34169. /**
  34170. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34171. */
  34172. readonly unlocked: boolean;
  34173. /**
  34174. * Event raised when audio has been unlocked on the browser.
  34175. */
  34176. onAudioUnlockedObservable: Observable<AudioEngine>;
  34177. /**
  34178. * Event raised when audio has been locked on the browser.
  34179. */
  34180. onAudioLockedObservable: Observable<AudioEngine>;
  34181. /**
  34182. * Flags the audio engine in Locked state.
  34183. * This happens due to new browser policies preventing audio to autoplay.
  34184. */
  34185. lock(): void;
  34186. /**
  34187. * Unlocks the audio engine once a user action has been done on the dom.
  34188. * This is helpful to resume play once browser policies have been satisfied.
  34189. */
  34190. unlock(): void;
  34191. /**
  34192. * Gets the global volume sets on the master gain.
  34193. * @returns the global volume if set or -1 otherwise
  34194. */
  34195. getGlobalVolume(): number;
  34196. /**
  34197. * Sets the global volume of your experience (sets on the master gain).
  34198. * @param newVolume Defines the new global volume of the application
  34199. */
  34200. setGlobalVolume(newVolume: number): void;
  34201. /**
  34202. * Connect the audio engine to an audio analyser allowing some amazing
  34203. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34205. * @param analyser The analyser to connect to the engine
  34206. */
  34207. connectToAnalyser(analyser: Analyser): void;
  34208. }
  34209. /**
  34210. * This represents the default audio engine used in babylon.
  34211. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34213. */
  34214. export class AudioEngine implements IAudioEngine {
  34215. private _audioContext;
  34216. private _audioContextInitialized;
  34217. private _muteButton;
  34218. private _hostElement;
  34219. /**
  34220. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34221. */
  34222. canUseWebAudio: boolean;
  34223. /**
  34224. * The master gain node defines the global audio volume of your audio engine.
  34225. */
  34226. masterGain: GainNode;
  34227. /**
  34228. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34229. * @ignoreNaming
  34230. */
  34231. WarnedWebAudioUnsupported: boolean;
  34232. /**
  34233. * Gets whether or not mp3 are supported by your browser.
  34234. */
  34235. isMP3supported: boolean;
  34236. /**
  34237. * Gets whether or not ogg are supported by your browser.
  34238. */
  34239. isOGGsupported: boolean;
  34240. /**
  34241. * Gets whether audio has been unlocked on the device.
  34242. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34243. * a user interaction has happened.
  34244. */
  34245. unlocked: boolean;
  34246. /**
  34247. * Defines if the audio engine relies on a custom unlocked button.
  34248. * In this case, the embedded button will not be displayed.
  34249. */
  34250. useCustomUnlockedButton: boolean;
  34251. /**
  34252. * Event raised when audio has been unlocked on the browser.
  34253. */
  34254. onAudioUnlockedObservable: Observable<AudioEngine>;
  34255. /**
  34256. * Event raised when audio has been locked on the browser.
  34257. */
  34258. onAudioLockedObservable: Observable<AudioEngine>;
  34259. /**
  34260. * Gets the current AudioContext if available.
  34261. */
  34262. get audioContext(): Nullable<AudioContext>;
  34263. private _connectedAnalyser;
  34264. /**
  34265. * Instantiates a new audio engine.
  34266. *
  34267. * There should be only one per page as some browsers restrict the number
  34268. * of audio contexts you can create.
  34269. * @param hostElement defines the host element where to display the mute icon if necessary
  34270. */
  34271. constructor(hostElement?: Nullable<HTMLElement>);
  34272. /**
  34273. * Flags the audio engine in Locked state.
  34274. * This happens due to new browser policies preventing audio to autoplay.
  34275. */
  34276. lock(): void;
  34277. /**
  34278. * Unlocks the audio engine once a user action has been done on the dom.
  34279. * This is helpful to resume play once browser policies have been satisfied.
  34280. */
  34281. unlock(): void;
  34282. private _resumeAudioContext;
  34283. private _initializeAudioContext;
  34284. private _tryToRun;
  34285. private _triggerRunningState;
  34286. private _triggerSuspendedState;
  34287. private _displayMuteButton;
  34288. private _moveButtonToTopLeft;
  34289. private _onResize;
  34290. private _hideMuteButton;
  34291. /**
  34292. * Destroy and release the resources associated with the audio ccontext.
  34293. */
  34294. dispose(): void;
  34295. /**
  34296. * Gets the global volume sets on the master gain.
  34297. * @returns the global volume if set or -1 otherwise
  34298. */
  34299. getGlobalVolume(): number;
  34300. /**
  34301. * Sets the global volume of your experience (sets on the master gain).
  34302. * @param newVolume Defines the new global volume of the application
  34303. */
  34304. setGlobalVolume(newVolume: number): void;
  34305. /**
  34306. * Connect the audio engine to an audio analyser allowing some amazing
  34307. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34309. * @param analyser The analyser to connect to the engine
  34310. */
  34311. connectToAnalyser(analyser: Analyser): void;
  34312. }
  34313. }
  34314. declare module "babylonjs/Loading/loadingScreen" {
  34315. /**
  34316. * Interface used to present a loading screen while loading a scene
  34317. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34318. */
  34319. export interface ILoadingScreen {
  34320. /**
  34321. * Function called to display the loading screen
  34322. */
  34323. displayLoadingUI: () => void;
  34324. /**
  34325. * Function called to hide the loading screen
  34326. */
  34327. hideLoadingUI: () => void;
  34328. /**
  34329. * Gets or sets the color to use for the background
  34330. */
  34331. loadingUIBackgroundColor: string;
  34332. /**
  34333. * Gets or sets the text to display while loading
  34334. */
  34335. loadingUIText: string;
  34336. }
  34337. /**
  34338. * Class used for the default loading screen
  34339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34340. */
  34341. export class DefaultLoadingScreen implements ILoadingScreen {
  34342. private _renderingCanvas;
  34343. private _loadingText;
  34344. private _loadingDivBackgroundColor;
  34345. private _loadingDiv;
  34346. private _loadingTextDiv;
  34347. /** Gets or sets the logo url to use for the default loading screen */
  34348. static DefaultLogoUrl: string;
  34349. /** Gets or sets the spinner url to use for the default loading screen */
  34350. static DefaultSpinnerUrl: string;
  34351. /**
  34352. * Creates a new default loading screen
  34353. * @param _renderingCanvas defines the canvas used to render the scene
  34354. * @param _loadingText defines the default text to display
  34355. * @param _loadingDivBackgroundColor defines the default background color
  34356. */
  34357. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34358. /**
  34359. * Function called to display the loading screen
  34360. */
  34361. displayLoadingUI(): void;
  34362. /**
  34363. * Function called to hide the loading screen
  34364. */
  34365. hideLoadingUI(): void;
  34366. /**
  34367. * Gets or sets the text to display while loading
  34368. */
  34369. set loadingUIText(text: string);
  34370. get loadingUIText(): string;
  34371. /**
  34372. * Gets or sets the color to use for the background
  34373. */
  34374. get loadingUIBackgroundColor(): string;
  34375. set loadingUIBackgroundColor(color: string);
  34376. private _resizeLoadingUI;
  34377. }
  34378. }
  34379. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34380. /**
  34381. * Interface for any object that can request an animation frame
  34382. */
  34383. export interface ICustomAnimationFrameRequester {
  34384. /**
  34385. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34386. */
  34387. renderFunction?: Function;
  34388. /**
  34389. * Called to request the next frame to render to
  34390. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34391. */
  34392. requestAnimationFrame: Function;
  34393. /**
  34394. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34395. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34396. */
  34397. requestID?: number;
  34398. }
  34399. }
  34400. declare module "babylonjs/Misc/performanceMonitor" {
  34401. /**
  34402. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34403. */
  34404. export class PerformanceMonitor {
  34405. private _enabled;
  34406. private _rollingFrameTime;
  34407. private _lastFrameTimeMs;
  34408. /**
  34409. * constructor
  34410. * @param frameSampleSize The number of samples required to saturate the sliding window
  34411. */
  34412. constructor(frameSampleSize?: number);
  34413. /**
  34414. * Samples current frame
  34415. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34416. */
  34417. sampleFrame(timeMs?: number): void;
  34418. /**
  34419. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34420. */
  34421. get averageFrameTime(): number;
  34422. /**
  34423. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34424. */
  34425. get averageFrameTimeVariance(): number;
  34426. /**
  34427. * Returns the frame time of the most recent frame
  34428. */
  34429. get instantaneousFrameTime(): number;
  34430. /**
  34431. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34432. */
  34433. get averageFPS(): number;
  34434. /**
  34435. * Returns the average framerate in frames per second using the most recent frame time
  34436. */
  34437. get instantaneousFPS(): number;
  34438. /**
  34439. * Returns true if enough samples have been taken to completely fill the sliding window
  34440. */
  34441. get isSaturated(): boolean;
  34442. /**
  34443. * Enables contributions to the sliding window sample set
  34444. */
  34445. enable(): void;
  34446. /**
  34447. * Disables contributions to the sliding window sample set
  34448. * Samples will not be interpolated over the disabled period
  34449. */
  34450. disable(): void;
  34451. /**
  34452. * Returns true if sampling is enabled
  34453. */
  34454. get isEnabled(): boolean;
  34455. /**
  34456. * Resets performance monitor
  34457. */
  34458. reset(): void;
  34459. }
  34460. /**
  34461. * RollingAverage
  34462. *
  34463. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34464. */
  34465. export class RollingAverage {
  34466. /**
  34467. * Current average
  34468. */
  34469. average: number;
  34470. /**
  34471. * Current variance
  34472. */
  34473. variance: number;
  34474. protected _samples: Array<number>;
  34475. protected _sampleCount: number;
  34476. protected _pos: number;
  34477. protected _m2: number;
  34478. /**
  34479. * constructor
  34480. * @param length The number of samples required to saturate the sliding window
  34481. */
  34482. constructor(length: number);
  34483. /**
  34484. * Adds a sample to the sample set
  34485. * @param v The sample value
  34486. */
  34487. add(v: number): void;
  34488. /**
  34489. * Returns previously added values or null if outside of history or outside the sliding window domain
  34490. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34491. * @return Value previously recorded with add() or null if outside of range
  34492. */
  34493. history(i: number): number;
  34494. /**
  34495. * Returns true if enough samples have been taken to completely fill the sliding window
  34496. * @return true if sample-set saturated
  34497. */
  34498. isSaturated(): boolean;
  34499. /**
  34500. * Resets the rolling average (equivalent to 0 samples taken so far)
  34501. */
  34502. reset(): void;
  34503. /**
  34504. * Wraps a value around the sample range boundaries
  34505. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34506. * @return Wrapped position in sample range
  34507. */
  34508. protected _wrapPosition(i: number): number;
  34509. }
  34510. }
  34511. declare module "babylonjs/Misc/perfCounter" {
  34512. /**
  34513. * This class is used to track a performance counter which is number based.
  34514. * The user has access to many properties which give statistics of different nature.
  34515. *
  34516. * The implementer can track two kinds of Performance Counter: time and count.
  34517. * 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.
  34518. * 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.
  34519. */
  34520. export class PerfCounter {
  34521. /**
  34522. * Gets or sets a global boolean to turn on and off all the counters
  34523. */
  34524. static Enabled: boolean;
  34525. /**
  34526. * Returns the smallest value ever
  34527. */
  34528. get min(): number;
  34529. /**
  34530. * Returns the biggest value ever
  34531. */
  34532. get max(): number;
  34533. /**
  34534. * Returns the average value since the performance counter is running
  34535. */
  34536. get average(): number;
  34537. /**
  34538. * Returns the average value of the last second the counter was monitored
  34539. */
  34540. get lastSecAverage(): number;
  34541. /**
  34542. * Returns the current value
  34543. */
  34544. get current(): number;
  34545. /**
  34546. * Gets the accumulated total
  34547. */
  34548. get total(): number;
  34549. /**
  34550. * Gets the total value count
  34551. */
  34552. get count(): number;
  34553. /**
  34554. * Creates a new counter
  34555. */
  34556. constructor();
  34557. /**
  34558. * Call this method to start monitoring a new frame.
  34559. * 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.
  34560. */
  34561. fetchNewFrame(): void;
  34562. /**
  34563. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34564. * @param newCount the count value to add to the monitored count
  34565. * @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.
  34566. */
  34567. addCount(newCount: number, fetchResult: boolean): void;
  34568. /**
  34569. * Start monitoring this performance counter
  34570. */
  34571. beginMonitoring(): void;
  34572. /**
  34573. * Compute the time lapsed since the previous beginMonitoring() call.
  34574. * @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
  34575. */
  34576. endMonitoring(newFrame?: boolean): void;
  34577. private _fetchResult;
  34578. private _startMonitoringTime;
  34579. private _min;
  34580. private _max;
  34581. private _average;
  34582. private _current;
  34583. private _totalValueCount;
  34584. private _totalAccumulated;
  34585. private _lastSecAverage;
  34586. private _lastSecAccumulated;
  34587. private _lastSecTime;
  34588. private _lastSecValueCount;
  34589. }
  34590. }
  34591. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34592. module "babylonjs/Engines/thinEngine" {
  34593. interface ThinEngine {
  34594. /**
  34595. * Sets alpha constants used by some alpha blending modes
  34596. * @param r defines the red component
  34597. * @param g defines the green component
  34598. * @param b defines the blue component
  34599. * @param a defines the alpha component
  34600. */
  34601. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34602. /**
  34603. * Sets the current alpha mode
  34604. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34605. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34606. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34607. */
  34608. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34609. /**
  34610. * Gets the current alpha mode
  34611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34612. * @returns the current alpha mode
  34613. */
  34614. getAlphaMode(): number;
  34615. /**
  34616. * Sets the current alpha equation
  34617. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34618. */
  34619. setAlphaEquation(equation: number): void;
  34620. /**
  34621. * Gets the current alpha equation.
  34622. * @returns the current alpha equation
  34623. */
  34624. getAlphaEquation(): number;
  34625. }
  34626. }
  34627. }
  34628. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  34629. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34630. import { Nullable } from "babylonjs/types";
  34631. module "babylonjs/Engines/thinEngine" {
  34632. interface ThinEngine {
  34633. /** @hidden */
  34634. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34635. }
  34636. }
  34637. }
  34638. declare module "babylonjs/Engines/engine" {
  34639. import { Observable } from "babylonjs/Misc/observable";
  34640. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34641. import { Scene } from "babylonjs/scene";
  34642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34643. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34644. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34645. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34646. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34647. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34648. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34649. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34650. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34651. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34652. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34653. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34654. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34655. import "babylonjs/Engines/Extensions/engine.alpha";
  34656. import "babylonjs/Engines/Extensions/engine.readTexture";
  34657. import { Material } from "babylonjs/Materials/material";
  34658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34659. /**
  34660. * Defines the interface used by display changed events
  34661. */
  34662. export interface IDisplayChangedEventArgs {
  34663. /** Gets the vrDisplay object (if any) */
  34664. vrDisplay: Nullable<any>;
  34665. /** Gets a boolean indicating if webVR is supported */
  34666. vrSupported: boolean;
  34667. }
  34668. /**
  34669. * Defines the interface used by objects containing a viewport (like a camera)
  34670. */
  34671. interface IViewportOwnerLike {
  34672. /**
  34673. * Gets or sets the viewport
  34674. */
  34675. viewport: IViewportLike;
  34676. }
  34677. /**
  34678. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34679. */
  34680. export class Engine extends ThinEngine {
  34681. /** Defines that alpha blending is disabled */
  34682. static readonly ALPHA_DISABLE: number;
  34683. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34684. static readonly ALPHA_ADD: number;
  34685. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34686. static readonly ALPHA_COMBINE: number;
  34687. /** Defines that alpha blending to DEST - SRC * DEST */
  34688. static readonly ALPHA_SUBTRACT: number;
  34689. /** Defines that alpha blending to SRC * DEST */
  34690. static readonly ALPHA_MULTIPLY: number;
  34691. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34692. static readonly ALPHA_MAXIMIZED: number;
  34693. /** Defines that alpha blending to SRC + DEST */
  34694. static readonly ALPHA_ONEONE: number;
  34695. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34696. static readonly ALPHA_PREMULTIPLIED: number;
  34697. /**
  34698. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34699. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34700. */
  34701. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34702. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34703. static readonly ALPHA_INTERPOLATE: number;
  34704. /**
  34705. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34706. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34707. */
  34708. static readonly ALPHA_SCREENMODE: number;
  34709. /** Defines that the ressource is not delayed*/
  34710. static readonly DELAYLOADSTATE_NONE: number;
  34711. /** Defines that the ressource was successfully delay loaded */
  34712. static readonly DELAYLOADSTATE_LOADED: number;
  34713. /** Defines that the ressource is currently delay loading */
  34714. static readonly DELAYLOADSTATE_LOADING: number;
  34715. /** Defines that the ressource is delayed and has not started loading */
  34716. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34718. static readonly NEVER: number;
  34719. /** 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 */
  34720. static readonly ALWAYS: number;
  34721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34722. static readonly LESS: number;
  34723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34724. static readonly EQUAL: number;
  34725. /** 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 */
  34726. static readonly LEQUAL: number;
  34727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34728. static readonly GREATER: number;
  34729. /** 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 */
  34730. static readonly GEQUAL: number;
  34731. /** 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 */
  34732. static readonly NOTEQUAL: number;
  34733. /** Passed to stencilOperation to specify that stencil value must be kept */
  34734. static readonly KEEP: number;
  34735. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34736. static readonly REPLACE: number;
  34737. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34738. static readonly INCR: number;
  34739. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34740. static readonly DECR: number;
  34741. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34742. static readonly INVERT: number;
  34743. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34744. static readonly INCR_WRAP: number;
  34745. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34746. static readonly DECR_WRAP: number;
  34747. /** Texture is not repeating outside of 0..1 UVs */
  34748. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34749. /** Texture is repeating outside of 0..1 UVs */
  34750. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34751. /** Texture is repeating and mirrored */
  34752. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34753. /** ALPHA */
  34754. static readonly TEXTUREFORMAT_ALPHA: number;
  34755. /** LUMINANCE */
  34756. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34757. /** LUMINANCE_ALPHA */
  34758. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34759. /** RGB */
  34760. static readonly TEXTUREFORMAT_RGB: number;
  34761. /** RGBA */
  34762. static readonly TEXTUREFORMAT_RGBA: number;
  34763. /** RED */
  34764. static readonly TEXTUREFORMAT_RED: number;
  34765. /** RED (2nd reference) */
  34766. static readonly TEXTUREFORMAT_R: number;
  34767. /** RG */
  34768. static readonly TEXTUREFORMAT_RG: number;
  34769. /** RED_INTEGER */
  34770. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34771. /** RED_INTEGER (2nd reference) */
  34772. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34773. /** RG_INTEGER */
  34774. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34775. /** RGB_INTEGER */
  34776. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34777. /** RGBA_INTEGER */
  34778. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34779. /** UNSIGNED_BYTE */
  34780. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34781. /** UNSIGNED_BYTE (2nd reference) */
  34782. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34783. /** FLOAT */
  34784. static readonly TEXTURETYPE_FLOAT: number;
  34785. /** HALF_FLOAT */
  34786. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34787. /** BYTE */
  34788. static readonly TEXTURETYPE_BYTE: number;
  34789. /** SHORT */
  34790. static readonly TEXTURETYPE_SHORT: number;
  34791. /** UNSIGNED_SHORT */
  34792. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34793. /** INT */
  34794. static readonly TEXTURETYPE_INT: number;
  34795. /** UNSIGNED_INT */
  34796. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34797. /** UNSIGNED_SHORT_4_4_4_4 */
  34798. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34799. /** UNSIGNED_SHORT_5_5_5_1 */
  34800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34801. /** UNSIGNED_SHORT_5_6_5 */
  34802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34803. /** UNSIGNED_INT_2_10_10_10_REV */
  34804. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34805. /** UNSIGNED_INT_24_8 */
  34806. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34807. /** UNSIGNED_INT_10F_11F_11F_REV */
  34808. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34809. /** UNSIGNED_INT_5_9_9_9_REV */
  34810. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34811. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34812. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34813. /** nearest is mag = nearest and min = nearest and mip = linear */
  34814. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34817. /** Trilinear is mag = linear and min = linear and mip = linear */
  34818. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34819. /** nearest is mag = nearest and min = nearest and mip = linear */
  34820. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34822. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34823. /** Trilinear is mag = linear and min = linear and mip = linear */
  34824. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34825. /** mag = nearest and min = nearest and mip = nearest */
  34826. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34827. /** mag = nearest and min = linear and mip = nearest */
  34828. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34829. /** mag = nearest and min = linear and mip = linear */
  34830. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34831. /** mag = nearest and min = linear and mip = none */
  34832. static readonly TEXTURE_NEAREST_LINEAR: number;
  34833. /** mag = nearest and min = nearest and mip = none */
  34834. static readonly TEXTURE_NEAREST_NEAREST: number;
  34835. /** mag = linear and min = nearest and mip = nearest */
  34836. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34837. /** mag = linear and min = nearest and mip = linear */
  34838. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34839. /** mag = linear and min = linear and mip = none */
  34840. static readonly TEXTURE_LINEAR_LINEAR: number;
  34841. /** mag = linear and min = nearest and mip = none */
  34842. static readonly TEXTURE_LINEAR_NEAREST: number;
  34843. /** Explicit coordinates mode */
  34844. static readonly TEXTURE_EXPLICIT_MODE: number;
  34845. /** Spherical coordinates mode */
  34846. static readonly TEXTURE_SPHERICAL_MODE: number;
  34847. /** Planar coordinates mode */
  34848. static readonly TEXTURE_PLANAR_MODE: number;
  34849. /** Cubic coordinates mode */
  34850. static readonly TEXTURE_CUBIC_MODE: number;
  34851. /** Projection coordinates mode */
  34852. static readonly TEXTURE_PROJECTION_MODE: number;
  34853. /** Skybox coordinates mode */
  34854. static readonly TEXTURE_SKYBOX_MODE: number;
  34855. /** Inverse Cubic coordinates mode */
  34856. static readonly TEXTURE_INVCUBIC_MODE: number;
  34857. /** Equirectangular coordinates mode */
  34858. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34859. /** Equirectangular Fixed coordinates mode */
  34860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34861. /** Equirectangular Fixed Mirrored coordinates mode */
  34862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34863. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34864. static readonly SCALEMODE_FLOOR: number;
  34865. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34866. static readonly SCALEMODE_NEAREST: number;
  34867. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34868. static readonly SCALEMODE_CEILING: number;
  34869. /**
  34870. * Returns the current npm package of the sdk
  34871. */
  34872. static get NpmPackage(): string;
  34873. /**
  34874. * Returns the current version of the framework
  34875. */
  34876. static get Version(): string;
  34877. /** Gets the list of created engines */
  34878. static get Instances(): Engine[];
  34879. /**
  34880. * Gets the latest created engine
  34881. */
  34882. static get LastCreatedEngine(): Nullable<Engine>;
  34883. /**
  34884. * Gets the latest created scene
  34885. */
  34886. static get LastCreatedScene(): Nullable<Scene>;
  34887. /**
  34888. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34889. * @param flag defines which part of the materials must be marked as dirty
  34890. * @param predicate defines a predicate used to filter which materials should be affected
  34891. */
  34892. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34893. /**
  34894. * Method called to create the default loading screen.
  34895. * This can be overriden in your own app.
  34896. * @param canvas The rendering canvas element
  34897. * @returns The loading screen
  34898. */
  34899. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34900. /**
  34901. * Method called to create the default rescale post process on each engine.
  34902. */
  34903. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34904. /**
  34905. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34906. **/
  34907. enableOfflineSupport: boolean;
  34908. /**
  34909. * 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)
  34910. **/
  34911. disableManifestCheck: boolean;
  34912. /**
  34913. * Gets the list of created scenes
  34914. */
  34915. scenes: Scene[];
  34916. /**
  34917. * Event raised when a new scene is created
  34918. */
  34919. onNewSceneAddedObservable: Observable<Scene>;
  34920. /**
  34921. * Gets the list of created postprocesses
  34922. */
  34923. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34924. /**
  34925. * Gets a boolean indicating if the pointer is currently locked
  34926. */
  34927. isPointerLock: boolean;
  34928. /**
  34929. * Observable event triggered each time the rendering canvas is resized
  34930. */
  34931. onResizeObservable: Observable<Engine>;
  34932. /**
  34933. * Observable event triggered each time the canvas loses focus
  34934. */
  34935. onCanvasBlurObservable: Observable<Engine>;
  34936. /**
  34937. * Observable event triggered each time the canvas gains focus
  34938. */
  34939. onCanvasFocusObservable: Observable<Engine>;
  34940. /**
  34941. * Observable event triggered each time the canvas receives pointerout event
  34942. */
  34943. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34944. /**
  34945. * Observable raised when the engine begins a new frame
  34946. */
  34947. onBeginFrameObservable: Observable<Engine>;
  34948. /**
  34949. * If set, will be used to request the next animation frame for the render loop
  34950. */
  34951. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34952. /**
  34953. * Observable raised when the engine ends the current frame
  34954. */
  34955. onEndFrameObservable: Observable<Engine>;
  34956. /**
  34957. * Observable raised when the engine is about to compile a shader
  34958. */
  34959. onBeforeShaderCompilationObservable: Observable<Engine>;
  34960. /**
  34961. * Observable raised when the engine has jsut compiled a shader
  34962. */
  34963. onAfterShaderCompilationObservable: Observable<Engine>;
  34964. /**
  34965. * Gets the audio engine
  34966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34967. * @ignorenaming
  34968. */
  34969. static audioEngine: IAudioEngine;
  34970. /**
  34971. * Default AudioEngine factory responsible of creating the Audio Engine.
  34972. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34973. */
  34974. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34975. /**
  34976. * Default offline support factory responsible of creating a tool used to store data locally.
  34977. * By default, this will create a Database object if the workload has been embedded.
  34978. */
  34979. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34980. private _loadingScreen;
  34981. private _pointerLockRequested;
  34982. private _rescalePostProcess;
  34983. private _deterministicLockstep;
  34984. private _lockstepMaxSteps;
  34985. private _timeStep;
  34986. protected get _supportsHardwareTextureRescaling(): boolean;
  34987. private _fps;
  34988. private _deltaTime;
  34989. /** @hidden */
  34990. _drawCalls: PerfCounter;
  34991. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34992. canvasTabIndex: number;
  34993. /**
  34994. * Turn this value on if you want to pause FPS computation when in background
  34995. */
  34996. disablePerformanceMonitorInBackground: boolean;
  34997. private _performanceMonitor;
  34998. /**
  34999. * Gets the performance monitor attached to this engine
  35000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  35001. */
  35002. get performanceMonitor(): PerformanceMonitor;
  35003. private _onFocus;
  35004. private _onBlur;
  35005. private _onCanvasPointerOut;
  35006. private _onCanvasBlur;
  35007. private _onCanvasFocus;
  35008. private _onFullscreenChange;
  35009. private _onPointerLockChange;
  35010. /**
  35011. * Gets the HTML element used to attach event listeners
  35012. * @returns a HTML element
  35013. */
  35014. getInputElement(): Nullable<HTMLElement>;
  35015. /**
  35016. * Creates a new engine
  35017. * @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
  35018. * @param antialias defines enable antialiasing (default: false)
  35019. * @param options defines further options to be sent to the getContext() function
  35020. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35021. */
  35022. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35023. /**
  35024. * Gets current aspect ratio
  35025. * @param viewportOwner defines the camera to use to get the aspect ratio
  35026. * @param useScreen defines if screen size must be used (or the current render target if any)
  35027. * @returns a number defining the aspect ratio
  35028. */
  35029. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  35030. /**
  35031. * Gets current screen aspect ratio
  35032. * @returns a number defining the aspect ratio
  35033. */
  35034. getScreenAspectRatio(): number;
  35035. /**
  35036. * Gets the client rect of the HTML canvas attached with the current webGL context
  35037. * @returns a client rectanglee
  35038. */
  35039. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  35040. /**
  35041. * Gets the client rect of the HTML element used for events
  35042. * @returns a client rectanglee
  35043. */
  35044. getInputElementClientRect(): Nullable<ClientRect>;
  35045. /**
  35046. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35048. * @returns true if engine is in deterministic lock step mode
  35049. */
  35050. isDeterministicLockStep(): boolean;
  35051. /**
  35052. * Gets the max steps when engine is running in deterministic lock step
  35053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35054. * @returns the max steps
  35055. */
  35056. getLockstepMaxSteps(): number;
  35057. /**
  35058. * Returns the time in ms between steps when using deterministic lock step.
  35059. * @returns time step in (ms)
  35060. */
  35061. getTimeStep(): number;
  35062. /**
  35063. * Force the mipmap generation for the given render target texture
  35064. * @param texture defines the render target texture to use
  35065. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35066. */
  35067. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35068. /** States */
  35069. /**
  35070. * Set various states to the webGL context
  35071. * @param culling defines backface culling state
  35072. * @param zOffset defines the value to apply to zOffset (0 by default)
  35073. * @param force defines if states must be applied even if cache is up to date
  35074. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35075. */
  35076. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35077. /**
  35078. * Set the z offset to apply to current rendering
  35079. * @param value defines the offset to apply
  35080. */
  35081. setZOffset(value: number): void;
  35082. /**
  35083. * Gets the current value of the zOffset
  35084. * @returns the current zOffset state
  35085. */
  35086. getZOffset(): number;
  35087. /**
  35088. * Enable or disable depth buffering
  35089. * @param enable defines the state to set
  35090. */
  35091. setDepthBuffer(enable: boolean): void;
  35092. /**
  35093. * Gets a boolean indicating if depth writing is enabled
  35094. * @returns the current depth writing state
  35095. */
  35096. getDepthWrite(): boolean;
  35097. /**
  35098. * Enable or disable depth writing
  35099. * @param enable defines the state to set
  35100. */
  35101. setDepthWrite(enable: boolean): void;
  35102. /**
  35103. * Gets a boolean indicating if stencil buffer is enabled
  35104. * @returns the current stencil buffer state
  35105. */
  35106. getStencilBuffer(): boolean;
  35107. /**
  35108. * Enable or disable the stencil buffer
  35109. * @param enable defines if the stencil buffer must be enabled or disabled
  35110. */
  35111. setStencilBuffer(enable: boolean): void;
  35112. /**
  35113. * Gets the current stencil mask
  35114. * @returns a number defining the new stencil mask to use
  35115. */
  35116. getStencilMask(): number;
  35117. /**
  35118. * Sets the current stencil mask
  35119. * @param mask defines the new stencil mask to use
  35120. */
  35121. setStencilMask(mask: number): void;
  35122. /**
  35123. * Gets the current stencil function
  35124. * @returns a number defining the stencil function to use
  35125. */
  35126. getStencilFunction(): number;
  35127. /**
  35128. * Gets the current stencil reference value
  35129. * @returns a number defining the stencil reference value to use
  35130. */
  35131. getStencilFunctionReference(): number;
  35132. /**
  35133. * Gets the current stencil mask
  35134. * @returns a number defining the stencil mask to use
  35135. */
  35136. getStencilFunctionMask(): number;
  35137. /**
  35138. * Sets the current stencil function
  35139. * @param stencilFunc defines the new stencil function to use
  35140. */
  35141. setStencilFunction(stencilFunc: number): void;
  35142. /**
  35143. * Sets the current stencil reference
  35144. * @param reference defines the new stencil reference to use
  35145. */
  35146. setStencilFunctionReference(reference: number): void;
  35147. /**
  35148. * Sets the current stencil mask
  35149. * @param mask defines the new stencil mask to use
  35150. */
  35151. setStencilFunctionMask(mask: number): void;
  35152. /**
  35153. * Gets the current stencil operation when stencil fails
  35154. * @returns a number defining stencil operation to use when stencil fails
  35155. */
  35156. getStencilOperationFail(): number;
  35157. /**
  35158. * Gets the current stencil operation when depth fails
  35159. * @returns a number defining stencil operation to use when depth fails
  35160. */
  35161. getStencilOperationDepthFail(): number;
  35162. /**
  35163. * Gets the current stencil operation when stencil passes
  35164. * @returns a number defining stencil operation to use when stencil passes
  35165. */
  35166. getStencilOperationPass(): number;
  35167. /**
  35168. * Sets the stencil operation to use when stencil fails
  35169. * @param operation defines the stencil operation to use when stencil fails
  35170. */
  35171. setStencilOperationFail(operation: number): void;
  35172. /**
  35173. * Sets the stencil operation to use when depth fails
  35174. * @param operation defines the stencil operation to use when depth fails
  35175. */
  35176. setStencilOperationDepthFail(operation: number): void;
  35177. /**
  35178. * Sets the stencil operation to use when stencil passes
  35179. * @param operation defines the stencil operation to use when stencil passes
  35180. */
  35181. setStencilOperationPass(operation: number): void;
  35182. /**
  35183. * Sets a boolean indicating if the dithering state is enabled or disabled
  35184. * @param value defines the dithering state
  35185. */
  35186. setDitheringState(value: boolean): void;
  35187. /**
  35188. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35189. * @param value defines the rasterizer state
  35190. */
  35191. setRasterizerState(value: boolean): void;
  35192. /**
  35193. * Gets the current depth function
  35194. * @returns a number defining the depth function
  35195. */
  35196. getDepthFunction(): Nullable<number>;
  35197. /**
  35198. * Sets the current depth function
  35199. * @param depthFunc defines the function to use
  35200. */
  35201. setDepthFunction(depthFunc: number): void;
  35202. /**
  35203. * Sets the current depth function to GREATER
  35204. */
  35205. setDepthFunctionToGreater(): void;
  35206. /**
  35207. * Sets the current depth function to GEQUAL
  35208. */
  35209. setDepthFunctionToGreaterOrEqual(): void;
  35210. /**
  35211. * Sets the current depth function to LESS
  35212. */
  35213. setDepthFunctionToLess(): void;
  35214. /**
  35215. * Sets the current depth function to LEQUAL
  35216. */
  35217. setDepthFunctionToLessOrEqual(): void;
  35218. private _cachedStencilBuffer;
  35219. private _cachedStencilFunction;
  35220. private _cachedStencilMask;
  35221. private _cachedStencilOperationPass;
  35222. private _cachedStencilOperationFail;
  35223. private _cachedStencilOperationDepthFail;
  35224. private _cachedStencilReference;
  35225. /**
  35226. * Caches the the state of the stencil buffer
  35227. */
  35228. cacheStencilState(): void;
  35229. /**
  35230. * Restores the state of the stencil buffer
  35231. */
  35232. restoreStencilState(): void;
  35233. /**
  35234. * Directly set the WebGL Viewport
  35235. * @param x defines the x coordinate of the viewport (in screen space)
  35236. * @param y defines the y coordinate of the viewport (in screen space)
  35237. * @param width defines the width of the viewport (in screen space)
  35238. * @param height defines the height of the viewport (in screen space)
  35239. * @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
  35240. */
  35241. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35242. /**
  35243. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35244. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35245. * @param y defines the y-coordinate of the corner of the clear rectangle
  35246. * @param width defines the width of the clear rectangle
  35247. * @param height defines the height of the clear rectangle
  35248. * @param clearColor defines the clear color
  35249. */
  35250. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35251. /**
  35252. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35253. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35254. * @param y defines the y-coordinate of the corner of the clear rectangle
  35255. * @param width defines the width of the clear rectangle
  35256. * @param height defines the height of the clear rectangle
  35257. */
  35258. enableScissor(x: number, y: number, width: number, height: number): void;
  35259. /**
  35260. * Disable previously set scissor test rectangle
  35261. */
  35262. disableScissor(): void;
  35263. protected _reportDrawCall(): void;
  35264. /**
  35265. * Initializes a webVR display and starts listening to display change events
  35266. * The onVRDisplayChangedObservable will be notified upon these changes
  35267. * @returns The onVRDisplayChangedObservable
  35268. */
  35269. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35270. /** @hidden */
  35271. _prepareVRComponent(): void;
  35272. /** @hidden */
  35273. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35274. /** @hidden */
  35275. _submitVRFrame(): void;
  35276. /**
  35277. * Call this function to leave webVR mode
  35278. * Will do nothing if webVR is not supported or if there is no webVR device
  35279. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35280. */
  35281. disableVR(): void;
  35282. /**
  35283. * Gets a boolean indicating that the system is in VR mode and is presenting
  35284. * @returns true if VR mode is engaged
  35285. */
  35286. isVRPresenting(): boolean;
  35287. /** @hidden */
  35288. _requestVRFrame(): void;
  35289. /** @hidden */
  35290. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35291. /**
  35292. * Gets the source code of the vertex shader associated with a specific webGL program
  35293. * @param program defines the program to use
  35294. * @returns a string containing the source code of the vertex shader associated with the program
  35295. */
  35296. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35297. /**
  35298. * Gets the source code of the fragment shader associated with a specific webGL program
  35299. * @param program defines the program to use
  35300. * @returns a string containing the source code of the fragment shader associated with the program
  35301. */
  35302. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35303. /**
  35304. * Sets a depth stencil texture from a render target to the according uniform.
  35305. * @param channel The texture channel
  35306. * @param uniform The uniform to set
  35307. * @param texture The render target texture containing the depth stencil texture to apply
  35308. */
  35309. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35310. /**
  35311. * Sets a texture to the webGL context from a postprocess
  35312. * @param channel defines the channel to use
  35313. * @param postProcess defines the source postprocess
  35314. */
  35315. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35316. /**
  35317. * Binds the output of the passed in post process to the texture channel specified
  35318. * @param channel The channel the texture should be bound to
  35319. * @param postProcess The post process which's output should be bound
  35320. */
  35321. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35322. protected _rebuildBuffers(): void;
  35323. /** @hidden */
  35324. _renderFrame(): void;
  35325. _renderLoop(): void;
  35326. /** @hidden */
  35327. _renderViews(): boolean;
  35328. /**
  35329. * Toggle full screen mode
  35330. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35331. */
  35332. switchFullscreen(requestPointerLock: boolean): void;
  35333. /**
  35334. * Enters full screen mode
  35335. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35336. */
  35337. enterFullscreen(requestPointerLock: boolean): void;
  35338. /**
  35339. * Exits full screen mode
  35340. */
  35341. exitFullscreen(): void;
  35342. /**
  35343. * Enters Pointerlock mode
  35344. */
  35345. enterPointerlock(): void;
  35346. /**
  35347. * Exits Pointerlock mode
  35348. */
  35349. exitPointerlock(): void;
  35350. /**
  35351. * Begin a new frame
  35352. */
  35353. beginFrame(): void;
  35354. /**
  35355. * Enf the current frame
  35356. */
  35357. endFrame(): void;
  35358. resize(): void;
  35359. /**
  35360. * Force a specific size of the canvas
  35361. * @param width defines the new canvas' width
  35362. * @param height defines the new canvas' height
  35363. */
  35364. setSize(width: number, height: number): void;
  35365. /**
  35366. * Updates a dynamic vertex buffer.
  35367. * @param vertexBuffer the vertex buffer to update
  35368. * @param data the data used to update the vertex buffer
  35369. * @param byteOffset the byte offset of the data
  35370. * @param byteLength the byte length of the data
  35371. */
  35372. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35373. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35374. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35375. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35376. _releaseTexture(texture: InternalTexture): void;
  35377. /**
  35378. * @hidden
  35379. * Rescales a texture
  35380. * @param source input texutre
  35381. * @param destination destination texture
  35382. * @param scene scene to use to render the resize
  35383. * @param internalFormat format to use when resizing
  35384. * @param onComplete callback to be called when resize has completed
  35385. */
  35386. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35387. /**
  35388. * Gets the current framerate
  35389. * @returns a number representing the framerate
  35390. */
  35391. getFps(): number;
  35392. /**
  35393. * Gets the time spent between current and previous frame
  35394. * @returns a number representing the delta time in ms
  35395. */
  35396. getDeltaTime(): number;
  35397. private _measureFps;
  35398. /** @hidden */
  35399. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35400. /**
  35401. * Update a dynamic index buffer
  35402. * @param indexBuffer defines the target index buffer
  35403. * @param indices defines the data to update
  35404. * @param offset defines the offset in the target index buffer where update should start
  35405. */
  35406. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35407. /**
  35408. * Updates the sample count of a render target texture
  35409. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35410. * @param texture defines the texture to update
  35411. * @param samples defines the sample count to set
  35412. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35413. */
  35414. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35415. /**
  35416. * Updates a depth texture Comparison Mode and Function.
  35417. * If the comparison Function is equal to 0, the mode will be set to none.
  35418. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35419. * @param texture The texture to set the comparison function for
  35420. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35421. */
  35422. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35423. /**
  35424. * Creates a webGL buffer to use with instanciation
  35425. * @param capacity defines the size of the buffer
  35426. * @returns the webGL buffer
  35427. */
  35428. createInstancesBuffer(capacity: number): DataBuffer;
  35429. /**
  35430. * Delete a webGL buffer used with instanciation
  35431. * @param buffer defines the webGL buffer to delete
  35432. */
  35433. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35434. private _clientWaitAsync;
  35435. /** @hidden */
  35436. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35437. dispose(): void;
  35438. private _disableTouchAction;
  35439. /**
  35440. * Display the loading screen
  35441. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35442. */
  35443. displayLoadingUI(): void;
  35444. /**
  35445. * Hide the loading screen
  35446. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35447. */
  35448. hideLoadingUI(): void;
  35449. /**
  35450. * Gets the current loading screen object
  35451. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35452. */
  35453. get loadingScreen(): ILoadingScreen;
  35454. /**
  35455. * Sets the current loading screen object
  35456. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35457. */
  35458. set loadingScreen(loadingScreen: ILoadingScreen);
  35459. /**
  35460. * Sets the current loading screen text
  35461. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35462. */
  35463. set loadingUIText(text: string);
  35464. /**
  35465. * Sets the current loading screen background color
  35466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35467. */
  35468. set loadingUIBackgroundColor(color: string);
  35469. /** Pointerlock and fullscreen */
  35470. /**
  35471. * Ask the browser to promote the current element to pointerlock mode
  35472. * @param element defines the DOM element to promote
  35473. */
  35474. static _RequestPointerlock(element: HTMLElement): void;
  35475. /**
  35476. * Asks the browser to exit pointerlock mode
  35477. */
  35478. static _ExitPointerlock(): void;
  35479. /**
  35480. * Ask the browser to promote the current element to fullscreen rendering mode
  35481. * @param element defines the DOM element to promote
  35482. */
  35483. static _RequestFullscreen(element: HTMLElement): void;
  35484. /**
  35485. * Asks the browser to exit fullscreen mode
  35486. */
  35487. static _ExitFullscreen(): void;
  35488. }
  35489. }
  35490. declare module "babylonjs/Engines/engineStore" {
  35491. import { Nullable } from "babylonjs/types";
  35492. import { Engine } from "babylonjs/Engines/engine";
  35493. import { Scene } from "babylonjs/scene";
  35494. /**
  35495. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35496. * during the life time of the application.
  35497. */
  35498. export class EngineStore {
  35499. /** Gets the list of created engines */
  35500. static Instances: import("babylonjs/Engines/engine").Engine[];
  35501. /** @hidden */
  35502. static _LastCreatedScene: Nullable<Scene>;
  35503. /**
  35504. * Gets the latest created engine
  35505. */
  35506. static get LastCreatedEngine(): Nullable<Engine>;
  35507. /**
  35508. * Gets the latest created scene
  35509. */
  35510. static get LastCreatedScene(): Nullable<Scene>;
  35511. /**
  35512. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35513. * @ignorenaming
  35514. */
  35515. static UseFallbackTexture: boolean;
  35516. /**
  35517. * Texture content used if a texture cannot loaded
  35518. * @ignorenaming
  35519. */
  35520. static FallbackTexture: string;
  35521. }
  35522. }
  35523. declare module "babylonjs/Misc/promise" {
  35524. /**
  35525. * Helper class that provides a small promise polyfill
  35526. */
  35527. export class PromisePolyfill {
  35528. /**
  35529. * Static function used to check if the polyfill is required
  35530. * If this is the case then the function will inject the polyfill to window.Promise
  35531. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35532. */
  35533. static Apply(force?: boolean): void;
  35534. }
  35535. }
  35536. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35537. /**
  35538. * Interface for screenshot methods with describe argument called `size` as object with options
  35539. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35540. */
  35541. export interface IScreenshotSize {
  35542. /**
  35543. * number in pixels for canvas height
  35544. */
  35545. height?: number;
  35546. /**
  35547. * multiplier allowing render at a higher or lower resolution
  35548. * If value is defined then height and width will be ignored and taken from camera
  35549. */
  35550. precision?: number;
  35551. /**
  35552. * number in pixels for canvas width
  35553. */
  35554. width?: number;
  35555. }
  35556. }
  35557. declare module "babylonjs/Misc/tools" {
  35558. import { Nullable, float } from "babylonjs/types";
  35559. import { DomManagement } from "babylonjs/Misc/domManagement";
  35560. import { WebRequest } from "babylonjs/Misc/webRequest";
  35561. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35562. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35563. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35564. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35565. import { Camera } from "babylonjs/Cameras/camera";
  35566. import { Engine } from "babylonjs/Engines/engine";
  35567. interface IColor4Like {
  35568. r: float;
  35569. g: float;
  35570. b: float;
  35571. a: float;
  35572. }
  35573. /**
  35574. * Class containing a set of static utilities functions
  35575. */
  35576. export class Tools {
  35577. /**
  35578. * Gets or sets the base URL to use to load assets
  35579. */
  35580. static get BaseUrl(): string;
  35581. static set BaseUrl(value: string);
  35582. /**
  35583. * Enable/Disable Custom HTTP Request Headers globally.
  35584. * default = false
  35585. * @see CustomRequestHeaders
  35586. */
  35587. static UseCustomRequestHeaders: boolean;
  35588. /**
  35589. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35590. * i.e. when loading files, where the server/service expects an Authorization header
  35591. */
  35592. static CustomRequestHeaders: {
  35593. [key: string]: string;
  35594. };
  35595. /**
  35596. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35597. */
  35598. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35599. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35600. /**
  35601. * Default behaviour for cors in the application.
  35602. * It can be a string if the expected behavior is identical in the entire app.
  35603. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35604. */
  35605. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35606. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35607. /**
  35608. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35609. * @ignorenaming
  35610. */
  35611. static get UseFallbackTexture(): boolean;
  35612. static set UseFallbackTexture(value: boolean);
  35613. /**
  35614. * Use this object to register external classes like custom textures or material
  35615. * to allow the laoders to instantiate them
  35616. */
  35617. static get RegisteredExternalClasses(): {
  35618. [key: string]: Object;
  35619. };
  35620. static set RegisteredExternalClasses(classes: {
  35621. [key: string]: Object;
  35622. });
  35623. /**
  35624. * Texture content used if a texture cannot loaded
  35625. * @ignorenaming
  35626. */
  35627. static get fallbackTexture(): string;
  35628. static set fallbackTexture(value: string);
  35629. /**
  35630. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35631. * @param u defines the coordinate on X axis
  35632. * @param v defines the coordinate on Y axis
  35633. * @param width defines the width of the source data
  35634. * @param height defines the height of the source data
  35635. * @param pixels defines the source byte array
  35636. * @param color defines the output color
  35637. */
  35638. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35639. /**
  35640. * Interpolates between a and b via alpha
  35641. * @param a The lower value (returned when alpha = 0)
  35642. * @param b The upper value (returned when alpha = 1)
  35643. * @param alpha The interpolation-factor
  35644. * @return The mixed value
  35645. */
  35646. static Mix(a: number, b: number, alpha: number): number;
  35647. /**
  35648. * Tries to instantiate a new object from a given class name
  35649. * @param className defines the class name to instantiate
  35650. * @returns the new object or null if the system was not able to do the instantiation
  35651. */
  35652. static Instantiate(className: string): any;
  35653. /**
  35654. * Provides a slice function that will work even on IE
  35655. * @param data defines the array to slice
  35656. * @param start defines the start of the data (optional)
  35657. * @param end defines the end of the data (optional)
  35658. * @returns the new sliced array
  35659. */
  35660. static Slice<T>(data: T, start?: number, end?: number): T;
  35661. /**
  35662. * Polyfill for setImmediate
  35663. * @param action defines the action to execute after the current execution block
  35664. */
  35665. static SetImmediate(action: () => void): void;
  35666. /**
  35667. * Function indicating if a number is an exponent of 2
  35668. * @param value defines the value to test
  35669. * @returns true if the value is an exponent of 2
  35670. */
  35671. static IsExponentOfTwo(value: number): boolean;
  35672. private static _tmpFloatArray;
  35673. /**
  35674. * Returns the nearest 32-bit single precision float representation of a Number
  35675. * @param value A Number. If the parameter is of a different type, it will get converted
  35676. * to a number or to NaN if it cannot be converted
  35677. * @returns number
  35678. */
  35679. static FloatRound(value: number): number;
  35680. /**
  35681. * Extracts the filename from a path
  35682. * @param path defines the path to use
  35683. * @returns the filename
  35684. */
  35685. static GetFilename(path: string): string;
  35686. /**
  35687. * Extracts the "folder" part of a path (everything before the filename).
  35688. * @param uri The URI to extract the info from
  35689. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35690. * @returns The "folder" part of the path
  35691. */
  35692. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35693. /**
  35694. * Extracts text content from a DOM element hierarchy
  35695. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35696. */
  35697. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35698. /**
  35699. * Convert an angle in radians to degrees
  35700. * @param angle defines the angle to convert
  35701. * @returns the angle in degrees
  35702. */
  35703. static ToDegrees(angle: number): number;
  35704. /**
  35705. * Convert an angle in degrees to radians
  35706. * @param angle defines the angle to convert
  35707. * @returns the angle in radians
  35708. */
  35709. static ToRadians(angle: number): number;
  35710. /**
  35711. * Returns an array if obj is not an array
  35712. * @param obj defines the object to evaluate as an array
  35713. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35714. * @returns either obj directly if obj is an array or a new array containing obj
  35715. */
  35716. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35717. /**
  35718. * Gets the pointer prefix to use
  35719. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35720. */
  35721. static GetPointerPrefix(): string;
  35722. /**
  35723. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35724. * @param url define the url we are trying
  35725. * @param element define the dom element where to configure the cors policy
  35726. */
  35727. static SetCorsBehavior(url: string | string[], element: {
  35728. crossOrigin: string | null;
  35729. }): void;
  35730. /**
  35731. * Removes unwanted characters from an url
  35732. * @param url defines the url to clean
  35733. * @returns the cleaned url
  35734. */
  35735. static CleanUrl(url: string): string;
  35736. /**
  35737. * Gets or sets a function used to pre-process url before using them to load assets
  35738. */
  35739. static get PreprocessUrl(): (url: string) => string;
  35740. static set PreprocessUrl(processor: (url: string) => string);
  35741. /**
  35742. * Loads an image as an HTMLImageElement.
  35743. * @param input url string, ArrayBuffer, or Blob to load
  35744. * @param onLoad callback called when the image successfully loads
  35745. * @param onError callback called when the image fails to load
  35746. * @param offlineProvider offline provider for caching
  35747. * @param mimeType optional mime type
  35748. * @returns the HTMLImageElement of the loaded image
  35749. */
  35750. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35751. /**
  35752. * Loads a file from a url
  35753. * @param url url string, ArrayBuffer, or Blob to load
  35754. * @param onSuccess callback called when the file successfully loads
  35755. * @param onProgress callback called while file is loading (if the server supports this mode)
  35756. * @param offlineProvider defines the offline provider for caching
  35757. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35758. * @param onError callback called when the file fails to load
  35759. * @returns a file request object
  35760. */
  35761. 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;
  35762. /**
  35763. * Loads a file from a url
  35764. * @param url the file url to load
  35765. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35766. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35767. */
  35768. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35769. /**
  35770. * Load a script (identified by an url). When the url returns, the
  35771. * content of this file is added into a new script element, attached to the DOM (body element)
  35772. * @param scriptUrl defines the url of the script to laod
  35773. * @param onSuccess defines the callback called when the script is loaded
  35774. * @param onError defines the callback to call if an error occurs
  35775. * @param scriptId defines the id of the script element
  35776. */
  35777. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35778. /**
  35779. * Load an asynchronous script (identified by an url). When the url returns, the
  35780. * content of this file is added into a new script element, attached to the DOM (body element)
  35781. * @param scriptUrl defines the url of the script to laod
  35782. * @param scriptId defines the id of the script element
  35783. * @returns a promise request object
  35784. */
  35785. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35786. /**
  35787. * Loads a file from a blob
  35788. * @param fileToLoad defines the blob to use
  35789. * @param callback defines the callback to call when data is loaded
  35790. * @param progressCallback defines the callback to call during loading process
  35791. * @returns a file request object
  35792. */
  35793. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35794. /**
  35795. * Reads a file from a File object
  35796. * @param file defines the file to load
  35797. * @param onSuccess defines the callback to call when data is loaded
  35798. * @param onProgress defines the callback to call during loading process
  35799. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35800. * @param onError defines the callback to call when an error occurs
  35801. * @returns a file request object
  35802. */
  35803. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35804. /**
  35805. * Creates a data url from a given string content
  35806. * @param content defines the content to convert
  35807. * @returns the new data url link
  35808. */
  35809. static FileAsURL(content: string): string;
  35810. /**
  35811. * Format the given number to a specific decimal format
  35812. * @param value defines the number to format
  35813. * @param decimals defines the number of decimals to use
  35814. * @returns the formatted string
  35815. */
  35816. static Format(value: number, decimals?: number): string;
  35817. /**
  35818. * Tries to copy an object by duplicating every property
  35819. * @param source defines the source object
  35820. * @param destination defines the target object
  35821. * @param doNotCopyList defines a list of properties to avoid
  35822. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35823. */
  35824. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35825. /**
  35826. * Gets a boolean indicating if the given object has no own property
  35827. * @param obj defines the object to test
  35828. * @returns true if object has no own property
  35829. */
  35830. static IsEmpty(obj: any): boolean;
  35831. /**
  35832. * Function used to register events at window level
  35833. * @param windowElement defines the Window object to use
  35834. * @param events defines the events to register
  35835. */
  35836. static RegisterTopRootEvents(windowElement: Window, events: {
  35837. name: string;
  35838. handler: Nullable<(e: FocusEvent) => any>;
  35839. }[]): void;
  35840. /**
  35841. * Function used to unregister events from window level
  35842. * @param windowElement defines the Window object to use
  35843. * @param events defines the events to unregister
  35844. */
  35845. static UnregisterTopRootEvents(windowElement: Window, events: {
  35846. name: string;
  35847. handler: Nullable<(e: FocusEvent) => any>;
  35848. }[]): void;
  35849. /**
  35850. * @ignore
  35851. */
  35852. static _ScreenshotCanvas: HTMLCanvasElement;
  35853. /**
  35854. * Dumps the current bound framebuffer
  35855. * @param width defines the rendering width
  35856. * @param height defines the rendering height
  35857. * @param engine defines the hosting engine
  35858. * @param successCallback defines the callback triggered once the data are available
  35859. * @param mimeType defines the mime type of the result
  35860. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35861. */
  35862. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35863. /**
  35864. * Converts the canvas data to blob.
  35865. * This acts as a polyfill for browsers not supporting the to blob function.
  35866. * @param canvas Defines the canvas to extract the data from
  35867. * @param successCallback Defines the callback triggered once the data are available
  35868. * @param mimeType Defines the mime type of the result
  35869. */
  35870. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35871. /**
  35872. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35873. * @param successCallback defines the callback triggered once the data are available
  35874. * @param mimeType defines the mime type of the result
  35875. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35876. */
  35877. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35878. /**
  35879. * Downloads a blob in the browser
  35880. * @param blob defines the blob to download
  35881. * @param fileName defines the name of the downloaded file
  35882. */
  35883. static Download(blob: Blob, fileName: string): void;
  35884. /**
  35885. * Captures a screenshot of the current rendering
  35886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35887. * @param engine defines the rendering engine
  35888. * @param camera defines the source camera
  35889. * @param size This parameter can be set to a single number or to an object with the
  35890. * following (optional) properties: precision, width, height. If a single number is passed,
  35891. * it will be used for both width and height. If an object is passed, the screenshot size
  35892. * will be derived from the parameters. The precision property is a multiplier allowing
  35893. * rendering at a higher or lower resolution
  35894. * @param successCallback defines the callback receives a single parameter which contains the
  35895. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35896. * src parameter of an <img> to display it
  35897. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35898. * Check your browser for supported MIME types
  35899. */
  35900. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35901. /**
  35902. * Captures a screenshot of the current rendering
  35903. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35904. * @param engine defines the rendering engine
  35905. * @param camera defines the source camera
  35906. * @param size This parameter can be set to a single number or to an object with the
  35907. * following (optional) properties: precision, width, height. If a single number is passed,
  35908. * it will be used for both width and height. If an object is passed, the screenshot size
  35909. * will be derived from the parameters. The precision property is a multiplier allowing
  35910. * rendering at a higher or lower resolution
  35911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35912. * Check your browser for supported MIME types
  35913. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35914. * to the src parameter of an <img> to display it
  35915. */
  35916. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35917. /**
  35918. * Generates an image screenshot from the specified camera.
  35919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35920. * @param engine The engine to use for rendering
  35921. * @param camera The camera to use for rendering
  35922. * @param size This parameter can be set to a single number or to an object with the
  35923. * following (optional) properties: precision, width, height. If a single number is passed,
  35924. * it will be used for both width and height. If an object is passed, the screenshot size
  35925. * will be derived from the parameters. The precision property is a multiplier allowing
  35926. * rendering at a higher or lower resolution
  35927. * @param successCallback The callback receives a single parameter which contains the
  35928. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35929. * src parameter of an <img> to display it
  35930. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35931. * Check your browser for supported MIME types
  35932. * @param samples Texture samples (default: 1)
  35933. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35934. * @param fileName A name for for the downloaded file.
  35935. */
  35936. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35937. /**
  35938. * Generates an image screenshot from the specified camera.
  35939. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35940. * @param engine The engine to use for rendering
  35941. * @param camera The camera to use for rendering
  35942. * @param size This parameter can be set to a single number or to an object with the
  35943. * following (optional) properties: precision, width, height. If a single number is passed,
  35944. * it will be used for both width and height. If an object is passed, the screenshot size
  35945. * will be derived from the parameters. The precision property is a multiplier allowing
  35946. * rendering at a higher or lower resolution
  35947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35948. * Check your browser for supported MIME types
  35949. * @param samples Texture samples (default: 1)
  35950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35951. * @param fileName A name for for the downloaded file.
  35952. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35953. * to the src parameter of an <img> to display it
  35954. */
  35955. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35956. /**
  35957. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35958. * Be aware Math.random() could cause collisions, but:
  35959. * "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"
  35960. * @returns a pseudo random id
  35961. */
  35962. static RandomId(): string;
  35963. /**
  35964. * Test if the given uri is a base64 string
  35965. * @param uri The uri to test
  35966. * @return True if the uri is a base64 string or false otherwise
  35967. */
  35968. static IsBase64(uri: string): boolean;
  35969. /**
  35970. * Decode the given base64 uri.
  35971. * @param uri The uri to decode
  35972. * @return The decoded base64 data.
  35973. */
  35974. static DecodeBase64(uri: string): ArrayBuffer;
  35975. /**
  35976. * Gets the absolute url.
  35977. * @param url the input url
  35978. * @return the absolute url
  35979. */
  35980. static GetAbsoluteUrl(url: string): string;
  35981. /**
  35982. * No log
  35983. */
  35984. static readonly NoneLogLevel: number;
  35985. /**
  35986. * Only message logs
  35987. */
  35988. static readonly MessageLogLevel: number;
  35989. /**
  35990. * Only warning logs
  35991. */
  35992. static readonly WarningLogLevel: number;
  35993. /**
  35994. * Only error logs
  35995. */
  35996. static readonly ErrorLogLevel: number;
  35997. /**
  35998. * All logs
  35999. */
  36000. static readonly AllLogLevel: number;
  36001. /**
  36002. * Gets a value indicating the number of loading errors
  36003. * @ignorenaming
  36004. */
  36005. static get errorsCount(): number;
  36006. /**
  36007. * Callback called when a new log is added
  36008. */
  36009. static OnNewCacheEntry: (entry: string) => void;
  36010. /**
  36011. * Log a message to the console
  36012. * @param message defines the message to log
  36013. */
  36014. static Log(message: string): void;
  36015. /**
  36016. * Write a warning message to the console
  36017. * @param message defines the message to log
  36018. */
  36019. static Warn(message: string): void;
  36020. /**
  36021. * Write an error message to the console
  36022. * @param message defines the message to log
  36023. */
  36024. static Error(message: string): void;
  36025. /**
  36026. * Gets current log cache (list of logs)
  36027. */
  36028. static get LogCache(): string;
  36029. /**
  36030. * Clears the log cache
  36031. */
  36032. static ClearLogCache(): void;
  36033. /**
  36034. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  36035. */
  36036. static set LogLevels(level: number);
  36037. /**
  36038. * Checks if the window object exists
  36039. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  36040. */
  36041. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  36042. /**
  36043. * No performance log
  36044. */
  36045. static readonly PerformanceNoneLogLevel: number;
  36046. /**
  36047. * Use user marks to log performance
  36048. */
  36049. static readonly PerformanceUserMarkLogLevel: number;
  36050. /**
  36051. * Log performance to the console
  36052. */
  36053. static readonly PerformanceConsoleLogLevel: number;
  36054. private static _performance;
  36055. /**
  36056. * Sets the current performance log level
  36057. */
  36058. static set PerformanceLogLevel(level: number);
  36059. private static _StartPerformanceCounterDisabled;
  36060. private static _EndPerformanceCounterDisabled;
  36061. private static _StartUserMark;
  36062. private static _EndUserMark;
  36063. private static _StartPerformanceConsole;
  36064. private static _EndPerformanceConsole;
  36065. /**
  36066. * Starts a performance counter
  36067. */
  36068. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36069. /**
  36070. * Ends a specific performance coutner
  36071. */
  36072. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36073. /**
  36074. * Gets either window.performance.now() if supported or Date.now() else
  36075. */
  36076. static get Now(): number;
  36077. /**
  36078. * This method will return the name of the class used to create the instance of the given object.
  36079. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36080. * @param object the object to get the class name from
  36081. * @param isType defines if the object is actually a type
  36082. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36083. */
  36084. static GetClassName(object: any, isType?: boolean): string;
  36085. /**
  36086. * Gets the first element of an array satisfying a given predicate
  36087. * @param array defines the array to browse
  36088. * @param predicate defines the predicate to use
  36089. * @returns null if not found or the element
  36090. */
  36091. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36092. /**
  36093. * This method will return the name of the full name of the class, including its owning module (if any).
  36094. * 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).
  36095. * @param object the object to get the class name from
  36096. * @param isType defines if the object is actually a type
  36097. * @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.
  36098. * @ignorenaming
  36099. */
  36100. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36101. /**
  36102. * Returns a promise that resolves after the given amount of time.
  36103. * @param delay Number of milliseconds to delay
  36104. * @returns Promise that resolves after the given amount of time
  36105. */
  36106. static DelayAsync(delay: number): Promise<void>;
  36107. /**
  36108. * Utility function to detect if the current user agent is Safari
  36109. * @returns whether or not the current user agent is safari
  36110. */
  36111. static IsSafari(): boolean;
  36112. }
  36113. /**
  36114. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36115. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36116. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36117. * @param name The name of the class, case should be preserved
  36118. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36119. */
  36120. export function className(name: string, module?: string): (target: Object) => void;
  36121. /**
  36122. * An implementation of a loop for asynchronous functions.
  36123. */
  36124. export class AsyncLoop {
  36125. /**
  36126. * Defines the number of iterations for the loop
  36127. */
  36128. iterations: number;
  36129. /**
  36130. * Defines the current index of the loop.
  36131. */
  36132. index: number;
  36133. private _done;
  36134. private _fn;
  36135. private _successCallback;
  36136. /**
  36137. * Constructor.
  36138. * @param iterations the number of iterations.
  36139. * @param func the function to run each iteration
  36140. * @param successCallback the callback that will be called upon succesful execution
  36141. * @param offset starting offset.
  36142. */
  36143. constructor(
  36144. /**
  36145. * Defines the number of iterations for the loop
  36146. */
  36147. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36148. /**
  36149. * Execute the next iteration. Must be called after the last iteration was finished.
  36150. */
  36151. executeNext(): void;
  36152. /**
  36153. * Break the loop and run the success callback.
  36154. */
  36155. breakLoop(): void;
  36156. /**
  36157. * Create and run an async loop.
  36158. * @param iterations the number of iterations.
  36159. * @param fn the function to run each iteration
  36160. * @param successCallback the callback that will be called upon succesful execution
  36161. * @param offset starting offset.
  36162. * @returns the created async loop object
  36163. */
  36164. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36165. /**
  36166. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36167. * @param iterations total number of iterations
  36168. * @param syncedIterations number of synchronous iterations in each async iteration.
  36169. * @param fn the function to call each iteration.
  36170. * @param callback a success call back that will be called when iterating stops.
  36171. * @param breakFunction a break condition (optional)
  36172. * @param timeout timeout settings for the setTimeout function. default - 0.
  36173. * @returns the created async loop object
  36174. */
  36175. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36176. }
  36177. }
  36178. declare module "babylonjs/Misc/stringDictionary" {
  36179. import { Nullable } from "babylonjs/types";
  36180. /**
  36181. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36182. * The underlying implementation relies on an associative array to ensure the best performances.
  36183. * The value can be anything including 'null' but except 'undefined'
  36184. */
  36185. export class StringDictionary<T> {
  36186. /**
  36187. * This will clear this dictionary and copy the content from the 'source' one.
  36188. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36189. * @param source the dictionary to take the content from and copy to this dictionary
  36190. */
  36191. copyFrom(source: StringDictionary<T>): void;
  36192. /**
  36193. * Get a value based from its key
  36194. * @param key the given key to get the matching value from
  36195. * @return the value if found, otherwise undefined is returned
  36196. */
  36197. get(key: string): T | undefined;
  36198. /**
  36199. * Get a value from its key or add it if it doesn't exist.
  36200. * This method will ensure you that a given key/data will be present in the dictionary.
  36201. * @param key the given key to get the matching value from
  36202. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36203. * The factory will only be invoked if there's no data for the given key.
  36204. * @return the value corresponding to the key.
  36205. */
  36206. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36207. /**
  36208. * Get a value from its key if present in the dictionary otherwise add it
  36209. * @param key the key to get the value from
  36210. * @param val if there's no such key/value pair in the dictionary add it with this value
  36211. * @return the value corresponding to the key
  36212. */
  36213. getOrAdd(key: string, val: T): T;
  36214. /**
  36215. * Check if there's a given key in the dictionary
  36216. * @param key the key to check for
  36217. * @return true if the key is present, false otherwise
  36218. */
  36219. contains(key: string): boolean;
  36220. /**
  36221. * Add a new key and its corresponding value
  36222. * @param key the key to add
  36223. * @param value the value corresponding to the key
  36224. * @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
  36225. */
  36226. add(key: string, value: T): boolean;
  36227. /**
  36228. * Update a specific value associated to a key
  36229. * @param key defines the key to use
  36230. * @param value defines the value to store
  36231. * @returns true if the value was updated (or false if the key was not found)
  36232. */
  36233. set(key: string, value: T): boolean;
  36234. /**
  36235. * Get the element of the given key and remove it from the dictionary
  36236. * @param key defines the key to search
  36237. * @returns the value associated with the key or null if not found
  36238. */
  36239. getAndRemove(key: string): Nullable<T>;
  36240. /**
  36241. * Remove a key/value from the dictionary.
  36242. * @param key the key to remove
  36243. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36244. */
  36245. remove(key: string): boolean;
  36246. /**
  36247. * Clear the whole content of the dictionary
  36248. */
  36249. clear(): void;
  36250. /**
  36251. * Gets the current count
  36252. */
  36253. get count(): number;
  36254. /**
  36255. * Execute a callback on each key/val of the dictionary.
  36256. * Note that you can remove any element in this dictionary in the callback implementation
  36257. * @param callback the callback to execute on a given key/value pair
  36258. */
  36259. forEach(callback: (key: string, val: T) => void): void;
  36260. /**
  36261. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36262. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36263. * Note that you can remove any element in this dictionary in the callback implementation
  36264. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36265. * @returns the first item
  36266. */
  36267. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36268. private _count;
  36269. private _data;
  36270. }
  36271. }
  36272. declare module "babylonjs/Collisions/collisionCoordinator" {
  36273. import { Nullable } from "babylonjs/types";
  36274. import { Scene } from "babylonjs/scene";
  36275. import { Vector3 } from "babylonjs/Maths/math.vector";
  36276. import { Collider } from "babylonjs/Collisions/collider";
  36277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36278. /** @hidden */
  36279. export interface ICollisionCoordinator {
  36280. createCollider(): Collider;
  36281. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36282. init(scene: Scene): void;
  36283. }
  36284. /** @hidden */
  36285. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36286. private _scene;
  36287. private _scaledPosition;
  36288. private _scaledVelocity;
  36289. private _finalPosition;
  36290. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36291. createCollider(): Collider;
  36292. init(scene: Scene): void;
  36293. private _collideWithWorld;
  36294. }
  36295. }
  36296. declare module "babylonjs/Inputs/scene.inputManager" {
  36297. import { Nullable } from "babylonjs/types";
  36298. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36299. import { Vector2 } from "babylonjs/Maths/math.vector";
  36300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36301. import { Scene } from "babylonjs/scene";
  36302. /**
  36303. * Class used to manage all inputs for the scene.
  36304. */
  36305. export class InputManager {
  36306. /** The distance in pixel that you have to move to prevent some events */
  36307. static DragMovementThreshold: number;
  36308. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36309. static LongPressDelay: number;
  36310. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36311. static DoubleClickDelay: number;
  36312. /** If you need to check double click without raising a single click at first click, enable this flag */
  36313. static ExclusiveDoubleClickMode: boolean;
  36314. private _wheelEventName;
  36315. private _onPointerMove;
  36316. private _onPointerDown;
  36317. private _onPointerUp;
  36318. private _initClickEvent;
  36319. private _initActionManager;
  36320. private _delayedSimpleClick;
  36321. private _delayedSimpleClickTimeout;
  36322. private _previousDelayedSimpleClickTimeout;
  36323. private _meshPickProceed;
  36324. private _previousButtonPressed;
  36325. private _currentPickResult;
  36326. private _previousPickResult;
  36327. private _totalPointersPressed;
  36328. private _doubleClickOccured;
  36329. private _pointerOverMesh;
  36330. private _pickedDownMesh;
  36331. private _pickedUpMesh;
  36332. private _pointerX;
  36333. private _pointerY;
  36334. private _unTranslatedPointerX;
  36335. private _unTranslatedPointerY;
  36336. private _startingPointerPosition;
  36337. private _previousStartingPointerPosition;
  36338. private _startingPointerTime;
  36339. private _previousStartingPointerTime;
  36340. private _pointerCaptures;
  36341. private _onKeyDown;
  36342. private _onKeyUp;
  36343. private _onCanvasFocusObserver;
  36344. private _onCanvasBlurObserver;
  36345. private _scene;
  36346. /**
  36347. * Creates a new InputManager
  36348. * @param scene defines the hosting scene
  36349. */
  36350. constructor(scene: Scene);
  36351. /**
  36352. * Gets the mesh that is currently under the pointer
  36353. */
  36354. get meshUnderPointer(): Nullable<AbstractMesh>;
  36355. /**
  36356. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36357. */
  36358. get unTranslatedPointer(): Vector2;
  36359. /**
  36360. * Gets or sets the current on-screen X position of the pointer
  36361. */
  36362. get pointerX(): number;
  36363. set pointerX(value: number);
  36364. /**
  36365. * Gets or sets the current on-screen Y position of the pointer
  36366. */
  36367. get pointerY(): number;
  36368. set pointerY(value: number);
  36369. private _updatePointerPosition;
  36370. private _processPointerMove;
  36371. private _setRayOnPointerInfo;
  36372. private _checkPrePointerObservable;
  36373. /**
  36374. * Use this method to simulate a pointer move on a mesh
  36375. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36376. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36377. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36378. */
  36379. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36380. /**
  36381. * Use this method to simulate a pointer down on a mesh
  36382. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36383. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36384. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36385. */
  36386. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36387. private _processPointerDown;
  36388. /** @hidden */
  36389. _isPointerSwiping(): boolean;
  36390. /**
  36391. * Use this method to simulate a pointer up on a mesh
  36392. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36393. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36394. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36395. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36396. */
  36397. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36398. private _processPointerUp;
  36399. /**
  36400. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36401. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36402. * @returns true if the pointer was captured
  36403. */
  36404. isPointerCaptured(pointerId?: number): boolean;
  36405. /**
  36406. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36407. * @param attachUp defines if you want to attach events to pointerup
  36408. * @param attachDown defines if you want to attach events to pointerdown
  36409. * @param attachMove defines if you want to attach events to pointermove
  36410. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36411. */
  36412. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36413. /**
  36414. * Detaches all event handlers
  36415. */
  36416. detachControl(): void;
  36417. /**
  36418. * Force the value of meshUnderPointer
  36419. * @param mesh defines the mesh to use
  36420. */
  36421. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36422. /**
  36423. * Gets the mesh under the pointer
  36424. * @returns a Mesh or null if no mesh is under the pointer
  36425. */
  36426. getPointerOverMesh(): Nullable<AbstractMesh>;
  36427. }
  36428. }
  36429. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36430. /**
  36431. * Helper class used to generate session unique ID
  36432. */
  36433. export class UniqueIdGenerator {
  36434. private static _UniqueIdCounter;
  36435. /**
  36436. * Gets an unique (relatively to the current scene) Id
  36437. */
  36438. static get UniqueId(): number;
  36439. }
  36440. }
  36441. declare module "babylonjs/Animations/animationGroup" {
  36442. import { Animatable } from "babylonjs/Animations/animatable";
  36443. import { Animation } from "babylonjs/Animations/animation";
  36444. import { Scene, IDisposable } from "babylonjs/scene";
  36445. import { Observable } from "babylonjs/Misc/observable";
  36446. import { Nullable } from "babylonjs/types";
  36447. import "babylonjs/Animations/animatable";
  36448. /**
  36449. * This class defines the direct association between an animation and a target
  36450. */
  36451. export class TargetedAnimation {
  36452. /**
  36453. * Animation to perform
  36454. */
  36455. animation: Animation;
  36456. /**
  36457. * Target to animate
  36458. */
  36459. target: any;
  36460. /**
  36461. * Serialize the object
  36462. * @returns the JSON object representing the current entity
  36463. */
  36464. serialize(): any;
  36465. }
  36466. /**
  36467. * Use this class to create coordinated animations on multiple targets
  36468. */
  36469. export class AnimationGroup implements IDisposable {
  36470. /** The name of the animation group */
  36471. name: string;
  36472. private _scene;
  36473. private _targetedAnimations;
  36474. private _animatables;
  36475. private _from;
  36476. private _to;
  36477. private _isStarted;
  36478. private _isPaused;
  36479. private _speedRatio;
  36480. private _loopAnimation;
  36481. private _isAdditive;
  36482. /**
  36483. * Gets or sets the unique id of the node
  36484. */
  36485. uniqueId: number;
  36486. /**
  36487. * This observable will notify when one animation have ended
  36488. */
  36489. onAnimationEndObservable: Observable<TargetedAnimation>;
  36490. /**
  36491. * Observer raised when one animation loops
  36492. */
  36493. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36494. /**
  36495. * Observer raised when all animations have looped
  36496. */
  36497. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36498. /**
  36499. * This observable will notify when all animations have ended.
  36500. */
  36501. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36502. /**
  36503. * This observable will notify when all animations have paused.
  36504. */
  36505. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36506. /**
  36507. * This observable will notify when all animations are playing.
  36508. */
  36509. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36510. /**
  36511. * Gets the first frame
  36512. */
  36513. get from(): number;
  36514. /**
  36515. * Gets the last frame
  36516. */
  36517. get to(): number;
  36518. /**
  36519. * Define if the animations are started
  36520. */
  36521. get isStarted(): boolean;
  36522. /**
  36523. * Gets a value indicating that the current group is playing
  36524. */
  36525. get isPlaying(): boolean;
  36526. /**
  36527. * Gets or sets the speed ratio to use for all animations
  36528. */
  36529. get speedRatio(): number;
  36530. /**
  36531. * Gets or sets the speed ratio to use for all animations
  36532. */
  36533. set speedRatio(value: number);
  36534. /**
  36535. * Gets or sets if all animations should loop or not
  36536. */
  36537. get loopAnimation(): boolean;
  36538. set loopAnimation(value: boolean);
  36539. /**
  36540. * Gets or sets if all animations should be evaluated additively
  36541. */
  36542. get isAdditive(): boolean;
  36543. set isAdditive(value: boolean);
  36544. /**
  36545. * Gets the targeted animations for this animation group
  36546. */
  36547. get targetedAnimations(): Array<TargetedAnimation>;
  36548. /**
  36549. * returning the list of animatables controlled by this animation group.
  36550. */
  36551. get animatables(): Array<Animatable>;
  36552. /**
  36553. * Instantiates a new Animation Group.
  36554. * This helps managing several animations at once.
  36555. * @see http://doc.babylonjs.com/how_to/group
  36556. * @param name Defines the name of the group
  36557. * @param scene Defines the scene the group belongs to
  36558. */
  36559. constructor(
  36560. /** The name of the animation group */
  36561. name: string, scene?: Nullable<Scene>);
  36562. /**
  36563. * Add an animation (with its target) in the group
  36564. * @param animation defines the animation we want to add
  36565. * @param target defines the target of the animation
  36566. * @returns the TargetedAnimation object
  36567. */
  36568. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36569. /**
  36570. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36571. * It can add constant keys at begin or end
  36572. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36573. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36574. * @returns the animation group
  36575. */
  36576. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36577. private _animationLoopCount;
  36578. private _animationLoopFlags;
  36579. private _processLoop;
  36580. /**
  36581. * Start all animations on given targets
  36582. * @param loop defines if animations must loop
  36583. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36584. * @param from defines the from key (optional)
  36585. * @param to defines the to key (optional)
  36586. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36587. * @returns the current animation group
  36588. */
  36589. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36590. /**
  36591. * Pause all animations
  36592. * @returns the animation group
  36593. */
  36594. pause(): AnimationGroup;
  36595. /**
  36596. * Play all animations to initial state
  36597. * This function will start() the animations if they were not started or will restart() them if they were paused
  36598. * @param loop defines if animations must loop
  36599. * @returns the animation group
  36600. */
  36601. play(loop?: boolean): AnimationGroup;
  36602. /**
  36603. * Reset all animations to initial state
  36604. * @returns the animation group
  36605. */
  36606. reset(): AnimationGroup;
  36607. /**
  36608. * Restart animations from key 0
  36609. * @returns the animation group
  36610. */
  36611. restart(): AnimationGroup;
  36612. /**
  36613. * Stop all animations
  36614. * @returns the animation group
  36615. */
  36616. stop(): AnimationGroup;
  36617. /**
  36618. * Set animation weight for all animatables
  36619. * @param weight defines the weight to use
  36620. * @return the animationGroup
  36621. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36622. */
  36623. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36624. /**
  36625. * Synchronize and normalize all animatables with a source animatable
  36626. * @param root defines the root animatable to synchronize with
  36627. * @return the animationGroup
  36628. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36629. */
  36630. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36631. /**
  36632. * Goes to a specific frame in this animation group
  36633. * @param frame the frame number to go to
  36634. * @return the animationGroup
  36635. */
  36636. goToFrame(frame: number): AnimationGroup;
  36637. /**
  36638. * Dispose all associated resources
  36639. */
  36640. dispose(): void;
  36641. private _checkAnimationGroupEnded;
  36642. /**
  36643. * Clone the current animation group and returns a copy
  36644. * @param newName defines the name of the new group
  36645. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36646. * @returns the new aniamtion group
  36647. */
  36648. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36649. /**
  36650. * Serializes the animationGroup to an object
  36651. * @returns Serialized object
  36652. */
  36653. serialize(): any;
  36654. /**
  36655. * Returns a new AnimationGroup object parsed from the source provided.
  36656. * @param parsedAnimationGroup defines the source
  36657. * @param scene defines the scene that will receive the animationGroup
  36658. * @returns a new AnimationGroup
  36659. */
  36660. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36661. /**
  36662. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36663. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36664. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36665. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36666. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36667. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36668. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36669. */
  36670. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36671. /**
  36672. * Returns the string "AnimationGroup"
  36673. * @returns "AnimationGroup"
  36674. */
  36675. getClassName(): string;
  36676. /**
  36677. * Creates a detailled string about the object
  36678. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36679. * @returns a string representing the object
  36680. */
  36681. toString(fullDetails?: boolean): string;
  36682. }
  36683. }
  36684. declare module "babylonjs/scene" {
  36685. import { Nullable } from "babylonjs/types";
  36686. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36687. import { Observable } from "babylonjs/Misc/observable";
  36688. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36689. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36690. import { Geometry } from "babylonjs/Meshes/geometry";
  36691. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36692. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36694. import { Mesh } from "babylonjs/Meshes/mesh";
  36695. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36696. import { Bone } from "babylonjs/Bones/bone";
  36697. import { Skeleton } from "babylonjs/Bones/skeleton";
  36698. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36699. import { Camera } from "babylonjs/Cameras/camera";
  36700. import { AbstractScene } from "babylonjs/abstractScene";
  36701. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36702. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36703. import { Material } from "babylonjs/Materials/material";
  36704. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36705. import { Effect } from "babylonjs/Materials/effect";
  36706. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36707. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36708. import { Light } from "babylonjs/Lights/light";
  36709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36710. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36711. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36712. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36713. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36714. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36715. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36716. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36717. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36718. import { Engine } from "babylonjs/Engines/engine";
  36719. import { Node } from "babylonjs/node";
  36720. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36721. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36722. import { WebRequest } from "babylonjs/Misc/webRequest";
  36723. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36724. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36725. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36726. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36727. import { Plane } from "babylonjs/Maths/math.plane";
  36728. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36729. import { Ray } from "babylonjs/Culling/ray";
  36730. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36731. import { Animation } from "babylonjs/Animations/animation";
  36732. import { Animatable } from "babylonjs/Animations/animatable";
  36733. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36734. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36735. import { Collider } from "babylonjs/Collisions/collider";
  36736. /**
  36737. * Define an interface for all classes that will hold resources
  36738. */
  36739. export interface IDisposable {
  36740. /**
  36741. * Releases all held resources
  36742. */
  36743. dispose(): void;
  36744. }
  36745. /** Interface defining initialization parameters for Scene class */
  36746. export interface SceneOptions {
  36747. /**
  36748. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36749. * It will improve performance when the number of geometries becomes important.
  36750. */
  36751. useGeometryUniqueIdsMap?: boolean;
  36752. /**
  36753. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36754. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36755. */
  36756. useMaterialMeshMap?: boolean;
  36757. /**
  36758. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36759. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36760. */
  36761. useClonedMeshMap?: boolean;
  36762. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36763. virtual?: boolean;
  36764. }
  36765. /**
  36766. * Represents a scene to be rendered by the engine.
  36767. * @see http://doc.babylonjs.com/features/scene
  36768. */
  36769. export class Scene extends AbstractScene implements IAnimatable {
  36770. /** The fog is deactivated */
  36771. static readonly FOGMODE_NONE: number;
  36772. /** The fog density is following an exponential function */
  36773. static readonly FOGMODE_EXP: number;
  36774. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36775. static readonly FOGMODE_EXP2: number;
  36776. /** The fog density is following a linear function. */
  36777. static readonly FOGMODE_LINEAR: number;
  36778. /**
  36779. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36781. */
  36782. static MinDeltaTime: number;
  36783. /**
  36784. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36786. */
  36787. static MaxDeltaTime: number;
  36788. /**
  36789. * Factory used to create the default material.
  36790. * @param name The name of the material to create
  36791. * @param scene The scene to create the material for
  36792. * @returns The default material
  36793. */
  36794. static DefaultMaterialFactory(scene: Scene): Material;
  36795. /**
  36796. * Factory used to create the a collision coordinator.
  36797. * @returns The collision coordinator
  36798. */
  36799. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36800. /** @hidden */
  36801. _inputManager: InputManager;
  36802. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36803. cameraToUseForPointers: Nullable<Camera>;
  36804. /** @hidden */
  36805. readonly _isScene: boolean;
  36806. /** @hidden */
  36807. _blockEntityCollection: boolean;
  36808. /**
  36809. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36810. */
  36811. autoClear: boolean;
  36812. /**
  36813. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36814. */
  36815. autoClearDepthAndStencil: boolean;
  36816. /**
  36817. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36818. */
  36819. clearColor: Color4;
  36820. /**
  36821. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36822. */
  36823. ambientColor: Color3;
  36824. /**
  36825. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36826. * It should only be one of the following (if not the default embedded one):
  36827. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36828. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36829. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36830. * The material properties need to be setup according to the type of texture in use.
  36831. */
  36832. environmentBRDFTexture: BaseTexture;
  36833. /** @hidden */
  36834. protected _environmentTexture: Nullable<BaseTexture>;
  36835. /**
  36836. * Texture used in all pbr material as the reflection texture.
  36837. * As in the majority of the scene they are the same (exception for multi room and so on),
  36838. * this is easier to reference from here than from all the materials.
  36839. */
  36840. get environmentTexture(): Nullable<BaseTexture>;
  36841. /**
  36842. * Texture used in all pbr material as the reflection texture.
  36843. * As in the majority of the scene they are the same (exception for multi room and so on),
  36844. * this is easier to set here than in all the materials.
  36845. */
  36846. set environmentTexture(value: Nullable<BaseTexture>);
  36847. /** @hidden */
  36848. protected _environmentIntensity: number;
  36849. /**
  36850. * Intensity of the environment in all pbr material.
  36851. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36852. * As in the majority of the scene they are the same (exception for multi room and so on),
  36853. * this is easier to reference from here than from all the materials.
  36854. */
  36855. get environmentIntensity(): number;
  36856. /**
  36857. * Intensity of the environment in all pbr material.
  36858. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36859. * As in the majority of the scene they are the same (exception for multi room and so on),
  36860. * this is easier to set here than in all the materials.
  36861. */
  36862. set environmentIntensity(value: number);
  36863. /** @hidden */
  36864. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36865. /**
  36866. * Default image processing configuration used either in the rendering
  36867. * Forward main pass or through the imageProcessingPostProcess if present.
  36868. * As in the majority of the scene they are the same (exception for multi camera),
  36869. * this is easier to reference from here than from all the materials and post process.
  36870. *
  36871. * No setter as we it is a shared configuration, you can set the values instead.
  36872. */
  36873. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36874. private _forceWireframe;
  36875. /**
  36876. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36877. */
  36878. set forceWireframe(value: boolean);
  36879. get forceWireframe(): boolean;
  36880. private _skipFrustumClipping;
  36881. /**
  36882. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36883. */
  36884. set skipFrustumClipping(value: boolean);
  36885. get skipFrustumClipping(): boolean;
  36886. private _forcePointsCloud;
  36887. /**
  36888. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36889. */
  36890. set forcePointsCloud(value: boolean);
  36891. get forcePointsCloud(): boolean;
  36892. /**
  36893. * Gets or sets the active clipplane 1
  36894. */
  36895. clipPlane: Nullable<Plane>;
  36896. /**
  36897. * Gets or sets the active clipplane 2
  36898. */
  36899. clipPlane2: Nullable<Plane>;
  36900. /**
  36901. * Gets or sets the active clipplane 3
  36902. */
  36903. clipPlane3: Nullable<Plane>;
  36904. /**
  36905. * Gets or sets the active clipplane 4
  36906. */
  36907. clipPlane4: Nullable<Plane>;
  36908. /**
  36909. * Gets or sets the active clipplane 5
  36910. */
  36911. clipPlane5: Nullable<Plane>;
  36912. /**
  36913. * Gets or sets the active clipplane 6
  36914. */
  36915. clipPlane6: Nullable<Plane>;
  36916. /**
  36917. * Gets or sets a boolean indicating if animations are enabled
  36918. */
  36919. animationsEnabled: boolean;
  36920. private _animationPropertiesOverride;
  36921. /**
  36922. * Gets or sets the animation properties override
  36923. */
  36924. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36925. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36926. /**
  36927. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36928. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36929. */
  36930. useConstantAnimationDeltaTime: boolean;
  36931. /**
  36932. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36933. * Please note that it requires to run a ray cast through the scene on every frame
  36934. */
  36935. constantlyUpdateMeshUnderPointer: boolean;
  36936. /**
  36937. * Defines the HTML cursor to use when hovering over interactive elements
  36938. */
  36939. hoverCursor: string;
  36940. /**
  36941. * Defines the HTML default cursor to use (empty by default)
  36942. */
  36943. defaultCursor: string;
  36944. /**
  36945. * Defines whether cursors are handled by the scene.
  36946. */
  36947. doNotHandleCursors: boolean;
  36948. /**
  36949. * This is used to call preventDefault() on pointer down
  36950. * in order to block unwanted artifacts like system double clicks
  36951. */
  36952. preventDefaultOnPointerDown: boolean;
  36953. /**
  36954. * This is used to call preventDefault() on pointer up
  36955. * in order to block unwanted artifacts like system double clicks
  36956. */
  36957. preventDefaultOnPointerUp: boolean;
  36958. /**
  36959. * Gets or sets user defined metadata
  36960. */
  36961. metadata: any;
  36962. /**
  36963. * For internal use only. Please do not use.
  36964. */
  36965. reservedDataStore: any;
  36966. /**
  36967. * Gets the name of the plugin used to load this scene (null by default)
  36968. */
  36969. loadingPluginName: string;
  36970. /**
  36971. * Use this array to add regular expressions used to disable offline support for specific urls
  36972. */
  36973. disableOfflineSupportExceptionRules: RegExp[];
  36974. /**
  36975. * An event triggered when the scene is disposed.
  36976. */
  36977. onDisposeObservable: Observable<Scene>;
  36978. private _onDisposeObserver;
  36979. /** Sets a function to be executed when this scene is disposed. */
  36980. set onDispose(callback: () => void);
  36981. /**
  36982. * An event triggered before rendering the scene (right after animations and physics)
  36983. */
  36984. onBeforeRenderObservable: Observable<Scene>;
  36985. private _onBeforeRenderObserver;
  36986. /** Sets a function to be executed before rendering this scene */
  36987. set beforeRender(callback: Nullable<() => void>);
  36988. /**
  36989. * An event triggered after rendering the scene
  36990. */
  36991. onAfterRenderObservable: Observable<Scene>;
  36992. /**
  36993. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36994. */
  36995. onAfterRenderCameraObservable: Observable<Camera>;
  36996. private _onAfterRenderObserver;
  36997. /** Sets a function to be executed after rendering this scene */
  36998. set afterRender(callback: Nullable<() => void>);
  36999. /**
  37000. * An event triggered before animating the scene
  37001. */
  37002. onBeforeAnimationsObservable: Observable<Scene>;
  37003. /**
  37004. * An event triggered after animations processing
  37005. */
  37006. onAfterAnimationsObservable: Observable<Scene>;
  37007. /**
  37008. * An event triggered before draw calls are ready to be sent
  37009. */
  37010. onBeforeDrawPhaseObservable: Observable<Scene>;
  37011. /**
  37012. * An event triggered after draw calls have been sent
  37013. */
  37014. onAfterDrawPhaseObservable: Observable<Scene>;
  37015. /**
  37016. * An event triggered when the scene is ready
  37017. */
  37018. onReadyObservable: Observable<Scene>;
  37019. /**
  37020. * An event triggered before rendering a camera
  37021. */
  37022. onBeforeCameraRenderObservable: Observable<Camera>;
  37023. private _onBeforeCameraRenderObserver;
  37024. /** Sets a function to be executed before rendering a camera*/
  37025. set beforeCameraRender(callback: () => void);
  37026. /**
  37027. * An event triggered after rendering a camera
  37028. */
  37029. onAfterCameraRenderObservable: Observable<Camera>;
  37030. private _onAfterCameraRenderObserver;
  37031. /** Sets a function to be executed after rendering a camera*/
  37032. set afterCameraRender(callback: () => void);
  37033. /**
  37034. * An event triggered when active meshes evaluation is about to start
  37035. */
  37036. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  37037. /**
  37038. * An event triggered when active meshes evaluation is done
  37039. */
  37040. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  37041. /**
  37042. * An event triggered when particles rendering is about to start
  37043. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37044. */
  37045. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37046. /**
  37047. * An event triggered when particles rendering is done
  37048. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37049. */
  37050. onAfterParticlesRenderingObservable: Observable<Scene>;
  37051. /**
  37052. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37053. */
  37054. onDataLoadedObservable: Observable<Scene>;
  37055. /**
  37056. * An event triggered when a camera is created
  37057. */
  37058. onNewCameraAddedObservable: Observable<Camera>;
  37059. /**
  37060. * An event triggered when a camera is removed
  37061. */
  37062. onCameraRemovedObservable: Observable<Camera>;
  37063. /**
  37064. * An event triggered when a light is created
  37065. */
  37066. onNewLightAddedObservable: Observable<Light>;
  37067. /**
  37068. * An event triggered when a light is removed
  37069. */
  37070. onLightRemovedObservable: Observable<Light>;
  37071. /**
  37072. * An event triggered when a geometry is created
  37073. */
  37074. onNewGeometryAddedObservable: Observable<Geometry>;
  37075. /**
  37076. * An event triggered when a geometry is removed
  37077. */
  37078. onGeometryRemovedObservable: Observable<Geometry>;
  37079. /**
  37080. * An event triggered when a transform node is created
  37081. */
  37082. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37083. /**
  37084. * An event triggered when a transform node is removed
  37085. */
  37086. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37087. /**
  37088. * An event triggered when a mesh is created
  37089. */
  37090. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37091. /**
  37092. * An event triggered when a mesh is removed
  37093. */
  37094. onMeshRemovedObservable: Observable<AbstractMesh>;
  37095. /**
  37096. * An event triggered when a skeleton is created
  37097. */
  37098. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37099. /**
  37100. * An event triggered when a skeleton is removed
  37101. */
  37102. onSkeletonRemovedObservable: Observable<Skeleton>;
  37103. /**
  37104. * An event triggered when a material is created
  37105. */
  37106. onNewMaterialAddedObservable: Observable<Material>;
  37107. /**
  37108. * An event triggered when a material is removed
  37109. */
  37110. onMaterialRemovedObservable: Observable<Material>;
  37111. /**
  37112. * An event triggered when a texture is created
  37113. */
  37114. onNewTextureAddedObservable: Observable<BaseTexture>;
  37115. /**
  37116. * An event triggered when a texture is removed
  37117. */
  37118. onTextureRemovedObservable: Observable<BaseTexture>;
  37119. /**
  37120. * An event triggered when render targets are about to be rendered
  37121. * Can happen multiple times per frame.
  37122. */
  37123. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37124. /**
  37125. * An event triggered when render targets were rendered.
  37126. * Can happen multiple times per frame.
  37127. */
  37128. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37129. /**
  37130. * An event triggered before calculating deterministic simulation step
  37131. */
  37132. onBeforeStepObservable: Observable<Scene>;
  37133. /**
  37134. * An event triggered after calculating deterministic simulation step
  37135. */
  37136. onAfterStepObservable: Observable<Scene>;
  37137. /**
  37138. * An event triggered when the activeCamera property is updated
  37139. */
  37140. onActiveCameraChanged: Observable<Scene>;
  37141. /**
  37142. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37143. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37144. * 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)
  37145. */
  37146. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37147. /**
  37148. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37149. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37150. * 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)
  37151. */
  37152. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37153. /**
  37154. * This Observable will when a mesh has been imported into the scene.
  37155. */
  37156. onMeshImportedObservable: Observable<AbstractMesh>;
  37157. /**
  37158. * This Observable will when an animation file has been imported into the scene.
  37159. */
  37160. onAnimationFileImportedObservable: Observable<Scene>;
  37161. /**
  37162. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37163. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37164. */
  37165. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37166. /** @hidden */
  37167. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37168. /**
  37169. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37170. */
  37171. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37172. /**
  37173. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37174. */
  37175. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37176. /**
  37177. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37178. */
  37179. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37180. /** Callback called when a pointer move is detected */
  37181. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37182. /** Callback called when a pointer down is detected */
  37183. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37184. /** Callback called when a pointer up is detected */
  37185. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37186. /** Callback called when a pointer pick is detected */
  37187. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37188. /**
  37189. * 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).
  37190. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37191. */
  37192. onPrePointerObservable: Observable<PointerInfoPre>;
  37193. /**
  37194. * Observable event triggered each time an input event is received from the rendering canvas
  37195. */
  37196. onPointerObservable: Observable<PointerInfo>;
  37197. /**
  37198. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37199. */
  37200. get unTranslatedPointer(): Vector2;
  37201. /**
  37202. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37203. */
  37204. static get DragMovementThreshold(): number;
  37205. static set DragMovementThreshold(value: number);
  37206. /**
  37207. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37208. */
  37209. static get LongPressDelay(): number;
  37210. static set LongPressDelay(value: number);
  37211. /**
  37212. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37213. */
  37214. static get DoubleClickDelay(): number;
  37215. static set DoubleClickDelay(value: number);
  37216. /** If you need to check double click without raising a single click at first click, enable this flag */
  37217. static get ExclusiveDoubleClickMode(): boolean;
  37218. static set ExclusiveDoubleClickMode(value: boolean);
  37219. /** @hidden */
  37220. _mirroredCameraPosition: Nullable<Vector3>;
  37221. /**
  37222. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37223. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37224. */
  37225. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37226. /**
  37227. * Observable event triggered each time an keyboard event is received from the hosting window
  37228. */
  37229. onKeyboardObservable: Observable<KeyboardInfo>;
  37230. private _useRightHandedSystem;
  37231. /**
  37232. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37233. */
  37234. set useRightHandedSystem(value: boolean);
  37235. get useRightHandedSystem(): boolean;
  37236. private _timeAccumulator;
  37237. private _currentStepId;
  37238. private _currentInternalStep;
  37239. /**
  37240. * Sets the step Id used by deterministic lock step
  37241. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37242. * @param newStepId defines the step Id
  37243. */
  37244. setStepId(newStepId: number): void;
  37245. /**
  37246. * Gets the step Id used by deterministic lock step
  37247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37248. * @returns the step Id
  37249. */
  37250. getStepId(): number;
  37251. /**
  37252. * Gets the internal step used by deterministic lock step
  37253. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37254. * @returns the internal step
  37255. */
  37256. getInternalStep(): number;
  37257. private _fogEnabled;
  37258. /**
  37259. * Gets or sets a boolean indicating if fog is enabled on this scene
  37260. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37261. * (Default is true)
  37262. */
  37263. set fogEnabled(value: boolean);
  37264. get fogEnabled(): boolean;
  37265. private _fogMode;
  37266. /**
  37267. * Gets or sets the fog mode to use
  37268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37269. * | mode | value |
  37270. * | --- | --- |
  37271. * | FOGMODE_NONE | 0 |
  37272. * | FOGMODE_EXP | 1 |
  37273. * | FOGMODE_EXP2 | 2 |
  37274. * | FOGMODE_LINEAR | 3 |
  37275. */
  37276. set fogMode(value: number);
  37277. get fogMode(): number;
  37278. /**
  37279. * Gets or sets the fog color to use
  37280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37281. * (Default is Color3(0.2, 0.2, 0.3))
  37282. */
  37283. fogColor: Color3;
  37284. /**
  37285. * Gets or sets the fog density to use
  37286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37287. * (Default is 0.1)
  37288. */
  37289. fogDensity: number;
  37290. /**
  37291. * Gets or sets the fog start distance to use
  37292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37293. * (Default is 0)
  37294. */
  37295. fogStart: number;
  37296. /**
  37297. * Gets or sets the fog end distance to use
  37298. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37299. * (Default is 1000)
  37300. */
  37301. fogEnd: number;
  37302. private _shadowsEnabled;
  37303. /**
  37304. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37305. */
  37306. set shadowsEnabled(value: boolean);
  37307. get shadowsEnabled(): boolean;
  37308. private _lightsEnabled;
  37309. /**
  37310. * Gets or sets a boolean indicating if lights are enabled on this scene
  37311. */
  37312. set lightsEnabled(value: boolean);
  37313. get lightsEnabled(): boolean;
  37314. /** All of the active cameras added to this scene. */
  37315. activeCameras: Camera[];
  37316. /** @hidden */
  37317. _activeCamera: Nullable<Camera>;
  37318. /** Gets or sets the current active camera */
  37319. get activeCamera(): Nullable<Camera>;
  37320. set activeCamera(value: Nullable<Camera>);
  37321. private _defaultMaterial;
  37322. /** The default material used on meshes when no material is affected */
  37323. get defaultMaterial(): Material;
  37324. /** The default material used on meshes when no material is affected */
  37325. set defaultMaterial(value: Material);
  37326. private _texturesEnabled;
  37327. /**
  37328. * Gets or sets a boolean indicating if textures are enabled on this scene
  37329. */
  37330. set texturesEnabled(value: boolean);
  37331. get texturesEnabled(): boolean;
  37332. /**
  37333. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37334. */
  37335. physicsEnabled: boolean;
  37336. /**
  37337. * Gets or sets a boolean indicating if particles are enabled on this scene
  37338. */
  37339. particlesEnabled: boolean;
  37340. /**
  37341. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37342. */
  37343. spritesEnabled: boolean;
  37344. private _skeletonsEnabled;
  37345. /**
  37346. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37347. */
  37348. set skeletonsEnabled(value: boolean);
  37349. get skeletonsEnabled(): boolean;
  37350. /**
  37351. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37352. */
  37353. lensFlaresEnabled: boolean;
  37354. /**
  37355. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37357. */
  37358. collisionsEnabled: boolean;
  37359. private _collisionCoordinator;
  37360. /** @hidden */
  37361. get collisionCoordinator(): ICollisionCoordinator;
  37362. /**
  37363. * Defines the gravity applied to this scene (used only for collisions)
  37364. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37365. */
  37366. gravity: Vector3;
  37367. /**
  37368. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37369. */
  37370. postProcessesEnabled: boolean;
  37371. /**
  37372. * The list of postprocesses added to the scene
  37373. */
  37374. postProcesses: PostProcess[];
  37375. /**
  37376. * Gets the current postprocess manager
  37377. */
  37378. postProcessManager: PostProcessManager;
  37379. /**
  37380. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37381. */
  37382. renderTargetsEnabled: boolean;
  37383. /**
  37384. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37385. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37386. */
  37387. dumpNextRenderTargets: boolean;
  37388. /**
  37389. * The list of user defined render targets added to the scene
  37390. */
  37391. customRenderTargets: RenderTargetTexture[];
  37392. /**
  37393. * Defines if texture loading must be delayed
  37394. * If true, textures will only be loaded when they need to be rendered
  37395. */
  37396. useDelayedTextureLoading: boolean;
  37397. /**
  37398. * Gets the list of meshes imported to the scene through SceneLoader
  37399. */
  37400. importedMeshesFiles: String[];
  37401. /**
  37402. * Gets or sets a boolean indicating if probes are enabled on this scene
  37403. */
  37404. probesEnabled: boolean;
  37405. /**
  37406. * Gets or sets the current offline provider to use to store scene data
  37407. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37408. */
  37409. offlineProvider: IOfflineProvider;
  37410. /**
  37411. * Gets or sets the action manager associated with the scene
  37412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37413. */
  37414. actionManager: AbstractActionManager;
  37415. private _meshesForIntersections;
  37416. /**
  37417. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37418. */
  37419. proceduralTexturesEnabled: boolean;
  37420. private _engine;
  37421. private _totalVertices;
  37422. /** @hidden */
  37423. _activeIndices: PerfCounter;
  37424. /** @hidden */
  37425. _activeParticles: PerfCounter;
  37426. /** @hidden */
  37427. _activeBones: PerfCounter;
  37428. private _animationRatio;
  37429. /** @hidden */
  37430. _animationTimeLast: number;
  37431. /** @hidden */
  37432. _animationTime: number;
  37433. /**
  37434. * Gets or sets a general scale for animation speed
  37435. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37436. */
  37437. animationTimeScale: number;
  37438. /** @hidden */
  37439. _cachedMaterial: Nullable<Material>;
  37440. /** @hidden */
  37441. _cachedEffect: Nullable<Effect>;
  37442. /** @hidden */
  37443. _cachedVisibility: Nullable<number>;
  37444. private _renderId;
  37445. private _frameId;
  37446. private _executeWhenReadyTimeoutId;
  37447. private _intermediateRendering;
  37448. private _viewUpdateFlag;
  37449. private _projectionUpdateFlag;
  37450. /** @hidden */
  37451. _toBeDisposed: Nullable<IDisposable>[];
  37452. private _activeRequests;
  37453. /** @hidden */
  37454. _pendingData: any[];
  37455. private _isDisposed;
  37456. /**
  37457. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37458. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37459. */
  37460. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37461. private _activeMeshes;
  37462. private _processedMaterials;
  37463. private _renderTargets;
  37464. /** @hidden */
  37465. _activeParticleSystems: SmartArray<IParticleSystem>;
  37466. private _activeSkeletons;
  37467. private _softwareSkinnedMeshes;
  37468. private _renderingManager;
  37469. /** @hidden */
  37470. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37471. private _transformMatrix;
  37472. private _sceneUbo;
  37473. /** @hidden */
  37474. _viewMatrix: Matrix;
  37475. private _projectionMatrix;
  37476. /** @hidden */
  37477. _forcedViewPosition: Nullable<Vector3>;
  37478. /** @hidden */
  37479. _frustumPlanes: Plane[];
  37480. /**
  37481. * Gets the list of frustum planes (built from the active camera)
  37482. */
  37483. get frustumPlanes(): Plane[];
  37484. /**
  37485. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37486. * This is useful if there are more lights that the maximum simulteanous authorized
  37487. */
  37488. requireLightSorting: boolean;
  37489. /** @hidden */
  37490. readonly useMaterialMeshMap: boolean;
  37491. /** @hidden */
  37492. readonly useClonedMeshMap: boolean;
  37493. private _externalData;
  37494. private _uid;
  37495. /**
  37496. * @hidden
  37497. * Backing store of defined scene components.
  37498. */
  37499. _components: ISceneComponent[];
  37500. /**
  37501. * @hidden
  37502. * Backing store of defined scene components.
  37503. */
  37504. _serializableComponents: ISceneSerializableComponent[];
  37505. /**
  37506. * List of components to register on the next registration step.
  37507. */
  37508. private _transientComponents;
  37509. /**
  37510. * Registers the transient components if needed.
  37511. */
  37512. private _registerTransientComponents;
  37513. /**
  37514. * @hidden
  37515. * Add a component to the scene.
  37516. * Note that the ccomponent could be registered on th next frame if this is called after
  37517. * the register component stage.
  37518. * @param component Defines the component to add to the scene
  37519. */
  37520. _addComponent(component: ISceneComponent): void;
  37521. /**
  37522. * @hidden
  37523. * Gets a component from the scene.
  37524. * @param name defines the name of the component to retrieve
  37525. * @returns the component or null if not present
  37526. */
  37527. _getComponent(name: string): Nullable<ISceneComponent>;
  37528. /**
  37529. * @hidden
  37530. * Defines the actions happening before camera updates.
  37531. */
  37532. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37533. /**
  37534. * @hidden
  37535. * Defines the actions happening before clear the canvas.
  37536. */
  37537. _beforeClearStage: Stage<SimpleStageAction>;
  37538. /**
  37539. * @hidden
  37540. * Defines the actions when collecting render targets for the frame.
  37541. */
  37542. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37543. /**
  37544. * @hidden
  37545. * Defines the actions happening for one camera in the frame.
  37546. */
  37547. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37548. /**
  37549. * @hidden
  37550. * Defines the actions happening during the per mesh ready checks.
  37551. */
  37552. _isReadyForMeshStage: Stage<MeshStageAction>;
  37553. /**
  37554. * @hidden
  37555. * Defines the actions happening before evaluate active mesh checks.
  37556. */
  37557. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37558. /**
  37559. * @hidden
  37560. * Defines the actions happening during the evaluate sub mesh checks.
  37561. */
  37562. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37563. /**
  37564. * @hidden
  37565. * Defines the actions happening during the active mesh stage.
  37566. */
  37567. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37568. /**
  37569. * @hidden
  37570. * Defines the actions happening during the per camera render target step.
  37571. */
  37572. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37573. /**
  37574. * @hidden
  37575. * Defines the actions happening just before the active camera is drawing.
  37576. */
  37577. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37578. /**
  37579. * @hidden
  37580. * Defines the actions happening just before a render target is drawing.
  37581. */
  37582. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37583. /**
  37584. * @hidden
  37585. * Defines the actions happening just before a rendering group is drawing.
  37586. */
  37587. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37588. /**
  37589. * @hidden
  37590. * Defines the actions happening just before a mesh is drawing.
  37591. */
  37592. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37593. /**
  37594. * @hidden
  37595. * Defines the actions happening just after a mesh has been drawn.
  37596. */
  37597. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37598. /**
  37599. * @hidden
  37600. * Defines the actions happening just after a rendering group has been drawn.
  37601. */
  37602. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37603. /**
  37604. * @hidden
  37605. * Defines the actions happening just after the active camera has been drawn.
  37606. */
  37607. _afterCameraDrawStage: Stage<CameraStageAction>;
  37608. /**
  37609. * @hidden
  37610. * Defines the actions happening just after a render target has been drawn.
  37611. */
  37612. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37613. /**
  37614. * @hidden
  37615. * Defines the actions happening just after rendering all cameras and computing intersections.
  37616. */
  37617. _afterRenderStage: Stage<SimpleStageAction>;
  37618. /**
  37619. * @hidden
  37620. * Defines the actions happening when a pointer move event happens.
  37621. */
  37622. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37623. /**
  37624. * @hidden
  37625. * Defines the actions happening when a pointer down event happens.
  37626. */
  37627. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37628. /**
  37629. * @hidden
  37630. * Defines the actions happening when a pointer up event happens.
  37631. */
  37632. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37633. /**
  37634. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37635. */
  37636. private geometriesByUniqueId;
  37637. /**
  37638. * Creates a new Scene
  37639. * @param engine defines the engine to use to render this scene
  37640. * @param options defines the scene options
  37641. */
  37642. constructor(engine: Engine, options?: SceneOptions);
  37643. /**
  37644. * Gets a string idenfifying the name of the class
  37645. * @returns "Scene" string
  37646. */
  37647. getClassName(): string;
  37648. private _defaultMeshCandidates;
  37649. /**
  37650. * @hidden
  37651. */
  37652. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37653. private _defaultSubMeshCandidates;
  37654. /**
  37655. * @hidden
  37656. */
  37657. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37658. /**
  37659. * Sets the default candidate providers for the scene.
  37660. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37661. * and getCollidingSubMeshCandidates to their default function
  37662. */
  37663. setDefaultCandidateProviders(): void;
  37664. /**
  37665. * Gets the mesh that is currently under the pointer
  37666. */
  37667. get meshUnderPointer(): Nullable<AbstractMesh>;
  37668. /**
  37669. * Gets or sets the current on-screen X position of the pointer
  37670. */
  37671. get pointerX(): number;
  37672. set pointerX(value: number);
  37673. /**
  37674. * Gets or sets the current on-screen Y position of the pointer
  37675. */
  37676. get pointerY(): number;
  37677. set pointerY(value: number);
  37678. /**
  37679. * Gets the cached material (ie. the latest rendered one)
  37680. * @returns the cached material
  37681. */
  37682. getCachedMaterial(): Nullable<Material>;
  37683. /**
  37684. * Gets the cached effect (ie. the latest rendered one)
  37685. * @returns the cached effect
  37686. */
  37687. getCachedEffect(): Nullable<Effect>;
  37688. /**
  37689. * Gets the cached visibility state (ie. the latest rendered one)
  37690. * @returns the cached visibility state
  37691. */
  37692. getCachedVisibility(): Nullable<number>;
  37693. /**
  37694. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37695. * @param material defines the current material
  37696. * @param effect defines the current effect
  37697. * @param visibility defines the current visibility state
  37698. * @returns true if one parameter is not cached
  37699. */
  37700. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37701. /**
  37702. * Gets the engine associated with the scene
  37703. * @returns an Engine
  37704. */
  37705. getEngine(): Engine;
  37706. /**
  37707. * Gets the total number of vertices rendered per frame
  37708. * @returns the total number of vertices rendered per frame
  37709. */
  37710. getTotalVertices(): number;
  37711. /**
  37712. * Gets the performance counter for total vertices
  37713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37714. */
  37715. get totalVerticesPerfCounter(): PerfCounter;
  37716. /**
  37717. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37718. * @returns the total number of active indices rendered per frame
  37719. */
  37720. getActiveIndices(): number;
  37721. /**
  37722. * Gets the performance counter for active indices
  37723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37724. */
  37725. get totalActiveIndicesPerfCounter(): PerfCounter;
  37726. /**
  37727. * Gets the total number of active particles rendered per frame
  37728. * @returns the total number of active particles rendered per frame
  37729. */
  37730. getActiveParticles(): number;
  37731. /**
  37732. * Gets the performance counter for active particles
  37733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37734. */
  37735. get activeParticlesPerfCounter(): PerfCounter;
  37736. /**
  37737. * Gets the total number of active bones rendered per frame
  37738. * @returns the total number of active bones rendered per frame
  37739. */
  37740. getActiveBones(): number;
  37741. /**
  37742. * Gets the performance counter for active bones
  37743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37744. */
  37745. get activeBonesPerfCounter(): PerfCounter;
  37746. /**
  37747. * Gets the array of active meshes
  37748. * @returns an array of AbstractMesh
  37749. */
  37750. getActiveMeshes(): SmartArray<AbstractMesh>;
  37751. /**
  37752. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37753. * @returns a number
  37754. */
  37755. getAnimationRatio(): number;
  37756. /**
  37757. * Gets an unique Id for the current render phase
  37758. * @returns a number
  37759. */
  37760. getRenderId(): number;
  37761. /**
  37762. * Gets an unique Id for the current frame
  37763. * @returns a number
  37764. */
  37765. getFrameId(): number;
  37766. /** Call this function if you want to manually increment the render Id*/
  37767. incrementRenderId(): void;
  37768. private _createUbo;
  37769. /**
  37770. * Use this method to simulate a pointer move on a mesh
  37771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37774. * @returns the current scene
  37775. */
  37776. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37777. /**
  37778. * Use this method to simulate a pointer down on a mesh
  37779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37782. * @returns the current scene
  37783. */
  37784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37785. /**
  37786. * Use this method to simulate a pointer up on a mesh
  37787. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37788. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37789. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37790. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37791. * @returns the current scene
  37792. */
  37793. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37794. /**
  37795. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37796. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37797. * @returns true if the pointer was captured
  37798. */
  37799. isPointerCaptured(pointerId?: number): boolean;
  37800. /**
  37801. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37802. * @param attachUp defines if you want to attach events to pointerup
  37803. * @param attachDown defines if you want to attach events to pointerdown
  37804. * @param attachMove defines if you want to attach events to pointermove
  37805. */
  37806. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37807. /** Detaches all event handlers*/
  37808. detachControl(): void;
  37809. /**
  37810. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37811. * Delay loaded resources are not taking in account
  37812. * @return true if all required resources are ready
  37813. */
  37814. isReady(): boolean;
  37815. /** Resets all cached information relative to material (including effect and visibility) */
  37816. resetCachedMaterial(): void;
  37817. /**
  37818. * Registers a function to be called before every frame render
  37819. * @param func defines the function to register
  37820. */
  37821. registerBeforeRender(func: () => void): void;
  37822. /**
  37823. * Unregisters a function called before every frame render
  37824. * @param func defines the function to unregister
  37825. */
  37826. unregisterBeforeRender(func: () => void): void;
  37827. /**
  37828. * Registers a function to be called after every frame render
  37829. * @param func defines the function to register
  37830. */
  37831. registerAfterRender(func: () => void): void;
  37832. /**
  37833. * Unregisters a function called after every frame render
  37834. * @param func defines the function to unregister
  37835. */
  37836. unregisterAfterRender(func: () => void): void;
  37837. private _executeOnceBeforeRender;
  37838. /**
  37839. * The provided function will run before render once and will be disposed afterwards.
  37840. * A timeout delay can be provided so that the function will be executed in N ms.
  37841. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37842. * @param func The function to be executed.
  37843. * @param timeout optional delay in ms
  37844. */
  37845. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37846. /** @hidden */
  37847. _addPendingData(data: any): void;
  37848. /** @hidden */
  37849. _removePendingData(data: any): void;
  37850. /**
  37851. * Returns the number of items waiting to be loaded
  37852. * @returns the number of items waiting to be loaded
  37853. */
  37854. getWaitingItemsCount(): number;
  37855. /**
  37856. * Returns a boolean indicating if the scene is still loading data
  37857. */
  37858. get isLoading(): boolean;
  37859. /**
  37860. * Registers a function to be executed when the scene is ready
  37861. * @param {Function} func - the function to be executed
  37862. */
  37863. executeWhenReady(func: () => void): void;
  37864. /**
  37865. * Returns a promise that resolves when the scene is ready
  37866. * @returns A promise that resolves when the scene is ready
  37867. */
  37868. whenReadyAsync(): Promise<void>;
  37869. /** @hidden */
  37870. _checkIsReady(): void;
  37871. /**
  37872. * Gets all animatable attached to the scene
  37873. */
  37874. get animatables(): Animatable[];
  37875. /**
  37876. * Resets the last animation time frame.
  37877. * Useful to override when animations start running when loading a scene for the first time.
  37878. */
  37879. resetLastAnimationTimeFrame(): void;
  37880. /**
  37881. * Gets the current view matrix
  37882. * @returns a Matrix
  37883. */
  37884. getViewMatrix(): Matrix;
  37885. /**
  37886. * Gets the current projection matrix
  37887. * @returns a Matrix
  37888. */
  37889. getProjectionMatrix(): Matrix;
  37890. /**
  37891. * Gets the current transform matrix
  37892. * @returns a Matrix made of View * Projection
  37893. */
  37894. getTransformMatrix(): Matrix;
  37895. /**
  37896. * Sets the current transform matrix
  37897. * @param viewL defines the View matrix to use
  37898. * @param projectionL defines the Projection matrix to use
  37899. * @param viewR defines the right View matrix to use (if provided)
  37900. * @param projectionR defines the right Projection matrix to use (if provided)
  37901. */
  37902. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37903. /**
  37904. * Gets the uniform buffer used to store scene data
  37905. * @returns a UniformBuffer
  37906. */
  37907. getSceneUniformBuffer(): UniformBuffer;
  37908. /**
  37909. * Gets an unique (relatively to the current scene) Id
  37910. * @returns an unique number for the scene
  37911. */
  37912. getUniqueId(): number;
  37913. /**
  37914. * Add a mesh to the list of scene's meshes
  37915. * @param newMesh defines the mesh to add
  37916. * @param recursive if all child meshes should also be added to the scene
  37917. */
  37918. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37919. /**
  37920. * Remove a mesh for the list of scene's meshes
  37921. * @param toRemove defines the mesh to remove
  37922. * @param recursive if all child meshes should also be removed from the scene
  37923. * @returns the index where the mesh was in the mesh list
  37924. */
  37925. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37926. /**
  37927. * Add a transform node to the list of scene's transform nodes
  37928. * @param newTransformNode defines the transform node to add
  37929. */
  37930. addTransformNode(newTransformNode: TransformNode): void;
  37931. /**
  37932. * Remove a transform node for the list of scene's transform nodes
  37933. * @param toRemove defines the transform node to remove
  37934. * @returns the index where the transform node was in the transform node list
  37935. */
  37936. removeTransformNode(toRemove: TransformNode): number;
  37937. /**
  37938. * Remove a skeleton for the list of scene's skeletons
  37939. * @param toRemove defines the skeleton to remove
  37940. * @returns the index where the skeleton was in the skeleton list
  37941. */
  37942. removeSkeleton(toRemove: Skeleton): number;
  37943. /**
  37944. * Remove a morph target for the list of scene's morph targets
  37945. * @param toRemove defines the morph target to remove
  37946. * @returns the index where the morph target was in the morph target list
  37947. */
  37948. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37949. /**
  37950. * Remove a light for the list of scene's lights
  37951. * @param toRemove defines the light to remove
  37952. * @returns the index where the light was in the light list
  37953. */
  37954. removeLight(toRemove: Light): number;
  37955. /**
  37956. * Remove a camera for the list of scene's cameras
  37957. * @param toRemove defines the camera to remove
  37958. * @returns the index where the camera was in the camera list
  37959. */
  37960. removeCamera(toRemove: Camera): number;
  37961. /**
  37962. * Remove a particle system for the list of scene's particle systems
  37963. * @param toRemove defines the particle system to remove
  37964. * @returns the index where the particle system was in the particle system list
  37965. */
  37966. removeParticleSystem(toRemove: IParticleSystem): number;
  37967. /**
  37968. * Remove a animation for the list of scene's animations
  37969. * @param toRemove defines the animation to remove
  37970. * @returns the index where the animation was in the animation list
  37971. */
  37972. removeAnimation(toRemove: Animation): number;
  37973. /**
  37974. * Will stop the animation of the given target
  37975. * @param target - the target
  37976. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37977. * @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)
  37978. */
  37979. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37980. /**
  37981. * Removes the given animation group from this scene.
  37982. * @param toRemove The animation group to remove
  37983. * @returns The index of the removed animation group
  37984. */
  37985. removeAnimationGroup(toRemove: AnimationGroup): number;
  37986. /**
  37987. * Removes the given multi-material from this scene.
  37988. * @param toRemove The multi-material to remove
  37989. * @returns The index of the removed multi-material
  37990. */
  37991. removeMultiMaterial(toRemove: MultiMaterial): number;
  37992. /**
  37993. * Removes the given material from this scene.
  37994. * @param toRemove The material to remove
  37995. * @returns The index of the removed material
  37996. */
  37997. removeMaterial(toRemove: Material): number;
  37998. /**
  37999. * Removes the given action manager from this scene.
  38000. * @param toRemove The action manager to remove
  38001. * @returns The index of the removed action manager
  38002. */
  38003. removeActionManager(toRemove: AbstractActionManager): number;
  38004. /**
  38005. * Removes the given texture from this scene.
  38006. * @param toRemove The texture to remove
  38007. * @returns The index of the removed texture
  38008. */
  38009. removeTexture(toRemove: BaseTexture): number;
  38010. /**
  38011. * Adds the given light to this scene
  38012. * @param newLight The light to add
  38013. */
  38014. addLight(newLight: Light): void;
  38015. /**
  38016. * Sorts the list list based on light priorities
  38017. */
  38018. sortLightsByPriority(): void;
  38019. /**
  38020. * Adds the given camera to this scene
  38021. * @param newCamera The camera to add
  38022. */
  38023. addCamera(newCamera: Camera): void;
  38024. /**
  38025. * Adds the given skeleton to this scene
  38026. * @param newSkeleton The skeleton to add
  38027. */
  38028. addSkeleton(newSkeleton: Skeleton): void;
  38029. /**
  38030. * Adds the given particle system to this scene
  38031. * @param newParticleSystem The particle system to add
  38032. */
  38033. addParticleSystem(newParticleSystem: IParticleSystem): void;
  38034. /**
  38035. * Adds the given animation to this scene
  38036. * @param newAnimation The animation to add
  38037. */
  38038. addAnimation(newAnimation: Animation): void;
  38039. /**
  38040. * Adds the given animation group to this scene.
  38041. * @param newAnimationGroup The animation group to add
  38042. */
  38043. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  38044. /**
  38045. * Adds the given multi-material to this scene
  38046. * @param newMultiMaterial The multi-material to add
  38047. */
  38048. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38049. /**
  38050. * Adds the given material to this scene
  38051. * @param newMaterial The material to add
  38052. */
  38053. addMaterial(newMaterial: Material): void;
  38054. /**
  38055. * Adds the given morph target to this scene
  38056. * @param newMorphTargetManager The morph target to add
  38057. */
  38058. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38059. /**
  38060. * Adds the given geometry to this scene
  38061. * @param newGeometry The geometry to add
  38062. */
  38063. addGeometry(newGeometry: Geometry): void;
  38064. /**
  38065. * Adds the given action manager to this scene
  38066. * @param newActionManager The action manager to add
  38067. */
  38068. addActionManager(newActionManager: AbstractActionManager): void;
  38069. /**
  38070. * Adds the given texture to this scene.
  38071. * @param newTexture The texture to add
  38072. */
  38073. addTexture(newTexture: BaseTexture): void;
  38074. /**
  38075. * Switch active camera
  38076. * @param newCamera defines the new active camera
  38077. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38078. */
  38079. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38080. /**
  38081. * sets the active camera of the scene using its ID
  38082. * @param id defines the camera's ID
  38083. * @return the new active camera or null if none found.
  38084. */
  38085. setActiveCameraByID(id: string): Nullable<Camera>;
  38086. /**
  38087. * sets the active camera of the scene using its name
  38088. * @param name defines the camera's name
  38089. * @returns the new active camera or null if none found.
  38090. */
  38091. setActiveCameraByName(name: string): Nullable<Camera>;
  38092. /**
  38093. * get an animation group using its name
  38094. * @param name defines the material's name
  38095. * @return the animation group or null if none found.
  38096. */
  38097. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38098. /**
  38099. * Get a material using its unique id
  38100. * @param uniqueId defines the material's unique id
  38101. * @return the material or null if none found.
  38102. */
  38103. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38104. /**
  38105. * get a material using its id
  38106. * @param id defines the material's ID
  38107. * @return the material or null if none found.
  38108. */
  38109. getMaterialByID(id: string): Nullable<Material>;
  38110. /**
  38111. * Gets a the last added material using a given id
  38112. * @param id defines the material's ID
  38113. * @return the last material with the given id or null if none found.
  38114. */
  38115. getLastMaterialByID(id: string): Nullable<Material>;
  38116. /**
  38117. * Gets a material using its name
  38118. * @param name defines the material's name
  38119. * @return the material or null if none found.
  38120. */
  38121. getMaterialByName(name: string): Nullable<Material>;
  38122. /**
  38123. * Get a texture using its unique id
  38124. * @param uniqueId defines the texture's unique id
  38125. * @return the texture or null if none found.
  38126. */
  38127. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38128. /**
  38129. * Gets a camera using its id
  38130. * @param id defines the id to look for
  38131. * @returns the camera or null if not found
  38132. */
  38133. getCameraByID(id: string): Nullable<Camera>;
  38134. /**
  38135. * Gets a camera using its unique id
  38136. * @param uniqueId defines the unique id to look for
  38137. * @returns the camera or null if not found
  38138. */
  38139. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38140. /**
  38141. * Gets a camera using its name
  38142. * @param name defines the camera's name
  38143. * @return the camera or null if none found.
  38144. */
  38145. getCameraByName(name: string): Nullable<Camera>;
  38146. /**
  38147. * Gets a bone using its id
  38148. * @param id defines the bone's id
  38149. * @return the bone or null if not found
  38150. */
  38151. getBoneByID(id: string): Nullable<Bone>;
  38152. /**
  38153. * Gets a bone using its id
  38154. * @param name defines the bone's name
  38155. * @return the bone or null if not found
  38156. */
  38157. getBoneByName(name: string): Nullable<Bone>;
  38158. /**
  38159. * Gets a light node using its name
  38160. * @param name defines the the light's name
  38161. * @return the light or null if none found.
  38162. */
  38163. getLightByName(name: string): Nullable<Light>;
  38164. /**
  38165. * Gets a light node using its id
  38166. * @param id defines the light's id
  38167. * @return the light or null if none found.
  38168. */
  38169. getLightByID(id: string): Nullable<Light>;
  38170. /**
  38171. * Gets a light node using its scene-generated unique ID
  38172. * @param uniqueId defines the light's unique id
  38173. * @return the light or null if none found.
  38174. */
  38175. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38176. /**
  38177. * Gets a particle system by id
  38178. * @param id defines the particle system id
  38179. * @return the corresponding system or null if none found
  38180. */
  38181. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38182. /**
  38183. * Gets a geometry using its ID
  38184. * @param id defines the geometry's id
  38185. * @return the geometry or null if none found.
  38186. */
  38187. getGeometryByID(id: string): Nullable<Geometry>;
  38188. private _getGeometryByUniqueID;
  38189. /**
  38190. * Add a new geometry to this scene
  38191. * @param geometry defines the geometry to be added to the scene.
  38192. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38193. * @return a boolean defining if the geometry was added or not
  38194. */
  38195. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38196. /**
  38197. * Removes an existing geometry
  38198. * @param geometry defines the geometry to be removed from the scene
  38199. * @return a boolean defining if the geometry was removed or not
  38200. */
  38201. removeGeometry(geometry: Geometry): boolean;
  38202. /**
  38203. * Gets the list of geometries attached to the scene
  38204. * @returns an array of Geometry
  38205. */
  38206. getGeometries(): Geometry[];
  38207. /**
  38208. * Gets the first added mesh found of a given ID
  38209. * @param id defines the id to search for
  38210. * @return the mesh found or null if not found at all
  38211. */
  38212. getMeshByID(id: string): Nullable<AbstractMesh>;
  38213. /**
  38214. * Gets a list of meshes using their id
  38215. * @param id defines the id to search for
  38216. * @returns a list of meshes
  38217. */
  38218. getMeshesByID(id: string): Array<AbstractMesh>;
  38219. /**
  38220. * Gets the first added transform node found of a given ID
  38221. * @param id defines the id to search for
  38222. * @return the found transform node or null if not found at all.
  38223. */
  38224. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38225. /**
  38226. * Gets a transform node with its auto-generated unique id
  38227. * @param uniqueId efines the unique id to search for
  38228. * @return the found transform node or null if not found at all.
  38229. */
  38230. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38231. /**
  38232. * Gets a list of transform nodes using their id
  38233. * @param id defines the id to search for
  38234. * @returns a list of transform nodes
  38235. */
  38236. getTransformNodesByID(id: string): Array<TransformNode>;
  38237. /**
  38238. * Gets a mesh with its auto-generated unique id
  38239. * @param uniqueId defines the unique id to search for
  38240. * @return the found mesh or null if not found at all.
  38241. */
  38242. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38243. /**
  38244. * Gets a the last added mesh using a given id
  38245. * @param id defines the id to search for
  38246. * @return the found mesh or null if not found at all.
  38247. */
  38248. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38249. /**
  38250. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38251. * @param id defines the id to search for
  38252. * @return the found node or null if not found at all
  38253. */
  38254. getLastEntryByID(id: string): Nullable<Node>;
  38255. /**
  38256. * Gets a node (Mesh, Camera, Light) using a given id
  38257. * @param id defines the id to search for
  38258. * @return the found node or null if not found at all
  38259. */
  38260. getNodeByID(id: string): Nullable<Node>;
  38261. /**
  38262. * Gets a node (Mesh, Camera, Light) using a given name
  38263. * @param name defines the name to search for
  38264. * @return the found node or null if not found at all.
  38265. */
  38266. getNodeByName(name: string): Nullable<Node>;
  38267. /**
  38268. * Gets a mesh using a given name
  38269. * @param name defines the name to search for
  38270. * @return the found mesh or null if not found at all.
  38271. */
  38272. getMeshByName(name: string): Nullable<AbstractMesh>;
  38273. /**
  38274. * Gets a transform node using a given name
  38275. * @param name defines the name to search for
  38276. * @return the found transform node or null if not found at all.
  38277. */
  38278. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38279. /**
  38280. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38281. * @param id defines the id to search for
  38282. * @return the found skeleton or null if not found at all.
  38283. */
  38284. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38285. /**
  38286. * Gets a skeleton using a given auto generated unique id
  38287. * @param uniqueId defines the unique id to search for
  38288. * @return the found skeleton or null if not found at all.
  38289. */
  38290. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38291. /**
  38292. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38293. * @param id defines the id to search for
  38294. * @return the found skeleton or null if not found at all.
  38295. */
  38296. getSkeletonById(id: string): Nullable<Skeleton>;
  38297. /**
  38298. * Gets a skeleton using a given name
  38299. * @param name defines the name to search for
  38300. * @return the found skeleton or null if not found at all.
  38301. */
  38302. getSkeletonByName(name: string): Nullable<Skeleton>;
  38303. /**
  38304. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38305. * @param id defines the id to search for
  38306. * @return the found morph target manager or null if not found at all.
  38307. */
  38308. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38309. /**
  38310. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38311. * @param id defines the id to search for
  38312. * @return the found morph target or null if not found at all.
  38313. */
  38314. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38315. /**
  38316. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38317. * @param name defines the name to search for
  38318. * @return the found morph target or null if not found at all.
  38319. */
  38320. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38321. /**
  38322. * Gets a boolean indicating if the given mesh is active
  38323. * @param mesh defines the mesh to look for
  38324. * @returns true if the mesh is in the active list
  38325. */
  38326. isActiveMesh(mesh: AbstractMesh): boolean;
  38327. /**
  38328. * Return a unique id as a string which can serve as an identifier for the scene
  38329. */
  38330. get uid(): string;
  38331. /**
  38332. * Add an externaly attached data from its key.
  38333. * This method call will fail and return false, if such key already exists.
  38334. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38335. * @param key the unique key that identifies the data
  38336. * @param data the data object to associate to the key for this Engine instance
  38337. * @return true if no such key were already present and the data was added successfully, false otherwise
  38338. */
  38339. addExternalData<T>(key: string, data: T): boolean;
  38340. /**
  38341. * Get an externaly attached data from its key
  38342. * @param key the unique key that identifies the data
  38343. * @return the associated data, if present (can be null), or undefined if not present
  38344. */
  38345. getExternalData<T>(key: string): Nullable<T>;
  38346. /**
  38347. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38348. * @param key the unique key that identifies the data
  38349. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38350. * @return the associated data, can be null if the factory returned null.
  38351. */
  38352. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38353. /**
  38354. * Remove an externaly attached data from the Engine instance
  38355. * @param key the unique key that identifies the data
  38356. * @return true if the data was successfully removed, false if it doesn't exist
  38357. */
  38358. removeExternalData(key: string): boolean;
  38359. private _evaluateSubMesh;
  38360. /**
  38361. * Clear the processed materials smart array preventing retention point in material dispose.
  38362. */
  38363. freeProcessedMaterials(): void;
  38364. private _preventFreeActiveMeshesAndRenderingGroups;
  38365. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38366. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38367. * when disposing several meshes in a row or a hierarchy of meshes.
  38368. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38369. */
  38370. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38371. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38372. /**
  38373. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38374. */
  38375. freeActiveMeshes(): void;
  38376. /**
  38377. * Clear the info related to rendering groups preventing retention points during dispose.
  38378. */
  38379. freeRenderingGroups(): void;
  38380. /** @hidden */
  38381. _isInIntermediateRendering(): boolean;
  38382. /**
  38383. * Lambda returning the list of potentially active meshes.
  38384. */
  38385. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38386. /**
  38387. * Lambda returning the list of potentially active sub meshes.
  38388. */
  38389. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38390. /**
  38391. * Lambda returning the list of potentially intersecting sub meshes.
  38392. */
  38393. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38394. /**
  38395. * Lambda returning the list of potentially colliding sub meshes.
  38396. */
  38397. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38398. private _activeMeshesFrozen;
  38399. private _skipEvaluateActiveMeshesCompletely;
  38400. /**
  38401. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38402. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38403. * @returns the current scene
  38404. */
  38405. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38406. /**
  38407. * Use this function to restart evaluating active meshes on every frame
  38408. * @returns the current scene
  38409. */
  38410. unfreezeActiveMeshes(): Scene;
  38411. private _evaluateActiveMeshes;
  38412. private _activeMesh;
  38413. /**
  38414. * Update the transform matrix to update from the current active camera
  38415. * @param force defines a boolean used to force the update even if cache is up to date
  38416. */
  38417. updateTransformMatrix(force?: boolean): void;
  38418. private _bindFrameBuffer;
  38419. /** @hidden */
  38420. _allowPostProcessClearColor: boolean;
  38421. /** @hidden */
  38422. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38423. private _processSubCameras;
  38424. private _checkIntersections;
  38425. /** @hidden */
  38426. _advancePhysicsEngineStep(step: number): void;
  38427. /**
  38428. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38429. */
  38430. getDeterministicFrameTime: () => number;
  38431. /** @hidden */
  38432. _animate(): void;
  38433. /** Execute all animations (for a frame) */
  38434. animate(): void;
  38435. /**
  38436. * Render the scene
  38437. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38438. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38439. */
  38440. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38441. /**
  38442. * Freeze all materials
  38443. * A frozen material will not be updatable but should be faster to render
  38444. */
  38445. freezeMaterials(): void;
  38446. /**
  38447. * Unfreeze all materials
  38448. * A frozen material will not be updatable but should be faster to render
  38449. */
  38450. unfreezeMaterials(): void;
  38451. /**
  38452. * Releases all held ressources
  38453. */
  38454. dispose(): void;
  38455. /**
  38456. * Gets if the scene is already disposed
  38457. */
  38458. get isDisposed(): boolean;
  38459. /**
  38460. * Call this function to reduce memory footprint of the scene.
  38461. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38462. */
  38463. clearCachedVertexData(): void;
  38464. /**
  38465. * This function will remove the local cached buffer data from texture.
  38466. * It will save memory but will prevent the texture from being rebuilt
  38467. */
  38468. cleanCachedTextureBuffer(): void;
  38469. /**
  38470. * Get the world extend vectors with an optional filter
  38471. *
  38472. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38473. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38474. */
  38475. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38476. min: Vector3;
  38477. max: Vector3;
  38478. };
  38479. /**
  38480. * Creates a ray that can be used to pick in the scene
  38481. * @param x defines the x coordinate of the origin (on-screen)
  38482. * @param y defines the y coordinate of the origin (on-screen)
  38483. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38484. * @param camera defines the camera to use for the picking
  38485. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38486. * @returns a Ray
  38487. */
  38488. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38489. /**
  38490. * Creates a ray that can be used to pick in the scene
  38491. * @param x defines the x coordinate of the origin (on-screen)
  38492. * @param y defines the y coordinate of the origin (on-screen)
  38493. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38494. * @param result defines the ray where to store the picking ray
  38495. * @param camera defines the camera to use for the picking
  38496. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38497. * @returns the current scene
  38498. */
  38499. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38500. /**
  38501. * Creates a ray that can be used to pick in the scene
  38502. * @param x defines the x coordinate of the origin (on-screen)
  38503. * @param y defines the y coordinate of the origin (on-screen)
  38504. * @param camera defines the camera to use for the picking
  38505. * @returns a Ray
  38506. */
  38507. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38508. /**
  38509. * Creates a ray that can be used to pick in the scene
  38510. * @param x defines the x coordinate of the origin (on-screen)
  38511. * @param y defines the y coordinate of the origin (on-screen)
  38512. * @param result defines the ray where to store the picking ray
  38513. * @param camera defines the camera to use for the picking
  38514. * @returns the current scene
  38515. */
  38516. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38517. /** Launch a ray to try to pick a mesh in the scene
  38518. * @param x position on screen
  38519. * @param y position on screen
  38520. * @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
  38521. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38522. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38524. * @returns a PickingInfo
  38525. */
  38526. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38527. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38528. * @param x position on screen
  38529. * @param y position on screen
  38530. * @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
  38531. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38532. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38533. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  38534. */
  38535. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38536. /** Use the given ray to pick a mesh in the scene
  38537. * @param ray The ray to use to pick meshes
  38538. * @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
  38539. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38540. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38541. * @returns a PickingInfo
  38542. */
  38543. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38544. /**
  38545. * Launch a ray to try to pick a mesh in the scene
  38546. * @param x X position on screen
  38547. * @param y Y position on screen
  38548. * @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
  38549. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38551. * @returns an array of PickingInfo
  38552. */
  38553. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38554. /**
  38555. * Launch a ray to try to pick a mesh in the scene
  38556. * @param ray Ray to use
  38557. * @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
  38558. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38559. * @returns an array of PickingInfo
  38560. */
  38561. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38562. /**
  38563. * Force the value of meshUnderPointer
  38564. * @param mesh defines the mesh to use
  38565. */
  38566. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38567. /**
  38568. * Gets the mesh under the pointer
  38569. * @returns a Mesh or null if no mesh is under the pointer
  38570. */
  38571. getPointerOverMesh(): Nullable<AbstractMesh>;
  38572. /** @hidden */
  38573. _rebuildGeometries(): void;
  38574. /** @hidden */
  38575. _rebuildTextures(): void;
  38576. private _getByTags;
  38577. /**
  38578. * Get a list of meshes by tags
  38579. * @param tagsQuery defines the tags query to use
  38580. * @param forEach defines a predicate used to filter results
  38581. * @returns an array of Mesh
  38582. */
  38583. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38584. /**
  38585. * Get a list of cameras by tags
  38586. * @param tagsQuery defines the tags query to use
  38587. * @param forEach defines a predicate used to filter results
  38588. * @returns an array of Camera
  38589. */
  38590. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38591. /**
  38592. * Get a list of lights by tags
  38593. * @param tagsQuery defines the tags query to use
  38594. * @param forEach defines a predicate used to filter results
  38595. * @returns an array of Light
  38596. */
  38597. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38598. /**
  38599. * Get a list of materials by tags
  38600. * @param tagsQuery defines the tags query to use
  38601. * @param forEach defines a predicate used to filter results
  38602. * @returns an array of Material
  38603. */
  38604. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38605. /**
  38606. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38607. * This allowed control for front to back rendering or reversly depending of the special needs.
  38608. *
  38609. * @param renderingGroupId The rendering group id corresponding to its index
  38610. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38611. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38612. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38613. */
  38614. 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;
  38615. /**
  38616. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38617. *
  38618. * @param renderingGroupId The rendering group id corresponding to its index
  38619. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38620. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38621. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38622. */
  38623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38624. /**
  38625. * Gets the current auto clear configuration for one rendering group of the rendering
  38626. * manager.
  38627. * @param index the rendering group index to get the information for
  38628. * @returns The auto clear setup for the requested rendering group
  38629. */
  38630. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38631. private _blockMaterialDirtyMechanism;
  38632. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38633. get blockMaterialDirtyMechanism(): boolean;
  38634. set blockMaterialDirtyMechanism(value: boolean);
  38635. /**
  38636. * Will flag all materials as dirty to trigger new shader compilation
  38637. * @param flag defines the flag used to specify which material part must be marked as dirty
  38638. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38639. */
  38640. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38641. /** @hidden */
  38642. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38643. /** @hidden */
  38644. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38645. /** @hidden */
  38646. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38647. /** @hidden */
  38648. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38649. /** @hidden */
  38650. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38651. /** @hidden */
  38652. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38653. }
  38654. }
  38655. declare module "babylonjs/assetContainer" {
  38656. import { AbstractScene } from "babylonjs/abstractScene";
  38657. import { Scene } from "babylonjs/scene";
  38658. import { Mesh } from "babylonjs/Meshes/mesh";
  38659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38660. import { Skeleton } from "babylonjs/Bones/skeleton";
  38661. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38662. import { Animatable } from "babylonjs/Animations/animatable";
  38663. import { Nullable } from "babylonjs/types";
  38664. import { Node } from "babylonjs/node";
  38665. /**
  38666. * Set of assets to keep when moving a scene into an asset container.
  38667. */
  38668. export class KeepAssets extends AbstractScene {
  38669. }
  38670. /**
  38671. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38672. */
  38673. export class InstantiatedEntries {
  38674. /**
  38675. * List of new root nodes (eg. nodes with no parent)
  38676. */
  38677. rootNodes: TransformNode[];
  38678. /**
  38679. * List of new skeletons
  38680. */
  38681. skeletons: Skeleton[];
  38682. /**
  38683. * List of new animation groups
  38684. */
  38685. animationGroups: AnimationGroup[];
  38686. }
  38687. /**
  38688. * Container with a set of assets that can be added or removed from a scene.
  38689. */
  38690. export class AssetContainer extends AbstractScene {
  38691. private _wasAddedToScene;
  38692. /**
  38693. * The scene the AssetContainer belongs to.
  38694. */
  38695. scene: Scene;
  38696. /**
  38697. * Instantiates an AssetContainer.
  38698. * @param scene The scene the AssetContainer belongs to.
  38699. */
  38700. constructor(scene: Scene);
  38701. /**
  38702. * Instantiate or clone all meshes and add the new ones to the scene.
  38703. * Skeletons and animation groups will all be cloned
  38704. * @param nameFunction defines an optional function used to get new names for clones
  38705. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38706. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38707. */
  38708. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38709. /**
  38710. * Adds all the assets from the container to the scene.
  38711. */
  38712. addAllToScene(): void;
  38713. /**
  38714. * Removes all the assets in the container from the scene
  38715. */
  38716. removeAllFromScene(): void;
  38717. /**
  38718. * Disposes all the assets in the container
  38719. */
  38720. dispose(): void;
  38721. private _moveAssets;
  38722. /**
  38723. * Removes all the assets contained in the scene and adds them to the container.
  38724. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38725. */
  38726. moveAllFromScene(keepAssets?: KeepAssets): void;
  38727. /**
  38728. * 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.
  38729. * @returns the root mesh
  38730. */
  38731. createRootMesh(): Mesh;
  38732. /**
  38733. * Merge animations (direct and animation groups) from this asset container into a scene
  38734. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38735. * @param animatables set of animatables to retarget to a node from the scene
  38736. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38737. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38738. */
  38739. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38740. }
  38741. }
  38742. declare module "babylonjs/abstractScene" {
  38743. import { Scene } from "babylonjs/scene";
  38744. import { Nullable } from "babylonjs/types";
  38745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38746. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38747. import { Geometry } from "babylonjs/Meshes/geometry";
  38748. import { Skeleton } from "babylonjs/Bones/skeleton";
  38749. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38750. import { AssetContainer } from "babylonjs/assetContainer";
  38751. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38752. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38754. import { Material } from "babylonjs/Materials/material";
  38755. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38756. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38757. import { Camera } from "babylonjs/Cameras/camera";
  38758. import { Light } from "babylonjs/Lights/light";
  38759. import { Node } from "babylonjs/node";
  38760. import { Animation } from "babylonjs/Animations/animation";
  38761. /**
  38762. * Defines how the parser contract is defined.
  38763. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38764. */
  38765. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38766. /**
  38767. * Defines how the individual parser contract is defined.
  38768. * These parser can parse an individual asset
  38769. */
  38770. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38771. /**
  38772. * Base class of the scene acting as a container for the different elements composing a scene.
  38773. * This class is dynamically extended by the different components of the scene increasing
  38774. * flexibility and reducing coupling
  38775. */
  38776. export abstract class AbstractScene {
  38777. /**
  38778. * Stores the list of available parsers in the application.
  38779. */
  38780. private static _BabylonFileParsers;
  38781. /**
  38782. * Stores the list of available individual parsers in the application.
  38783. */
  38784. private static _IndividualBabylonFileParsers;
  38785. /**
  38786. * Adds a parser in the list of available ones
  38787. * @param name Defines the name of the parser
  38788. * @param parser Defines the parser to add
  38789. */
  38790. static AddParser(name: string, parser: BabylonFileParser): void;
  38791. /**
  38792. * Gets a general parser from the list of avaialble ones
  38793. * @param name Defines the name of the parser
  38794. * @returns the requested parser or null
  38795. */
  38796. static GetParser(name: string): Nullable<BabylonFileParser>;
  38797. /**
  38798. * Adds n individual parser in the list of available ones
  38799. * @param name Defines the name of the parser
  38800. * @param parser Defines the parser to add
  38801. */
  38802. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38803. /**
  38804. * Gets an individual parser from the list of avaialble ones
  38805. * @param name Defines the name of the parser
  38806. * @returns the requested parser or null
  38807. */
  38808. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38809. /**
  38810. * Parser json data and populate both a scene and its associated container object
  38811. * @param jsonData Defines the data to parse
  38812. * @param scene Defines the scene to parse the data for
  38813. * @param container Defines the container attached to the parsing sequence
  38814. * @param rootUrl Defines the root url of the data
  38815. */
  38816. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38817. /**
  38818. * Gets the list of root nodes (ie. nodes with no parent)
  38819. */
  38820. rootNodes: Node[];
  38821. /** All of the cameras added to this scene
  38822. * @see http://doc.babylonjs.com/babylon101/cameras
  38823. */
  38824. cameras: Camera[];
  38825. /**
  38826. * All of the lights added to this scene
  38827. * @see http://doc.babylonjs.com/babylon101/lights
  38828. */
  38829. lights: Light[];
  38830. /**
  38831. * All of the (abstract) meshes added to this scene
  38832. */
  38833. meshes: AbstractMesh[];
  38834. /**
  38835. * The list of skeletons added to the scene
  38836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38837. */
  38838. skeletons: Skeleton[];
  38839. /**
  38840. * All of the particle systems added to this scene
  38841. * @see http://doc.babylonjs.com/babylon101/particles
  38842. */
  38843. particleSystems: IParticleSystem[];
  38844. /**
  38845. * Gets a list of Animations associated with the scene
  38846. */
  38847. animations: Animation[];
  38848. /**
  38849. * All of the animation groups added to this scene
  38850. * @see http://doc.babylonjs.com/how_to/group
  38851. */
  38852. animationGroups: AnimationGroup[];
  38853. /**
  38854. * All of the multi-materials added to this scene
  38855. * @see http://doc.babylonjs.com/how_to/multi_materials
  38856. */
  38857. multiMaterials: MultiMaterial[];
  38858. /**
  38859. * All of the materials added to this scene
  38860. * In the context of a Scene, it is not supposed to be modified manually.
  38861. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38862. * Note also that the order of the Material within the array is not significant and might change.
  38863. * @see http://doc.babylonjs.com/babylon101/materials
  38864. */
  38865. materials: Material[];
  38866. /**
  38867. * The list of morph target managers added to the scene
  38868. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38869. */
  38870. morphTargetManagers: MorphTargetManager[];
  38871. /**
  38872. * The list of geometries used in the scene.
  38873. */
  38874. geometries: Geometry[];
  38875. /**
  38876. * All of the tranform nodes added to this scene
  38877. * In the context of a Scene, it is not supposed to be modified manually.
  38878. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38879. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38880. * @see http://doc.babylonjs.com/how_to/transformnode
  38881. */
  38882. transformNodes: TransformNode[];
  38883. /**
  38884. * ActionManagers available on the scene.
  38885. */
  38886. actionManagers: AbstractActionManager[];
  38887. /**
  38888. * Textures to keep.
  38889. */
  38890. textures: BaseTexture[];
  38891. /**
  38892. * Environment texture for the scene
  38893. */
  38894. environmentTexture: Nullable<BaseTexture>;
  38895. /**
  38896. * @returns all meshes, lights, cameras, transformNodes and bones
  38897. */
  38898. getNodes(): Array<Node>;
  38899. }
  38900. }
  38901. declare module "babylonjs/Audio/sound" {
  38902. import { Observable } from "babylonjs/Misc/observable";
  38903. import { Vector3 } from "babylonjs/Maths/math.vector";
  38904. import { Nullable } from "babylonjs/types";
  38905. import { Scene } from "babylonjs/scene";
  38906. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38907. /**
  38908. * Interface used to define options for Sound class
  38909. */
  38910. export interface ISoundOptions {
  38911. /**
  38912. * Does the sound autoplay once loaded.
  38913. */
  38914. autoplay?: boolean;
  38915. /**
  38916. * Does the sound loop after it finishes playing once.
  38917. */
  38918. loop?: boolean;
  38919. /**
  38920. * Sound's volume
  38921. */
  38922. volume?: number;
  38923. /**
  38924. * Is it a spatial sound?
  38925. */
  38926. spatialSound?: boolean;
  38927. /**
  38928. * Maximum distance to hear that sound
  38929. */
  38930. maxDistance?: number;
  38931. /**
  38932. * Uses user defined attenuation function
  38933. */
  38934. useCustomAttenuation?: boolean;
  38935. /**
  38936. * Define the roll off factor of spatial sounds.
  38937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38938. */
  38939. rolloffFactor?: number;
  38940. /**
  38941. * Define the reference distance the sound should be heard perfectly.
  38942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38943. */
  38944. refDistance?: number;
  38945. /**
  38946. * Define the distance attenuation model the sound will follow.
  38947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38948. */
  38949. distanceModel?: string;
  38950. /**
  38951. * Defines the playback speed (1 by default)
  38952. */
  38953. playbackRate?: number;
  38954. /**
  38955. * Defines if the sound is from a streaming source
  38956. */
  38957. streaming?: boolean;
  38958. /**
  38959. * Defines an optional length (in seconds) inside the sound file
  38960. */
  38961. length?: number;
  38962. /**
  38963. * Defines an optional offset (in seconds) inside the sound file
  38964. */
  38965. offset?: number;
  38966. /**
  38967. * If true, URLs will not be required to state the audio file codec to use.
  38968. */
  38969. skipCodecCheck?: boolean;
  38970. }
  38971. /**
  38972. * Defines a sound that can be played in the application.
  38973. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38975. */
  38976. export class Sound {
  38977. /**
  38978. * The name of the sound in the scene.
  38979. */
  38980. name: string;
  38981. /**
  38982. * Does the sound autoplay once loaded.
  38983. */
  38984. autoplay: boolean;
  38985. /**
  38986. * Does the sound loop after it finishes playing once.
  38987. */
  38988. loop: boolean;
  38989. /**
  38990. * Does the sound use a custom attenuation curve to simulate the falloff
  38991. * happening when the source gets further away from the camera.
  38992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38993. */
  38994. useCustomAttenuation: boolean;
  38995. /**
  38996. * The sound track id this sound belongs to.
  38997. */
  38998. soundTrackId: number;
  38999. /**
  39000. * Is this sound currently played.
  39001. */
  39002. isPlaying: boolean;
  39003. /**
  39004. * Is this sound currently paused.
  39005. */
  39006. isPaused: boolean;
  39007. /**
  39008. * Does this sound enables spatial sound.
  39009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39010. */
  39011. spatialSound: boolean;
  39012. /**
  39013. * Define the reference distance the sound should be heard perfectly.
  39014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39015. */
  39016. refDistance: number;
  39017. /**
  39018. * Define the roll off factor of spatial sounds.
  39019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39020. */
  39021. rolloffFactor: number;
  39022. /**
  39023. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  39024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39025. */
  39026. maxDistance: number;
  39027. /**
  39028. * Define the distance attenuation model the sound will follow.
  39029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39030. */
  39031. distanceModel: string;
  39032. /**
  39033. * @hidden
  39034. * Back Compat
  39035. **/
  39036. onended: () => any;
  39037. /**
  39038. * Observable event when the current playing sound finishes.
  39039. */
  39040. onEndedObservable: Observable<Sound>;
  39041. private _panningModel;
  39042. private _playbackRate;
  39043. private _streaming;
  39044. private _startTime;
  39045. private _startOffset;
  39046. private _position;
  39047. /** @hidden */
  39048. _positionInEmitterSpace: boolean;
  39049. private _localDirection;
  39050. private _volume;
  39051. private _isReadyToPlay;
  39052. private _isDirectional;
  39053. private _readyToPlayCallback;
  39054. private _audioBuffer;
  39055. private _soundSource;
  39056. private _streamingSource;
  39057. private _soundPanner;
  39058. private _soundGain;
  39059. private _inputAudioNode;
  39060. private _outputAudioNode;
  39061. private _coneInnerAngle;
  39062. private _coneOuterAngle;
  39063. private _coneOuterGain;
  39064. private _scene;
  39065. private _connectedTransformNode;
  39066. private _customAttenuationFunction;
  39067. private _registerFunc;
  39068. private _isOutputConnected;
  39069. private _htmlAudioElement;
  39070. private _urlType;
  39071. private _length?;
  39072. private _offset?;
  39073. /** @hidden */
  39074. static _SceneComponentInitialization: (scene: Scene) => void;
  39075. /**
  39076. * Create a sound and attach it to a scene
  39077. * @param name Name of your sound
  39078. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39079. * @param scene defines the scene the sound belongs to
  39080. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39081. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39082. */
  39083. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39084. /**
  39085. * Release the sound and its associated resources
  39086. */
  39087. dispose(): void;
  39088. /**
  39089. * Gets if the sounds is ready to be played or not.
  39090. * @returns true if ready, otherwise false
  39091. */
  39092. isReady(): boolean;
  39093. private _soundLoaded;
  39094. /**
  39095. * Sets the data of the sound from an audiobuffer
  39096. * @param audioBuffer The audioBuffer containing the data
  39097. */
  39098. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39099. /**
  39100. * Updates the current sounds options such as maxdistance, loop...
  39101. * @param options A JSON object containing values named as the object properties
  39102. */
  39103. updateOptions(options: ISoundOptions): void;
  39104. private _createSpatialParameters;
  39105. private _updateSpatialParameters;
  39106. /**
  39107. * Switch the panning model to HRTF:
  39108. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39110. */
  39111. switchPanningModelToHRTF(): void;
  39112. /**
  39113. * Switch the panning model to Equal Power:
  39114. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39116. */
  39117. switchPanningModelToEqualPower(): void;
  39118. private _switchPanningModel;
  39119. /**
  39120. * Connect this sound to a sound track audio node like gain...
  39121. * @param soundTrackAudioNode the sound track audio node to connect to
  39122. */
  39123. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39124. /**
  39125. * Transform this sound into a directional source
  39126. * @param coneInnerAngle Size of the inner cone in degree
  39127. * @param coneOuterAngle Size of the outer cone in degree
  39128. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39129. */
  39130. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39131. /**
  39132. * Gets or sets the inner angle for the directional cone.
  39133. */
  39134. get directionalConeInnerAngle(): number;
  39135. /**
  39136. * Gets or sets the inner angle for the directional cone.
  39137. */
  39138. set directionalConeInnerAngle(value: number);
  39139. /**
  39140. * Gets or sets the outer angle for the directional cone.
  39141. */
  39142. get directionalConeOuterAngle(): number;
  39143. /**
  39144. * Gets or sets the outer angle for the directional cone.
  39145. */
  39146. set directionalConeOuterAngle(value: number);
  39147. /**
  39148. * Sets the position of the emitter if spatial sound is enabled
  39149. * @param newPosition Defines the new posisiton
  39150. */
  39151. setPosition(newPosition: Vector3): void;
  39152. /**
  39153. * Sets the local direction of the emitter if spatial sound is enabled
  39154. * @param newLocalDirection Defines the new local direction
  39155. */
  39156. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39157. private _updateDirection;
  39158. /** @hidden */
  39159. updateDistanceFromListener(): void;
  39160. /**
  39161. * Sets a new custom attenuation function for the sound.
  39162. * @param callback Defines the function used for the attenuation
  39163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39164. */
  39165. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39166. /**
  39167. * Play the sound
  39168. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39169. * @param offset (optional) Start the sound at a specific time in seconds
  39170. * @param length (optional) Sound duration (in seconds)
  39171. */
  39172. play(time?: number, offset?: number, length?: number): void;
  39173. private _onended;
  39174. /**
  39175. * Stop the sound
  39176. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39177. */
  39178. stop(time?: number): void;
  39179. /**
  39180. * Put the sound in pause
  39181. */
  39182. pause(): void;
  39183. /**
  39184. * Sets a dedicated volume for this sounds
  39185. * @param newVolume Define the new volume of the sound
  39186. * @param time Define time for gradual change to new volume
  39187. */
  39188. setVolume(newVolume: number, time?: number): void;
  39189. /**
  39190. * Set the sound play back rate
  39191. * @param newPlaybackRate Define the playback rate the sound should be played at
  39192. */
  39193. setPlaybackRate(newPlaybackRate: number): void;
  39194. /**
  39195. * Gets the volume of the sound.
  39196. * @returns the volume of the sound
  39197. */
  39198. getVolume(): number;
  39199. /**
  39200. * Attach the sound to a dedicated mesh
  39201. * @param transformNode The transform node to connect the sound with
  39202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39203. */
  39204. attachToMesh(transformNode: TransformNode): void;
  39205. /**
  39206. * Detach the sound from the previously attached mesh
  39207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39208. */
  39209. detachFromMesh(): void;
  39210. private _onRegisterAfterWorldMatrixUpdate;
  39211. /**
  39212. * Clone the current sound in the scene.
  39213. * @returns the new sound clone
  39214. */
  39215. clone(): Nullable<Sound>;
  39216. /**
  39217. * Gets the current underlying audio buffer containing the data
  39218. * @returns the audio buffer
  39219. */
  39220. getAudioBuffer(): Nullable<AudioBuffer>;
  39221. /**
  39222. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39223. * @returns the source node
  39224. */
  39225. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39226. /**
  39227. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39228. * @returns the gain node
  39229. */
  39230. getSoundGain(): Nullable<GainNode>;
  39231. /**
  39232. * Serializes the Sound in a JSON representation
  39233. * @returns the JSON representation of the sound
  39234. */
  39235. serialize(): any;
  39236. /**
  39237. * Parse a JSON representation of a sound to innstantiate in a given scene
  39238. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39239. * @param scene Define the scene the new parsed sound should be created in
  39240. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39241. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39242. * @returns the newly parsed sound
  39243. */
  39244. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39245. }
  39246. }
  39247. declare module "babylonjs/Actions/directAudioActions" {
  39248. import { Action } from "babylonjs/Actions/action";
  39249. import { Condition } from "babylonjs/Actions/condition";
  39250. import { Sound } from "babylonjs/Audio/sound";
  39251. /**
  39252. * This defines an action helpful to play a defined sound on a triggered action.
  39253. */
  39254. export class PlaySoundAction extends Action {
  39255. private _sound;
  39256. /**
  39257. * Instantiate the action
  39258. * @param triggerOptions defines the trigger options
  39259. * @param sound defines the sound to play
  39260. * @param condition defines the trigger related conditions
  39261. */
  39262. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39263. /** @hidden */
  39264. _prepare(): void;
  39265. /**
  39266. * Execute the action and play the sound.
  39267. */
  39268. execute(): void;
  39269. /**
  39270. * Serializes the actions and its related information.
  39271. * @param parent defines the object to serialize in
  39272. * @returns the serialized object
  39273. */
  39274. serialize(parent: any): any;
  39275. }
  39276. /**
  39277. * This defines an action helpful to stop a defined sound on a triggered action.
  39278. */
  39279. export class StopSoundAction extends Action {
  39280. private _sound;
  39281. /**
  39282. * Instantiate the action
  39283. * @param triggerOptions defines the trigger options
  39284. * @param sound defines the sound to stop
  39285. * @param condition defines the trigger related conditions
  39286. */
  39287. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39288. /** @hidden */
  39289. _prepare(): void;
  39290. /**
  39291. * Execute the action and stop the sound.
  39292. */
  39293. execute(): void;
  39294. /**
  39295. * Serializes the actions and its related information.
  39296. * @param parent defines the object to serialize in
  39297. * @returns the serialized object
  39298. */
  39299. serialize(parent: any): any;
  39300. }
  39301. }
  39302. declare module "babylonjs/Actions/interpolateValueAction" {
  39303. import { Action } from "babylonjs/Actions/action";
  39304. import { Condition } from "babylonjs/Actions/condition";
  39305. import { Observable } from "babylonjs/Misc/observable";
  39306. /**
  39307. * This defines an action responsible to change the value of a property
  39308. * by interpolating between its current value and the newly set one once triggered.
  39309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39310. */
  39311. export class InterpolateValueAction extends Action {
  39312. /**
  39313. * Defines the path of the property where the value should be interpolated
  39314. */
  39315. propertyPath: string;
  39316. /**
  39317. * Defines the target value at the end of the interpolation.
  39318. */
  39319. value: any;
  39320. /**
  39321. * Defines the time it will take for the property to interpolate to the value.
  39322. */
  39323. duration: number;
  39324. /**
  39325. * Defines if the other scene animations should be stopped when the action has been triggered
  39326. */
  39327. stopOtherAnimations?: boolean;
  39328. /**
  39329. * Defines a callback raised once the interpolation animation has been done.
  39330. */
  39331. onInterpolationDone?: () => void;
  39332. /**
  39333. * Observable triggered once the interpolation animation has been done.
  39334. */
  39335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39336. private _target;
  39337. private _effectiveTarget;
  39338. private _property;
  39339. /**
  39340. * Instantiate the action
  39341. * @param triggerOptions defines the trigger options
  39342. * @param target defines the object containing the value to interpolate
  39343. * @param propertyPath defines the path to the property in the target object
  39344. * @param value defines the target value at the end of the interpolation
  39345. * @param duration deines the time it will take for the property to interpolate to the value.
  39346. * @param condition defines the trigger related conditions
  39347. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39348. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39349. */
  39350. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39351. /** @hidden */
  39352. _prepare(): void;
  39353. /**
  39354. * Execute the action starts the value interpolation.
  39355. */
  39356. execute(): void;
  39357. /**
  39358. * Serializes the actions and its related information.
  39359. * @param parent defines the object to serialize in
  39360. * @returns the serialized object
  39361. */
  39362. serialize(parent: any): any;
  39363. }
  39364. }
  39365. declare module "babylonjs/Actions/index" {
  39366. export * from "babylonjs/Actions/abstractActionManager";
  39367. export * from "babylonjs/Actions/action";
  39368. export * from "babylonjs/Actions/actionEvent";
  39369. export * from "babylonjs/Actions/actionManager";
  39370. export * from "babylonjs/Actions/condition";
  39371. export * from "babylonjs/Actions/directActions";
  39372. export * from "babylonjs/Actions/directAudioActions";
  39373. export * from "babylonjs/Actions/interpolateValueAction";
  39374. }
  39375. declare module "babylonjs/Animations/index" {
  39376. export * from "babylonjs/Animations/animatable";
  39377. export * from "babylonjs/Animations/animation";
  39378. export * from "babylonjs/Animations/animationGroup";
  39379. export * from "babylonjs/Animations/animationPropertiesOverride";
  39380. export * from "babylonjs/Animations/easing";
  39381. export * from "babylonjs/Animations/runtimeAnimation";
  39382. export * from "babylonjs/Animations/animationEvent";
  39383. export * from "babylonjs/Animations/animationGroup";
  39384. export * from "babylonjs/Animations/animationKey";
  39385. export * from "babylonjs/Animations/animationRange";
  39386. export * from "babylonjs/Animations/animatable.interface";
  39387. }
  39388. declare module "babylonjs/Audio/soundTrack" {
  39389. import { Sound } from "babylonjs/Audio/sound";
  39390. import { Analyser } from "babylonjs/Audio/analyser";
  39391. import { Scene } from "babylonjs/scene";
  39392. /**
  39393. * Options allowed during the creation of a sound track.
  39394. */
  39395. export interface ISoundTrackOptions {
  39396. /**
  39397. * The volume the sound track should take during creation
  39398. */
  39399. volume?: number;
  39400. /**
  39401. * Define if the sound track is the main sound track of the scene
  39402. */
  39403. mainTrack?: boolean;
  39404. }
  39405. /**
  39406. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39407. * It will be also used in a future release to apply effects on a specific track.
  39408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39409. */
  39410. export class SoundTrack {
  39411. /**
  39412. * The unique identifier of the sound track in the scene.
  39413. */
  39414. id: number;
  39415. /**
  39416. * The list of sounds included in the sound track.
  39417. */
  39418. soundCollection: Array<Sound>;
  39419. private _outputAudioNode;
  39420. private _scene;
  39421. private _connectedAnalyser;
  39422. private _options;
  39423. private _isInitialized;
  39424. /**
  39425. * Creates a new sound track.
  39426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39427. * @param scene Define the scene the sound track belongs to
  39428. * @param options
  39429. */
  39430. constructor(scene: Scene, options?: ISoundTrackOptions);
  39431. private _initializeSoundTrackAudioGraph;
  39432. /**
  39433. * Release the sound track and its associated resources
  39434. */
  39435. dispose(): void;
  39436. /**
  39437. * Adds a sound to this sound track
  39438. * @param sound define the cound to add
  39439. * @ignoreNaming
  39440. */
  39441. AddSound(sound: Sound): void;
  39442. /**
  39443. * Removes a sound to this sound track
  39444. * @param sound define the cound to remove
  39445. * @ignoreNaming
  39446. */
  39447. RemoveSound(sound: Sound): void;
  39448. /**
  39449. * Set a global volume for the full sound track.
  39450. * @param newVolume Define the new volume of the sound track
  39451. */
  39452. setVolume(newVolume: number): void;
  39453. /**
  39454. * Switch the panning model to HRTF:
  39455. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39457. */
  39458. switchPanningModelToHRTF(): void;
  39459. /**
  39460. * Switch the panning model to Equal Power:
  39461. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39463. */
  39464. switchPanningModelToEqualPower(): void;
  39465. /**
  39466. * Connect the sound track to an audio analyser allowing some amazing
  39467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39469. * @param analyser The analyser to connect to the engine
  39470. */
  39471. connectToAnalyser(analyser: Analyser): void;
  39472. }
  39473. }
  39474. declare module "babylonjs/Audio/audioSceneComponent" {
  39475. import { Sound } from "babylonjs/Audio/sound";
  39476. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39477. import { Nullable } from "babylonjs/types";
  39478. import { Vector3 } from "babylonjs/Maths/math.vector";
  39479. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39480. import { Scene } from "babylonjs/scene";
  39481. import { AbstractScene } from "babylonjs/abstractScene";
  39482. import "babylonjs/Audio/audioEngine";
  39483. module "babylonjs/abstractScene" {
  39484. interface AbstractScene {
  39485. /**
  39486. * The list of sounds used in the scene.
  39487. */
  39488. sounds: Nullable<Array<Sound>>;
  39489. }
  39490. }
  39491. module "babylonjs/scene" {
  39492. interface Scene {
  39493. /**
  39494. * @hidden
  39495. * Backing field
  39496. */
  39497. _mainSoundTrack: SoundTrack;
  39498. /**
  39499. * The main sound track played by the scene.
  39500. * It cotains your primary collection of sounds.
  39501. */
  39502. mainSoundTrack: SoundTrack;
  39503. /**
  39504. * The list of sound tracks added to the scene
  39505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39506. */
  39507. soundTracks: Nullable<Array<SoundTrack>>;
  39508. /**
  39509. * Gets a sound using a given name
  39510. * @param name defines the name to search for
  39511. * @return the found sound or null if not found at all.
  39512. */
  39513. getSoundByName(name: string): Nullable<Sound>;
  39514. /**
  39515. * Gets or sets if audio support is enabled
  39516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39517. */
  39518. audioEnabled: boolean;
  39519. /**
  39520. * Gets or sets if audio will be output to headphones
  39521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39522. */
  39523. headphone: boolean;
  39524. /**
  39525. * Gets or sets custom audio listener position provider
  39526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39527. */
  39528. audioListenerPositionProvider: Nullable<() => Vector3>;
  39529. /**
  39530. * Gets or sets a refresh rate when using 3D audio positioning
  39531. */
  39532. audioPositioningRefreshRate: number;
  39533. }
  39534. }
  39535. /**
  39536. * Defines the sound scene component responsible to manage any sounds
  39537. * in a given scene.
  39538. */
  39539. export class AudioSceneComponent implements ISceneSerializableComponent {
  39540. /**
  39541. * The component name helpfull to identify the component in the list of scene components.
  39542. */
  39543. readonly name: string;
  39544. /**
  39545. * The scene the component belongs to.
  39546. */
  39547. scene: Scene;
  39548. private _audioEnabled;
  39549. /**
  39550. * Gets whether audio is enabled or not.
  39551. * Please use related enable/disable method to switch state.
  39552. */
  39553. get audioEnabled(): boolean;
  39554. private _headphone;
  39555. /**
  39556. * Gets whether audio is outputing to headphone or not.
  39557. * Please use the according Switch methods to change output.
  39558. */
  39559. get headphone(): boolean;
  39560. /**
  39561. * Gets or sets a refresh rate when using 3D audio positioning
  39562. */
  39563. audioPositioningRefreshRate: number;
  39564. private _audioListenerPositionProvider;
  39565. /**
  39566. * Gets the current audio listener position provider
  39567. */
  39568. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39569. /**
  39570. * Sets a custom listener position for all sounds in the scene
  39571. * By default, this is the position of the first active camera
  39572. */
  39573. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39574. /**
  39575. * Creates a new instance of the component for the given scene
  39576. * @param scene Defines the scene to register the component in
  39577. */
  39578. constructor(scene: Scene);
  39579. /**
  39580. * Registers the component in a given scene
  39581. */
  39582. register(): void;
  39583. /**
  39584. * Rebuilds the elements related to this component in case of
  39585. * context lost for instance.
  39586. */
  39587. rebuild(): void;
  39588. /**
  39589. * Serializes the component data to the specified json object
  39590. * @param serializationObject The object to serialize to
  39591. */
  39592. serialize(serializationObject: any): void;
  39593. /**
  39594. * Adds all the elements from the container to the scene
  39595. * @param container the container holding the elements
  39596. */
  39597. addFromContainer(container: AbstractScene): void;
  39598. /**
  39599. * Removes all the elements in the container from the scene
  39600. * @param container contains the elements to remove
  39601. * @param dispose if the removed element should be disposed (default: false)
  39602. */
  39603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39604. /**
  39605. * Disposes the component and the associated ressources.
  39606. */
  39607. dispose(): void;
  39608. /**
  39609. * Disables audio in the associated scene.
  39610. */
  39611. disableAudio(): void;
  39612. /**
  39613. * Enables audio in the associated scene.
  39614. */
  39615. enableAudio(): void;
  39616. /**
  39617. * Switch audio to headphone output.
  39618. */
  39619. switchAudioModeForHeadphones(): void;
  39620. /**
  39621. * Switch audio to normal speakers.
  39622. */
  39623. switchAudioModeForNormalSpeakers(): void;
  39624. private _cachedCameraDirection;
  39625. private _cachedCameraPosition;
  39626. private _lastCheck;
  39627. private _afterRender;
  39628. }
  39629. }
  39630. declare module "babylonjs/Audio/weightedsound" {
  39631. import { Sound } from "babylonjs/Audio/sound";
  39632. /**
  39633. * Wraps one or more Sound objects and selects one with random weight for playback.
  39634. */
  39635. export class WeightedSound {
  39636. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39637. loop: boolean;
  39638. private _coneInnerAngle;
  39639. private _coneOuterAngle;
  39640. private _volume;
  39641. /** A Sound is currently playing. */
  39642. isPlaying: boolean;
  39643. /** A Sound is currently paused. */
  39644. isPaused: boolean;
  39645. private _sounds;
  39646. private _weights;
  39647. private _currentIndex?;
  39648. /**
  39649. * Creates a new WeightedSound from the list of sounds given.
  39650. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39651. * @param sounds Array of Sounds that will be selected from.
  39652. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39653. */
  39654. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39655. /**
  39656. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39657. */
  39658. get directionalConeInnerAngle(): number;
  39659. /**
  39660. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39661. */
  39662. set directionalConeInnerAngle(value: number);
  39663. /**
  39664. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39665. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39666. */
  39667. get directionalConeOuterAngle(): number;
  39668. /**
  39669. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39670. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39671. */
  39672. set directionalConeOuterAngle(value: number);
  39673. /**
  39674. * Playback volume.
  39675. */
  39676. get volume(): number;
  39677. /**
  39678. * Playback volume.
  39679. */
  39680. set volume(value: number);
  39681. private _onended;
  39682. /**
  39683. * Suspend playback
  39684. */
  39685. pause(): void;
  39686. /**
  39687. * Stop playback
  39688. */
  39689. stop(): void;
  39690. /**
  39691. * Start playback.
  39692. * @param startOffset Position the clip head at a specific time in seconds.
  39693. */
  39694. play(startOffset?: number): void;
  39695. }
  39696. }
  39697. declare module "babylonjs/Audio/index" {
  39698. export * from "babylonjs/Audio/analyser";
  39699. export * from "babylonjs/Audio/audioEngine";
  39700. export * from "babylonjs/Audio/audioSceneComponent";
  39701. export * from "babylonjs/Audio/sound";
  39702. export * from "babylonjs/Audio/soundTrack";
  39703. export * from "babylonjs/Audio/weightedsound";
  39704. }
  39705. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39706. import { Behavior } from "babylonjs/Behaviors/behavior";
  39707. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39708. import { BackEase } from "babylonjs/Animations/easing";
  39709. /**
  39710. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39712. */
  39713. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39714. /**
  39715. * Gets the name of the behavior.
  39716. */
  39717. get name(): string;
  39718. /**
  39719. * The easing function used by animations
  39720. */
  39721. static EasingFunction: BackEase;
  39722. /**
  39723. * The easing mode used by animations
  39724. */
  39725. static EasingMode: number;
  39726. /**
  39727. * The duration of the animation, in milliseconds
  39728. */
  39729. transitionDuration: number;
  39730. /**
  39731. * Length of the distance animated by the transition when lower radius is reached
  39732. */
  39733. lowerRadiusTransitionRange: number;
  39734. /**
  39735. * Length of the distance animated by the transition when upper radius is reached
  39736. */
  39737. upperRadiusTransitionRange: number;
  39738. private _autoTransitionRange;
  39739. /**
  39740. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39741. */
  39742. get autoTransitionRange(): boolean;
  39743. /**
  39744. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39745. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39746. */
  39747. set autoTransitionRange(value: boolean);
  39748. private _attachedCamera;
  39749. private _onAfterCheckInputsObserver;
  39750. private _onMeshTargetChangedObserver;
  39751. /**
  39752. * Initializes the behavior.
  39753. */
  39754. init(): void;
  39755. /**
  39756. * Attaches the behavior to its arc rotate camera.
  39757. * @param camera Defines the camera to attach the behavior to
  39758. */
  39759. attach(camera: ArcRotateCamera): void;
  39760. /**
  39761. * Detaches the behavior from its current arc rotate camera.
  39762. */
  39763. detach(): void;
  39764. private _radiusIsAnimating;
  39765. private _radiusBounceTransition;
  39766. private _animatables;
  39767. private _cachedWheelPrecision;
  39768. /**
  39769. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39770. * @param radiusLimit The limit to check against.
  39771. * @return Bool to indicate if at limit.
  39772. */
  39773. private _isRadiusAtLimit;
  39774. /**
  39775. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39776. * @param radiusDelta The delta by which to animate to. Can be negative.
  39777. */
  39778. private _applyBoundRadiusAnimation;
  39779. /**
  39780. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39781. */
  39782. protected _clearAnimationLocks(): void;
  39783. /**
  39784. * Stops and removes all animations that have been applied to the camera
  39785. */
  39786. stopAllAnimations(): void;
  39787. }
  39788. }
  39789. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39790. import { Behavior } from "babylonjs/Behaviors/behavior";
  39791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39792. import { ExponentialEase } from "babylonjs/Animations/easing";
  39793. import { Nullable } from "babylonjs/types";
  39794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39795. import { Vector3 } from "babylonjs/Maths/math.vector";
  39796. /**
  39797. * 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.
  39798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39799. */
  39800. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39801. /**
  39802. * Gets the name of the behavior.
  39803. */
  39804. get name(): string;
  39805. private _mode;
  39806. private _radiusScale;
  39807. private _positionScale;
  39808. private _defaultElevation;
  39809. private _elevationReturnTime;
  39810. private _elevationReturnWaitTime;
  39811. private _zoomStopsAnimation;
  39812. private _framingTime;
  39813. /**
  39814. * The easing function used by animations
  39815. */
  39816. static EasingFunction: ExponentialEase;
  39817. /**
  39818. * The easing mode used by animations
  39819. */
  39820. static EasingMode: number;
  39821. /**
  39822. * Sets the current mode used by the behavior
  39823. */
  39824. set mode(mode: number);
  39825. /**
  39826. * Gets current mode used by the behavior.
  39827. */
  39828. get mode(): number;
  39829. /**
  39830. * Sets the scale applied to the radius (1 by default)
  39831. */
  39832. set radiusScale(radius: number);
  39833. /**
  39834. * Gets the scale applied to the radius
  39835. */
  39836. get radiusScale(): number;
  39837. /**
  39838. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39839. */
  39840. set positionScale(scale: number);
  39841. /**
  39842. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39843. */
  39844. get positionScale(): number;
  39845. /**
  39846. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39847. * behaviour is triggered, in radians.
  39848. */
  39849. set defaultElevation(elevation: number);
  39850. /**
  39851. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39852. * behaviour is triggered, in radians.
  39853. */
  39854. get defaultElevation(): number;
  39855. /**
  39856. * Sets the time (in milliseconds) taken to return to the default beta position.
  39857. * Negative value indicates camera should not return to default.
  39858. */
  39859. set elevationReturnTime(speed: number);
  39860. /**
  39861. * Gets the time (in milliseconds) taken to return to the default beta position.
  39862. * Negative value indicates camera should not return to default.
  39863. */
  39864. get elevationReturnTime(): number;
  39865. /**
  39866. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39867. */
  39868. set elevationReturnWaitTime(time: number);
  39869. /**
  39870. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39871. */
  39872. get elevationReturnWaitTime(): number;
  39873. /**
  39874. * Sets the flag that indicates if user zooming should stop animation.
  39875. */
  39876. set zoomStopsAnimation(flag: boolean);
  39877. /**
  39878. * Gets the flag that indicates if user zooming should stop animation.
  39879. */
  39880. get zoomStopsAnimation(): boolean;
  39881. /**
  39882. * Sets the transition time when framing the mesh, in milliseconds
  39883. */
  39884. set framingTime(time: number);
  39885. /**
  39886. * Gets the transition time when framing the mesh, in milliseconds
  39887. */
  39888. get framingTime(): number;
  39889. /**
  39890. * Define if the behavior should automatically change the configured
  39891. * camera limits and sensibilities.
  39892. */
  39893. autoCorrectCameraLimitsAndSensibility: boolean;
  39894. private _onPrePointerObservableObserver;
  39895. private _onAfterCheckInputsObserver;
  39896. private _onMeshTargetChangedObserver;
  39897. private _attachedCamera;
  39898. private _isPointerDown;
  39899. private _lastInteractionTime;
  39900. /**
  39901. * Initializes the behavior.
  39902. */
  39903. init(): void;
  39904. /**
  39905. * Attaches the behavior to its arc rotate camera.
  39906. * @param camera Defines the camera to attach the behavior to
  39907. */
  39908. attach(camera: ArcRotateCamera): void;
  39909. /**
  39910. * Detaches the behavior from its current arc rotate camera.
  39911. */
  39912. detach(): void;
  39913. private _animatables;
  39914. private _betaIsAnimating;
  39915. private _betaTransition;
  39916. private _radiusTransition;
  39917. private _vectorTransition;
  39918. /**
  39919. * Targets the given mesh and updates zoom level accordingly.
  39920. * @param mesh The mesh to target.
  39921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39923. */
  39924. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39925. /**
  39926. * Targets the given mesh with its children and updates zoom level accordingly.
  39927. * @param mesh The mesh to target.
  39928. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39929. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39930. */
  39931. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39932. /**
  39933. * Targets the given meshes with their children and updates zoom level accordingly.
  39934. * @param meshes The mesh to target.
  39935. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39936. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39937. */
  39938. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39939. /**
  39940. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39941. * @param minimumWorld Determines the smaller position of the bounding box extend
  39942. * @param maximumWorld Determines the bigger position of the bounding box extend
  39943. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39944. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39945. */
  39946. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39947. /**
  39948. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39949. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39950. * frustum width.
  39951. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39952. * to fully enclose the mesh in the viewing frustum.
  39953. */
  39954. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39955. /**
  39956. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39957. * is automatically returned to its default position (expected to be above ground plane).
  39958. */
  39959. private _maintainCameraAboveGround;
  39960. /**
  39961. * Returns the frustum slope based on the canvas ratio and camera FOV
  39962. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39963. */
  39964. private _getFrustumSlope;
  39965. /**
  39966. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39967. */
  39968. private _clearAnimationLocks;
  39969. /**
  39970. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39971. */
  39972. private _applyUserInteraction;
  39973. /**
  39974. * Stops and removes all animations that have been applied to the camera
  39975. */
  39976. stopAllAnimations(): void;
  39977. /**
  39978. * Gets a value indicating if the user is moving the camera
  39979. */
  39980. get isUserIsMoving(): boolean;
  39981. /**
  39982. * The camera can move all the way towards the mesh.
  39983. */
  39984. static IgnoreBoundsSizeMode: number;
  39985. /**
  39986. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39987. */
  39988. static FitFrustumSidesMode: number;
  39989. }
  39990. }
  39991. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39992. import { Nullable } from "babylonjs/types";
  39993. import { Camera } from "babylonjs/Cameras/camera";
  39994. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39995. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39996. /**
  39997. * Base class for Camera Pointer Inputs.
  39998. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39999. * for example usage.
  40000. */
  40001. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  40002. /**
  40003. * Defines the camera the input is attached to.
  40004. */
  40005. abstract camera: Camera;
  40006. /**
  40007. * Whether keyboard modifier keys are pressed at time of last mouse event.
  40008. */
  40009. protected _altKey: boolean;
  40010. protected _ctrlKey: boolean;
  40011. protected _metaKey: boolean;
  40012. protected _shiftKey: boolean;
  40013. /**
  40014. * Which mouse buttons were pressed at time of last mouse event.
  40015. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  40016. */
  40017. protected _buttonsPressed: number;
  40018. /**
  40019. * Defines the buttons associated with the input to handle camera move.
  40020. */
  40021. buttons: number[];
  40022. /**
  40023. * Attach the input controls to a specific dom element to get the input from.
  40024. * @param element Defines the element the controls should be listened from
  40025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40026. */
  40027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40028. /**
  40029. * Detach the current controls from the specified dom element.
  40030. * @param element Defines the element to stop listening the inputs from
  40031. */
  40032. detachControl(element: Nullable<HTMLElement>): void;
  40033. /**
  40034. * Gets the class name of the current input.
  40035. * @returns the class name
  40036. */
  40037. getClassName(): string;
  40038. /**
  40039. * Get the friendly name associated with the input class.
  40040. * @returns the input friendly name
  40041. */
  40042. getSimpleName(): string;
  40043. /**
  40044. * Called on pointer POINTERDOUBLETAP event.
  40045. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40046. */
  40047. protected onDoubleTap(type: string): void;
  40048. /**
  40049. * Called on pointer POINTERMOVE event if only a single touch is active.
  40050. * Override this method to provide functionality.
  40051. */
  40052. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40053. /**
  40054. * Called on pointer POINTERMOVE event if multiple touches are active.
  40055. * Override this method to provide functionality.
  40056. */
  40057. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40058. /**
  40059. * Called on JS contextmenu event.
  40060. * Override this method to provide functionality.
  40061. */
  40062. protected onContextMenu(evt: PointerEvent): void;
  40063. /**
  40064. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40065. * press.
  40066. * Override this method to provide functionality.
  40067. */
  40068. protected onButtonDown(evt: PointerEvent): void;
  40069. /**
  40070. * Called each time a new POINTERUP event occurs. Ie, for each button
  40071. * release.
  40072. * Override this method to provide functionality.
  40073. */
  40074. protected onButtonUp(evt: PointerEvent): void;
  40075. /**
  40076. * Called when window becomes inactive.
  40077. * Override this method to provide functionality.
  40078. */
  40079. protected onLostFocus(): void;
  40080. private _pointerInput;
  40081. private _observer;
  40082. private _onLostFocus;
  40083. private pointA;
  40084. private pointB;
  40085. }
  40086. }
  40087. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40088. import { Nullable } from "babylonjs/types";
  40089. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40090. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40091. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40092. /**
  40093. * Manage the pointers inputs to control an arc rotate camera.
  40094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40095. */
  40096. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40097. /**
  40098. * Defines the camera the input is attached to.
  40099. */
  40100. camera: ArcRotateCamera;
  40101. /**
  40102. * Gets the class name of the current input.
  40103. * @returns the class name
  40104. */
  40105. getClassName(): string;
  40106. /**
  40107. * Defines the buttons associated with the input to handle camera move.
  40108. */
  40109. buttons: number[];
  40110. /**
  40111. * Defines the pointer angular sensibility along the X axis or how fast is
  40112. * the camera rotating.
  40113. */
  40114. angularSensibilityX: number;
  40115. /**
  40116. * Defines the pointer angular sensibility along the Y axis or how fast is
  40117. * the camera rotating.
  40118. */
  40119. angularSensibilityY: number;
  40120. /**
  40121. * Defines the pointer pinch precision or how fast is the camera zooming.
  40122. */
  40123. pinchPrecision: number;
  40124. /**
  40125. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40126. * from 0.
  40127. * It defines the percentage of current camera.radius to use as delta when
  40128. * pinch zoom is used.
  40129. */
  40130. pinchDeltaPercentage: number;
  40131. /**
  40132. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40133. * that any object in the plane at the camera's target point will scale
  40134. * perfectly with finger motion.
  40135. * Overrides pinchDeltaPercentage and pinchPrecision.
  40136. */
  40137. useNaturalPinchZoom: boolean;
  40138. /**
  40139. * Defines the pointer panning sensibility or how fast is the camera moving.
  40140. */
  40141. panningSensibility: number;
  40142. /**
  40143. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40144. */
  40145. multiTouchPanning: boolean;
  40146. /**
  40147. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40148. * zoom (pinch) through multitouch.
  40149. */
  40150. multiTouchPanAndZoom: boolean;
  40151. /**
  40152. * Revers pinch action direction.
  40153. */
  40154. pinchInwards: boolean;
  40155. private _isPanClick;
  40156. private _twoFingerActivityCount;
  40157. private _isPinching;
  40158. /**
  40159. * Called on pointer POINTERMOVE event if only a single touch is active.
  40160. */
  40161. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40162. /**
  40163. * Called on pointer POINTERDOUBLETAP event.
  40164. */
  40165. protected onDoubleTap(type: string): void;
  40166. /**
  40167. * Called on pointer POINTERMOVE event if multiple touches are active.
  40168. */
  40169. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40170. /**
  40171. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40172. * press.
  40173. */
  40174. protected onButtonDown(evt: PointerEvent): void;
  40175. /**
  40176. * Called each time a new POINTERUP event occurs. Ie, for each button
  40177. * release.
  40178. */
  40179. protected onButtonUp(evt: PointerEvent): void;
  40180. /**
  40181. * Called when window becomes inactive.
  40182. */
  40183. protected onLostFocus(): void;
  40184. }
  40185. }
  40186. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40187. import { Nullable } from "babylonjs/types";
  40188. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40190. /**
  40191. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40193. */
  40194. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40195. /**
  40196. * Defines the camera the input is attached to.
  40197. */
  40198. camera: ArcRotateCamera;
  40199. /**
  40200. * Defines the list of key codes associated with the up action (increase alpha)
  40201. */
  40202. keysUp: number[];
  40203. /**
  40204. * Defines the list of key codes associated with the down action (decrease alpha)
  40205. */
  40206. keysDown: number[];
  40207. /**
  40208. * Defines the list of key codes associated with the left action (increase beta)
  40209. */
  40210. keysLeft: number[];
  40211. /**
  40212. * Defines the list of key codes associated with the right action (decrease beta)
  40213. */
  40214. keysRight: number[];
  40215. /**
  40216. * Defines the list of key codes associated with the reset action.
  40217. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40218. */
  40219. keysReset: number[];
  40220. /**
  40221. * Defines the panning sensibility of the inputs.
  40222. * (How fast is the camera panning)
  40223. */
  40224. panningSensibility: number;
  40225. /**
  40226. * Defines the zooming sensibility of the inputs.
  40227. * (How fast is the camera zooming)
  40228. */
  40229. zoomingSensibility: number;
  40230. /**
  40231. * Defines whether maintaining the alt key down switch the movement mode from
  40232. * orientation to zoom.
  40233. */
  40234. useAltToZoom: boolean;
  40235. /**
  40236. * Rotation speed of the camera
  40237. */
  40238. angularSpeed: number;
  40239. private _keys;
  40240. private _ctrlPressed;
  40241. private _altPressed;
  40242. private _onCanvasBlurObserver;
  40243. private _onKeyboardObserver;
  40244. private _engine;
  40245. private _scene;
  40246. /**
  40247. * Attach the input controls to a specific dom element to get the input from.
  40248. * @param element Defines the element the controls should be listened from
  40249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40250. */
  40251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40252. /**
  40253. * Detach the current controls from the specified dom element.
  40254. * @param element Defines the element to stop listening the inputs from
  40255. */
  40256. detachControl(element: Nullable<HTMLElement>): void;
  40257. /**
  40258. * Update the current camera state depending on the inputs that have been used this frame.
  40259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40260. */
  40261. checkInputs(): void;
  40262. /**
  40263. * Gets the class name of the current intput.
  40264. * @returns the class name
  40265. */
  40266. getClassName(): string;
  40267. /**
  40268. * Get the friendly name associated with the input class.
  40269. * @returns the input friendly name
  40270. */
  40271. getSimpleName(): string;
  40272. }
  40273. }
  40274. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40275. import { Nullable } from "babylonjs/types";
  40276. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40278. /**
  40279. * Manage the mouse wheel inputs to control an arc rotate camera.
  40280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40281. */
  40282. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40283. /**
  40284. * Defines the camera the input is attached to.
  40285. */
  40286. camera: ArcRotateCamera;
  40287. /**
  40288. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40289. */
  40290. wheelPrecision: number;
  40291. /**
  40292. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40293. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40294. */
  40295. wheelDeltaPercentage: number;
  40296. private _wheel;
  40297. private _observer;
  40298. private computeDeltaFromMouseWheelLegacyEvent;
  40299. /**
  40300. * Attach the input controls to a specific dom element to get the input from.
  40301. * @param element Defines the element the controls should be listened from
  40302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40303. */
  40304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40305. /**
  40306. * Detach the current controls from the specified dom element.
  40307. * @param element Defines the element to stop listening the inputs from
  40308. */
  40309. detachControl(element: Nullable<HTMLElement>): void;
  40310. /**
  40311. * Gets the class name of the current intput.
  40312. * @returns the class name
  40313. */
  40314. getClassName(): string;
  40315. /**
  40316. * Get the friendly name associated with the input class.
  40317. * @returns the input friendly name
  40318. */
  40319. getSimpleName(): string;
  40320. }
  40321. }
  40322. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40323. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40324. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40325. /**
  40326. * Default Inputs manager for the ArcRotateCamera.
  40327. * It groups all the default supported inputs for ease of use.
  40328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40329. */
  40330. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40331. /**
  40332. * Instantiates a new ArcRotateCameraInputsManager.
  40333. * @param camera Defines the camera the inputs belong to
  40334. */
  40335. constructor(camera: ArcRotateCamera);
  40336. /**
  40337. * Add mouse wheel input support to the input manager.
  40338. * @returns the current input manager
  40339. */
  40340. addMouseWheel(): ArcRotateCameraInputsManager;
  40341. /**
  40342. * Add pointers input support to the input manager.
  40343. * @returns the current input manager
  40344. */
  40345. addPointers(): ArcRotateCameraInputsManager;
  40346. /**
  40347. * Add keyboard input support to the input manager.
  40348. * @returns the current input manager
  40349. */
  40350. addKeyboard(): ArcRotateCameraInputsManager;
  40351. }
  40352. }
  40353. declare module "babylonjs/Cameras/arcRotateCamera" {
  40354. import { Observable } from "babylonjs/Misc/observable";
  40355. import { Nullable } from "babylonjs/types";
  40356. import { Scene } from "babylonjs/scene";
  40357. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40359. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40360. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40361. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40362. import { Camera } from "babylonjs/Cameras/camera";
  40363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40364. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40365. import { Collider } from "babylonjs/Collisions/collider";
  40366. /**
  40367. * This represents an orbital type of camera.
  40368. *
  40369. * 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.
  40370. * 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.
  40371. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40372. */
  40373. export class ArcRotateCamera extends TargetCamera {
  40374. /**
  40375. * Defines the rotation angle of the camera along the longitudinal axis.
  40376. */
  40377. alpha: number;
  40378. /**
  40379. * Defines the rotation angle of the camera along the latitudinal axis.
  40380. */
  40381. beta: number;
  40382. /**
  40383. * Defines the radius of the camera from it s target point.
  40384. */
  40385. radius: number;
  40386. protected _target: Vector3;
  40387. protected _targetHost: Nullable<AbstractMesh>;
  40388. /**
  40389. * Defines the target point of the camera.
  40390. * The camera looks towards it form the radius distance.
  40391. */
  40392. get target(): Vector3;
  40393. set target(value: Vector3);
  40394. /**
  40395. * Define the current local position of the camera in the scene
  40396. */
  40397. get position(): Vector3;
  40398. set position(newPosition: Vector3);
  40399. protected _upVector: Vector3;
  40400. protected _upToYMatrix: Matrix;
  40401. protected _YToUpMatrix: Matrix;
  40402. /**
  40403. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40404. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40405. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40406. */
  40407. set upVector(vec: Vector3);
  40408. get upVector(): Vector3;
  40409. /**
  40410. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40411. */
  40412. setMatUp(): void;
  40413. /**
  40414. * Current inertia value on the longitudinal axis.
  40415. * The bigger this number the longer it will take for the camera to stop.
  40416. */
  40417. inertialAlphaOffset: number;
  40418. /**
  40419. * Current inertia value on the latitudinal axis.
  40420. * The bigger this number the longer it will take for the camera to stop.
  40421. */
  40422. inertialBetaOffset: number;
  40423. /**
  40424. * Current inertia value on the radius axis.
  40425. * The bigger this number the longer it will take for the camera to stop.
  40426. */
  40427. inertialRadiusOffset: number;
  40428. /**
  40429. * Minimum allowed angle on the longitudinal axis.
  40430. * This can help limiting how the Camera is able to move in the scene.
  40431. */
  40432. lowerAlphaLimit: Nullable<number>;
  40433. /**
  40434. * Maximum allowed angle on the longitudinal axis.
  40435. * This can help limiting how the Camera is able to move in the scene.
  40436. */
  40437. upperAlphaLimit: Nullable<number>;
  40438. /**
  40439. * Minimum allowed angle on the latitudinal axis.
  40440. * This can help limiting how the Camera is able to move in the scene.
  40441. */
  40442. lowerBetaLimit: number;
  40443. /**
  40444. * Maximum allowed angle on the latitudinal axis.
  40445. * This can help limiting how the Camera is able to move in the scene.
  40446. */
  40447. upperBetaLimit: number;
  40448. /**
  40449. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40450. * This can help limiting how the Camera is able to move in the scene.
  40451. */
  40452. lowerRadiusLimit: Nullable<number>;
  40453. /**
  40454. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40455. * This can help limiting how the Camera is able to move in the scene.
  40456. */
  40457. upperRadiusLimit: Nullable<number>;
  40458. /**
  40459. * Defines the current inertia value used during panning of the camera along the X axis.
  40460. */
  40461. inertialPanningX: number;
  40462. /**
  40463. * Defines the current inertia value used during panning of the camera along the Y axis.
  40464. */
  40465. inertialPanningY: number;
  40466. /**
  40467. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40468. * Basically if your fingers moves away from more than this distance you will be considered
  40469. * in pinch mode.
  40470. */
  40471. pinchToPanMaxDistance: number;
  40472. /**
  40473. * Defines the maximum distance the camera can pan.
  40474. * This could help keeping the cammera always in your scene.
  40475. */
  40476. panningDistanceLimit: Nullable<number>;
  40477. /**
  40478. * Defines the target of the camera before paning.
  40479. */
  40480. panningOriginTarget: Vector3;
  40481. /**
  40482. * Defines the value of the inertia used during panning.
  40483. * 0 would mean stop inertia and one would mean no decelleration at all.
  40484. */
  40485. panningInertia: number;
  40486. /**
  40487. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40488. */
  40489. get angularSensibilityX(): number;
  40490. set angularSensibilityX(value: number);
  40491. /**
  40492. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40493. */
  40494. get angularSensibilityY(): number;
  40495. set angularSensibilityY(value: number);
  40496. /**
  40497. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40498. */
  40499. get pinchPrecision(): number;
  40500. set pinchPrecision(value: number);
  40501. /**
  40502. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40503. * It will be used instead of pinchDeltaPrecision if different from 0.
  40504. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40505. */
  40506. get pinchDeltaPercentage(): number;
  40507. set pinchDeltaPercentage(value: number);
  40508. /**
  40509. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40510. * and pinch delta percentage.
  40511. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40512. * that any object in the plane at the camera's target point will scale
  40513. * perfectly with finger motion.
  40514. */
  40515. get useNaturalPinchZoom(): boolean;
  40516. set useNaturalPinchZoom(value: boolean);
  40517. /**
  40518. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40519. */
  40520. get panningSensibility(): number;
  40521. set panningSensibility(value: number);
  40522. /**
  40523. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40524. */
  40525. get keysUp(): number[];
  40526. set keysUp(value: number[]);
  40527. /**
  40528. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40529. */
  40530. get keysDown(): number[];
  40531. set keysDown(value: number[]);
  40532. /**
  40533. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40534. */
  40535. get keysLeft(): number[];
  40536. set keysLeft(value: number[]);
  40537. /**
  40538. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40539. */
  40540. get keysRight(): number[];
  40541. set keysRight(value: number[]);
  40542. /**
  40543. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40544. */
  40545. get wheelPrecision(): number;
  40546. set wheelPrecision(value: number);
  40547. /**
  40548. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40549. * It will be used instead of pinchDeltaPrecision if different from 0.
  40550. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40551. */
  40552. get wheelDeltaPercentage(): number;
  40553. set wheelDeltaPercentage(value: number);
  40554. /**
  40555. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40556. */
  40557. zoomOnFactor: number;
  40558. /**
  40559. * Defines a screen offset for the camera position.
  40560. */
  40561. targetScreenOffset: Vector2;
  40562. /**
  40563. * Allows the camera to be completely reversed.
  40564. * If false the camera can not arrive upside down.
  40565. */
  40566. allowUpsideDown: boolean;
  40567. /**
  40568. * Define if double tap/click is used to restore the previously saved state of the camera.
  40569. */
  40570. useInputToRestoreState: boolean;
  40571. /** @hidden */
  40572. _viewMatrix: Matrix;
  40573. /** @hidden */
  40574. _useCtrlForPanning: boolean;
  40575. /** @hidden */
  40576. _panningMouseButton: number;
  40577. /**
  40578. * Defines the input associated to the camera.
  40579. */
  40580. inputs: ArcRotateCameraInputsManager;
  40581. /** @hidden */
  40582. _reset: () => void;
  40583. /**
  40584. * Defines the allowed panning axis.
  40585. */
  40586. panningAxis: Vector3;
  40587. protected _localDirection: Vector3;
  40588. protected _transformedDirection: Vector3;
  40589. private _bouncingBehavior;
  40590. /**
  40591. * Gets the bouncing behavior of the camera if it has been enabled.
  40592. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40593. */
  40594. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40595. /**
  40596. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40597. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40598. */
  40599. get useBouncingBehavior(): boolean;
  40600. set useBouncingBehavior(value: boolean);
  40601. private _framingBehavior;
  40602. /**
  40603. * Gets the framing behavior of the camera if it has been enabled.
  40604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40605. */
  40606. get framingBehavior(): Nullable<FramingBehavior>;
  40607. /**
  40608. * Defines if the framing behavior of the camera is enabled on the camera.
  40609. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40610. */
  40611. get useFramingBehavior(): boolean;
  40612. set useFramingBehavior(value: boolean);
  40613. private _autoRotationBehavior;
  40614. /**
  40615. * Gets the auto rotation behavior of the camera if it has been enabled.
  40616. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40617. */
  40618. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40619. /**
  40620. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40621. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40622. */
  40623. get useAutoRotationBehavior(): boolean;
  40624. set useAutoRotationBehavior(value: boolean);
  40625. /**
  40626. * Observable triggered when the mesh target has been changed on the camera.
  40627. */
  40628. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40629. /**
  40630. * Event raised when the camera is colliding with a mesh.
  40631. */
  40632. onCollide: (collidedMesh: AbstractMesh) => void;
  40633. /**
  40634. * Defines whether the camera should check collision with the objects oh the scene.
  40635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40636. */
  40637. checkCollisions: boolean;
  40638. /**
  40639. * Defines the collision radius of the camera.
  40640. * This simulates a sphere around the camera.
  40641. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40642. */
  40643. collisionRadius: Vector3;
  40644. protected _collider: Collider;
  40645. protected _previousPosition: Vector3;
  40646. protected _collisionVelocity: Vector3;
  40647. protected _newPosition: Vector3;
  40648. protected _previousAlpha: number;
  40649. protected _previousBeta: number;
  40650. protected _previousRadius: number;
  40651. protected _collisionTriggered: boolean;
  40652. protected _targetBoundingCenter: Nullable<Vector3>;
  40653. private _computationVector;
  40654. /**
  40655. * Instantiates a new ArcRotateCamera in a given scene
  40656. * @param name Defines the name of the camera
  40657. * @param alpha Defines the camera rotation along the logitudinal axis
  40658. * @param beta Defines the camera rotation along the latitudinal axis
  40659. * @param radius Defines the camera distance from its target
  40660. * @param target Defines the camera target
  40661. * @param scene Defines the scene the camera belongs to
  40662. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40663. */
  40664. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40665. /** @hidden */
  40666. _initCache(): void;
  40667. /** @hidden */
  40668. _updateCache(ignoreParentClass?: boolean): void;
  40669. protected _getTargetPosition(): Vector3;
  40670. private _storedAlpha;
  40671. private _storedBeta;
  40672. private _storedRadius;
  40673. private _storedTarget;
  40674. private _storedTargetScreenOffset;
  40675. /**
  40676. * Stores the current state of the camera (alpha, beta, radius and target)
  40677. * @returns the camera itself
  40678. */
  40679. storeState(): Camera;
  40680. /**
  40681. * @hidden
  40682. * Restored camera state. You must call storeState() first
  40683. */
  40684. _restoreStateValues(): boolean;
  40685. /** @hidden */
  40686. _isSynchronizedViewMatrix(): boolean;
  40687. /**
  40688. * Attached controls to the current camera.
  40689. * @param element Defines the element the controls should be listened from
  40690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40691. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40692. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40693. */
  40694. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40695. /**
  40696. * Detach the current controls from the camera.
  40697. * The camera will stop reacting to inputs.
  40698. * @param element Defines the element to stop listening the inputs from
  40699. */
  40700. detachControl(element: HTMLElement): void;
  40701. /** @hidden */
  40702. _checkInputs(): void;
  40703. protected _checkLimits(): void;
  40704. /**
  40705. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40706. */
  40707. rebuildAnglesAndRadius(): void;
  40708. /**
  40709. * Use a position to define the current camera related information like alpha, beta and radius
  40710. * @param position Defines the position to set the camera at
  40711. */
  40712. setPosition(position: Vector3): void;
  40713. /**
  40714. * Defines the target the camera should look at.
  40715. * This will automatically adapt alpha beta and radius to fit within the new target.
  40716. * @param target Defines the new target as a Vector or a mesh
  40717. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40718. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40719. */
  40720. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40721. /** @hidden */
  40722. _getViewMatrix(): Matrix;
  40723. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40724. /**
  40725. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40726. * @param meshes Defines the mesh to zoom on
  40727. * @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)
  40728. */
  40729. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40730. /**
  40731. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40732. * The target will be changed but the radius
  40733. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40734. * @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)
  40735. */
  40736. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40737. min: Vector3;
  40738. max: Vector3;
  40739. distance: number;
  40740. }, doNotUpdateMaxZ?: boolean): void;
  40741. /**
  40742. * @override
  40743. * Override Camera.createRigCamera
  40744. */
  40745. createRigCamera(name: string, cameraIndex: number): Camera;
  40746. /**
  40747. * @hidden
  40748. * @override
  40749. * Override Camera._updateRigCameras
  40750. */
  40751. _updateRigCameras(): void;
  40752. /**
  40753. * Destroy the camera and release the current resources hold by it.
  40754. */
  40755. dispose(): void;
  40756. /**
  40757. * Gets the current object class name.
  40758. * @return the class name
  40759. */
  40760. getClassName(): string;
  40761. }
  40762. }
  40763. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40764. import { Behavior } from "babylonjs/Behaviors/behavior";
  40765. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40766. /**
  40767. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40769. */
  40770. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40771. /**
  40772. * Gets the name of the behavior.
  40773. */
  40774. get name(): string;
  40775. private _zoomStopsAnimation;
  40776. private _idleRotationSpeed;
  40777. private _idleRotationWaitTime;
  40778. private _idleRotationSpinupTime;
  40779. /**
  40780. * Sets the flag that indicates if user zooming should stop animation.
  40781. */
  40782. set zoomStopsAnimation(flag: boolean);
  40783. /**
  40784. * Gets the flag that indicates if user zooming should stop animation.
  40785. */
  40786. get zoomStopsAnimation(): boolean;
  40787. /**
  40788. * Sets the default speed at which the camera rotates around the model.
  40789. */
  40790. set idleRotationSpeed(speed: number);
  40791. /**
  40792. * Gets the default speed at which the camera rotates around the model.
  40793. */
  40794. get idleRotationSpeed(): number;
  40795. /**
  40796. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40797. */
  40798. set idleRotationWaitTime(time: number);
  40799. /**
  40800. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40801. */
  40802. get idleRotationWaitTime(): number;
  40803. /**
  40804. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40805. */
  40806. set idleRotationSpinupTime(time: number);
  40807. /**
  40808. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40809. */
  40810. get idleRotationSpinupTime(): number;
  40811. /**
  40812. * Gets a value indicating if the camera is currently rotating because of this behavior
  40813. */
  40814. get rotationInProgress(): boolean;
  40815. private _onPrePointerObservableObserver;
  40816. private _onAfterCheckInputsObserver;
  40817. private _attachedCamera;
  40818. private _isPointerDown;
  40819. private _lastFrameTime;
  40820. private _lastInteractionTime;
  40821. private _cameraRotationSpeed;
  40822. /**
  40823. * Initializes the behavior.
  40824. */
  40825. init(): void;
  40826. /**
  40827. * Attaches the behavior to its arc rotate camera.
  40828. * @param camera Defines the camera to attach the behavior to
  40829. */
  40830. attach(camera: ArcRotateCamera): void;
  40831. /**
  40832. * Detaches the behavior from its current arc rotate camera.
  40833. */
  40834. detach(): void;
  40835. /**
  40836. * Returns true if user is scrolling.
  40837. * @return true if user is scrolling.
  40838. */
  40839. private _userIsZooming;
  40840. private _lastFrameRadius;
  40841. private _shouldAnimationStopForInteraction;
  40842. /**
  40843. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40844. */
  40845. private _applyUserInteraction;
  40846. private _userIsMoving;
  40847. }
  40848. }
  40849. declare module "babylonjs/Behaviors/Cameras/index" {
  40850. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40851. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40852. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40853. }
  40854. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40855. import { Mesh } from "babylonjs/Meshes/mesh";
  40856. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40857. import { Behavior } from "babylonjs/Behaviors/behavior";
  40858. /**
  40859. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40860. */
  40861. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40862. private ui;
  40863. /**
  40864. * The name of the behavior
  40865. */
  40866. name: string;
  40867. /**
  40868. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40869. */
  40870. distanceAwayFromFace: number;
  40871. /**
  40872. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40873. */
  40874. distanceAwayFromBottomOfFace: number;
  40875. private _faceVectors;
  40876. private _target;
  40877. private _scene;
  40878. private _onRenderObserver;
  40879. private _tmpMatrix;
  40880. private _tmpVector;
  40881. /**
  40882. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40883. * @param ui The transform node that should be attched to the mesh
  40884. */
  40885. constructor(ui: TransformNode);
  40886. /**
  40887. * Initializes the behavior
  40888. */
  40889. init(): void;
  40890. private _closestFace;
  40891. private _zeroVector;
  40892. private _lookAtTmpMatrix;
  40893. private _lookAtToRef;
  40894. /**
  40895. * Attaches the AttachToBoxBehavior to the passed in mesh
  40896. * @param target The mesh that the specified node will be attached to
  40897. */
  40898. attach(target: Mesh): void;
  40899. /**
  40900. * Detaches the behavior from the mesh
  40901. */
  40902. detach(): void;
  40903. }
  40904. }
  40905. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40906. import { Behavior } from "babylonjs/Behaviors/behavior";
  40907. import { Mesh } from "babylonjs/Meshes/mesh";
  40908. /**
  40909. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40910. */
  40911. export class FadeInOutBehavior implements Behavior<Mesh> {
  40912. /**
  40913. * Time in milliseconds to delay before fading in (Default: 0)
  40914. */
  40915. delay: number;
  40916. /**
  40917. * Time in milliseconds for the mesh to fade in (Default: 300)
  40918. */
  40919. fadeInTime: number;
  40920. private _millisecondsPerFrame;
  40921. private _hovered;
  40922. private _hoverValue;
  40923. private _ownerNode;
  40924. /**
  40925. * Instatiates the FadeInOutBehavior
  40926. */
  40927. constructor();
  40928. /**
  40929. * The name of the behavior
  40930. */
  40931. get name(): string;
  40932. /**
  40933. * Initializes the behavior
  40934. */
  40935. init(): void;
  40936. /**
  40937. * Attaches the fade behavior on the passed in mesh
  40938. * @param ownerNode The mesh that will be faded in/out once attached
  40939. */
  40940. attach(ownerNode: Mesh): void;
  40941. /**
  40942. * Detaches the behavior from the mesh
  40943. */
  40944. detach(): void;
  40945. /**
  40946. * Triggers the mesh to begin fading in or out
  40947. * @param value if the object should fade in or out (true to fade in)
  40948. */
  40949. fadeIn(value: boolean): void;
  40950. private _update;
  40951. private _setAllVisibility;
  40952. }
  40953. }
  40954. declare module "babylonjs/Misc/pivotTools" {
  40955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40956. /**
  40957. * Class containing a set of static utilities functions for managing Pivots
  40958. * @hidden
  40959. */
  40960. export class PivotTools {
  40961. private static _PivotCached;
  40962. private static _OldPivotPoint;
  40963. private static _PivotTranslation;
  40964. private static _PivotTmpVector;
  40965. /** @hidden */
  40966. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40967. /** @hidden */
  40968. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40969. }
  40970. }
  40971. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40972. import { Scene } from "babylonjs/scene";
  40973. import { Vector4 } from "babylonjs/Maths/math.vector";
  40974. import { Mesh } from "babylonjs/Meshes/mesh";
  40975. import { Nullable } from "babylonjs/types";
  40976. import { Plane } from "babylonjs/Maths/math.plane";
  40977. /**
  40978. * Class containing static functions to help procedurally build meshes
  40979. */
  40980. export class PlaneBuilder {
  40981. /**
  40982. * Creates a plane mesh
  40983. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40984. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40985. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40989. * @param name defines the name of the mesh
  40990. * @param options defines the options used to create the mesh
  40991. * @param scene defines the hosting scene
  40992. * @returns the plane mesh
  40993. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40994. */
  40995. static CreatePlane(name: string, options: {
  40996. size?: number;
  40997. width?: number;
  40998. height?: number;
  40999. sideOrientation?: number;
  41000. frontUVs?: Vector4;
  41001. backUVs?: Vector4;
  41002. updatable?: boolean;
  41003. sourcePlane?: Plane;
  41004. }, scene?: Nullable<Scene>): Mesh;
  41005. }
  41006. }
  41007. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  41008. import { Behavior } from "babylonjs/Behaviors/behavior";
  41009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41010. import { Observable } from "babylonjs/Misc/observable";
  41011. import { Vector3 } from "babylonjs/Maths/math.vector";
  41012. import { Ray } from "babylonjs/Culling/ray";
  41013. import "babylonjs/Meshes/Builders/planeBuilder";
  41014. /**
  41015. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41016. */
  41017. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  41018. private static _AnyMouseID;
  41019. /**
  41020. * Abstract mesh the behavior is set on
  41021. */
  41022. attachedNode: AbstractMesh;
  41023. private _dragPlane;
  41024. private _scene;
  41025. private _pointerObserver;
  41026. private _beforeRenderObserver;
  41027. private static _planeScene;
  41028. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  41029. /**
  41030. * 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)
  41031. */
  41032. maxDragAngle: number;
  41033. /**
  41034. * @hidden
  41035. */
  41036. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41037. /**
  41038. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41039. */
  41040. currentDraggingPointerID: number;
  41041. /**
  41042. * The last position where the pointer hit the drag plane in world space
  41043. */
  41044. lastDragPosition: Vector3;
  41045. /**
  41046. * If the behavior is currently in a dragging state
  41047. */
  41048. dragging: boolean;
  41049. /**
  41050. * 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)
  41051. */
  41052. dragDeltaRatio: number;
  41053. /**
  41054. * If the drag plane orientation should be updated during the dragging (Default: true)
  41055. */
  41056. updateDragPlane: boolean;
  41057. private _debugMode;
  41058. private _moving;
  41059. /**
  41060. * Fires each time the attached mesh is dragged with the pointer
  41061. * * delta between last drag position and current drag position in world space
  41062. * * dragDistance along the drag axis
  41063. * * dragPlaneNormal normal of the current drag plane used during the drag
  41064. * * dragPlanePoint in world space where the drag intersects the drag plane
  41065. */
  41066. onDragObservable: Observable<{
  41067. delta: Vector3;
  41068. dragPlanePoint: Vector3;
  41069. dragPlaneNormal: Vector3;
  41070. dragDistance: number;
  41071. pointerId: number;
  41072. }>;
  41073. /**
  41074. * Fires each time a drag begins (eg. mouse down on mesh)
  41075. */
  41076. onDragStartObservable: Observable<{
  41077. dragPlanePoint: Vector3;
  41078. pointerId: number;
  41079. }>;
  41080. /**
  41081. * Fires each time a drag ends (eg. mouse release after drag)
  41082. */
  41083. onDragEndObservable: Observable<{
  41084. dragPlanePoint: Vector3;
  41085. pointerId: number;
  41086. }>;
  41087. /**
  41088. * If the attached mesh should be moved when dragged
  41089. */
  41090. moveAttached: boolean;
  41091. /**
  41092. * If the drag behavior will react to drag events (Default: true)
  41093. */
  41094. enabled: boolean;
  41095. /**
  41096. * If pointer events should start and release the drag (Default: true)
  41097. */
  41098. startAndReleaseDragOnPointerEvents: boolean;
  41099. /**
  41100. * If camera controls should be detached during the drag
  41101. */
  41102. detachCameraControls: boolean;
  41103. /**
  41104. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41105. */
  41106. useObjectOrientationForDragging: boolean;
  41107. private _options;
  41108. /**
  41109. * Gets the options used by the behavior
  41110. */
  41111. get options(): {
  41112. dragAxis?: Vector3;
  41113. dragPlaneNormal?: Vector3;
  41114. };
  41115. /**
  41116. * Sets the options used by the behavior
  41117. */
  41118. set options(options: {
  41119. dragAxis?: Vector3;
  41120. dragPlaneNormal?: Vector3;
  41121. });
  41122. /**
  41123. * Creates a pointer drag behavior that can be attached to a mesh
  41124. * @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)
  41125. */
  41126. constructor(options?: {
  41127. dragAxis?: Vector3;
  41128. dragPlaneNormal?: Vector3;
  41129. });
  41130. /**
  41131. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41132. */
  41133. validateDrag: (targetPosition: Vector3) => boolean;
  41134. /**
  41135. * The name of the behavior
  41136. */
  41137. get name(): string;
  41138. /**
  41139. * Initializes the behavior
  41140. */
  41141. init(): void;
  41142. private _tmpVector;
  41143. private _alternatePickedPoint;
  41144. private _worldDragAxis;
  41145. private _targetPosition;
  41146. private _attachedElement;
  41147. /**
  41148. * Attaches the drag behavior the passed in mesh
  41149. * @param ownerNode The mesh that will be dragged around once attached
  41150. * @param predicate Predicate to use for pick filtering
  41151. */
  41152. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41153. /**
  41154. * Force relase the drag action by code.
  41155. */
  41156. releaseDrag(): void;
  41157. private _startDragRay;
  41158. private _lastPointerRay;
  41159. /**
  41160. * Simulates the start of a pointer drag event on the behavior
  41161. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41162. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41163. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41164. */
  41165. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41166. private _startDrag;
  41167. private _dragDelta;
  41168. private _moveDrag;
  41169. private _pickWithRayOnDragPlane;
  41170. private _pointA;
  41171. private _pointB;
  41172. private _pointC;
  41173. private _lineA;
  41174. private _lineB;
  41175. private _localAxis;
  41176. private _lookAt;
  41177. private _updateDragPlanePosition;
  41178. /**
  41179. * Detaches the behavior from the mesh
  41180. */
  41181. detach(): void;
  41182. }
  41183. }
  41184. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41185. import { Mesh } from "babylonjs/Meshes/mesh";
  41186. import { Behavior } from "babylonjs/Behaviors/behavior";
  41187. /**
  41188. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41189. */
  41190. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41191. private _dragBehaviorA;
  41192. private _dragBehaviorB;
  41193. private _startDistance;
  41194. private _initialScale;
  41195. private _targetScale;
  41196. private _ownerNode;
  41197. private _sceneRenderObserver;
  41198. /**
  41199. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41200. */
  41201. constructor();
  41202. /**
  41203. * The name of the behavior
  41204. */
  41205. get name(): string;
  41206. /**
  41207. * Initializes the behavior
  41208. */
  41209. init(): void;
  41210. private _getCurrentDistance;
  41211. /**
  41212. * Attaches the scale behavior the passed in mesh
  41213. * @param ownerNode The mesh that will be scaled around once attached
  41214. */
  41215. attach(ownerNode: Mesh): void;
  41216. /**
  41217. * Detaches the behavior from the mesh
  41218. */
  41219. detach(): void;
  41220. }
  41221. }
  41222. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41223. import { Behavior } from "babylonjs/Behaviors/behavior";
  41224. import { Mesh } from "babylonjs/Meshes/mesh";
  41225. import { Observable } from "babylonjs/Misc/observable";
  41226. /**
  41227. * 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
  41228. */
  41229. export class SixDofDragBehavior implements Behavior<Mesh> {
  41230. private static _virtualScene;
  41231. private _ownerNode;
  41232. private _sceneRenderObserver;
  41233. private _scene;
  41234. private _targetPosition;
  41235. private _virtualOriginMesh;
  41236. private _virtualDragMesh;
  41237. private _pointerObserver;
  41238. private _moving;
  41239. private _startingOrientation;
  41240. private _attachedElement;
  41241. /**
  41242. * 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)
  41243. */
  41244. private zDragFactor;
  41245. /**
  41246. * If the object should rotate to face the drag origin
  41247. */
  41248. rotateDraggedObject: boolean;
  41249. /**
  41250. * If the behavior is currently in a dragging state
  41251. */
  41252. dragging: boolean;
  41253. /**
  41254. * 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)
  41255. */
  41256. dragDeltaRatio: number;
  41257. /**
  41258. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41259. */
  41260. currentDraggingPointerID: number;
  41261. /**
  41262. * If camera controls should be detached during the drag
  41263. */
  41264. detachCameraControls: boolean;
  41265. /**
  41266. * Fires each time a drag starts
  41267. */
  41268. onDragStartObservable: Observable<{}>;
  41269. /**
  41270. * Fires each time a drag ends (eg. mouse release after drag)
  41271. */
  41272. onDragEndObservable: Observable<{}>;
  41273. /**
  41274. * 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
  41275. */
  41276. constructor();
  41277. /**
  41278. * The name of the behavior
  41279. */
  41280. get name(): string;
  41281. /**
  41282. * Initializes the behavior
  41283. */
  41284. init(): void;
  41285. /**
  41286. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41287. */
  41288. private get _pointerCamera();
  41289. /**
  41290. * Attaches the scale behavior the passed in mesh
  41291. * @param ownerNode The mesh that will be scaled around once attached
  41292. */
  41293. attach(ownerNode: Mesh): void;
  41294. /**
  41295. * Detaches the behavior from the mesh
  41296. */
  41297. detach(): void;
  41298. }
  41299. }
  41300. declare module "babylonjs/Behaviors/Meshes/index" {
  41301. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41302. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41303. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41304. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41305. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41306. }
  41307. declare module "babylonjs/Behaviors/index" {
  41308. export * from "babylonjs/Behaviors/behavior";
  41309. export * from "babylonjs/Behaviors/Cameras/index";
  41310. export * from "babylonjs/Behaviors/Meshes/index";
  41311. }
  41312. declare module "babylonjs/Bones/boneIKController" {
  41313. import { Bone } from "babylonjs/Bones/bone";
  41314. import { Vector3 } from "babylonjs/Maths/math.vector";
  41315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41316. import { Nullable } from "babylonjs/types";
  41317. /**
  41318. * Class used to apply inverse kinematics to bones
  41319. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41320. */
  41321. export class BoneIKController {
  41322. private static _tmpVecs;
  41323. private static _tmpQuat;
  41324. private static _tmpMats;
  41325. /**
  41326. * Gets or sets the target mesh
  41327. */
  41328. targetMesh: AbstractMesh;
  41329. /** Gets or sets the mesh used as pole */
  41330. poleTargetMesh: AbstractMesh;
  41331. /**
  41332. * Gets or sets the bone used as pole
  41333. */
  41334. poleTargetBone: Nullable<Bone>;
  41335. /**
  41336. * Gets or sets the target position
  41337. */
  41338. targetPosition: Vector3;
  41339. /**
  41340. * Gets or sets the pole target position
  41341. */
  41342. poleTargetPosition: Vector3;
  41343. /**
  41344. * Gets or sets the pole target local offset
  41345. */
  41346. poleTargetLocalOffset: Vector3;
  41347. /**
  41348. * Gets or sets the pole angle
  41349. */
  41350. poleAngle: number;
  41351. /**
  41352. * Gets or sets the mesh associated with the controller
  41353. */
  41354. mesh: AbstractMesh;
  41355. /**
  41356. * 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)
  41357. */
  41358. slerpAmount: number;
  41359. private _bone1Quat;
  41360. private _bone1Mat;
  41361. private _bone2Ang;
  41362. private _bone1;
  41363. private _bone2;
  41364. private _bone1Length;
  41365. private _bone2Length;
  41366. private _maxAngle;
  41367. private _maxReach;
  41368. private _rightHandedSystem;
  41369. private _bendAxis;
  41370. private _slerping;
  41371. private _adjustRoll;
  41372. /**
  41373. * Gets or sets maximum allowed angle
  41374. */
  41375. get maxAngle(): number;
  41376. set maxAngle(value: number);
  41377. /**
  41378. * Creates a new BoneIKController
  41379. * @param mesh defines the mesh to control
  41380. * @param bone defines the bone to control
  41381. * @param options defines options to set up the controller
  41382. */
  41383. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41384. targetMesh?: AbstractMesh;
  41385. poleTargetMesh?: AbstractMesh;
  41386. poleTargetBone?: Bone;
  41387. poleTargetLocalOffset?: Vector3;
  41388. poleAngle?: number;
  41389. bendAxis?: Vector3;
  41390. maxAngle?: number;
  41391. slerpAmount?: number;
  41392. });
  41393. private _setMaxAngle;
  41394. /**
  41395. * Force the controller to update the bones
  41396. */
  41397. update(): void;
  41398. }
  41399. }
  41400. declare module "babylonjs/Bones/boneLookController" {
  41401. import { Vector3 } from "babylonjs/Maths/math.vector";
  41402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41403. import { Bone } from "babylonjs/Bones/bone";
  41404. import { Space } from "babylonjs/Maths/math.axis";
  41405. /**
  41406. * Class used to make a bone look toward a point in space
  41407. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41408. */
  41409. export class BoneLookController {
  41410. private static _tmpVecs;
  41411. private static _tmpQuat;
  41412. private static _tmpMats;
  41413. /**
  41414. * The target Vector3 that the bone will look at
  41415. */
  41416. target: Vector3;
  41417. /**
  41418. * The mesh that the bone is attached to
  41419. */
  41420. mesh: AbstractMesh;
  41421. /**
  41422. * The bone that will be looking to the target
  41423. */
  41424. bone: Bone;
  41425. /**
  41426. * The up axis of the coordinate system that is used when the bone is rotated
  41427. */
  41428. upAxis: Vector3;
  41429. /**
  41430. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41431. */
  41432. upAxisSpace: Space;
  41433. /**
  41434. * Used to make an adjustment to the yaw of the bone
  41435. */
  41436. adjustYaw: number;
  41437. /**
  41438. * Used to make an adjustment to the pitch of the bone
  41439. */
  41440. adjustPitch: number;
  41441. /**
  41442. * Used to make an adjustment to the roll of the bone
  41443. */
  41444. adjustRoll: number;
  41445. /**
  41446. * 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)
  41447. */
  41448. slerpAmount: number;
  41449. private _minYaw;
  41450. private _maxYaw;
  41451. private _minPitch;
  41452. private _maxPitch;
  41453. private _minYawSin;
  41454. private _minYawCos;
  41455. private _maxYawSin;
  41456. private _maxYawCos;
  41457. private _midYawConstraint;
  41458. private _minPitchTan;
  41459. private _maxPitchTan;
  41460. private _boneQuat;
  41461. private _slerping;
  41462. private _transformYawPitch;
  41463. private _transformYawPitchInv;
  41464. private _firstFrameSkipped;
  41465. private _yawRange;
  41466. private _fowardAxis;
  41467. /**
  41468. * Gets or sets the minimum yaw angle that the bone can look to
  41469. */
  41470. get minYaw(): number;
  41471. set minYaw(value: number);
  41472. /**
  41473. * Gets or sets the maximum yaw angle that the bone can look to
  41474. */
  41475. get maxYaw(): number;
  41476. set maxYaw(value: number);
  41477. /**
  41478. * Gets or sets the minimum pitch angle that the bone can look to
  41479. */
  41480. get minPitch(): number;
  41481. set minPitch(value: number);
  41482. /**
  41483. * Gets or sets the maximum pitch angle that the bone can look to
  41484. */
  41485. get maxPitch(): number;
  41486. set maxPitch(value: number);
  41487. /**
  41488. * Create a BoneLookController
  41489. * @param mesh the mesh that the bone belongs to
  41490. * @param bone the bone that will be looking to the target
  41491. * @param target the target Vector3 to look at
  41492. * @param options optional settings:
  41493. * * maxYaw: the maximum angle the bone will yaw to
  41494. * * minYaw: the minimum angle the bone will yaw to
  41495. * * maxPitch: the maximum angle the bone will pitch to
  41496. * * minPitch: the minimum angle the bone will yaw to
  41497. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41498. * * upAxis: the up axis of the coordinate system
  41499. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41500. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41501. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41502. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41503. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41504. * * adjustRoll: used to make an adjustment to the roll of the bone
  41505. **/
  41506. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41507. maxYaw?: number;
  41508. minYaw?: number;
  41509. maxPitch?: number;
  41510. minPitch?: number;
  41511. slerpAmount?: number;
  41512. upAxis?: Vector3;
  41513. upAxisSpace?: Space;
  41514. yawAxis?: Vector3;
  41515. pitchAxis?: Vector3;
  41516. adjustYaw?: number;
  41517. adjustPitch?: number;
  41518. adjustRoll?: number;
  41519. });
  41520. /**
  41521. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41522. */
  41523. update(): void;
  41524. private _getAngleDiff;
  41525. private _getAngleBetween;
  41526. private _isAngleBetween;
  41527. }
  41528. }
  41529. declare module "babylonjs/Bones/index" {
  41530. export * from "babylonjs/Bones/bone";
  41531. export * from "babylonjs/Bones/boneIKController";
  41532. export * from "babylonjs/Bones/boneLookController";
  41533. export * from "babylonjs/Bones/skeleton";
  41534. }
  41535. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41536. import { Nullable } from "babylonjs/types";
  41537. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41538. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41539. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41540. /**
  41541. * Manage the gamepad inputs to control an arc rotate camera.
  41542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41543. */
  41544. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41545. /**
  41546. * Defines the camera the input is attached to.
  41547. */
  41548. camera: ArcRotateCamera;
  41549. /**
  41550. * Defines the gamepad the input is gathering event from.
  41551. */
  41552. gamepad: Nullable<Gamepad>;
  41553. /**
  41554. * Defines the gamepad rotation sensiblity.
  41555. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41556. */
  41557. gamepadRotationSensibility: number;
  41558. /**
  41559. * Defines the gamepad move sensiblity.
  41560. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41561. */
  41562. gamepadMoveSensibility: number;
  41563. private _yAxisScale;
  41564. /**
  41565. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41566. */
  41567. get invertYAxis(): boolean;
  41568. set invertYAxis(value: boolean);
  41569. private _onGamepadConnectedObserver;
  41570. private _onGamepadDisconnectedObserver;
  41571. /**
  41572. * Attach the input controls to a specific dom element to get the input from.
  41573. * @param element Defines the element the controls should be listened from
  41574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41575. */
  41576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41577. /**
  41578. * Detach the current controls from the specified dom element.
  41579. * @param element Defines the element to stop listening the inputs from
  41580. */
  41581. detachControl(element: Nullable<HTMLElement>): void;
  41582. /**
  41583. * Update the current camera state depending on the inputs that have been used this frame.
  41584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41585. */
  41586. checkInputs(): void;
  41587. /**
  41588. * Gets the class name of the current intput.
  41589. * @returns the class name
  41590. */
  41591. getClassName(): string;
  41592. /**
  41593. * Get the friendly name associated with the input class.
  41594. * @returns the input friendly name
  41595. */
  41596. getSimpleName(): string;
  41597. }
  41598. }
  41599. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41600. import { Nullable } from "babylonjs/types";
  41601. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41602. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41603. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41604. interface ArcRotateCameraInputsManager {
  41605. /**
  41606. * Add orientation input support to the input manager.
  41607. * @returns the current input manager
  41608. */
  41609. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41610. }
  41611. }
  41612. /**
  41613. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41615. */
  41616. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41617. /**
  41618. * Defines the camera the input is attached to.
  41619. */
  41620. camera: ArcRotateCamera;
  41621. /**
  41622. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41623. */
  41624. alphaCorrection: number;
  41625. /**
  41626. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41627. */
  41628. gammaCorrection: number;
  41629. private _alpha;
  41630. private _gamma;
  41631. private _dirty;
  41632. private _deviceOrientationHandler;
  41633. /**
  41634. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41635. */
  41636. constructor();
  41637. /**
  41638. * Attach the input controls to a specific dom element to get the input from.
  41639. * @param element Defines the element the controls should be listened from
  41640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41641. */
  41642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41643. /** @hidden */
  41644. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41645. /**
  41646. * Update the current camera state depending on the inputs that have been used this frame.
  41647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41648. */
  41649. checkInputs(): void;
  41650. /**
  41651. * Detach the current controls from the specified dom element.
  41652. * @param element Defines the element to stop listening the inputs from
  41653. */
  41654. detachControl(element: Nullable<HTMLElement>): void;
  41655. /**
  41656. * Gets the class name of the current intput.
  41657. * @returns the class name
  41658. */
  41659. getClassName(): string;
  41660. /**
  41661. * Get the friendly name associated with the input class.
  41662. * @returns the input friendly name
  41663. */
  41664. getSimpleName(): string;
  41665. }
  41666. }
  41667. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41668. import { Nullable } from "babylonjs/types";
  41669. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41670. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41671. /**
  41672. * Listen to mouse events to control the camera.
  41673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41674. */
  41675. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41676. /**
  41677. * Defines the camera the input is attached to.
  41678. */
  41679. camera: FlyCamera;
  41680. /**
  41681. * Defines if touch is enabled. (Default is true.)
  41682. */
  41683. touchEnabled: boolean;
  41684. /**
  41685. * Defines the buttons associated with the input to handle camera rotation.
  41686. */
  41687. buttons: number[];
  41688. /**
  41689. * Assign buttons for Yaw control.
  41690. */
  41691. buttonsYaw: number[];
  41692. /**
  41693. * Assign buttons for Pitch control.
  41694. */
  41695. buttonsPitch: number[];
  41696. /**
  41697. * Assign buttons for Roll control.
  41698. */
  41699. buttonsRoll: number[];
  41700. /**
  41701. * Detect if any button is being pressed while mouse is moved.
  41702. * -1 = Mouse locked.
  41703. * 0 = Left button.
  41704. * 1 = Middle Button.
  41705. * 2 = Right Button.
  41706. */
  41707. activeButton: number;
  41708. /**
  41709. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41710. * Higher values reduce its sensitivity.
  41711. */
  41712. angularSensibility: number;
  41713. private _mousemoveCallback;
  41714. private _observer;
  41715. private _rollObserver;
  41716. private previousPosition;
  41717. private noPreventDefault;
  41718. private element;
  41719. /**
  41720. * Listen to mouse events to control the camera.
  41721. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41723. */
  41724. constructor(touchEnabled?: boolean);
  41725. /**
  41726. * Attach the mouse control to the HTML DOM element.
  41727. * @param element Defines the element that listens to the input events.
  41728. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41729. */
  41730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41731. /**
  41732. * Detach the current controls from the specified dom element.
  41733. * @param element Defines the element to stop listening the inputs from
  41734. */
  41735. detachControl(element: Nullable<HTMLElement>): void;
  41736. /**
  41737. * Gets the class name of the current input.
  41738. * @returns the class name.
  41739. */
  41740. getClassName(): string;
  41741. /**
  41742. * Get the friendly name associated with the input class.
  41743. * @returns the input's friendly name.
  41744. */
  41745. getSimpleName(): string;
  41746. private _pointerInput;
  41747. private _onMouseMove;
  41748. /**
  41749. * Rotate camera by mouse offset.
  41750. */
  41751. private rotateCamera;
  41752. }
  41753. }
  41754. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41755. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41756. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41757. /**
  41758. * Default Inputs manager for the FlyCamera.
  41759. * It groups all the default supported inputs for ease of use.
  41760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41761. */
  41762. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41763. /**
  41764. * Instantiates a new FlyCameraInputsManager.
  41765. * @param camera Defines the camera the inputs belong to.
  41766. */
  41767. constructor(camera: FlyCamera);
  41768. /**
  41769. * Add keyboard input support to the input manager.
  41770. * @returns the new FlyCameraKeyboardMoveInput().
  41771. */
  41772. addKeyboard(): FlyCameraInputsManager;
  41773. /**
  41774. * Add mouse input support to the input manager.
  41775. * @param touchEnabled Enable touch screen support.
  41776. * @returns the new FlyCameraMouseInput().
  41777. */
  41778. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41779. }
  41780. }
  41781. declare module "babylonjs/Cameras/flyCamera" {
  41782. import { Scene } from "babylonjs/scene";
  41783. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41785. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41786. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41787. /**
  41788. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41789. * such as in a 3D Space Shooter or a Flight Simulator.
  41790. */
  41791. export class FlyCamera extends TargetCamera {
  41792. /**
  41793. * Define the collision ellipsoid of the camera.
  41794. * This is helpful for simulating a camera body, like a player's body.
  41795. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41796. */
  41797. ellipsoid: Vector3;
  41798. /**
  41799. * Define an offset for the position of the ellipsoid around the camera.
  41800. * This can be helpful if the camera is attached away from the player's body center,
  41801. * such as at its head.
  41802. */
  41803. ellipsoidOffset: Vector3;
  41804. /**
  41805. * Enable or disable collisions of the camera with the rest of the scene objects.
  41806. */
  41807. checkCollisions: boolean;
  41808. /**
  41809. * Enable or disable gravity on the camera.
  41810. */
  41811. applyGravity: boolean;
  41812. /**
  41813. * Define the current direction the camera is moving to.
  41814. */
  41815. cameraDirection: Vector3;
  41816. /**
  41817. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41818. * This overrides and empties cameraRotation.
  41819. */
  41820. rotationQuaternion: Quaternion;
  41821. /**
  41822. * Track Roll to maintain the wanted Rolling when looking around.
  41823. */
  41824. _trackRoll: number;
  41825. /**
  41826. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41827. */
  41828. rollCorrect: number;
  41829. /**
  41830. * Mimic a banked turn, Rolling the camera when Yawing.
  41831. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41832. */
  41833. bankedTurn: boolean;
  41834. /**
  41835. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41836. */
  41837. bankedTurnLimit: number;
  41838. /**
  41839. * Value of 0 disables the banked Roll.
  41840. * Value of 1 is equal to the Yaw angle in radians.
  41841. */
  41842. bankedTurnMultiplier: number;
  41843. /**
  41844. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41845. */
  41846. inputs: FlyCameraInputsManager;
  41847. /**
  41848. * Gets the input sensibility for mouse input.
  41849. * Higher values reduce sensitivity.
  41850. */
  41851. get angularSensibility(): number;
  41852. /**
  41853. * Sets the input sensibility for a mouse input.
  41854. * Higher values reduce sensitivity.
  41855. */
  41856. set angularSensibility(value: number);
  41857. /**
  41858. * Get the keys for camera movement forward.
  41859. */
  41860. get keysForward(): number[];
  41861. /**
  41862. * Set the keys for camera movement forward.
  41863. */
  41864. set keysForward(value: number[]);
  41865. /**
  41866. * Get the keys for camera movement backward.
  41867. */
  41868. get keysBackward(): number[];
  41869. set keysBackward(value: number[]);
  41870. /**
  41871. * Get the keys for camera movement up.
  41872. */
  41873. get keysUp(): number[];
  41874. /**
  41875. * Set the keys for camera movement up.
  41876. */
  41877. set keysUp(value: number[]);
  41878. /**
  41879. * Get the keys for camera movement down.
  41880. */
  41881. get keysDown(): number[];
  41882. /**
  41883. * Set the keys for camera movement down.
  41884. */
  41885. set keysDown(value: number[]);
  41886. /**
  41887. * Get the keys for camera movement left.
  41888. */
  41889. get keysLeft(): number[];
  41890. /**
  41891. * Set the keys for camera movement left.
  41892. */
  41893. set keysLeft(value: number[]);
  41894. /**
  41895. * Set the keys for camera movement right.
  41896. */
  41897. get keysRight(): number[];
  41898. /**
  41899. * Set the keys for camera movement right.
  41900. */
  41901. set keysRight(value: number[]);
  41902. /**
  41903. * Event raised when the camera collides with a mesh in the scene.
  41904. */
  41905. onCollide: (collidedMesh: AbstractMesh) => void;
  41906. private _collider;
  41907. private _needMoveForGravity;
  41908. private _oldPosition;
  41909. private _diffPosition;
  41910. private _newPosition;
  41911. /** @hidden */
  41912. _localDirection: Vector3;
  41913. /** @hidden */
  41914. _transformedDirection: Vector3;
  41915. /**
  41916. * Instantiates a FlyCamera.
  41917. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41918. * such as in a 3D Space Shooter or a Flight Simulator.
  41919. * @param name Define the name of the camera in the scene.
  41920. * @param position Define the starting position of the camera in the scene.
  41921. * @param scene Define the scene the camera belongs to.
  41922. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41923. */
  41924. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41925. /**
  41926. * Attach a control to the HTML DOM element.
  41927. * @param element Defines the element that listens to the input events.
  41928. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41929. */
  41930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41931. /**
  41932. * Detach a control from the HTML DOM element.
  41933. * The camera will stop reacting to that input.
  41934. * @param element Defines the element that listens to the input events.
  41935. */
  41936. detachControl(element: HTMLElement): void;
  41937. private _collisionMask;
  41938. /**
  41939. * Get the mask that the camera ignores in collision events.
  41940. */
  41941. get collisionMask(): number;
  41942. /**
  41943. * Set the mask that the camera ignores in collision events.
  41944. */
  41945. set collisionMask(mask: number);
  41946. /** @hidden */
  41947. _collideWithWorld(displacement: Vector3): void;
  41948. /** @hidden */
  41949. private _onCollisionPositionChange;
  41950. /** @hidden */
  41951. _checkInputs(): void;
  41952. /** @hidden */
  41953. _decideIfNeedsToMove(): boolean;
  41954. /** @hidden */
  41955. _updatePosition(): void;
  41956. /**
  41957. * Restore the Roll to its target value at the rate specified.
  41958. * @param rate - Higher means slower restoring.
  41959. * @hidden
  41960. */
  41961. restoreRoll(rate: number): void;
  41962. /**
  41963. * Destroy the camera and release the current resources held by it.
  41964. */
  41965. dispose(): void;
  41966. /**
  41967. * Get the current object class name.
  41968. * @returns the class name.
  41969. */
  41970. getClassName(): string;
  41971. }
  41972. }
  41973. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41974. import { Nullable } from "babylonjs/types";
  41975. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41976. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41977. /**
  41978. * Listen to keyboard events to control the camera.
  41979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41980. */
  41981. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41982. /**
  41983. * Defines the camera the input is attached to.
  41984. */
  41985. camera: FlyCamera;
  41986. /**
  41987. * The list of keyboard keys used to control the forward move of the camera.
  41988. */
  41989. keysForward: number[];
  41990. /**
  41991. * The list of keyboard keys used to control the backward move of the camera.
  41992. */
  41993. keysBackward: number[];
  41994. /**
  41995. * The list of keyboard keys used to control the forward move of the camera.
  41996. */
  41997. keysUp: number[];
  41998. /**
  41999. * The list of keyboard keys used to control the backward move of the camera.
  42000. */
  42001. keysDown: number[];
  42002. /**
  42003. * The list of keyboard keys used to control the right strafe move of the camera.
  42004. */
  42005. keysRight: number[];
  42006. /**
  42007. * The list of keyboard keys used to control the left strafe move of the camera.
  42008. */
  42009. keysLeft: number[];
  42010. private _keys;
  42011. private _onCanvasBlurObserver;
  42012. private _onKeyboardObserver;
  42013. private _engine;
  42014. private _scene;
  42015. /**
  42016. * Attach the input controls to a specific dom element to get the input from.
  42017. * @param element Defines the element the controls should be listened from
  42018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42019. */
  42020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42021. /**
  42022. * Detach the current controls from the specified dom element.
  42023. * @param element Defines the element to stop listening the inputs from
  42024. */
  42025. detachControl(element: Nullable<HTMLElement>): void;
  42026. /**
  42027. * Gets the class name of the current intput.
  42028. * @returns the class name
  42029. */
  42030. getClassName(): string;
  42031. /** @hidden */
  42032. _onLostFocus(e: FocusEvent): void;
  42033. /**
  42034. * Get the friendly name associated with the input class.
  42035. * @returns the input friendly name
  42036. */
  42037. getSimpleName(): string;
  42038. /**
  42039. * Update the current camera state depending on the inputs that have been used this frame.
  42040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42041. */
  42042. checkInputs(): void;
  42043. }
  42044. }
  42045. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42046. import { Nullable } from "babylonjs/types";
  42047. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42049. /**
  42050. * Manage the mouse wheel inputs to control a follow camera.
  42051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42052. */
  42053. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42054. /**
  42055. * Defines the camera the input is attached to.
  42056. */
  42057. camera: FollowCamera;
  42058. /**
  42059. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42060. */
  42061. axisControlRadius: boolean;
  42062. /**
  42063. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42064. */
  42065. axisControlHeight: boolean;
  42066. /**
  42067. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42068. */
  42069. axisControlRotation: boolean;
  42070. /**
  42071. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42072. * relation to mouseWheel events.
  42073. */
  42074. wheelPrecision: number;
  42075. /**
  42076. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42077. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42078. */
  42079. wheelDeltaPercentage: number;
  42080. private _wheel;
  42081. private _observer;
  42082. /**
  42083. * Attach the input controls to a specific dom element to get the input from.
  42084. * @param element Defines the element the controls should be listened from
  42085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42086. */
  42087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42088. /**
  42089. * Detach the current controls from the specified dom element.
  42090. * @param element Defines the element to stop listening the inputs from
  42091. */
  42092. detachControl(element: Nullable<HTMLElement>): void;
  42093. /**
  42094. * Gets the class name of the current intput.
  42095. * @returns the class name
  42096. */
  42097. getClassName(): string;
  42098. /**
  42099. * Get the friendly name associated with the input class.
  42100. * @returns the input friendly name
  42101. */
  42102. getSimpleName(): string;
  42103. }
  42104. }
  42105. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42106. import { Nullable } from "babylonjs/types";
  42107. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42108. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42109. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42110. /**
  42111. * Manage the pointers inputs to control an follow camera.
  42112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42113. */
  42114. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42115. /**
  42116. * Defines the camera the input is attached to.
  42117. */
  42118. camera: FollowCamera;
  42119. /**
  42120. * Gets the class name of the current input.
  42121. * @returns the class name
  42122. */
  42123. getClassName(): string;
  42124. /**
  42125. * Defines the pointer angular sensibility along the X axis or how fast is
  42126. * the camera rotating.
  42127. * A negative number will reverse the axis direction.
  42128. */
  42129. angularSensibilityX: number;
  42130. /**
  42131. * Defines the pointer angular sensibility along the Y axis or how fast is
  42132. * the camera rotating.
  42133. * A negative number will reverse the axis direction.
  42134. */
  42135. angularSensibilityY: number;
  42136. /**
  42137. * Defines the pointer pinch precision or how fast is the camera zooming.
  42138. * A negative number will reverse the axis direction.
  42139. */
  42140. pinchPrecision: number;
  42141. /**
  42142. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42143. * from 0.
  42144. * It defines the percentage of current camera.radius to use as delta when
  42145. * pinch zoom is used.
  42146. */
  42147. pinchDeltaPercentage: number;
  42148. /**
  42149. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42150. */
  42151. axisXControlRadius: boolean;
  42152. /**
  42153. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42154. */
  42155. axisXControlHeight: boolean;
  42156. /**
  42157. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42158. */
  42159. axisXControlRotation: boolean;
  42160. /**
  42161. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42162. */
  42163. axisYControlRadius: boolean;
  42164. /**
  42165. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42166. */
  42167. axisYControlHeight: boolean;
  42168. /**
  42169. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42170. */
  42171. axisYControlRotation: boolean;
  42172. /**
  42173. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42174. */
  42175. axisPinchControlRadius: boolean;
  42176. /**
  42177. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42178. */
  42179. axisPinchControlHeight: boolean;
  42180. /**
  42181. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42182. */
  42183. axisPinchControlRotation: boolean;
  42184. /**
  42185. * Log error messages if basic misconfiguration has occurred.
  42186. */
  42187. warningEnable: boolean;
  42188. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42189. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42190. private _warningCounter;
  42191. private _warning;
  42192. }
  42193. }
  42194. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42195. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42196. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42197. /**
  42198. * Default Inputs manager for the FollowCamera.
  42199. * It groups all the default supported inputs for ease of use.
  42200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42201. */
  42202. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42203. /**
  42204. * Instantiates a new FollowCameraInputsManager.
  42205. * @param camera Defines the camera the inputs belong to
  42206. */
  42207. constructor(camera: FollowCamera);
  42208. /**
  42209. * Add keyboard input support to the input manager.
  42210. * @returns the current input manager
  42211. */
  42212. addKeyboard(): FollowCameraInputsManager;
  42213. /**
  42214. * Add mouse wheel input support to the input manager.
  42215. * @returns the current input manager
  42216. */
  42217. addMouseWheel(): FollowCameraInputsManager;
  42218. /**
  42219. * Add pointers input support to the input manager.
  42220. * @returns the current input manager
  42221. */
  42222. addPointers(): FollowCameraInputsManager;
  42223. /**
  42224. * Add orientation input support to the input manager.
  42225. * @returns the current input manager
  42226. */
  42227. addVRDeviceOrientation(): FollowCameraInputsManager;
  42228. }
  42229. }
  42230. declare module "babylonjs/Cameras/followCamera" {
  42231. import { Nullable } from "babylonjs/types";
  42232. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42233. import { Scene } from "babylonjs/scene";
  42234. import { Vector3 } from "babylonjs/Maths/math.vector";
  42235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42236. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42237. /**
  42238. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42239. * an arc rotate version arcFollowCamera are available.
  42240. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42241. */
  42242. export class FollowCamera extends TargetCamera {
  42243. /**
  42244. * Distance the follow camera should follow an object at
  42245. */
  42246. radius: number;
  42247. /**
  42248. * Minimum allowed distance of the camera to the axis of rotation
  42249. * (The camera can not get closer).
  42250. * This can help limiting how the Camera is able to move in the scene.
  42251. */
  42252. lowerRadiusLimit: Nullable<number>;
  42253. /**
  42254. * Maximum allowed distance of the camera to the axis of rotation
  42255. * (The camera can not get further).
  42256. * This can help limiting how the Camera is able to move in the scene.
  42257. */
  42258. upperRadiusLimit: Nullable<number>;
  42259. /**
  42260. * Define a rotation offset between the camera and the object it follows
  42261. */
  42262. rotationOffset: number;
  42263. /**
  42264. * Minimum allowed angle to camera position relative to target object.
  42265. * This can help limiting how the Camera is able to move in the scene.
  42266. */
  42267. lowerRotationOffsetLimit: Nullable<number>;
  42268. /**
  42269. * Maximum allowed angle to camera position relative to target object.
  42270. * This can help limiting how the Camera is able to move in the scene.
  42271. */
  42272. upperRotationOffsetLimit: Nullable<number>;
  42273. /**
  42274. * Define a height offset between the camera and the object it follows.
  42275. * It can help following an object from the top (like a car chaing a plane)
  42276. */
  42277. heightOffset: number;
  42278. /**
  42279. * Minimum allowed height of camera position relative to target object.
  42280. * This can help limiting how the Camera is able to move in the scene.
  42281. */
  42282. lowerHeightOffsetLimit: Nullable<number>;
  42283. /**
  42284. * Maximum allowed height of camera position relative to target object.
  42285. * This can help limiting how the Camera is able to move in the scene.
  42286. */
  42287. upperHeightOffsetLimit: Nullable<number>;
  42288. /**
  42289. * Define how fast the camera can accelerate to follow it s target.
  42290. */
  42291. cameraAcceleration: number;
  42292. /**
  42293. * Define the speed limit of the camera following an object.
  42294. */
  42295. maxCameraSpeed: number;
  42296. /**
  42297. * Define the target of the camera.
  42298. */
  42299. lockedTarget: Nullable<AbstractMesh>;
  42300. /**
  42301. * Defines the input associated with the camera.
  42302. */
  42303. inputs: FollowCameraInputsManager;
  42304. /**
  42305. * Instantiates the follow camera.
  42306. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42307. * @param name Define the name of the camera in the scene
  42308. * @param position Define the position of the camera
  42309. * @param scene Define the scene the camera belong to
  42310. * @param lockedTarget Define the target of the camera
  42311. */
  42312. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42313. private _follow;
  42314. /**
  42315. * Attached controls to the current camera.
  42316. * @param element Defines the element the controls should be listened from
  42317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42318. */
  42319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42320. /**
  42321. * Detach the current controls from the camera.
  42322. * The camera will stop reacting to inputs.
  42323. * @param element Defines the element to stop listening the inputs from
  42324. */
  42325. detachControl(element: HTMLElement): void;
  42326. /** @hidden */
  42327. _checkInputs(): void;
  42328. private _checkLimits;
  42329. /**
  42330. * Gets the camera class name.
  42331. * @returns the class name
  42332. */
  42333. getClassName(): string;
  42334. }
  42335. /**
  42336. * Arc Rotate version of the follow camera.
  42337. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42338. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42339. */
  42340. export class ArcFollowCamera extends TargetCamera {
  42341. /** The longitudinal angle of the camera */
  42342. alpha: number;
  42343. /** The latitudinal angle of the camera */
  42344. beta: number;
  42345. /** The radius of the camera from its target */
  42346. radius: number;
  42347. /** Define the camera target (the messh it should follow) */
  42348. target: Nullable<AbstractMesh>;
  42349. private _cartesianCoordinates;
  42350. /**
  42351. * Instantiates a new ArcFollowCamera
  42352. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42353. * @param name Define the name of the camera
  42354. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42355. * @param beta Define the rotation angle of the camera around the elevation axis
  42356. * @param radius Define the radius of the camera from its target point
  42357. * @param target Define the target of the camera
  42358. * @param scene Define the scene the camera belongs to
  42359. */
  42360. constructor(name: string,
  42361. /** The longitudinal angle of the camera */
  42362. alpha: number,
  42363. /** The latitudinal angle of the camera */
  42364. beta: number,
  42365. /** The radius of the camera from its target */
  42366. radius: number,
  42367. /** Define the camera target (the messh it should follow) */
  42368. target: Nullable<AbstractMesh>, scene: Scene);
  42369. private _follow;
  42370. /** @hidden */
  42371. _checkInputs(): void;
  42372. /**
  42373. * Returns the class name of the object.
  42374. * It is mostly used internally for serialization purposes.
  42375. */
  42376. getClassName(): string;
  42377. }
  42378. }
  42379. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42380. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42381. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42382. import { Nullable } from "babylonjs/types";
  42383. /**
  42384. * Manage the keyboard inputs to control the movement of a follow camera.
  42385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42386. */
  42387. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42388. /**
  42389. * Defines the camera the input is attached to.
  42390. */
  42391. camera: FollowCamera;
  42392. /**
  42393. * Defines the list of key codes associated with the up action (increase heightOffset)
  42394. */
  42395. keysHeightOffsetIncr: number[];
  42396. /**
  42397. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42398. */
  42399. keysHeightOffsetDecr: number[];
  42400. /**
  42401. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42402. */
  42403. keysHeightOffsetModifierAlt: boolean;
  42404. /**
  42405. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42406. */
  42407. keysHeightOffsetModifierCtrl: boolean;
  42408. /**
  42409. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42410. */
  42411. keysHeightOffsetModifierShift: boolean;
  42412. /**
  42413. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42414. */
  42415. keysRotationOffsetIncr: number[];
  42416. /**
  42417. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42418. */
  42419. keysRotationOffsetDecr: number[];
  42420. /**
  42421. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42422. */
  42423. keysRotationOffsetModifierAlt: boolean;
  42424. /**
  42425. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42426. */
  42427. keysRotationOffsetModifierCtrl: boolean;
  42428. /**
  42429. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42430. */
  42431. keysRotationOffsetModifierShift: boolean;
  42432. /**
  42433. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42434. */
  42435. keysRadiusIncr: number[];
  42436. /**
  42437. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42438. */
  42439. keysRadiusDecr: number[];
  42440. /**
  42441. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42442. */
  42443. keysRadiusModifierAlt: boolean;
  42444. /**
  42445. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42446. */
  42447. keysRadiusModifierCtrl: boolean;
  42448. /**
  42449. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42450. */
  42451. keysRadiusModifierShift: boolean;
  42452. /**
  42453. * Defines the rate of change of heightOffset.
  42454. */
  42455. heightSensibility: number;
  42456. /**
  42457. * Defines the rate of change of rotationOffset.
  42458. */
  42459. rotationSensibility: number;
  42460. /**
  42461. * Defines the rate of change of radius.
  42462. */
  42463. radiusSensibility: number;
  42464. private _keys;
  42465. private _ctrlPressed;
  42466. private _altPressed;
  42467. private _shiftPressed;
  42468. private _onCanvasBlurObserver;
  42469. private _onKeyboardObserver;
  42470. private _engine;
  42471. private _scene;
  42472. /**
  42473. * Attach the input controls to a specific dom element to get the input from.
  42474. * @param element Defines the element the controls should be listened from
  42475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42476. */
  42477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42478. /**
  42479. * Detach the current controls from the specified dom element.
  42480. * @param element Defines the element to stop listening the inputs from
  42481. */
  42482. detachControl(element: Nullable<HTMLElement>): void;
  42483. /**
  42484. * Update the current camera state depending on the inputs that have been used this frame.
  42485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42486. */
  42487. checkInputs(): void;
  42488. /**
  42489. * Gets the class name of the current input.
  42490. * @returns the class name
  42491. */
  42492. getClassName(): string;
  42493. /**
  42494. * Get the friendly name associated with the input class.
  42495. * @returns the input friendly name
  42496. */
  42497. getSimpleName(): string;
  42498. /**
  42499. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42500. * allow modification of the heightOffset value.
  42501. */
  42502. private _modifierHeightOffset;
  42503. /**
  42504. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42505. * allow modification of the rotationOffset value.
  42506. */
  42507. private _modifierRotationOffset;
  42508. /**
  42509. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42510. * allow modification of the radius value.
  42511. */
  42512. private _modifierRadius;
  42513. }
  42514. }
  42515. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42516. import { Nullable } from "babylonjs/types";
  42517. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42519. import { Observable } from "babylonjs/Misc/observable";
  42520. module "babylonjs/Cameras/freeCameraInputsManager" {
  42521. interface FreeCameraInputsManager {
  42522. /**
  42523. * @hidden
  42524. */
  42525. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42526. /**
  42527. * Add orientation input support to the input manager.
  42528. * @returns the current input manager
  42529. */
  42530. addDeviceOrientation(): FreeCameraInputsManager;
  42531. }
  42532. }
  42533. /**
  42534. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42535. * Screen rotation is taken into account.
  42536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42537. */
  42538. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42539. private _camera;
  42540. private _screenOrientationAngle;
  42541. private _constantTranform;
  42542. private _screenQuaternion;
  42543. private _alpha;
  42544. private _beta;
  42545. private _gamma;
  42546. /**
  42547. * Can be used to detect if a device orientation sensor is available on a device
  42548. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42549. * @returns a promise that will resolve on orientation change
  42550. */
  42551. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42552. /**
  42553. * @hidden
  42554. */
  42555. _onDeviceOrientationChangedObservable: Observable<void>;
  42556. /**
  42557. * Instantiates a new input
  42558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42559. */
  42560. constructor();
  42561. /**
  42562. * Define the camera controlled by the input.
  42563. */
  42564. get camera(): FreeCamera;
  42565. set camera(camera: FreeCamera);
  42566. /**
  42567. * Attach the input controls to a specific dom element to get the input from.
  42568. * @param element Defines the element the controls should be listened from
  42569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42570. */
  42571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42572. private _orientationChanged;
  42573. private _deviceOrientation;
  42574. /**
  42575. * Detach the current controls from the specified dom element.
  42576. * @param element Defines the element to stop listening the inputs from
  42577. */
  42578. detachControl(element: Nullable<HTMLElement>): void;
  42579. /**
  42580. * Update the current camera state depending on the inputs that have been used this frame.
  42581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42582. */
  42583. checkInputs(): void;
  42584. /**
  42585. * Gets the class name of the current intput.
  42586. * @returns the class name
  42587. */
  42588. getClassName(): string;
  42589. /**
  42590. * Get the friendly name associated with the input class.
  42591. * @returns the input friendly name
  42592. */
  42593. getSimpleName(): string;
  42594. }
  42595. }
  42596. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42597. import { Nullable } from "babylonjs/types";
  42598. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42600. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42601. /**
  42602. * Manage the gamepad inputs to control a free camera.
  42603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42604. */
  42605. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42606. /**
  42607. * Define the camera the input is attached to.
  42608. */
  42609. camera: FreeCamera;
  42610. /**
  42611. * Define the Gamepad controlling the input
  42612. */
  42613. gamepad: Nullable<Gamepad>;
  42614. /**
  42615. * Defines the gamepad rotation sensiblity.
  42616. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42617. */
  42618. gamepadAngularSensibility: number;
  42619. /**
  42620. * Defines the gamepad move sensiblity.
  42621. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42622. */
  42623. gamepadMoveSensibility: number;
  42624. private _yAxisScale;
  42625. /**
  42626. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42627. */
  42628. get invertYAxis(): boolean;
  42629. set invertYAxis(value: boolean);
  42630. private _onGamepadConnectedObserver;
  42631. private _onGamepadDisconnectedObserver;
  42632. private _cameraTransform;
  42633. private _deltaTransform;
  42634. private _vector3;
  42635. private _vector2;
  42636. /**
  42637. * Attach the input controls to a specific dom element to get the input from.
  42638. * @param element Defines the element the controls should be listened from
  42639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42640. */
  42641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42642. /**
  42643. * Detach the current controls from the specified dom element.
  42644. * @param element Defines the element to stop listening the inputs from
  42645. */
  42646. detachControl(element: Nullable<HTMLElement>): void;
  42647. /**
  42648. * Update the current camera state depending on the inputs that have been used this frame.
  42649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42650. */
  42651. checkInputs(): void;
  42652. /**
  42653. * Gets the class name of the current intput.
  42654. * @returns the class name
  42655. */
  42656. getClassName(): string;
  42657. /**
  42658. * Get the friendly name associated with the input class.
  42659. * @returns the input friendly name
  42660. */
  42661. getSimpleName(): string;
  42662. }
  42663. }
  42664. declare module "babylonjs/Misc/virtualJoystick" {
  42665. import { Nullable } from "babylonjs/types";
  42666. import { Vector3 } from "babylonjs/Maths/math.vector";
  42667. /**
  42668. * Defines the potential axis of a Joystick
  42669. */
  42670. export enum JoystickAxis {
  42671. /** X axis */
  42672. X = 0,
  42673. /** Y axis */
  42674. Y = 1,
  42675. /** Z axis */
  42676. Z = 2
  42677. }
  42678. /**
  42679. * Class used to define virtual joystick (used in touch mode)
  42680. */
  42681. export class VirtualJoystick {
  42682. /**
  42683. * Gets or sets a boolean indicating that left and right values must be inverted
  42684. */
  42685. reverseLeftRight: boolean;
  42686. /**
  42687. * Gets or sets a boolean indicating that up and down values must be inverted
  42688. */
  42689. reverseUpDown: boolean;
  42690. /**
  42691. * Gets the offset value for the position (ie. the change of the position value)
  42692. */
  42693. deltaPosition: Vector3;
  42694. /**
  42695. * Gets a boolean indicating if the virtual joystick was pressed
  42696. */
  42697. pressed: boolean;
  42698. /**
  42699. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42700. */
  42701. static Canvas: Nullable<HTMLCanvasElement>;
  42702. private static _globalJoystickIndex;
  42703. private static vjCanvasContext;
  42704. private static vjCanvasWidth;
  42705. private static vjCanvasHeight;
  42706. private static halfWidth;
  42707. private _action;
  42708. private _axisTargetedByLeftAndRight;
  42709. private _axisTargetedByUpAndDown;
  42710. private _joystickSensibility;
  42711. private _inversedSensibility;
  42712. private _joystickPointerID;
  42713. private _joystickColor;
  42714. private _joystickPointerPos;
  42715. private _joystickPreviousPointerPos;
  42716. private _joystickPointerStartPos;
  42717. private _deltaJoystickVector;
  42718. private _leftJoystick;
  42719. private _touches;
  42720. private _onPointerDownHandlerRef;
  42721. private _onPointerMoveHandlerRef;
  42722. private _onPointerUpHandlerRef;
  42723. private _onResize;
  42724. /**
  42725. * Creates a new virtual joystick
  42726. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42727. */
  42728. constructor(leftJoystick?: boolean);
  42729. /**
  42730. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42731. * @param newJoystickSensibility defines the new sensibility
  42732. */
  42733. setJoystickSensibility(newJoystickSensibility: number): void;
  42734. private _onPointerDown;
  42735. private _onPointerMove;
  42736. private _onPointerUp;
  42737. /**
  42738. * Change the color of the virtual joystick
  42739. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42740. */
  42741. setJoystickColor(newColor: string): void;
  42742. /**
  42743. * Defines a callback to call when the joystick is touched
  42744. * @param action defines the callback
  42745. */
  42746. setActionOnTouch(action: () => any): void;
  42747. /**
  42748. * Defines which axis you'd like to control for left & right
  42749. * @param axis defines the axis to use
  42750. */
  42751. setAxisForLeftRight(axis: JoystickAxis): void;
  42752. /**
  42753. * Defines which axis you'd like to control for up & down
  42754. * @param axis defines the axis to use
  42755. */
  42756. setAxisForUpDown(axis: JoystickAxis): void;
  42757. private _drawVirtualJoystick;
  42758. /**
  42759. * Release internal HTML canvas
  42760. */
  42761. releaseCanvas(): void;
  42762. }
  42763. }
  42764. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42765. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42766. import { Nullable } from "babylonjs/types";
  42767. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42768. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42769. module "babylonjs/Cameras/freeCameraInputsManager" {
  42770. interface FreeCameraInputsManager {
  42771. /**
  42772. * Add virtual joystick input support to the input manager.
  42773. * @returns the current input manager
  42774. */
  42775. addVirtualJoystick(): FreeCameraInputsManager;
  42776. }
  42777. }
  42778. /**
  42779. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42781. */
  42782. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42783. /**
  42784. * Defines the camera the input is attached to.
  42785. */
  42786. camera: FreeCamera;
  42787. private _leftjoystick;
  42788. private _rightjoystick;
  42789. /**
  42790. * Gets the left stick of the virtual joystick.
  42791. * @returns The virtual Joystick
  42792. */
  42793. getLeftJoystick(): VirtualJoystick;
  42794. /**
  42795. * Gets the right stick of the virtual joystick.
  42796. * @returns The virtual Joystick
  42797. */
  42798. getRightJoystick(): VirtualJoystick;
  42799. /**
  42800. * Update the current camera state depending on the inputs that have been used this frame.
  42801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42802. */
  42803. checkInputs(): void;
  42804. /**
  42805. * Attach the input controls to a specific dom element to get the input from.
  42806. * @param element Defines the element the controls should be listened from
  42807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42808. */
  42809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42810. /**
  42811. * Detach the current controls from the specified dom element.
  42812. * @param element Defines the element to stop listening the inputs from
  42813. */
  42814. detachControl(element: Nullable<HTMLElement>): void;
  42815. /**
  42816. * Gets the class name of the current intput.
  42817. * @returns the class name
  42818. */
  42819. getClassName(): string;
  42820. /**
  42821. * Get the friendly name associated with the input class.
  42822. * @returns the input friendly name
  42823. */
  42824. getSimpleName(): string;
  42825. }
  42826. }
  42827. declare module "babylonjs/Cameras/Inputs/index" {
  42828. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42829. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42830. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42831. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42832. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42833. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42834. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42835. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42836. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42837. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42838. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42839. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42840. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42841. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42842. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42843. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42844. }
  42845. declare module "babylonjs/Cameras/touchCamera" {
  42846. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42847. import { Scene } from "babylonjs/scene";
  42848. import { Vector3 } from "babylonjs/Maths/math.vector";
  42849. /**
  42850. * This represents a FPS type of camera controlled by touch.
  42851. * This is like a universal camera minus the Gamepad controls.
  42852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42853. */
  42854. export class TouchCamera extends FreeCamera {
  42855. /**
  42856. * Defines the touch sensibility for rotation.
  42857. * The higher the faster.
  42858. */
  42859. get touchAngularSensibility(): number;
  42860. set touchAngularSensibility(value: number);
  42861. /**
  42862. * Defines the touch sensibility for move.
  42863. * The higher the faster.
  42864. */
  42865. get touchMoveSensibility(): number;
  42866. set touchMoveSensibility(value: number);
  42867. /**
  42868. * Instantiates a new touch camera.
  42869. * This represents a FPS type of camera controlled by touch.
  42870. * This is like a universal camera minus the Gamepad controls.
  42871. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42872. * @param name Define the name of the camera in the scene
  42873. * @param position Define the start position of the camera in the scene
  42874. * @param scene Define the scene the camera belongs to
  42875. */
  42876. constructor(name: string, position: Vector3, scene: Scene);
  42877. /**
  42878. * Gets the current object class name.
  42879. * @return the class name
  42880. */
  42881. getClassName(): string;
  42882. /** @hidden */
  42883. _setupInputs(): void;
  42884. }
  42885. }
  42886. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42887. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42888. import { Scene } from "babylonjs/scene";
  42889. import { Vector3 } from "babylonjs/Maths/math.vector";
  42890. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42891. import { Axis } from "babylonjs/Maths/math.axis";
  42892. /**
  42893. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42894. * being tilted forward or back and left or right.
  42895. */
  42896. export class DeviceOrientationCamera extends FreeCamera {
  42897. private _initialQuaternion;
  42898. private _quaternionCache;
  42899. private _tmpDragQuaternion;
  42900. private _disablePointerInputWhenUsingDeviceOrientation;
  42901. /**
  42902. * Creates a new device orientation camera
  42903. * @param name The name of the camera
  42904. * @param position The start position camera
  42905. * @param scene The scene the camera belongs to
  42906. */
  42907. constructor(name: string, position: Vector3, scene: Scene);
  42908. /**
  42909. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42910. */
  42911. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42912. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42913. private _dragFactor;
  42914. /**
  42915. * Enabled turning on the y axis when the orientation sensor is active
  42916. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42917. */
  42918. enableHorizontalDragging(dragFactor?: number): void;
  42919. /**
  42920. * Gets the current instance class name ("DeviceOrientationCamera").
  42921. * This helps avoiding instanceof at run time.
  42922. * @returns the class name
  42923. */
  42924. getClassName(): string;
  42925. /**
  42926. * @hidden
  42927. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42928. */
  42929. _checkInputs(): void;
  42930. /**
  42931. * Reset the camera to its default orientation on the specified axis only.
  42932. * @param axis The axis to reset
  42933. */
  42934. resetToCurrentRotation(axis?: Axis): void;
  42935. }
  42936. }
  42937. declare module "babylonjs/Gamepads/xboxGamepad" {
  42938. import { Observable } from "babylonjs/Misc/observable";
  42939. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42940. /**
  42941. * Defines supported buttons for XBox360 compatible gamepads
  42942. */
  42943. export enum Xbox360Button {
  42944. /** A */
  42945. A = 0,
  42946. /** B */
  42947. B = 1,
  42948. /** X */
  42949. X = 2,
  42950. /** Y */
  42951. Y = 3,
  42952. /** Left button */
  42953. LB = 4,
  42954. /** Right button */
  42955. RB = 5,
  42956. /** Back */
  42957. Back = 8,
  42958. /** Start */
  42959. Start = 9,
  42960. /** Left stick */
  42961. LeftStick = 10,
  42962. /** Right stick */
  42963. RightStick = 11
  42964. }
  42965. /** Defines values for XBox360 DPad */
  42966. export enum Xbox360Dpad {
  42967. /** Up */
  42968. Up = 12,
  42969. /** Down */
  42970. Down = 13,
  42971. /** Left */
  42972. Left = 14,
  42973. /** Right */
  42974. Right = 15
  42975. }
  42976. /**
  42977. * Defines a XBox360 gamepad
  42978. */
  42979. export class Xbox360Pad extends Gamepad {
  42980. private _leftTrigger;
  42981. private _rightTrigger;
  42982. private _onlefttriggerchanged;
  42983. private _onrighttriggerchanged;
  42984. private _onbuttondown;
  42985. private _onbuttonup;
  42986. private _ondpaddown;
  42987. private _ondpadup;
  42988. /** Observable raised when a button is pressed */
  42989. onButtonDownObservable: Observable<Xbox360Button>;
  42990. /** Observable raised when a button is released */
  42991. onButtonUpObservable: Observable<Xbox360Button>;
  42992. /** Observable raised when a pad is pressed */
  42993. onPadDownObservable: Observable<Xbox360Dpad>;
  42994. /** Observable raised when a pad is released */
  42995. onPadUpObservable: Observable<Xbox360Dpad>;
  42996. private _buttonA;
  42997. private _buttonB;
  42998. private _buttonX;
  42999. private _buttonY;
  43000. private _buttonBack;
  43001. private _buttonStart;
  43002. private _buttonLB;
  43003. private _buttonRB;
  43004. private _buttonLeftStick;
  43005. private _buttonRightStick;
  43006. private _dPadUp;
  43007. private _dPadDown;
  43008. private _dPadLeft;
  43009. private _dPadRight;
  43010. private _isXboxOnePad;
  43011. /**
  43012. * Creates a new XBox360 gamepad object
  43013. * @param id defines the id of this gamepad
  43014. * @param index defines its index
  43015. * @param gamepad defines the internal HTML gamepad object
  43016. * @param xboxOne defines if it is a XBox One gamepad
  43017. */
  43018. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  43019. /**
  43020. * Defines the callback to call when left trigger is pressed
  43021. * @param callback defines the callback to use
  43022. */
  43023. onlefttriggerchanged(callback: (value: number) => void): void;
  43024. /**
  43025. * Defines the callback to call when right trigger is pressed
  43026. * @param callback defines the callback to use
  43027. */
  43028. onrighttriggerchanged(callback: (value: number) => void): void;
  43029. /**
  43030. * Gets the left trigger value
  43031. */
  43032. get leftTrigger(): number;
  43033. /**
  43034. * Sets the left trigger value
  43035. */
  43036. set leftTrigger(newValue: number);
  43037. /**
  43038. * Gets the right trigger value
  43039. */
  43040. get rightTrigger(): number;
  43041. /**
  43042. * Sets the right trigger value
  43043. */
  43044. set rightTrigger(newValue: number);
  43045. /**
  43046. * Defines the callback to call when a button is pressed
  43047. * @param callback defines the callback to use
  43048. */
  43049. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43050. /**
  43051. * Defines the callback to call when a button is released
  43052. * @param callback defines the callback to use
  43053. */
  43054. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43055. /**
  43056. * Defines the callback to call when a pad is pressed
  43057. * @param callback defines the callback to use
  43058. */
  43059. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43060. /**
  43061. * Defines the callback to call when a pad is released
  43062. * @param callback defines the callback to use
  43063. */
  43064. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43065. private _setButtonValue;
  43066. private _setDPadValue;
  43067. /**
  43068. * Gets the value of the `A` button
  43069. */
  43070. get buttonA(): number;
  43071. /**
  43072. * Sets the value of the `A` button
  43073. */
  43074. set buttonA(value: number);
  43075. /**
  43076. * Gets the value of the `B` button
  43077. */
  43078. get buttonB(): number;
  43079. /**
  43080. * Sets the value of the `B` button
  43081. */
  43082. set buttonB(value: number);
  43083. /**
  43084. * Gets the value of the `X` button
  43085. */
  43086. get buttonX(): number;
  43087. /**
  43088. * Sets the value of the `X` button
  43089. */
  43090. set buttonX(value: number);
  43091. /**
  43092. * Gets the value of the `Y` button
  43093. */
  43094. get buttonY(): number;
  43095. /**
  43096. * Sets the value of the `Y` button
  43097. */
  43098. set buttonY(value: number);
  43099. /**
  43100. * Gets the value of the `Start` button
  43101. */
  43102. get buttonStart(): number;
  43103. /**
  43104. * Sets the value of the `Start` button
  43105. */
  43106. set buttonStart(value: number);
  43107. /**
  43108. * Gets the value of the `Back` button
  43109. */
  43110. get buttonBack(): number;
  43111. /**
  43112. * Sets the value of the `Back` button
  43113. */
  43114. set buttonBack(value: number);
  43115. /**
  43116. * Gets the value of the `Left` button
  43117. */
  43118. get buttonLB(): number;
  43119. /**
  43120. * Sets the value of the `Left` button
  43121. */
  43122. set buttonLB(value: number);
  43123. /**
  43124. * Gets the value of the `Right` button
  43125. */
  43126. get buttonRB(): number;
  43127. /**
  43128. * Sets the value of the `Right` button
  43129. */
  43130. set buttonRB(value: number);
  43131. /**
  43132. * Gets the value of the Left joystick
  43133. */
  43134. get buttonLeftStick(): number;
  43135. /**
  43136. * Sets the value of the Left joystick
  43137. */
  43138. set buttonLeftStick(value: number);
  43139. /**
  43140. * Gets the value of the Right joystick
  43141. */
  43142. get buttonRightStick(): number;
  43143. /**
  43144. * Sets the value of the Right joystick
  43145. */
  43146. set buttonRightStick(value: number);
  43147. /**
  43148. * Gets the value of D-pad up
  43149. */
  43150. get dPadUp(): number;
  43151. /**
  43152. * Sets the value of D-pad up
  43153. */
  43154. set dPadUp(value: number);
  43155. /**
  43156. * Gets the value of D-pad down
  43157. */
  43158. get dPadDown(): number;
  43159. /**
  43160. * Sets the value of D-pad down
  43161. */
  43162. set dPadDown(value: number);
  43163. /**
  43164. * Gets the value of D-pad left
  43165. */
  43166. get dPadLeft(): number;
  43167. /**
  43168. * Sets the value of D-pad left
  43169. */
  43170. set dPadLeft(value: number);
  43171. /**
  43172. * Gets the value of D-pad right
  43173. */
  43174. get dPadRight(): number;
  43175. /**
  43176. * Sets the value of D-pad right
  43177. */
  43178. set dPadRight(value: number);
  43179. /**
  43180. * Force the gamepad to synchronize with device values
  43181. */
  43182. update(): void;
  43183. /**
  43184. * Disposes the gamepad
  43185. */
  43186. dispose(): void;
  43187. }
  43188. }
  43189. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43190. import { Observable } from "babylonjs/Misc/observable";
  43191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43192. /**
  43193. * Defines supported buttons for DualShock compatible gamepads
  43194. */
  43195. export enum DualShockButton {
  43196. /** Cross */
  43197. Cross = 0,
  43198. /** Circle */
  43199. Circle = 1,
  43200. /** Square */
  43201. Square = 2,
  43202. /** Triangle */
  43203. Triangle = 3,
  43204. /** L1 */
  43205. L1 = 4,
  43206. /** R1 */
  43207. R1 = 5,
  43208. /** Share */
  43209. Share = 8,
  43210. /** Options */
  43211. Options = 9,
  43212. /** Left stick */
  43213. LeftStick = 10,
  43214. /** Right stick */
  43215. RightStick = 11
  43216. }
  43217. /** Defines values for DualShock DPad */
  43218. export enum DualShockDpad {
  43219. /** Up */
  43220. Up = 12,
  43221. /** Down */
  43222. Down = 13,
  43223. /** Left */
  43224. Left = 14,
  43225. /** Right */
  43226. Right = 15
  43227. }
  43228. /**
  43229. * Defines a DualShock gamepad
  43230. */
  43231. export class DualShockPad extends Gamepad {
  43232. private _leftTrigger;
  43233. private _rightTrigger;
  43234. private _onlefttriggerchanged;
  43235. private _onrighttriggerchanged;
  43236. private _onbuttondown;
  43237. private _onbuttonup;
  43238. private _ondpaddown;
  43239. private _ondpadup;
  43240. /** Observable raised when a button is pressed */
  43241. onButtonDownObservable: Observable<DualShockButton>;
  43242. /** Observable raised when a button is released */
  43243. onButtonUpObservable: Observable<DualShockButton>;
  43244. /** Observable raised when a pad is pressed */
  43245. onPadDownObservable: Observable<DualShockDpad>;
  43246. /** Observable raised when a pad is released */
  43247. onPadUpObservable: Observable<DualShockDpad>;
  43248. private _buttonCross;
  43249. private _buttonCircle;
  43250. private _buttonSquare;
  43251. private _buttonTriangle;
  43252. private _buttonShare;
  43253. private _buttonOptions;
  43254. private _buttonL1;
  43255. private _buttonR1;
  43256. private _buttonLeftStick;
  43257. private _buttonRightStick;
  43258. private _dPadUp;
  43259. private _dPadDown;
  43260. private _dPadLeft;
  43261. private _dPadRight;
  43262. /**
  43263. * Creates a new DualShock gamepad object
  43264. * @param id defines the id of this gamepad
  43265. * @param index defines its index
  43266. * @param gamepad defines the internal HTML gamepad object
  43267. */
  43268. constructor(id: string, index: number, gamepad: any);
  43269. /**
  43270. * Defines the callback to call when left trigger is pressed
  43271. * @param callback defines the callback to use
  43272. */
  43273. onlefttriggerchanged(callback: (value: number) => void): void;
  43274. /**
  43275. * Defines the callback to call when right trigger is pressed
  43276. * @param callback defines the callback to use
  43277. */
  43278. onrighttriggerchanged(callback: (value: number) => void): void;
  43279. /**
  43280. * Gets the left trigger value
  43281. */
  43282. get leftTrigger(): number;
  43283. /**
  43284. * Sets the left trigger value
  43285. */
  43286. set leftTrigger(newValue: number);
  43287. /**
  43288. * Gets the right trigger value
  43289. */
  43290. get rightTrigger(): number;
  43291. /**
  43292. * Sets the right trigger value
  43293. */
  43294. set rightTrigger(newValue: number);
  43295. /**
  43296. * Defines the callback to call when a button is pressed
  43297. * @param callback defines the callback to use
  43298. */
  43299. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43300. /**
  43301. * Defines the callback to call when a button is released
  43302. * @param callback defines the callback to use
  43303. */
  43304. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43305. /**
  43306. * Defines the callback to call when a pad is pressed
  43307. * @param callback defines the callback to use
  43308. */
  43309. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43310. /**
  43311. * Defines the callback to call when a pad is released
  43312. * @param callback defines the callback to use
  43313. */
  43314. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43315. private _setButtonValue;
  43316. private _setDPadValue;
  43317. /**
  43318. * Gets the value of the `Cross` button
  43319. */
  43320. get buttonCross(): number;
  43321. /**
  43322. * Sets the value of the `Cross` button
  43323. */
  43324. set buttonCross(value: number);
  43325. /**
  43326. * Gets the value of the `Circle` button
  43327. */
  43328. get buttonCircle(): number;
  43329. /**
  43330. * Sets the value of the `Circle` button
  43331. */
  43332. set buttonCircle(value: number);
  43333. /**
  43334. * Gets the value of the `Square` button
  43335. */
  43336. get buttonSquare(): number;
  43337. /**
  43338. * Sets the value of the `Square` button
  43339. */
  43340. set buttonSquare(value: number);
  43341. /**
  43342. * Gets the value of the `Triangle` button
  43343. */
  43344. get buttonTriangle(): number;
  43345. /**
  43346. * Sets the value of the `Triangle` button
  43347. */
  43348. set buttonTriangle(value: number);
  43349. /**
  43350. * Gets the value of the `Options` button
  43351. */
  43352. get buttonOptions(): number;
  43353. /**
  43354. * Sets the value of the `Options` button
  43355. */
  43356. set buttonOptions(value: number);
  43357. /**
  43358. * Gets the value of the `Share` button
  43359. */
  43360. get buttonShare(): number;
  43361. /**
  43362. * Sets the value of the `Share` button
  43363. */
  43364. set buttonShare(value: number);
  43365. /**
  43366. * Gets the value of the `L1` button
  43367. */
  43368. get buttonL1(): number;
  43369. /**
  43370. * Sets the value of the `L1` button
  43371. */
  43372. set buttonL1(value: number);
  43373. /**
  43374. * Gets the value of the `R1` button
  43375. */
  43376. get buttonR1(): number;
  43377. /**
  43378. * Sets the value of the `R1` button
  43379. */
  43380. set buttonR1(value: number);
  43381. /**
  43382. * Gets the value of the Left joystick
  43383. */
  43384. get buttonLeftStick(): number;
  43385. /**
  43386. * Sets the value of the Left joystick
  43387. */
  43388. set buttonLeftStick(value: number);
  43389. /**
  43390. * Gets the value of the Right joystick
  43391. */
  43392. get buttonRightStick(): number;
  43393. /**
  43394. * Sets the value of the Right joystick
  43395. */
  43396. set buttonRightStick(value: number);
  43397. /**
  43398. * Gets the value of D-pad up
  43399. */
  43400. get dPadUp(): number;
  43401. /**
  43402. * Sets the value of D-pad up
  43403. */
  43404. set dPadUp(value: number);
  43405. /**
  43406. * Gets the value of D-pad down
  43407. */
  43408. get dPadDown(): number;
  43409. /**
  43410. * Sets the value of D-pad down
  43411. */
  43412. set dPadDown(value: number);
  43413. /**
  43414. * Gets the value of D-pad left
  43415. */
  43416. get dPadLeft(): number;
  43417. /**
  43418. * Sets the value of D-pad left
  43419. */
  43420. set dPadLeft(value: number);
  43421. /**
  43422. * Gets the value of D-pad right
  43423. */
  43424. get dPadRight(): number;
  43425. /**
  43426. * Sets the value of D-pad right
  43427. */
  43428. set dPadRight(value: number);
  43429. /**
  43430. * Force the gamepad to synchronize with device values
  43431. */
  43432. update(): void;
  43433. /**
  43434. * Disposes the gamepad
  43435. */
  43436. dispose(): void;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/gamepadManager" {
  43440. import { Observable } from "babylonjs/Misc/observable";
  43441. import { Nullable } from "babylonjs/types";
  43442. import { Scene } from "babylonjs/scene";
  43443. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43444. /**
  43445. * Manager for handling gamepads
  43446. */
  43447. export class GamepadManager {
  43448. private _scene?;
  43449. private _babylonGamepads;
  43450. private _oneGamepadConnected;
  43451. /** @hidden */
  43452. _isMonitoring: boolean;
  43453. private _gamepadEventSupported;
  43454. private _gamepadSupport?;
  43455. /**
  43456. * observable to be triggered when the gamepad controller has been connected
  43457. */
  43458. onGamepadConnectedObservable: Observable<Gamepad>;
  43459. /**
  43460. * observable to be triggered when the gamepad controller has been disconnected
  43461. */
  43462. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43463. private _onGamepadConnectedEvent;
  43464. private _onGamepadDisconnectedEvent;
  43465. /**
  43466. * Initializes the gamepad manager
  43467. * @param _scene BabylonJS scene
  43468. */
  43469. constructor(_scene?: Scene | undefined);
  43470. /**
  43471. * The gamepads in the game pad manager
  43472. */
  43473. get gamepads(): Gamepad[];
  43474. /**
  43475. * Get the gamepad controllers based on type
  43476. * @param type The type of gamepad controller
  43477. * @returns Nullable gamepad
  43478. */
  43479. getGamepadByType(type?: number): Nullable<Gamepad>;
  43480. /**
  43481. * Disposes the gamepad manager
  43482. */
  43483. dispose(): void;
  43484. private _addNewGamepad;
  43485. private _startMonitoringGamepads;
  43486. private _stopMonitoringGamepads;
  43487. /** @hidden */
  43488. _checkGamepadsStatus(): void;
  43489. private _updateGamepadObjects;
  43490. }
  43491. }
  43492. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43493. import { Nullable } from "babylonjs/types";
  43494. import { Scene } from "babylonjs/scene";
  43495. import { ISceneComponent } from "babylonjs/sceneComponent";
  43496. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43497. module "babylonjs/scene" {
  43498. interface Scene {
  43499. /** @hidden */
  43500. _gamepadManager: Nullable<GamepadManager>;
  43501. /**
  43502. * Gets the gamepad manager associated with the scene
  43503. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43504. */
  43505. gamepadManager: GamepadManager;
  43506. }
  43507. }
  43508. module "babylonjs/Cameras/freeCameraInputsManager" {
  43509. /**
  43510. * Interface representing a free camera inputs manager
  43511. */
  43512. interface FreeCameraInputsManager {
  43513. /**
  43514. * Adds gamepad input support to the FreeCameraInputsManager.
  43515. * @returns the FreeCameraInputsManager
  43516. */
  43517. addGamepad(): FreeCameraInputsManager;
  43518. }
  43519. }
  43520. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43521. /**
  43522. * Interface representing an arc rotate camera inputs manager
  43523. */
  43524. interface ArcRotateCameraInputsManager {
  43525. /**
  43526. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43527. * @returns the camera inputs manager
  43528. */
  43529. addGamepad(): ArcRotateCameraInputsManager;
  43530. }
  43531. }
  43532. /**
  43533. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43534. */
  43535. export class GamepadSystemSceneComponent implements ISceneComponent {
  43536. /**
  43537. * The component name helpfull to identify the component in the list of scene components.
  43538. */
  43539. readonly name: string;
  43540. /**
  43541. * The scene the component belongs to.
  43542. */
  43543. scene: Scene;
  43544. /**
  43545. * Creates a new instance of the component for the given scene
  43546. * @param scene Defines the scene to register the component in
  43547. */
  43548. constructor(scene: Scene);
  43549. /**
  43550. * Registers the component in a given scene
  43551. */
  43552. register(): void;
  43553. /**
  43554. * Rebuilds the elements related to this component in case of
  43555. * context lost for instance.
  43556. */
  43557. rebuild(): void;
  43558. /**
  43559. * Disposes the component and the associated ressources
  43560. */
  43561. dispose(): void;
  43562. private _beforeCameraUpdate;
  43563. }
  43564. }
  43565. declare module "babylonjs/Cameras/universalCamera" {
  43566. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43567. import { Scene } from "babylonjs/scene";
  43568. import { Vector3 } from "babylonjs/Maths/math.vector";
  43569. import "babylonjs/Gamepads/gamepadSceneComponent";
  43570. /**
  43571. * 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,
  43572. * which still works and will still be found in many Playgrounds.
  43573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43574. */
  43575. export class UniversalCamera extends TouchCamera {
  43576. /**
  43577. * Defines the gamepad rotation sensiblity.
  43578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43579. */
  43580. get gamepadAngularSensibility(): number;
  43581. set gamepadAngularSensibility(value: number);
  43582. /**
  43583. * Defines the gamepad move sensiblity.
  43584. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43585. */
  43586. get gamepadMoveSensibility(): number;
  43587. set gamepadMoveSensibility(value: number);
  43588. /**
  43589. * 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,
  43590. * which still works and will still be found in many Playgrounds.
  43591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43592. * @param name Define the name of the camera in the scene
  43593. * @param position Define the start position of the camera in the scene
  43594. * @param scene Define the scene the camera belongs to
  43595. */
  43596. constructor(name: string, position: Vector3, scene: Scene);
  43597. /**
  43598. * Gets the current object class name.
  43599. * @return the class name
  43600. */
  43601. getClassName(): string;
  43602. }
  43603. }
  43604. declare module "babylonjs/Cameras/gamepadCamera" {
  43605. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43606. import { Scene } from "babylonjs/scene";
  43607. import { Vector3 } from "babylonjs/Maths/math.vector";
  43608. /**
  43609. * This represents a FPS type of camera. This is only here for back compat purpose.
  43610. * Please use the UniversalCamera instead as both are identical.
  43611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43612. */
  43613. export class GamepadCamera extends UniversalCamera {
  43614. /**
  43615. * Instantiates a new Gamepad Camera
  43616. * This represents a FPS type of camera. This is only here for back compat purpose.
  43617. * Please use the UniversalCamera instead as both are identical.
  43618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43619. * @param name Define the name of the camera in the scene
  43620. * @param position Define the start position of the camera in the scene
  43621. * @param scene Define the scene the camera belongs to
  43622. */
  43623. constructor(name: string, position: Vector3, scene: Scene);
  43624. /**
  43625. * Gets the current object class name.
  43626. * @return the class name
  43627. */
  43628. getClassName(): string;
  43629. }
  43630. }
  43631. declare module "babylonjs/Shaders/pass.fragment" {
  43632. /** @hidden */
  43633. export var passPixelShader: {
  43634. name: string;
  43635. shader: string;
  43636. };
  43637. }
  43638. declare module "babylonjs/Shaders/passCube.fragment" {
  43639. /** @hidden */
  43640. export var passCubePixelShader: {
  43641. name: string;
  43642. shader: string;
  43643. };
  43644. }
  43645. declare module "babylonjs/PostProcesses/passPostProcess" {
  43646. import { Nullable } from "babylonjs/types";
  43647. import { Camera } from "babylonjs/Cameras/camera";
  43648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43649. import { Engine } from "babylonjs/Engines/engine";
  43650. import "babylonjs/Shaders/pass.fragment";
  43651. import "babylonjs/Shaders/passCube.fragment";
  43652. /**
  43653. * PassPostProcess which produces an output the same as it's input
  43654. */
  43655. export class PassPostProcess extends PostProcess {
  43656. /**
  43657. * Creates the PassPostProcess
  43658. * @param name The name of the effect.
  43659. * @param options The required width/height ratio to downsize to before computing the render pass.
  43660. * @param camera The camera to apply the render pass to.
  43661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43662. * @param engine The engine which the post process will be applied. (default: current engine)
  43663. * @param reusable If the post process can be reused on the same frame. (default: false)
  43664. * @param textureType The type of texture to be used when performing the post processing.
  43665. * @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)
  43666. */
  43667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43668. }
  43669. /**
  43670. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43671. */
  43672. export class PassCubePostProcess extends PostProcess {
  43673. private _face;
  43674. /**
  43675. * Gets or sets the cube face to display.
  43676. * * 0 is +X
  43677. * * 1 is -X
  43678. * * 2 is +Y
  43679. * * 3 is -Y
  43680. * * 4 is +Z
  43681. * * 5 is -Z
  43682. */
  43683. get face(): number;
  43684. set face(value: number);
  43685. /**
  43686. * Creates the PassCubePostProcess
  43687. * @param name The name of the effect.
  43688. * @param options The required width/height ratio to downsize to before computing the render pass.
  43689. * @param camera The camera to apply the render pass to.
  43690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43691. * @param engine The engine which the post process will be applied. (default: current engine)
  43692. * @param reusable If the post process can be reused on the same frame. (default: false)
  43693. * @param textureType The type of texture to be used when performing the post processing.
  43694. * @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)
  43695. */
  43696. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43697. }
  43698. }
  43699. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43700. /** @hidden */
  43701. export var anaglyphPixelShader: {
  43702. name: string;
  43703. shader: string;
  43704. };
  43705. }
  43706. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43707. import { Engine } from "babylonjs/Engines/engine";
  43708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43709. import { Camera } from "babylonjs/Cameras/camera";
  43710. import "babylonjs/Shaders/anaglyph.fragment";
  43711. /**
  43712. * Postprocess used to generate anaglyphic rendering
  43713. */
  43714. export class AnaglyphPostProcess extends PostProcess {
  43715. private _passedProcess;
  43716. /**
  43717. * Creates a new AnaglyphPostProcess
  43718. * @param name defines postprocess name
  43719. * @param options defines creation options or target ratio scale
  43720. * @param rigCameras defines cameras using this postprocess
  43721. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43722. * @param engine defines hosting engine
  43723. * @param reusable defines if the postprocess will be reused multiple times per frame
  43724. */
  43725. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43726. }
  43727. }
  43728. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43729. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43730. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43731. import { Scene } from "babylonjs/scene";
  43732. import { Vector3 } from "babylonjs/Maths/math.vector";
  43733. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43734. /**
  43735. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43736. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43737. */
  43738. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43739. /**
  43740. * Creates a new AnaglyphArcRotateCamera
  43741. * @param name defines camera name
  43742. * @param alpha defines alpha angle (in radians)
  43743. * @param beta defines beta angle (in radians)
  43744. * @param radius defines radius
  43745. * @param target defines camera target
  43746. * @param interaxialDistance defines distance between each color axis
  43747. * @param scene defines the hosting scene
  43748. */
  43749. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43750. /**
  43751. * Gets camera class name
  43752. * @returns AnaglyphArcRotateCamera
  43753. */
  43754. getClassName(): string;
  43755. }
  43756. }
  43757. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43758. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43759. import { Scene } from "babylonjs/scene";
  43760. import { Vector3 } from "babylonjs/Maths/math.vector";
  43761. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43762. /**
  43763. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43764. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43765. */
  43766. export class AnaglyphFreeCamera extends FreeCamera {
  43767. /**
  43768. * Creates a new AnaglyphFreeCamera
  43769. * @param name defines camera name
  43770. * @param position defines initial position
  43771. * @param interaxialDistance defines distance between each color axis
  43772. * @param scene defines the hosting scene
  43773. */
  43774. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43775. /**
  43776. * Gets camera class name
  43777. * @returns AnaglyphFreeCamera
  43778. */
  43779. getClassName(): string;
  43780. }
  43781. }
  43782. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43783. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43784. import { Scene } from "babylonjs/scene";
  43785. import { Vector3 } from "babylonjs/Maths/math.vector";
  43786. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43787. /**
  43788. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43789. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43790. */
  43791. export class AnaglyphGamepadCamera extends GamepadCamera {
  43792. /**
  43793. * Creates a new AnaglyphGamepadCamera
  43794. * @param name defines camera name
  43795. * @param position defines initial position
  43796. * @param interaxialDistance defines distance between each color axis
  43797. * @param scene defines the hosting scene
  43798. */
  43799. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43800. /**
  43801. * Gets camera class name
  43802. * @returns AnaglyphGamepadCamera
  43803. */
  43804. getClassName(): string;
  43805. }
  43806. }
  43807. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43808. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43809. import { Scene } from "babylonjs/scene";
  43810. import { Vector3 } from "babylonjs/Maths/math.vector";
  43811. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43812. /**
  43813. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43814. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43815. */
  43816. export class AnaglyphUniversalCamera extends UniversalCamera {
  43817. /**
  43818. * Creates a new AnaglyphUniversalCamera
  43819. * @param name defines camera name
  43820. * @param position defines initial position
  43821. * @param interaxialDistance defines distance between each color axis
  43822. * @param scene defines the hosting scene
  43823. */
  43824. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43825. /**
  43826. * Gets camera class name
  43827. * @returns AnaglyphUniversalCamera
  43828. */
  43829. getClassName(): string;
  43830. }
  43831. }
  43832. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43833. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43835. import { Scene } from "babylonjs/scene";
  43836. import { Vector3 } from "babylonjs/Maths/math.vector";
  43837. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43838. /**
  43839. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43840. * @see http://doc.babylonjs.com/features/cameras
  43841. */
  43842. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43843. /**
  43844. * Creates a new StereoscopicArcRotateCamera
  43845. * @param name defines camera name
  43846. * @param alpha defines alpha angle (in radians)
  43847. * @param beta defines beta angle (in radians)
  43848. * @param radius defines radius
  43849. * @param target defines camera target
  43850. * @param interaxialDistance defines distance between each color axis
  43851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43852. * @param scene defines the hosting scene
  43853. */
  43854. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43855. /**
  43856. * Gets camera class name
  43857. * @returns StereoscopicArcRotateCamera
  43858. */
  43859. getClassName(): string;
  43860. }
  43861. }
  43862. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43864. import { Scene } from "babylonjs/scene";
  43865. import { Vector3 } from "babylonjs/Maths/math.vector";
  43866. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43867. /**
  43868. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43869. * @see http://doc.babylonjs.com/features/cameras
  43870. */
  43871. export class StereoscopicFreeCamera extends FreeCamera {
  43872. /**
  43873. * Creates a new StereoscopicFreeCamera
  43874. * @param name defines camera name
  43875. * @param position defines initial position
  43876. * @param interaxialDistance defines distance between each color axis
  43877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43878. * @param scene defines the hosting scene
  43879. */
  43880. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43881. /**
  43882. * Gets camera class name
  43883. * @returns StereoscopicFreeCamera
  43884. */
  43885. getClassName(): string;
  43886. }
  43887. }
  43888. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43889. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43890. import { Scene } from "babylonjs/scene";
  43891. import { Vector3 } from "babylonjs/Maths/math.vector";
  43892. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43893. /**
  43894. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43895. * @see http://doc.babylonjs.com/features/cameras
  43896. */
  43897. export class StereoscopicGamepadCamera extends GamepadCamera {
  43898. /**
  43899. * Creates a new StereoscopicGamepadCamera
  43900. * @param name defines camera name
  43901. * @param position defines initial position
  43902. * @param interaxialDistance defines distance between each color axis
  43903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43904. * @param scene defines the hosting scene
  43905. */
  43906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43907. /**
  43908. * Gets camera class name
  43909. * @returns StereoscopicGamepadCamera
  43910. */
  43911. getClassName(): string;
  43912. }
  43913. }
  43914. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43915. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43916. import { Scene } from "babylonjs/scene";
  43917. import { Vector3 } from "babylonjs/Maths/math.vector";
  43918. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43919. /**
  43920. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43921. * @see http://doc.babylonjs.com/features/cameras
  43922. */
  43923. export class StereoscopicUniversalCamera extends UniversalCamera {
  43924. /**
  43925. * Creates a new StereoscopicUniversalCamera
  43926. * @param name defines camera name
  43927. * @param position defines initial position
  43928. * @param interaxialDistance defines distance between each color axis
  43929. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43930. * @param scene defines the hosting scene
  43931. */
  43932. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43933. /**
  43934. * Gets camera class name
  43935. * @returns StereoscopicUniversalCamera
  43936. */
  43937. getClassName(): string;
  43938. }
  43939. }
  43940. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43941. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43942. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43943. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43944. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43945. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43946. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43947. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43948. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43949. }
  43950. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43952. import { Scene } from "babylonjs/scene";
  43953. import { Vector3 } from "babylonjs/Maths/math.vector";
  43954. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43955. /**
  43956. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43957. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43958. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43959. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43960. */
  43961. export class VirtualJoysticksCamera extends FreeCamera {
  43962. /**
  43963. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43964. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43965. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43966. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43967. * @param name Define the name of the camera in the scene
  43968. * @param position Define the start position of the camera in the scene
  43969. * @param scene Define the scene the camera belongs to
  43970. */
  43971. constructor(name: string, position: Vector3, scene: Scene);
  43972. /**
  43973. * Gets the current object class name.
  43974. * @return the class name
  43975. */
  43976. getClassName(): string;
  43977. }
  43978. }
  43979. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43980. import { Matrix } from "babylonjs/Maths/math.vector";
  43981. /**
  43982. * This represents all the required metrics to create a VR camera.
  43983. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43984. */
  43985. export class VRCameraMetrics {
  43986. /**
  43987. * Define the horizontal resolution off the screen.
  43988. */
  43989. hResolution: number;
  43990. /**
  43991. * Define the vertical resolution off the screen.
  43992. */
  43993. vResolution: number;
  43994. /**
  43995. * Define the horizontal screen size.
  43996. */
  43997. hScreenSize: number;
  43998. /**
  43999. * Define the vertical screen size.
  44000. */
  44001. vScreenSize: number;
  44002. /**
  44003. * Define the vertical screen center position.
  44004. */
  44005. vScreenCenter: number;
  44006. /**
  44007. * Define the distance of the eyes to the screen.
  44008. */
  44009. eyeToScreenDistance: number;
  44010. /**
  44011. * Define the distance between both lenses
  44012. */
  44013. lensSeparationDistance: number;
  44014. /**
  44015. * Define the distance between both viewer's eyes.
  44016. */
  44017. interpupillaryDistance: number;
  44018. /**
  44019. * Define the distortion factor of the VR postprocess.
  44020. * Please, touch with care.
  44021. */
  44022. distortionK: number[];
  44023. /**
  44024. * Define the chromatic aberration correction factors for the VR post process.
  44025. */
  44026. chromaAbCorrection: number[];
  44027. /**
  44028. * Define the scale factor of the post process.
  44029. * The smaller the better but the slower.
  44030. */
  44031. postProcessScaleFactor: number;
  44032. /**
  44033. * Define an offset for the lens center.
  44034. */
  44035. lensCenterOffset: number;
  44036. /**
  44037. * Define if the current vr camera should compensate the distortion of the lense or not.
  44038. */
  44039. compensateDistortion: boolean;
  44040. /**
  44041. * Defines if multiview should be enabled when rendering (Default: false)
  44042. */
  44043. multiviewEnabled: boolean;
  44044. /**
  44045. * Gets the rendering aspect ratio based on the provided resolutions.
  44046. */
  44047. get aspectRatio(): number;
  44048. /**
  44049. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44050. */
  44051. get aspectRatioFov(): number;
  44052. /**
  44053. * @hidden
  44054. */
  44055. get leftHMatrix(): Matrix;
  44056. /**
  44057. * @hidden
  44058. */
  44059. get rightHMatrix(): Matrix;
  44060. /**
  44061. * @hidden
  44062. */
  44063. get leftPreViewMatrix(): Matrix;
  44064. /**
  44065. * @hidden
  44066. */
  44067. get rightPreViewMatrix(): Matrix;
  44068. /**
  44069. * Get the default VRMetrics based on the most generic setup.
  44070. * @returns the default vr metrics
  44071. */
  44072. static GetDefault(): VRCameraMetrics;
  44073. }
  44074. }
  44075. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44076. /** @hidden */
  44077. export var vrDistortionCorrectionPixelShader: {
  44078. name: string;
  44079. shader: string;
  44080. };
  44081. }
  44082. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44083. import { Camera } from "babylonjs/Cameras/camera";
  44084. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44085. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44086. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44087. /**
  44088. * VRDistortionCorrectionPostProcess used for mobile VR
  44089. */
  44090. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44091. private _isRightEye;
  44092. private _distortionFactors;
  44093. private _postProcessScaleFactor;
  44094. private _lensCenterOffset;
  44095. private _scaleIn;
  44096. private _scaleFactor;
  44097. private _lensCenter;
  44098. /**
  44099. * Initializes the VRDistortionCorrectionPostProcess
  44100. * @param name The name of the effect.
  44101. * @param camera The camera to apply the render pass to.
  44102. * @param isRightEye If this is for the right eye distortion
  44103. * @param vrMetrics All the required metrics for the VR camera
  44104. */
  44105. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44106. }
  44107. }
  44108. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44109. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44110. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44111. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44112. import { Scene } from "babylonjs/scene";
  44113. import { Vector3 } from "babylonjs/Maths/math.vector";
  44114. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44115. import "babylonjs/Cameras/RigModes/vrRigMode";
  44116. /**
  44117. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44118. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44119. */
  44120. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44121. /**
  44122. * Creates a new VRDeviceOrientationArcRotateCamera
  44123. * @param name defines camera name
  44124. * @param alpha defines the camera rotation along the logitudinal axis
  44125. * @param beta defines the camera rotation along the latitudinal axis
  44126. * @param radius defines the camera distance from its target
  44127. * @param target defines the camera target
  44128. * @param scene defines the scene the camera belongs to
  44129. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44130. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44131. */
  44132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44133. /**
  44134. * Gets camera class name
  44135. * @returns VRDeviceOrientationArcRotateCamera
  44136. */
  44137. getClassName(): string;
  44138. }
  44139. }
  44140. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44141. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44142. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44143. import { Scene } from "babylonjs/scene";
  44144. import { Vector3 } from "babylonjs/Maths/math.vector";
  44145. import "babylonjs/Cameras/RigModes/vrRigMode";
  44146. /**
  44147. * Camera used to simulate VR rendering (based on FreeCamera)
  44148. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44149. */
  44150. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44151. /**
  44152. * Creates a new VRDeviceOrientationFreeCamera
  44153. * @param name defines camera name
  44154. * @param position defines the start position of the camera
  44155. * @param scene defines the scene the camera belongs to
  44156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44158. */
  44159. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44160. /**
  44161. * Gets camera class name
  44162. * @returns VRDeviceOrientationFreeCamera
  44163. */
  44164. getClassName(): string;
  44165. }
  44166. }
  44167. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44168. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44169. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44170. import { Scene } from "babylonjs/scene";
  44171. import { Vector3 } from "babylonjs/Maths/math.vector";
  44172. import "babylonjs/Gamepads/gamepadSceneComponent";
  44173. /**
  44174. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44175. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44176. */
  44177. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44178. /**
  44179. * Creates a new VRDeviceOrientationGamepadCamera
  44180. * @param name defines camera name
  44181. * @param position defines the start position of the camera
  44182. * @param scene defines the scene the camera belongs to
  44183. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44184. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44185. */
  44186. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44187. /**
  44188. * Gets camera class name
  44189. * @returns VRDeviceOrientationGamepadCamera
  44190. */
  44191. getClassName(): string;
  44192. }
  44193. }
  44194. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44195. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44196. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44197. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44198. /** @hidden */
  44199. export var imageProcessingPixelShader: {
  44200. name: string;
  44201. shader: string;
  44202. };
  44203. }
  44204. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44205. import { Nullable } from "babylonjs/types";
  44206. import { Color4 } from "babylonjs/Maths/math.color";
  44207. import { Camera } from "babylonjs/Cameras/camera";
  44208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44209. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44210. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44212. import { Engine } from "babylonjs/Engines/engine";
  44213. import "babylonjs/Shaders/imageProcessing.fragment";
  44214. import "babylonjs/Shaders/postprocess.vertex";
  44215. /**
  44216. * ImageProcessingPostProcess
  44217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44218. */
  44219. export class ImageProcessingPostProcess extends PostProcess {
  44220. /**
  44221. * Default configuration related to image processing available in the PBR Material.
  44222. */
  44223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44224. /**
  44225. * Gets the image processing configuration used either in this material.
  44226. */
  44227. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44228. /**
  44229. * Sets the Default image processing configuration used either in the this material.
  44230. *
  44231. * If sets to null, the scene one is in use.
  44232. */
  44233. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44234. /**
  44235. * Keep track of the image processing observer to allow dispose and replace.
  44236. */
  44237. private _imageProcessingObserver;
  44238. /**
  44239. * Attaches a new image processing configuration to the PBR Material.
  44240. * @param configuration
  44241. */
  44242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44243. /**
  44244. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44245. */
  44246. get colorCurves(): Nullable<ColorCurves>;
  44247. /**
  44248. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44249. */
  44250. set colorCurves(value: Nullable<ColorCurves>);
  44251. /**
  44252. * Gets wether the color curves effect is enabled.
  44253. */
  44254. get colorCurvesEnabled(): boolean;
  44255. /**
  44256. * Sets wether the color curves effect is enabled.
  44257. */
  44258. set colorCurvesEnabled(value: boolean);
  44259. /**
  44260. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44261. */
  44262. get colorGradingTexture(): Nullable<BaseTexture>;
  44263. /**
  44264. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44265. */
  44266. set colorGradingTexture(value: Nullable<BaseTexture>);
  44267. /**
  44268. * Gets wether the color grading effect is enabled.
  44269. */
  44270. get colorGradingEnabled(): boolean;
  44271. /**
  44272. * Gets wether the color grading effect is enabled.
  44273. */
  44274. set colorGradingEnabled(value: boolean);
  44275. /**
  44276. * Gets exposure used in the effect.
  44277. */
  44278. get exposure(): number;
  44279. /**
  44280. * Sets exposure used in the effect.
  44281. */
  44282. set exposure(value: number);
  44283. /**
  44284. * Gets wether tonemapping is enabled or not.
  44285. */
  44286. get toneMappingEnabled(): boolean;
  44287. /**
  44288. * Sets wether tonemapping is enabled or not
  44289. */
  44290. set toneMappingEnabled(value: boolean);
  44291. /**
  44292. * Gets the type of tone mapping effect.
  44293. */
  44294. get toneMappingType(): number;
  44295. /**
  44296. * Sets the type of tone mapping effect.
  44297. */
  44298. set toneMappingType(value: number);
  44299. /**
  44300. * Gets contrast used in the effect.
  44301. */
  44302. get contrast(): number;
  44303. /**
  44304. * Sets contrast used in the effect.
  44305. */
  44306. set contrast(value: number);
  44307. /**
  44308. * Gets Vignette stretch size.
  44309. */
  44310. get vignetteStretch(): number;
  44311. /**
  44312. * Sets Vignette stretch size.
  44313. */
  44314. set vignetteStretch(value: number);
  44315. /**
  44316. * Gets Vignette centre X Offset.
  44317. */
  44318. get vignetteCentreX(): number;
  44319. /**
  44320. * Sets Vignette centre X Offset.
  44321. */
  44322. set vignetteCentreX(value: number);
  44323. /**
  44324. * Gets Vignette centre Y Offset.
  44325. */
  44326. get vignetteCentreY(): number;
  44327. /**
  44328. * Sets Vignette centre Y Offset.
  44329. */
  44330. set vignetteCentreY(value: number);
  44331. /**
  44332. * Gets Vignette weight or intensity of the vignette effect.
  44333. */
  44334. get vignetteWeight(): number;
  44335. /**
  44336. * Sets Vignette weight or intensity of the vignette effect.
  44337. */
  44338. set vignetteWeight(value: number);
  44339. /**
  44340. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44341. * if vignetteEnabled is set to true.
  44342. */
  44343. get vignetteColor(): Color4;
  44344. /**
  44345. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44346. * if vignetteEnabled is set to true.
  44347. */
  44348. set vignetteColor(value: Color4);
  44349. /**
  44350. * Gets Camera field of view used by the Vignette effect.
  44351. */
  44352. get vignetteCameraFov(): number;
  44353. /**
  44354. * Sets Camera field of view used by the Vignette effect.
  44355. */
  44356. set vignetteCameraFov(value: number);
  44357. /**
  44358. * Gets the vignette blend mode allowing different kind of effect.
  44359. */
  44360. get vignetteBlendMode(): number;
  44361. /**
  44362. * Sets the vignette blend mode allowing different kind of effect.
  44363. */
  44364. set vignetteBlendMode(value: number);
  44365. /**
  44366. * Gets wether the vignette effect is enabled.
  44367. */
  44368. get vignetteEnabled(): boolean;
  44369. /**
  44370. * Sets wether the vignette effect is enabled.
  44371. */
  44372. set vignetteEnabled(value: boolean);
  44373. private _fromLinearSpace;
  44374. /**
  44375. * Gets wether the input of the processing is in Gamma or Linear Space.
  44376. */
  44377. get fromLinearSpace(): boolean;
  44378. /**
  44379. * Sets wether the input of the processing is in Gamma or Linear Space.
  44380. */
  44381. set fromLinearSpace(value: boolean);
  44382. /**
  44383. * Defines cache preventing GC.
  44384. */
  44385. private _defines;
  44386. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44387. /**
  44388. * "ImageProcessingPostProcess"
  44389. * @returns "ImageProcessingPostProcess"
  44390. */
  44391. getClassName(): string;
  44392. protected _updateParameters(): void;
  44393. dispose(camera?: Camera): void;
  44394. }
  44395. }
  44396. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44397. import { Scene } from "babylonjs/scene";
  44398. import { Color3 } from "babylonjs/Maths/math.color";
  44399. import { Mesh } from "babylonjs/Meshes/mesh";
  44400. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44401. import { Nullable } from "babylonjs/types";
  44402. /**
  44403. * Class containing static functions to help procedurally build meshes
  44404. */
  44405. export class GroundBuilder {
  44406. /**
  44407. * Creates a ground mesh
  44408. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44409. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44411. * @param name defines the name of the mesh
  44412. * @param options defines the options used to create the mesh
  44413. * @param scene defines the hosting scene
  44414. * @returns the ground mesh
  44415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44416. */
  44417. static CreateGround(name: string, options: {
  44418. width?: number;
  44419. height?: number;
  44420. subdivisions?: number;
  44421. subdivisionsX?: number;
  44422. subdivisionsY?: number;
  44423. updatable?: boolean;
  44424. }, scene: any): Mesh;
  44425. /**
  44426. * Creates a tiled ground mesh
  44427. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44428. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44429. * * 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
  44430. * * 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
  44431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44432. * @param name defines the name of the mesh
  44433. * @param options defines the options used to create the mesh
  44434. * @param scene defines the hosting scene
  44435. * @returns the tiled ground mesh
  44436. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44437. */
  44438. static CreateTiledGround(name: string, options: {
  44439. xmin: number;
  44440. zmin: number;
  44441. xmax: number;
  44442. zmax: number;
  44443. subdivisions?: {
  44444. w: number;
  44445. h: number;
  44446. };
  44447. precision?: {
  44448. w: number;
  44449. h: number;
  44450. };
  44451. updatable?: boolean;
  44452. }, scene?: Nullable<Scene>): Mesh;
  44453. /**
  44454. * Creates a ground mesh from a height map
  44455. * * The parameter `url` sets the URL of the height map image resource.
  44456. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44457. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44458. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44459. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44460. * * 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.
  44461. * * 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).
  44462. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44464. * @param name defines the name of the mesh
  44465. * @param url defines the url to the height map
  44466. * @param options defines the options used to create the mesh
  44467. * @param scene defines the hosting scene
  44468. * @returns the ground mesh
  44469. * @see https://doc.babylonjs.com/babylon101/height_map
  44470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44471. */
  44472. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44473. width?: number;
  44474. height?: number;
  44475. subdivisions?: number;
  44476. minHeight?: number;
  44477. maxHeight?: number;
  44478. colorFilter?: Color3;
  44479. alphaFilter?: number;
  44480. updatable?: boolean;
  44481. onReady?: (mesh: GroundMesh) => void;
  44482. }, scene?: Nullable<Scene>): GroundMesh;
  44483. }
  44484. }
  44485. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44486. import { Vector4 } from "babylonjs/Maths/math.vector";
  44487. import { Mesh } from "babylonjs/Meshes/mesh";
  44488. /**
  44489. * Class containing static functions to help procedurally build meshes
  44490. */
  44491. export class TorusBuilder {
  44492. /**
  44493. * Creates a torus mesh
  44494. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44495. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44496. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44500. * @param name defines the name of the mesh
  44501. * @param options defines the options used to create the mesh
  44502. * @param scene defines the hosting scene
  44503. * @returns the torus mesh
  44504. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44505. */
  44506. static CreateTorus(name: string, options: {
  44507. diameter?: number;
  44508. thickness?: number;
  44509. tessellation?: number;
  44510. updatable?: boolean;
  44511. sideOrientation?: number;
  44512. frontUVs?: Vector4;
  44513. backUVs?: Vector4;
  44514. }, scene: any): Mesh;
  44515. }
  44516. }
  44517. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44518. import { Vector4 } from "babylonjs/Maths/math.vector";
  44519. import { Color4 } from "babylonjs/Maths/math.color";
  44520. import { Mesh } from "babylonjs/Meshes/mesh";
  44521. /**
  44522. * Class containing static functions to help procedurally build meshes
  44523. */
  44524. export class CylinderBuilder {
  44525. /**
  44526. * Creates a cylinder or a cone mesh
  44527. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44528. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44529. * * 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.
  44530. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44531. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44532. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44533. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44534. * * 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).
  44535. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44536. * * 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).
  44537. * * 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
  44538. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44539. * * 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
  44540. * * 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.
  44541. * * If `enclose` is false, a ring surface is one element.
  44542. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44543. * * 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
  44544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44547. * @param name defines the name of the mesh
  44548. * @param options defines the options used to create the mesh
  44549. * @param scene defines the hosting scene
  44550. * @returns the cylinder mesh
  44551. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44552. */
  44553. static CreateCylinder(name: string, options: {
  44554. height?: number;
  44555. diameterTop?: number;
  44556. diameterBottom?: number;
  44557. diameter?: number;
  44558. tessellation?: number;
  44559. subdivisions?: number;
  44560. arc?: number;
  44561. faceColors?: Color4[];
  44562. faceUV?: Vector4[];
  44563. updatable?: boolean;
  44564. hasRings?: boolean;
  44565. enclose?: boolean;
  44566. cap?: number;
  44567. sideOrientation?: number;
  44568. frontUVs?: Vector4;
  44569. backUVs?: Vector4;
  44570. }, scene: any): Mesh;
  44571. }
  44572. }
  44573. declare module "babylonjs/XR/webXRTypes" {
  44574. import { Nullable } from "babylonjs/types";
  44575. import { IDisposable } from "babylonjs/scene";
  44576. /**
  44577. * States of the webXR experience
  44578. */
  44579. export enum WebXRState {
  44580. /**
  44581. * Transitioning to being in XR mode
  44582. */
  44583. ENTERING_XR = 0,
  44584. /**
  44585. * Transitioning to non XR mode
  44586. */
  44587. EXITING_XR = 1,
  44588. /**
  44589. * In XR mode and presenting
  44590. */
  44591. IN_XR = 2,
  44592. /**
  44593. * Not entered XR mode
  44594. */
  44595. NOT_IN_XR = 3
  44596. }
  44597. /**
  44598. * Abstraction of the XR render target
  44599. */
  44600. export interface WebXRRenderTarget extends IDisposable {
  44601. /**
  44602. * xrpresent context of the canvas which can be used to display/mirror xr content
  44603. */
  44604. canvasContext: WebGLRenderingContext;
  44605. /**
  44606. * xr layer for the canvas
  44607. */
  44608. xrLayer: Nullable<XRWebGLLayer>;
  44609. /**
  44610. * Initializes the xr layer for the session
  44611. * @param xrSession xr session
  44612. * @returns a promise that will resolve once the XR Layer has been created
  44613. */
  44614. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44615. }
  44616. }
  44617. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44618. import { Nullable } from "babylonjs/types";
  44619. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44620. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44621. /**
  44622. * COnfiguration object for WebXR output canvas
  44623. */
  44624. export class WebXRManagedOutputCanvasOptions {
  44625. /**
  44626. * An optional canvas in case you wish to create it yourself and provide it here.
  44627. * If not provided, a new canvas will be created
  44628. */
  44629. canvasElement?: HTMLCanvasElement;
  44630. /**
  44631. * Options for this XR Layer output
  44632. */
  44633. canvasOptions?: XRWebGLLayerOptions;
  44634. /**
  44635. * CSS styling for a newly created canvas (if not provided)
  44636. */
  44637. newCanvasCssStyle?: string;
  44638. /**
  44639. * Get the default values of the configuration object
  44640. * @returns default values of this configuration object
  44641. */
  44642. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44643. }
  44644. /**
  44645. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44646. */
  44647. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44648. private _options;
  44649. private _canvas;
  44650. private _engine;
  44651. /**
  44652. * Rendering context of the canvas which can be used to display/mirror xr content
  44653. */
  44654. canvasContext: WebGLRenderingContext;
  44655. /**
  44656. * xr layer for the canvas
  44657. */
  44658. xrLayer: Nullable<XRWebGLLayer>;
  44659. /**
  44660. * Initializes the canvas to be added/removed upon entering/exiting xr
  44661. * @param _xrSessionManager The XR Session manager
  44662. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44663. */
  44664. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44665. /**
  44666. * Disposes of the object
  44667. */
  44668. dispose(): void;
  44669. /**
  44670. * Initializes the xr layer for the session
  44671. * @param xrSession xr session
  44672. * @returns a promise that will resolve once the XR Layer has been created
  44673. */
  44674. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44675. private _addCanvas;
  44676. private _removeCanvas;
  44677. private _setManagedOutputCanvas;
  44678. }
  44679. }
  44680. declare module "babylonjs/XR/webXRSessionManager" {
  44681. import { Observable } from "babylonjs/Misc/observable";
  44682. import { Nullable } from "babylonjs/types";
  44683. import { IDisposable, Scene } from "babylonjs/scene";
  44684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44685. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44686. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44687. /**
  44688. * Manages an XRSession to work with Babylon's engine
  44689. * @see https://doc.babylonjs.com/how_to/webxr
  44690. */
  44691. export class WebXRSessionManager implements IDisposable {
  44692. /** The scene which the session should be created for */
  44693. scene: Scene;
  44694. private _referenceSpace;
  44695. private _rttProvider;
  44696. private _sessionEnded;
  44697. private _xrNavigator;
  44698. private baseLayer;
  44699. /**
  44700. * The base reference space from which the session started. good if you want to reset your
  44701. * reference space
  44702. */
  44703. baseReferenceSpace: XRReferenceSpace;
  44704. /**
  44705. * Current XR frame
  44706. */
  44707. currentFrame: Nullable<XRFrame>;
  44708. /** WebXR timestamp updated every frame */
  44709. currentTimestamp: number;
  44710. /**
  44711. * Used just in case of a failure to initialize an immersive session.
  44712. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44713. */
  44714. defaultHeightCompensation: number;
  44715. /**
  44716. * Fires every time a new xrFrame arrives which can be used to update the camera
  44717. */
  44718. onXRFrameObservable: Observable<XRFrame>;
  44719. /**
  44720. * Fires when the reference space changed
  44721. */
  44722. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44723. /**
  44724. * Fires when the xr session is ended either by the device or manually done
  44725. */
  44726. onXRSessionEnded: Observable<any>;
  44727. /**
  44728. * Fires when the xr session is ended either by the device or manually done
  44729. */
  44730. onXRSessionInit: Observable<XRSession>;
  44731. /**
  44732. * Underlying xr session
  44733. */
  44734. session: XRSession;
  44735. /**
  44736. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44737. * or get the offset the player is currently at.
  44738. */
  44739. viewerReferenceSpace: XRReferenceSpace;
  44740. /**
  44741. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44742. * @param scene The scene which the session should be created for
  44743. */
  44744. constructor(
  44745. /** The scene which the session should be created for */
  44746. scene: Scene);
  44747. /**
  44748. * The current reference space used in this session. This reference space can constantly change!
  44749. * It is mainly used to offset the camera's position.
  44750. */
  44751. get referenceSpace(): XRReferenceSpace;
  44752. /**
  44753. * Set a new reference space and triggers the observable
  44754. */
  44755. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44756. /**
  44757. * Disposes of the session manager
  44758. */
  44759. dispose(): void;
  44760. /**
  44761. * Stops the xrSession and restores the render loop
  44762. * @returns Promise which resolves after it exits XR
  44763. */
  44764. exitXRAsync(): Promise<void>;
  44765. /**
  44766. * Gets the correct render target texture to be rendered this frame for this eye
  44767. * @param eye the eye for which to get the render target
  44768. * @returns the render target for the specified eye
  44769. */
  44770. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44771. /**
  44772. * Creates a WebXRRenderTarget object for the XR session
  44773. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44774. * @param options optional options to provide when creating a new render target
  44775. * @returns a WebXR render target to which the session can render
  44776. */
  44777. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44778. /**
  44779. * Initializes the manager
  44780. * After initialization enterXR can be called to start an XR session
  44781. * @returns Promise which resolves after it is initialized
  44782. */
  44783. initializeAsync(): Promise<void>;
  44784. /**
  44785. * Initializes an xr session
  44786. * @param xrSessionMode mode to initialize
  44787. * @param xrSessionInit defines optional and required values to pass to the session builder
  44788. * @returns a promise which will resolve once the session has been initialized
  44789. */
  44790. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44791. /**
  44792. * Checks if a session would be supported for the creation options specified
  44793. * @param sessionMode session mode to check if supported eg. immersive-vr
  44794. * @returns A Promise that resolves to true if supported and false if not
  44795. */
  44796. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44797. /**
  44798. * Resets the reference space to the one started the session
  44799. */
  44800. resetReferenceSpace(): void;
  44801. /**
  44802. * Starts rendering to the xr layer
  44803. */
  44804. runXRRenderLoop(): void;
  44805. /**
  44806. * Sets the reference space on the xr session
  44807. * @param referenceSpaceType space to set
  44808. * @returns a promise that will resolve once the reference space has been set
  44809. */
  44810. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44811. /**
  44812. * Updates the render state of the session
  44813. * @param state state to set
  44814. * @returns a promise that resolves once the render state has been updated
  44815. */
  44816. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44817. /**
  44818. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44819. * @param sessionMode defines the session to test
  44820. * @returns a promise with boolean as final value
  44821. */
  44822. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44823. private _createRenderTargetTexture;
  44824. }
  44825. }
  44826. declare module "babylonjs/XR/webXRCamera" {
  44827. import { Scene } from "babylonjs/scene";
  44828. import { Camera } from "babylonjs/Cameras/camera";
  44829. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44831. /**
  44832. * WebXR Camera which holds the views for the xrSession
  44833. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44834. */
  44835. export class WebXRCamera extends FreeCamera {
  44836. private _xrSessionManager;
  44837. private _firstFrame;
  44838. private _referenceQuaternion;
  44839. private _referencedPosition;
  44840. private _xrInvPositionCache;
  44841. private _xrInvQuaternionCache;
  44842. /**
  44843. * Should position compensation execute on first frame.
  44844. * This is used when copying the position from a native (non XR) camera
  44845. */
  44846. compensateOnFirstFrame: boolean;
  44847. /**
  44848. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44849. * @param name the name of the camera
  44850. * @param scene the scene to add the camera to
  44851. * @param _xrSessionManager a constructed xr session manager
  44852. */
  44853. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44854. /**
  44855. * Return the user's height, unrelated to the current ground.
  44856. * This will be the y position of this camera, when ground level is 0.
  44857. */
  44858. get realWorldHeight(): number;
  44859. /** @hidden */
  44860. _updateForDualEyeDebugging(): void;
  44861. /**
  44862. * Sets this camera's transformation based on a non-vr camera
  44863. * @param otherCamera the non-vr camera to copy the transformation from
  44864. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44865. */
  44866. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44867. /**
  44868. * Gets the current instance class name ("WebXRCamera").
  44869. * @returns the class name
  44870. */
  44871. getClassName(): string;
  44872. private _updateFromXRSession;
  44873. private _updateNumberOfRigCameras;
  44874. private _updateReferenceSpace;
  44875. private _updateReferenceSpaceOffset;
  44876. }
  44877. }
  44878. declare module "babylonjs/XR/webXRFeaturesManager" {
  44879. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44880. import { IDisposable } from "babylonjs/scene";
  44881. /**
  44882. * Defining the interface required for a (webxr) feature
  44883. */
  44884. export interface IWebXRFeature extends IDisposable {
  44885. /**
  44886. * Is this feature attached
  44887. */
  44888. attached: boolean;
  44889. /**
  44890. * Should auto-attach be disabled?
  44891. */
  44892. disableAutoAttach: boolean;
  44893. /**
  44894. * Attach the feature to the session
  44895. * Will usually be called by the features manager
  44896. *
  44897. * @param force should attachment be forced (even when already attached)
  44898. * @returns true if successful.
  44899. */
  44900. attach(force?: boolean): boolean;
  44901. /**
  44902. * Detach the feature from the session
  44903. * Will usually be called by the features manager
  44904. *
  44905. * @returns true if successful.
  44906. */
  44907. detach(): boolean;
  44908. }
  44909. /**
  44910. * A list of the currently available features without referencing them
  44911. */
  44912. export class WebXRFeatureName {
  44913. /**
  44914. * The name of the anchor system feature
  44915. */
  44916. static ANCHOR_SYSTEM: string;
  44917. /**
  44918. * The name of the background remover feature
  44919. */
  44920. static BACKGROUND_REMOVER: string;
  44921. /**
  44922. * The name of the hit test feature
  44923. */
  44924. static HIT_TEST: string;
  44925. /**
  44926. * physics impostors for xr controllers feature
  44927. */
  44928. static PHYSICS_CONTROLLERS: string;
  44929. /**
  44930. * The name of the plane detection feature
  44931. */
  44932. static PLANE_DETECTION: string;
  44933. /**
  44934. * The name of the pointer selection feature
  44935. */
  44936. static POINTER_SELECTION: string;
  44937. /**
  44938. * The name of the teleportation feature
  44939. */
  44940. static TELEPORTATION: string;
  44941. }
  44942. /**
  44943. * Defining the constructor of a feature. Used to register the modules.
  44944. */
  44945. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44946. /**
  44947. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44948. * It is mainly used in AR sessions.
  44949. *
  44950. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44951. */
  44952. export class WebXRFeaturesManager implements IDisposable {
  44953. private _xrSessionManager;
  44954. private static readonly _AvailableFeatures;
  44955. private _features;
  44956. /**
  44957. * constructs a new features manages.
  44958. *
  44959. * @param _xrSessionManager an instance of WebXRSessionManager
  44960. */
  44961. constructor(_xrSessionManager: WebXRSessionManager);
  44962. /**
  44963. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44964. * Mainly used internally.
  44965. *
  44966. * @param featureName the name of the feature to register
  44967. * @param constructorFunction the function used to construct the module
  44968. * @param version the (babylon) version of the module
  44969. * @param stable is that a stable version of this module
  44970. */
  44971. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44972. /**
  44973. * Returns a constructor of a specific feature.
  44974. *
  44975. * @param featureName the name of the feature to construct
  44976. * @param version the version of the feature to load
  44977. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44978. * @param options optional options provided to the module.
  44979. * @returns a function that, when called, will return a new instance of this feature
  44980. */
  44981. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44982. /**
  44983. * Can be used to return the list of features currently registered
  44984. *
  44985. * @returns an Array of available features
  44986. */
  44987. static GetAvailableFeatures(): string[];
  44988. /**
  44989. * Gets the versions available for a specific feature
  44990. * @param featureName the name of the feature
  44991. * @returns an array with the available versions
  44992. */
  44993. static GetAvailableVersions(featureName: string): string[];
  44994. /**
  44995. * Return the latest unstable version of this feature
  44996. * @param featureName the name of the feature to search
  44997. * @returns the version number. if not found will return -1
  44998. */
  44999. static GetLatestVersionOfFeature(featureName: string): number;
  45000. /**
  45001. * Return the latest stable version of this feature
  45002. * @param featureName the name of the feature to search
  45003. * @returns the version number. if not found will return -1
  45004. */
  45005. static GetStableVersionOfFeature(featureName: string): number;
  45006. /**
  45007. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45008. * Can be used during a session to start a feature
  45009. * @param featureName the name of feature to attach
  45010. */
  45011. attachFeature(featureName: string): void;
  45012. /**
  45013. * Can be used inside a session or when the session ends to detach a specific feature
  45014. * @param featureName the name of the feature to detach
  45015. */
  45016. detachFeature(featureName: string): void;
  45017. /**
  45018. * Used to disable an already-enabled feature
  45019. * The feature will be disposed and will be recreated once enabled.
  45020. * @param featureName the feature to disable
  45021. * @returns true if disable was successful
  45022. */
  45023. disableFeature(featureName: string | {
  45024. Name: string;
  45025. }): boolean;
  45026. /**
  45027. * dispose this features manager
  45028. */
  45029. dispose(): void;
  45030. /**
  45031. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  45032. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  45033. *
  45034. * @param featureName the name of the feature to load or the class of the feature
  45035. * @param version optional version to load. if not provided the latest version will be enabled
  45036. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45037. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45038. * @returns a new constructed feature or throws an error if feature not found.
  45039. */
  45040. enableFeature(featureName: string | {
  45041. Name: string;
  45042. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45043. /**
  45044. * get the implementation of an enabled feature.
  45045. * @param featureName the name of the feature to load
  45046. * @returns the feature class, if found
  45047. */
  45048. getEnabledFeature(featureName: string): IWebXRFeature;
  45049. /**
  45050. * Get the list of enabled features
  45051. * @returns an array of enabled features
  45052. */
  45053. getEnabledFeatures(): string[];
  45054. }
  45055. }
  45056. declare module "babylonjs/XR/webXRExperienceHelper" {
  45057. import { Observable } from "babylonjs/Misc/observable";
  45058. import { IDisposable, Scene } from "babylonjs/scene";
  45059. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45060. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45061. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45062. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45063. /**
  45064. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45065. * @see https://doc.babylonjs.com/how_to/webxr
  45066. */
  45067. export class WebXRExperienceHelper implements IDisposable {
  45068. private scene;
  45069. private _nonVRCamera;
  45070. private _originalSceneAutoClear;
  45071. private _supported;
  45072. /**
  45073. * Camera used to render xr content
  45074. */
  45075. camera: WebXRCamera;
  45076. /** A features manager for this xr session */
  45077. featuresManager: WebXRFeaturesManager;
  45078. /**
  45079. * Observers registered here will be triggered after the camera's initial transformation is set
  45080. * This can be used to set a different ground level or an extra rotation.
  45081. *
  45082. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45083. * to the position set after this observable is done executing.
  45084. */
  45085. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45086. /**
  45087. * Fires when the state of the experience helper has changed
  45088. */
  45089. onStateChangedObservable: Observable<WebXRState>;
  45090. /** Session manager used to keep track of xr session */
  45091. sessionManager: WebXRSessionManager;
  45092. /**
  45093. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45094. */
  45095. state: WebXRState;
  45096. /**
  45097. * Creates a WebXRExperienceHelper
  45098. * @param scene The scene the helper should be created in
  45099. */
  45100. private constructor();
  45101. /**
  45102. * Creates the experience helper
  45103. * @param scene the scene to attach the experience helper to
  45104. * @returns a promise for the experience helper
  45105. */
  45106. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45107. /**
  45108. * Disposes of the experience helper
  45109. */
  45110. dispose(): void;
  45111. /**
  45112. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45113. * @param sessionMode options for the XR session
  45114. * @param referenceSpaceType frame of reference of the XR session
  45115. * @param renderTarget the output canvas that will be used to enter XR mode
  45116. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45117. * @returns promise that resolves after xr mode has entered
  45118. */
  45119. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45120. /**
  45121. * Exits XR mode and returns the scene to its original state
  45122. * @returns promise that resolves after xr mode has exited
  45123. */
  45124. exitXRAsync(): Promise<void>;
  45125. private _nonXRToXRCamera;
  45126. private _setState;
  45127. }
  45128. }
  45129. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45130. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45131. import { Observable } from "babylonjs/Misc/observable";
  45132. import { IDisposable } from "babylonjs/scene";
  45133. /**
  45134. * X-Y values for axes in WebXR
  45135. */
  45136. export interface IWebXRMotionControllerAxesValue {
  45137. /**
  45138. * The value of the x axis
  45139. */
  45140. x: number;
  45141. /**
  45142. * The value of the y-axis
  45143. */
  45144. y: number;
  45145. }
  45146. /**
  45147. * changed / previous values for the values of this component
  45148. */
  45149. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45150. /**
  45151. * current (this frame) value
  45152. */
  45153. current: T;
  45154. /**
  45155. * previous (last change) value
  45156. */
  45157. previous: T;
  45158. }
  45159. /**
  45160. * Represents changes in the component between current frame and last values recorded
  45161. */
  45162. export interface IWebXRMotionControllerComponentChanges {
  45163. /**
  45164. * will be populated with previous and current values if axes changed
  45165. */
  45166. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45167. /**
  45168. * will be populated with previous and current values if pressed changed
  45169. */
  45170. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45171. /**
  45172. * will be populated with previous and current values if touched changed
  45173. */
  45174. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45175. /**
  45176. * will be populated with previous and current values if value changed
  45177. */
  45178. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45179. }
  45180. /**
  45181. * This class represents a single component (for example button or thumbstick) of a motion controller
  45182. */
  45183. export class WebXRControllerComponent implements IDisposable {
  45184. /**
  45185. * the id of this component
  45186. */
  45187. id: string;
  45188. /**
  45189. * the type of the component
  45190. */
  45191. type: MotionControllerComponentType;
  45192. private _buttonIndex;
  45193. private _axesIndices;
  45194. private _axes;
  45195. private _changes;
  45196. private _currentValue;
  45197. private _hasChanges;
  45198. private _pressed;
  45199. private _touched;
  45200. /**
  45201. * button component type
  45202. */
  45203. static BUTTON_TYPE: MotionControllerComponentType;
  45204. /**
  45205. * squeeze component type
  45206. */
  45207. static SQUEEZE_TYPE: MotionControllerComponentType;
  45208. /**
  45209. * Thumbstick component type
  45210. */
  45211. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45212. /**
  45213. * Touchpad component type
  45214. */
  45215. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45216. /**
  45217. * trigger component type
  45218. */
  45219. static TRIGGER_TYPE: MotionControllerComponentType;
  45220. /**
  45221. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45222. * the axes data changes
  45223. */
  45224. onAxisValueChangedObservable: Observable<{
  45225. x: number;
  45226. y: number;
  45227. }>;
  45228. /**
  45229. * Observers registered here will be triggered when the state of a button changes
  45230. * State change is either pressed / touched / value
  45231. */
  45232. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45233. /**
  45234. * Creates a new component for a motion controller.
  45235. * It is created by the motion controller itself
  45236. *
  45237. * @param id the id of this component
  45238. * @param type the type of the component
  45239. * @param _buttonIndex index in the buttons array of the gamepad
  45240. * @param _axesIndices indices of the values in the axes array of the gamepad
  45241. */
  45242. constructor(
  45243. /**
  45244. * the id of this component
  45245. */
  45246. id: string,
  45247. /**
  45248. * the type of the component
  45249. */
  45250. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45251. /**
  45252. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45253. */
  45254. get axes(): IWebXRMotionControllerAxesValue;
  45255. /**
  45256. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45257. */
  45258. get changes(): IWebXRMotionControllerComponentChanges;
  45259. /**
  45260. * Return whether or not the component changed the last frame
  45261. */
  45262. get hasChanges(): boolean;
  45263. /**
  45264. * is the button currently pressed
  45265. */
  45266. get pressed(): boolean;
  45267. /**
  45268. * is the button currently touched
  45269. */
  45270. get touched(): boolean;
  45271. /**
  45272. * Get the current value of this component
  45273. */
  45274. get value(): number;
  45275. /**
  45276. * Dispose this component
  45277. */
  45278. dispose(): void;
  45279. /**
  45280. * Are there axes correlating to this component
  45281. * @return true is axes data is available
  45282. */
  45283. isAxes(): boolean;
  45284. /**
  45285. * Is this component a button (hence - pressable)
  45286. * @returns true if can be pressed
  45287. */
  45288. isButton(): boolean;
  45289. /**
  45290. * update this component using the gamepad object it is in. Called on every frame
  45291. * @param nativeController the native gamepad controller object
  45292. */
  45293. update(nativeController: IMinimalMotionControllerObject): void;
  45294. }
  45295. }
  45296. declare module "babylonjs/Loading/sceneLoader" {
  45297. import { Observable } from "babylonjs/Misc/observable";
  45298. import { Nullable } from "babylonjs/types";
  45299. import { Scene } from "babylonjs/scene";
  45300. import { Engine } from "babylonjs/Engines/engine";
  45301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45302. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45303. import { AssetContainer } from "babylonjs/assetContainer";
  45304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45305. import { Skeleton } from "babylonjs/Bones/skeleton";
  45306. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45307. import { WebRequest } from "babylonjs/Misc/webRequest";
  45308. /**
  45309. * Class used to represent data loading progression
  45310. */
  45311. export class SceneLoaderProgressEvent {
  45312. /** defines if data length to load can be evaluated */
  45313. readonly lengthComputable: boolean;
  45314. /** defines the loaded data length */
  45315. readonly loaded: number;
  45316. /** defines the data length to load */
  45317. readonly total: number;
  45318. /**
  45319. * Create a new progress event
  45320. * @param lengthComputable defines if data length to load can be evaluated
  45321. * @param loaded defines the loaded data length
  45322. * @param total defines the data length to load
  45323. */
  45324. constructor(
  45325. /** defines if data length to load can be evaluated */
  45326. lengthComputable: boolean,
  45327. /** defines the loaded data length */
  45328. loaded: number,
  45329. /** defines the data length to load */
  45330. total: number);
  45331. /**
  45332. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45333. * @param event defines the source event
  45334. * @returns a new SceneLoaderProgressEvent
  45335. */
  45336. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45337. }
  45338. /**
  45339. * Interface used by SceneLoader plugins to define supported file extensions
  45340. */
  45341. export interface ISceneLoaderPluginExtensions {
  45342. /**
  45343. * Defines the list of supported extensions
  45344. */
  45345. [extension: string]: {
  45346. isBinary: boolean;
  45347. };
  45348. }
  45349. /**
  45350. * Interface used by SceneLoader plugin factory
  45351. */
  45352. export interface ISceneLoaderPluginFactory {
  45353. /**
  45354. * Defines the name of the factory
  45355. */
  45356. name: string;
  45357. /**
  45358. * Function called to create a new plugin
  45359. * @return the new plugin
  45360. */
  45361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45362. /**
  45363. * The callback that returns true if the data can be directly loaded.
  45364. * @param data string containing the file data
  45365. * @returns if the data can be loaded directly
  45366. */
  45367. canDirectLoad?(data: string): boolean;
  45368. }
  45369. /**
  45370. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45371. */
  45372. export interface ISceneLoaderPluginBase {
  45373. /**
  45374. * The friendly name of this plugin.
  45375. */
  45376. name: string;
  45377. /**
  45378. * The file extensions supported by this plugin.
  45379. */
  45380. extensions: string | ISceneLoaderPluginExtensions;
  45381. /**
  45382. * The callback called when loading from a url.
  45383. * @param scene scene loading this url
  45384. * @param url url to load
  45385. * @param onSuccess callback called when the file successfully loads
  45386. * @param onProgress callback called while file is loading (if the server supports this mode)
  45387. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45388. * @param onError callback called when the file fails to load
  45389. * @returns a file request object
  45390. */
  45391. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45392. /**
  45393. * The callback called when loading from a file object.
  45394. * @param scene scene loading this file
  45395. * @param file defines the file to load
  45396. * @param onSuccess defines the callback to call when data is loaded
  45397. * @param onProgress defines the callback to call during loading process
  45398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45399. * @param onError defines the callback to call when an error occurs
  45400. * @returns a file request object
  45401. */
  45402. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45403. /**
  45404. * The callback that returns true if the data can be directly loaded.
  45405. * @param data string containing the file data
  45406. * @returns if the data can be loaded directly
  45407. */
  45408. canDirectLoad?(data: string): boolean;
  45409. /**
  45410. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45411. * @param scene scene loading this data
  45412. * @param data string containing the data
  45413. * @returns data to pass to the plugin
  45414. */
  45415. directLoad?(scene: Scene, data: string): any;
  45416. /**
  45417. * The callback that allows custom handling of the root url based on the response url.
  45418. * @param rootUrl the original root url
  45419. * @param responseURL the response url if available
  45420. * @returns the new root url
  45421. */
  45422. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45423. }
  45424. /**
  45425. * Interface used to define a SceneLoader plugin
  45426. */
  45427. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45428. /**
  45429. * Import meshes into a scene.
  45430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45431. * @param scene The scene to import into
  45432. * @param data The data to import
  45433. * @param rootUrl The root url for scene and resources
  45434. * @param meshes The meshes array to import into
  45435. * @param particleSystems The particle systems array to import into
  45436. * @param skeletons The skeletons array to import into
  45437. * @param onError The callback when import fails
  45438. * @returns True if successful or false otherwise
  45439. */
  45440. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45441. /**
  45442. * Load into a scene.
  45443. * @param scene The scene to load into
  45444. * @param data The data to import
  45445. * @param rootUrl The root url for scene and resources
  45446. * @param onError The callback when import fails
  45447. * @returns True if successful or false otherwise
  45448. */
  45449. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45450. /**
  45451. * Load into an asset container.
  45452. * @param scene The scene to load into
  45453. * @param data The data to import
  45454. * @param rootUrl The root url for scene and resources
  45455. * @param onError The callback when import fails
  45456. * @returns The loaded asset container
  45457. */
  45458. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45459. }
  45460. /**
  45461. * Interface used to define an async SceneLoader plugin
  45462. */
  45463. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45464. /**
  45465. * Import meshes into a scene.
  45466. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45467. * @param scene The scene to import into
  45468. * @param data The data to import
  45469. * @param rootUrl The root url for scene and resources
  45470. * @param onProgress The callback when the load progresses
  45471. * @param fileName Defines the name of the file to load
  45472. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45473. */
  45474. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45475. meshes: AbstractMesh[];
  45476. particleSystems: IParticleSystem[];
  45477. skeletons: Skeleton[];
  45478. animationGroups: AnimationGroup[];
  45479. }>;
  45480. /**
  45481. * Load into a scene.
  45482. * @param scene The scene to load into
  45483. * @param data The data to import
  45484. * @param rootUrl The root url for scene and resources
  45485. * @param onProgress The callback when the load progresses
  45486. * @param fileName Defines the name of the file to load
  45487. * @returns Nothing
  45488. */
  45489. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45490. /**
  45491. * Load into an asset container.
  45492. * @param scene The scene to load into
  45493. * @param data The data to import
  45494. * @param rootUrl The root url for scene and resources
  45495. * @param onProgress The callback when the load progresses
  45496. * @param fileName Defines the name of the file to load
  45497. * @returns The loaded asset container
  45498. */
  45499. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45500. }
  45501. /**
  45502. * Mode that determines how to handle old animation groups before loading new ones.
  45503. */
  45504. export enum SceneLoaderAnimationGroupLoadingMode {
  45505. /**
  45506. * Reset all old animations to initial state then dispose them.
  45507. */
  45508. Clean = 0,
  45509. /**
  45510. * Stop all old animations.
  45511. */
  45512. Stop = 1,
  45513. /**
  45514. * Restart old animations from first frame.
  45515. */
  45516. Sync = 2,
  45517. /**
  45518. * Old animations remains untouched.
  45519. */
  45520. NoSync = 3
  45521. }
  45522. /**
  45523. * Class used to load scene from various file formats using registered plugins
  45524. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45525. */
  45526. export class SceneLoader {
  45527. /**
  45528. * No logging while loading
  45529. */
  45530. static readonly NO_LOGGING: number;
  45531. /**
  45532. * Minimal logging while loading
  45533. */
  45534. static readonly MINIMAL_LOGGING: number;
  45535. /**
  45536. * Summary logging while loading
  45537. */
  45538. static readonly SUMMARY_LOGGING: number;
  45539. /**
  45540. * Detailled logging while loading
  45541. */
  45542. static readonly DETAILED_LOGGING: number;
  45543. /**
  45544. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45545. */
  45546. static get ForceFullSceneLoadingForIncremental(): boolean;
  45547. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45548. /**
  45549. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45550. */
  45551. static get ShowLoadingScreen(): boolean;
  45552. static set ShowLoadingScreen(value: boolean);
  45553. /**
  45554. * Defines the current logging level (while loading the scene)
  45555. * @ignorenaming
  45556. */
  45557. static get loggingLevel(): number;
  45558. static set loggingLevel(value: number);
  45559. /**
  45560. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45561. */
  45562. static get CleanBoneMatrixWeights(): boolean;
  45563. static set CleanBoneMatrixWeights(value: boolean);
  45564. /**
  45565. * Event raised when a plugin is used to load a scene
  45566. */
  45567. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45568. private static _registeredPlugins;
  45569. private static _getDefaultPlugin;
  45570. private static _getPluginForExtension;
  45571. private static _getPluginForDirectLoad;
  45572. private static _getPluginForFilename;
  45573. private static _getDirectLoad;
  45574. private static _loadData;
  45575. private static _getFileInfo;
  45576. /**
  45577. * Gets a plugin that can load the given extension
  45578. * @param extension defines the extension to load
  45579. * @returns a plugin or null if none works
  45580. */
  45581. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45582. /**
  45583. * Gets a boolean indicating that the given extension can be loaded
  45584. * @param extension defines the extension to load
  45585. * @returns true if the extension is supported
  45586. */
  45587. static IsPluginForExtensionAvailable(extension: string): boolean;
  45588. /**
  45589. * Adds a new plugin to the list of registered plugins
  45590. * @param plugin defines the plugin to add
  45591. */
  45592. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45593. /**
  45594. * Import meshes into a scene
  45595. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45596. * @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)
  45597. * @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)
  45598. * @param scene the instance of BABYLON.Scene to append to
  45599. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45600. * @param onProgress a callback with a progress event for each file being loaded
  45601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45602. * @param pluginExtension the extension used to determine the plugin
  45603. * @returns The loaded plugin
  45604. */
  45605. 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>;
  45606. /**
  45607. * Import meshes into a scene
  45608. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45609. * @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)
  45610. * @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)
  45611. * @param scene the instance of BABYLON.Scene to append to
  45612. * @param onProgress a callback with a progress event for each file being loaded
  45613. * @param pluginExtension the extension used to determine the plugin
  45614. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45615. */
  45616. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45617. meshes: AbstractMesh[];
  45618. particleSystems: IParticleSystem[];
  45619. skeletons: Skeleton[];
  45620. animationGroups: AnimationGroup[];
  45621. }>;
  45622. /**
  45623. * Load a scene
  45624. * @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)
  45625. * @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)
  45626. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45627. * @param onSuccess a callback with the scene when import succeeds
  45628. * @param onProgress a callback with a progress event for each file being loaded
  45629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45630. * @param pluginExtension the extension used to determine the plugin
  45631. * @returns The loaded plugin
  45632. */
  45633. 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>;
  45634. /**
  45635. * Load a scene
  45636. * @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)
  45637. * @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)
  45638. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45639. * @param onProgress a callback with a progress event for each file being loaded
  45640. * @param pluginExtension the extension used to determine the plugin
  45641. * @returns The loaded scene
  45642. */
  45643. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45644. /**
  45645. * Append a scene
  45646. * @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)
  45647. * @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)
  45648. * @param scene is the instance of BABYLON.Scene to append to
  45649. * @param onSuccess a callback with the scene when import succeeds
  45650. * @param onProgress a callback with a progress event for each file being loaded
  45651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45652. * @param pluginExtension the extension used to determine the plugin
  45653. * @returns The loaded plugin
  45654. */
  45655. 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>;
  45656. /**
  45657. * Append a scene
  45658. * @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)
  45659. * @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)
  45660. * @param scene is the instance of BABYLON.Scene to append to
  45661. * @param onProgress a callback with a progress event for each file being loaded
  45662. * @param pluginExtension the extension used to determine the plugin
  45663. * @returns The given scene
  45664. */
  45665. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45666. /**
  45667. * Load a scene into an asset container
  45668. * @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)
  45669. * @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)
  45670. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45671. * @param onSuccess a callback with the scene when import succeeds
  45672. * @param onProgress a callback with a progress event for each file being loaded
  45673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45674. * @param pluginExtension the extension used to determine the plugin
  45675. * @returns The loaded plugin
  45676. */
  45677. 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>;
  45678. /**
  45679. * Load a scene into an asset container
  45680. * @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)
  45681. * @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)
  45682. * @param scene is the instance of Scene to append to
  45683. * @param onProgress a callback with a progress event for each file being loaded
  45684. * @param pluginExtension the extension used to determine the plugin
  45685. * @returns The loaded asset container
  45686. */
  45687. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45688. /**
  45689. * Import animations from a file into a scene
  45690. * @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)
  45691. * @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)
  45692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45693. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45694. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45695. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45696. * @param onSuccess a callback with the scene when import succeeds
  45697. * @param onProgress a callback with a progress event for each file being loaded
  45698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45699. */
  45700. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45701. /**
  45702. * Import animations from a file into a scene
  45703. * @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)
  45704. * @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)
  45705. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45706. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45707. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45708. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45709. * @param onSuccess a callback with the scene when import succeeds
  45710. * @param onProgress a callback with a progress event for each file being loaded
  45711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45712. * @returns the updated scene with imported animations
  45713. */
  45714. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45715. }
  45716. }
  45717. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45718. import { IDisposable, Scene } from "babylonjs/scene";
  45719. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45720. import { Observable } from "babylonjs/Misc/observable";
  45721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45722. import { Nullable } from "babylonjs/types";
  45723. /**
  45724. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45725. */
  45726. export type MotionControllerHandedness = "none" | "left" | "right";
  45727. /**
  45728. * The type of components available in motion controllers.
  45729. * This is not the name of the component.
  45730. */
  45731. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45732. /**
  45733. * The state of a controller component
  45734. */
  45735. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45736. /**
  45737. * The schema of motion controller layout.
  45738. * No object will be initialized using this interface
  45739. * This is used just to define the profile.
  45740. */
  45741. export interface IMotionControllerLayout {
  45742. /**
  45743. * Path to load the assets. Usually relative to the base path
  45744. */
  45745. assetPath: string;
  45746. /**
  45747. * Available components (unsorted)
  45748. */
  45749. components: {
  45750. /**
  45751. * A map of component Ids
  45752. */
  45753. [componentId: string]: {
  45754. /**
  45755. * The type of input the component outputs
  45756. */
  45757. type: MotionControllerComponentType;
  45758. /**
  45759. * The indices of this component in the gamepad object
  45760. */
  45761. gamepadIndices: {
  45762. /**
  45763. * Index of button
  45764. */
  45765. button?: number;
  45766. /**
  45767. * If available, index of x-axis
  45768. */
  45769. xAxis?: number;
  45770. /**
  45771. * If available, index of y-axis
  45772. */
  45773. yAxis?: number;
  45774. };
  45775. /**
  45776. * The mesh's root node name
  45777. */
  45778. rootNodeName: string;
  45779. /**
  45780. * Animation definitions for this model
  45781. */
  45782. visualResponses: {
  45783. [stateKey: string]: {
  45784. /**
  45785. * What property will be animated
  45786. */
  45787. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45788. /**
  45789. * What states influence this visual response
  45790. */
  45791. states: MotionControllerComponentStateType[];
  45792. /**
  45793. * Type of animation - movement or visibility
  45794. */
  45795. valueNodeProperty: "transform" | "visibility";
  45796. /**
  45797. * Base node name to move. Its position will be calculated according to the min and max nodes
  45798. */
  45799. valueNodeName?: string;
  45800. /**
  45801. * Minimum movement node
  45802. */
  45803. minNodeName?: string;
  45804. /**
  45805. * Max movement node
  45806. */
  45807. maxNodeName?: string;
  45808. };
  45809. };
  45810. /**
  45811. * If touch enabled, what is the name of node to display user feedback
  45812. */
  45813. touchPointNodeName?: string;
  45814. };
  45815. };
  45816. /**
  45817. * Is it xr standard mapping or not
  45818. */
  45819. gamepadMapping: "" | "xr-standard";
  45820. /**
  45821. * Base root node of this entire model
  45822. */
  45823. rootNodeName: string;
  45824. /**
  45825. * Defines the main button component id
  45826. */
  45827. selectComponentId: string;
  45828. }
  45829. /**
  45830. * A definition for the layout map in the input profile
  45831. */
  45832. export interface IMotionControllerLayoutMap {
  45833. /**
  45834. * Layouts with handedness type as a key
  45835. */
  45836. [handedness: string]: IMotionControllerLayout;
  45837. }
  45838. /**
  45839. * The XR Input profile schema
  45840. * Profiles can be found here:
  45841. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45842. */
  45843. export interface IMotionControllerProfile {
  45844. /**
  45845. * fallback profiles for this profileId
  45846. */
  45847. fallbackProfileIds: string[];
  45848. /**
  45849. * The layout map, with handedness as key
  45850. */
  45851. layouts: IMotionControllerLayoutMap;
  45852. /**
  45853. * The id of this profile
  45854. * correlates to the profile(s) in the xrInput.profiles array
  45855. */
  45856. profileId: string;
  45857. }
  45858. /**
  45859. * A helper-interface for the 3 meshes needed for controller button animation
  45860. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45861. */
  45862. export interface IMotionControllerButtonMeshMap {
  45863. /**
  45864. * the mesh that defines the pressed value mesh position.
  45865. * This is used to find the max-position of this button
  45866. */
  45867. pressedMesh: AbstractMesh;
  45868. /**
  45869. * the mesh that defines the unpressed value mesh position.
  45870. * This is used to find the min (or initial) position of this button
  45871. */
  45872. unpressedMesh: AbstractMesh;
  45873. /**
  45874. * The mesh that will be changed when value changes
  45875. */
  45876. valueMesh: AbstractMesh;
  45877. }
  45878. /**
  45879. * A helper-interface for the 3 meshes needed for controller axis animation.
  45880. * This will be expanded when touchpad animations are fully supported
  45881. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45882. */
  45883. export interface IMotionControllerMeshMap {
  45884. /**
  45885. * the mesh that defines the maximum value mesh position.
  45886. */
  45887. maxMesh?: AbstractMesh;
  45888. /**
  45889. * the mesh that defines the minimum value mesh position.
  45890. */
  45891. minMesh?: AbstractMesh;
  45892. /**
  45893. * The mesh that will be changed when axis value changes
  45894. */
  45895. valueMesh: AbstractMesh;
  45896. }
  45897. /**
  45898. * The elements needed for change-detection of the gamepad objects in motion controllers
  45899. */
  45900. export interface IMinimalMotionControllerObject {
  45901. /**
  45902. * Available axes of this controller
  45903. */
  45904. axes: number[];
  45905. /**
  45906. * An array of available buttons
  45907. */
  45908. buttons: Array<{
  45909. /**
  45910. * Value of the button/trigger
  45911. */
  45912. value: number;
  45913. /**
  45914. * If the button/trigger is currently touched
  45915. */
  45916. touched: boolean;
  45917. /**
  45918. * If the button/trigger is currently pressed
  45919. */
  45920. pressed: boolean;
  45921. }>;
  45922. /**
  45923. * EXPERIMENTAL haptic support.
  45924. */
  45925. hapticActuators?: Array<{
  45926. pulse: (value: number, duration: number) => Promise<boolean>;
  45927. }>;
  45928. }
  45929. /**
  45930. * An Abstract Motion controller
  45931. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45932. * Each component has an observable to check for changes in value and state
  45933. */
  45934. export abstract class WebXRAbstractMotionController implements IDisposable {
  45935. protected scene: Scene;
  45936. protected layout: IMotionControllerLayout;
  45937. /**
  45938. * The gamepad object correlating to this controller
  45939. */
  45940. gamepadObject: IMinimalMotionControllerObject;
  45941. /**
  45942. * handedness (left/right/none) of this controller
  45943. */
  45944. handedness: MotionControllerHandedness;
  45945. private _initComponent;
  45946. private _modelReady;
  45947. /**
  45948. * A map of components (WebXRControllerComponent) in this motion controller
  45949. * Components have a ComponentType and can also have both button and axis definitions
  45950. */
  45951. readonly components: {
  45952. [id: string]: WebXRControllerComponent;
  45953. };
  45954. /**
  45955. * Disable the model's animation. Can be set at any time.
  45956. */
  45957. disableAnimation: boolean;
  45958. /**
  45959. * Observers registered here will be triggered when the model of this controller is done loading
  45960. */
  45961. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45962. /**
  45963. * The profile id of this motion controller
  45964. */
  45965. abstract profileId: string;
  45966. /**
  45967. * The root mesh of the model. It is null if the model was not yet initialized
  45968. */
  45969. rootMesh: Nullable<AbstractMesh>;
  45970. /**
  45971. * constructs a new abstract motion controller
  45972. * @param scene the scene to which the model of the controller will be added
  45973. * @param layout The profile layout to load
  45974. * @param gamepadObject The gamepad object correlating to this controller
  45975. * @param handedness handedness (left/right/none) of this controller
  45976. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45977. */
  45978. constructor(scene: Scene, layout: IMotionControllerLayout,
  45979. /**
  45980. * The gamepad object correlating to this controller
  45981. */
  45982. gamepadObject: IMinimalMotionControllerObject,
  45983. /**
  45984. * handedness (left/right/none) of this controller
  45985. */
  45986. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  45987. /**
  45988. * Dispose this controller, the model mesh and all its components
  45989. */
  45990. dispose(): void;
  45991. /**
  45992. * Returns all components of specific type
  45993. * @param type the type to search for
  45994. * @return an array of components with this type
  45995. */
  45996. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45997. /**
  45998. * get a component based an its component id as defined in layout.components
  45999. * @param id the id of the component
  46000. * @returns the component correlates to the id or undefined if not found
  46001. */
  46002. getComponent(id: string): WebXRControllerComponent;
  46003. /**
  46004. * Get the list of components available in this motion controller
  46005. * @returns an array of strings correlating to available components
  46006. */
  46007. getComponentIds(): string[];
  46008. /**
  46009. * Get the first component of specific type
  46010. * @param type type of component to find
  46011. * @return a controller component or null if not found
  46012. */
  46013. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46014. /**
  46015. * Get the main (Select) component of this controller as defined in the layout
  46016. * @returns the main component of this controller
  46017. */
  46018. getMainComponent(): WebXRControllerComponent;
  46019. /**
  46020. * Loads the model correlating to this controller
  46021. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46022. * @returns A promise fulfilled with the result of the model loading
  46023. */
  46024. loadModel(): Promise<boolean>;
  46025. /**
  46026. * Update this model using the current XRFrame
  46027. * @param xrFrame the current xr frame to use and update the model
  46028. */
  46029. updateFromXRFrame(xrFrame: XRFrame): void;
  46030. /**
  46031. * Backwards compatibility due to a deeply-integrated typo
  46032. */
  46033. get handness(): XREye;
  46034. /**
  46035. * Pulse (vibrate) this controller
  46036. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46037. * Consecutive calls to this function will cancel the last pulse call
  46038. *
  46039. * @param value the strength of the pulse in 0.0...1.0 range
  46040. * @param duration Duration of the pulse in milliseconds
  46041. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46042. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  46043. */
  46044. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46045. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46046. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46047. /**
  46048. * Moves the axis on the controller mesh based on its current state
  46049. * @param axis the index of the axis
  46050. * @param axisValue the value of the axis which determines the meshes new position
  46051. * @hidden
  46052. */
  46053. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46054. /**
  46055. * Update the model itself with the current frame data
  46056. * @param xrFrame the frame to use for updating the model mesh
  46057. */
  46058. protected updateModel(xrFrame: XRFrame): void;
  46059. /**
  46060. * Get the filename and path for this controller's model
  46061. * @returns a map of filename and path
  46062. */
  46063. protected abstract _getFilenameAndPath(): {
  46064. filename: string;
  46065. path: string;
  46066. };
  46067. /**
  46068. * This function is called before the mesh is loaded. It checks for loading constraints.
  46069. * For example, this function can check if the GLB loader is available
  46070. * If this function returns false, the generic controller will be loaded instead
  46071. * @returns Is the client ready to load the mesh
  46072. */
  46073. protected abstract _getModelLoadingConstraints(): boolean;
  46074. /**
  46075. * This function will be called after the model was successfully loaded and can be used
  46076. * for mesh transformations before it is available for the user
  46077. * @param meshes the loaded meshes
  46078. */
  46079. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46080. /**
  46081. * Set the root mesh for this controller. Important for the WebXR controller class
  46082. * @param meshes the loaded meshes
  46083. */
  46084. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46085. /**
  46086. * A function executed each frame that updates the mesh (if needed)
  46087. * @param xrFrame the current xrFrame
  46088. */
  46089. protected abstract _updateModel(xrFrame: XRFrame): void;
  46090. private _getGenericFilenameAndPath;
  46091. private _getGenericParentMesh;
  46092. }
  46093. }
  46094. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46095. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46097. import { Scene } from "babylonjs/scene";
  46098. /**
  46099. * A generic trigger-only motion controller for WebXR
  46100. */
  46101. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46102. /**
  46103. * Static version of the profile id of this controller
  46104. */
  46105. static ProfileId: string;
  46106. profileId: string;
  46107. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46108. protected _getFilenameAndPath(): {
  46109. filename: string;
  46110. path: string;
  46111. };
  46112. protected _getModelLoadingConstraints(): boolean;
  46113. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46114. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46115. protected _updateModel(): void;
  46116. }
  46117. }
  46118. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46119. import { Vector4 } from "babylonjs/Maths/math.vector";
  46120. import { Mesh } from "babylonjs/Meshes/mesh";
  46121. import { Scene } from "babylonjs/scene";
  46122. import { Nullable } from "babylonjs/types";
  46123. /**
  46124. * Class containing static functions to help procedurally build meshes
  46125. */
  46126. export class SphereBuilder {
  46127. /**
  46128. * Creates a sphere mesh
  46129. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46130. * * 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`)
  46131. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46132. * * 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
  46133. * * 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)
  46134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46137. * @param name defines the name of the mesh
  46138. * @param options defines the options used to create the mesh
  46139. * @param scene defines the hosting scene
  46140. * @returns the sphere mesh
  46141. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46142. */
  46143. static CreateSphere(name: string, options: {
  46144. segments?: number;
  46145. diameter?: number;
  46146. diameterX?: number;
  46147. diameterY?: number;
  46148. diameterZ?: number;
  46149. arc?: number;
  46150. slice?: number;
  46151. sideOrientation?: number;
  46152. frontUVs?: Vector4;
  46153. backUVs?: Vector4;
  46154. updatable?: boolean;
  46155. }, scene?: Nullable<Scene>): Mesh;
  46156. }
  46157. }
  46158. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46160. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46161. import { Scene } from "babylonjs/scene";
  46162. /**
  46163. * A profiled motion controller has its profile loaded from an online repository.
  46164. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46165. */
  46166. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46167. private _repositoryUrl;
  46168. private _buttonMeshMapping;
  46169. private _touchDots;
  46170. /**
  46171. * The profile ID of this controller. Will be populated when the controller initializes.
  46172. */
  46173. profileId: string;
  46174. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46175. dispose(): void;
  46176. protected _getFilenameAndPath(): {
  46177. filename: string;
  46178. path: string;
  46179. };
  46180. protected _getModelLoadingConstraints(): boolean;
  46181. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46182. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46183. protected _updateModel(_xrFrame: XRFrame): void;
  46184. }
  46185. }
  46186. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46187. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46188. import { Scene } from "babylonjs/scene";
  46189. /**
  46190. * A construction function type to create a new controller based on an xrInput object
  46191. */
  46192. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46193. /**
  46194. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46195. *
  46196. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46197. * it should be replaced with auto-loaded controllers.
  46198. *
  46199. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46200. */
  46201. export class WebXRMotionControllerManager {
  46202. private static _AvailableControllers;
  46203. private static _Fallbacks;
  46204. private static _ProfileLoadingPromises;
  46205. private static _ProfilesList;
  46206. /**
  46207. * The base URL of the online controller repository. Can be changed at any time.
  46208. */
  46209. static BaseRepositoryUrl: string;
  46210. /**
  46211. * Which repository gets priority - local or online
  46212. */
  46213. static PrioritizeOnlineRepository: boolean;
  46214. /**
  46215. * Use the online repository, or use only locally-defined controllers
  46216. */
  46217. static UseOnlineRepository: boolean;
  46218. /**
  46219. * Clear the cache used for profile loading and reload when requested again
  46220. */
  46221. static ClearProfilesCache(): void;
  46222. /**
  46223. * Register the default fallbacks.
  46224. * This function is called automatically when this file is imported.
  46225. */
  46226. static DefaultFallbacks(): void;
  46227. /**
  46228. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46229. * @param profileId the profile to which a fallback needs to be found
  46230. * @return an array with corresponding fallback profiles
  46231. */
  46232. static FindFallbackWithProfileId(profileId: string): string[];
  46233. /**
  46234. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46235. * The order of search:
  46236. *
  46237. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46238. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46239. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46240. * 4) return the generic trigger controller if none were found
  46241. *
  46242. * @param xrInput the xrInput to which a new controller is initialized
  46243. * @param scene the scene to which the model will be added
  46244. * @param forceProfile force a certain profile for this controller
  46245. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46246. */
  46247. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46248. /**
  46249. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46250. *
  46251. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46252. *
  46253. * @param type the profile type to register
  46254. * @param constructFunction the function to be called when loading this profile
  46255. */
  46256. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46257. /**
  46258. * Register a fallback to a specific profile.
  46259. * @param profileId the profileId that will receive the fallbacks
  46260. * @param fallbacks A list of fallback profiles
  46261. */
  46262. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46263. /**
  46264. * Will update the list of profiles available in the repository
  46265. * @return a promise that resolves to a map of profiles available online
  46266. */
  46267. static UpdateProfilesList(): Promise<{
  46268. [profile: string]: string;
  46269. }>;
  46270. private static _LoadProfileFromRepository;
  46271. private static _LoadProfilesFromAvailableControllers;
  46272. }
  46273. }
  46274. declare module "babylonjs/XR/webXRInputSource" {
  46275. import { Observable } from "babylonjs/Misc/observable";
  46276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46277. import { Ray } from "babylonjs/Culling/ray";
  46278. import { Scene } from "babylonjs/scene";
  46279. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46280. /**
  46281. * Configuration options for the WebXR controller creation
  46282. */
  46283. export interface IWebXRControllerOptions {
  46284. /**
  46285. * Should the controller mesh be animated when a user interacts with it
  46286. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46287. */
  46288. disableMotionControllerAnimation?: boolean;
  46289. /**
  46290. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46291. */
  46292. doNotLoadControllerMesh?: boolean;
  46293. /**
  46294. * Force a specific controller type for this controller.
  46295. * This can be used when creating your own profile or when testing different controllers
  46296. */
  46297. forceControllerProfile?: string;
  46298. /**
  46299. * Defines a rendering group ID for meshes that will be loaded.
  46300. * This is for the default controllers only.
  46301. */
  46302. renderingGroupId?: number;
  46303. }
  46304. /**
  46305. * Represents an XR controller
  46306. */
  46307. export class WebXRInputSource {
  46308. private _scene;
  46309. /** The underlying input source for the controller */
  46310. inputSource: XRInputSource;
  46311. private _options;
  46312. private _tmpQuaternion;
  46313. private _tmpVector;
  46314. private _uniqueId;
  46315. /**
  46316. * 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
  46317. */
  46318. grip?: AbstractMesh;
  46319. /**
  46320. * If available, this is the gamepad object related to this controller.
  46321. * Using this object it is possible to get click events and trackpad changes of the
  46322. * webxr controller that is currently being used.
  46323. */
  46324. motionController?: WebXRAbstractMotionController;
  46325. /**
  46326. * Event that fires when the controller is removed/disposed.
  46327. * The object provided as event data is this controller, after associated assets were disposed.
  46328. * uniqueId is still available.
  46329. */
  46330. onDisposeObservable: Observable<WebXRInputSource>;
  46331. /**
  46332. * Will be triggered when the mesh associated with the motion controller is done loading.
  46333. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46334. * A shortened version of controller -> motion controller -> on mesh loaded.
  46335. */
  46336. onMeshLoadedObservable: Observable<AbstractMesh>;
  46337. /**
  46338. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46339. */
  46340. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46341. /**
  46342. * Pointer which can be used to select objects or attach a visible laser to
  46343. */
  46344. pointer: AbstractMesh;
  46345. /**
  46346. * Creates the controller
  46347. * @see https://doc.babylonjs.com/how_to/webxr
  46348. * @param _scene the scene which the controller should be associated to
  46349. * @param inputSource the underlying input source for the controller
  46350. * @param _options options for this controller creation
  46351. */
  46352. constructor(_scene: Scene,
  46353. /** The underlying input source for the controller */
  46354. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46355. /**
  46356. * Get this controllers unique id
  46357. */
  46358. get uniqueId(): string;
  46359. /**
  46360. * Disposes of the object
  46361. */
  46362. dispose(): void;
  46363. /**
  46364. * Gets a world space ray coming from the pointer or grip
  46365. * @param result the resulting ray
  46366. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46367. */
  46368. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46369. /**
  46370. * Updates the controller pose based on the given XRFrame
  46371. * @param xrFrame xr frame to update the pose with
  46372. * @param referenceSpace reference space to use
  46373. */
  46374. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46375. }
  46376. }
  46377. declare module "babylonjs/XR/webXRInput" {
  46378. import { Observable } from "babylonjs/Misc/observable";
  46379. import { IDisposable } from "babylonjs/scene";
  46380. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46381. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46382. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46383. /**
  46384. * The schema for initialization options of the XR Input class
  46385. */
  46386. export interface IWebXRInputOptions {
  46387. /**
  46388. * If set to true no model will be automatically loaded
  46389. */
  46390. doNotLoadControllerMeshes?: boolean;
  46391. /**
  46392. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46393. * If not found, the xr input profile data will be used.
  46394. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46395. */
  46396. forceInputProfile?: string;
  46397. /**
  46398. * Do not send a request to the controller repository to load the profile.
  46399. *
  46400. * Instead, use the controllers available in babylon itself.
  46401. */
  46402. disableOnlineControllerRepository?: boolean;
  46403. /**
  46404. * A custom URL for the controllers repository
  46405. */
  46406. customControllersRepositoryURL?: string;
  46407. /**
  46408. * Should the controller model's components not move according to the user input
  46409. */
  46410. disableControllerAnimation?: boolean;
  46411. /**
  46412. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46413. */
  46414. controllerOptions?: IWebXRControllerOptions;
  46415. }
  46416. /**
  46417. * XR input used to track XR inputs such as controllers/rays
  46418. */
  46419. export class WebXRInput implements IDisposable {
  46420. /**
  46421. * the xr session manager for this session
  46422. */
  46423. xrSessionManager: WebXRSessionManager;
  46424. /**
  46425. * the WebXR camera for this session. Mainly used for teleportation
  46426. */
  46427. xrCamera: WebXRCamera;
  46428. private readonly options;
  46429. /**
  46430. * XR controllers being tracked
  46431. */
  46432. controllers: Array<WebXRInputSource>;
  46433. private _frameObserver;
  46434. private _sessionEndedObserver;
  46435. private _sessionInitObserver;
  46436. /**
  46437. * Event when a controller has been connected/added
  46438. */
  46439. onControllerAddedObservable: Observable<WebXRInputSource>;
  46440. /**
  46441. * Event when a controller has been removed/disconnected
  46442. */
  46443. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46444. /**
  46445. * Initializes the WebXRInput
  46446. * @param xrSessionManager the xr session manager for this session
  46447. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46448. * @param options = initialization options for this xr input
  46449. */
  46450. constructor(
  46451. /**
  46452. * the xr session manager for this session
  46453. */
  46454. xrSessionManager: WebXRSessionManager,
  46455. /**
  46456. * the WebXR camera for this session. Mainly used for teleportation
  46457. */
  46458. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46459. private _onInputSourcesChange;
  46460. private _addAndRemoveControllers;
  46461. /**
  46462. * Disposes of the object
  46463. */
  46464. dispose(): void;
  46465. }
  46466. }
  46467. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46468. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46469. import { Observable, EventState } from "babylonjs/Misc/observable";
  46470. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46471. /**
  46472. * This is the base class for all WebXR features.
  46473. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46474. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46475. */
  46476. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46477. protected _xrSessionManager: WebXRSessionManager;
  46478. private _attached;
  46479. private _removeOnDetach;
  46480. /**
  46481. * Should auto-attach be disabled?
  46482. */
  46483. disableAutoAttach: boolean;
  46484. /**
  46485. * Construct a new (abstract) WebXR feature
  46486. * @param _xrSessionManager the xr session manager for this feature
  46487. */
  46488. constructor(_xrSessionManager: WebXRSessionManager);
  46489. /**
  46490. * Is this feature attached
  46491. */
  46492. get attached(): boolean;
  46493. /**
  46494. * attach this feature
  46495. *
  46496. * @param force should attachment be forced (even when already attached)
  46497. * @returns true if successful, false is failed or already attached
  46498. */
  46499. attach(force?: boolean): boolean;
  46500. /**
  46501. * detach this feature.
  46502. *
  46503. * @returns true if successful, false if failed or already detached
  46504. */
  46505. detach(): boolean;
  46506. /**
  46507. * Dispose this feature and all of the resources attached
  46508. */
  46509. dispose(): void;
  46510. /**
  46511. * This is used to register callbacks that will automatically be removed when detach is called.
  46512. * @param observable the observable to which the observer will be attached
  46513. * @param callback the callback to register
  46514. */
  46515. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46516. /**
  46517. * Code in this function will be executed on each xrFrame received from the browser.
  46518. * This function will not execute after the feature is detached.
  46519. * @param _xrFrame the current frame
  46520. */
  46521. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46522. }
  46523. }
  46524. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46525. import { IDisposable, Scene } from "babylonjs/scene";
  46526. import { Nullable } from "babylonjs/types";
  46527. import { Observable } from "babylonjs/Misc/observable";
  46528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46529. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46530. import { Camera } from "babylonjs/Cameras/camera";
  46531. /**
  46532. * Renders a layer on top of an existing scene
  46533. */
  46534. export class UtilityLayerRenderer implements IDisposable {
  46535. /** the original scene that will be rendered on top of */
  46536. originalScene: Scene;
  46537. private _pointerCaptures;
  46538. private _lastPointerEvents;
  46539. private static _DefaultUtilityLayer;
  46540. private static _DefaultKeepDepthUtilityLayer;
  46541. private _sharedGizmoLight;
  46542. private _renderCamera;
  46543. /**
  46544. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46545. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46546. * @returns the camera that is used when rendering the utility layer
  46547. */
  46548. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46549. /**
  46550. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46551. * @param cam the camera that should be used when rendering the utility layer
  46552. */
  46553. setRenderCamera(cam: Nullable<Camera>): void;
  46554. /**
  46555. * @hidden
  46556. * Light which used by gizmos to get light shading
  46557. */
  46558. _getSharedGizmoLight(): HemisphericLight;
  46559. /**
  46560. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46561. */
  46562. pickUtilitySceneFirst: boolean;
  46563. /**
  46564. * 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)
  46565. */
  46566. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46567. /**
  46568. * 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)
  46569. */
  46570. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46571. /**
  46572. * The scene that is rendered on top of the original scene
  46573. */
  46574. utilityLayerScene: Scene;
  46575. /**
  46576. * If the utility layer should automatically be rendered on top of existing scene
  46577. */
  46578. shouldRender: boolean;
  46579. /**
  46580. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46581. */
  46582. onlyCheckPointerDownEvents: boolean;
  46583. /**
  46584. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46585. */
  46586. processAllEvents: boolean;
  46587. /**
  46588. * Observable raised when the pointer move from the utility layer scene to the main scene
  46589. */
  46590. onPointerOutObservable: Observable<number>;
  46591. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46592. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46593. private _afterRenderObserver;
  46594. private _sceneDisposeObserver;
  46595. private _originalPointerObserver;
  46596. /**
  46597. * Instantiates a UtilityLayerRenderer
  46598. * @param originalScene the original scene that will be rendered on top of
  46599. * @param handleEvents boolean indicating if the utility layer should handle events
  46600. */
  46601. constructor(
  46602. /** the original scene that will be rendered on top of */
  46603. originalScene: Scene, handleEvents?: boolean);
  46604. private _notifyObservers;
  46605. /**
  46606. * Renders the utility layers scene on top of the original scene
  46607. */
  46608. render(): void;
  46609. /**
  46610. * Disposes of the renderer
  46611. */
  46612. dispose(): void;
  46613. private _updateCamera;
  46614. }
  46615. }
  46616. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46617. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46619. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46620. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46621. import { Scene } from "babylonjs/scene";
  46622. import { Nullable } from "babylonjs/types";
  46623. import { Color3 } from "babylonjs/Maths/math.color";
  46624. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46625. /**
  46626. * Options interface for the pointer selection module
  46627. */
  46628. export interface IWebXRControllerPointerSelectionOptions {
  46629. /**
  46630. * if provided, this scene will be used to render meshes.
  46631. */
  46632. customUtilityLayerScene?: Scene;
  46633. /**
  46634. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  46635. * If not disabled, the last picked point will be used to execute a pointer up event
  46636. * If disabled, pointer up event will be triggered right after the pointer down event.
  46637. * Used in screen and gaze target ray mode only
  46638. */
  46639. disablePointerUpOnTouchOut: boolean;
  46640. /**
  46641. * For gaze mode (time to select instead of press)
  46642. */
  46643. forceGazeMode: boolean;
  46644. /**
  46645. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  46646. * to start a new countdown to the pointer down event.
  46647. * Defaults to 1.
  46648. */
  46649. gazeModePointerMovedFactor?: number;
  46650. /**
  46651. * Different button type to use instead of the main component
  46652. */
  46653. overrideButtonId?: string;
  46654. /**
  46655. * use this rendering group id for the meshes (optional)
  46656. */
  46657. renderingGroupId?: number;
  46658. /**
  46659. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46660. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46661. * 3000 means 3 seconds between pointing at something and selecting it
  46662. */
  46663. timeToSelect?: number;
  46664. /**
  46665. * Should meshes created here be added to a utility layer or the main scene
  46666. */
  46667. useUtilityLayer?: boolean;
  46668. /**
  46669. * the xr input to use with this pointer selection
  46670. */
  46671. xrInput: WebXRInput;
  46672. }
  46673. /**
  46674. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46675. */
  46676. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46677. private readonly _options;
  46678. private static _idCounter;
  46679. private _attachController;
  46680. private _controllers;
  46681. private _scene;
  46682. private _tmpVectorForPickCompare;
  46683. /**
  46684. * The module's name
  46685. */
  46686. static readonly Name: string;
  46687. /**
  46688. * The (Babylon) version of this module.
  46689. * This is an integer representing the implementation version.
  46690. * This number does not correspond to the WebXR specs version
  46691. */
  46692. static readonly Version: number;
  46693. /**
  46694. * Disable lighting on the laser pointer (so it will always be visible)
  46695. */
  46696. disablePointerLighting: boolean;
  46697. /**
  46698. * Disable lighting on the selection mesh (so it will always be visible)
  46699. */
  46700. disableSelectionMeshLighting: boolean;
  46701. /**
  46702. * Should the laser pointer be displayed
  46703. */
  46704. displayLaserPointer: boolean;
  46705. /**
  46706. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46707. */
  46708. displaySelectionMesh: boolean;
  46709. /**
  46710. * This color will be set to the laser pointer when selection is triggered
  46711. */
  46712. laserPointerPickedColor: Color3;
  46713. /**
  46714. * Default color of the laser pointer
  46715. */
  46716. lasterPointerDefaultColor: Color3;
  46717. /**
  46718. * default color of the selection ring
  46719. */
  46720. selectionMeshDefaultColor: Color3;
  46721. /**
  46722. * This color will be applied to the selection ring when selection is triggered
  46723. */
  46724. selectionMeshPickedColor: Color3;
  46725. /**
  46726. * Optional filter to be used for ray selection. This predicate shares behavior with
  46727. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46728. */
  46729. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46730. /**
  46731. * constructs a new background remover module
  46732. * @param _xrSessionManager the session manager for this module
  46733. * @param _options read-only options to be used in this module
  46734. */
  46735. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46736. /**
  46737. * attach this feature
  46738. * Will usually be called by the features manager
  46739. *
  46740. * @returns true if successful.
  46741. */
  46742. attach(): boolean;
  46743. /**
  46744. * detach this feature.
  46745. * Will usually be called by the features manager
  46746. *
  46747. * @returns true if successful.
  46748. */
  46749. detach(): boolean;
  46750. /**
  46751. * Will get the mesh under a specific pointer.
  46752. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46753. * @param controllerId the controllerId to check
  46754. * @returns The mesh under pointer or null if no mesh is under the pointer
  46755. */
  46756. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46757. /**
  46758. * Get the xr controller that correlates to the pointer id in the pointer event
  46759. *
  46760. * @param id the pointer id to search for
  46761. * @returns the controller that correlates to this id or null if not found
  46762. */
  46763. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46764. protected _onXRFrame(_xrFrame: XRFrame): void;
  46765. private _attachGazeMode;
  46766. private _attachScreenRayMode;
  46767. private _attachTrackedPointerRayMode;
  46768. private _convertNormalToDirectionOfRay;
  46769. private _detachController;
  46770. private _generateNewMeshPair;
  46771. private _pickingMoved;
  46772. private _updatePointerDistance;
  46773. }
  46774. }
  46775. declare module "babylonjs/XR/webXREnterExitUI" {
  46776. import { Nullable } from "babylonjs/types";
  46777. import { Observable } from "babylonjs/Misc/observable";
  46778. import { IDisposable, Scene } from "babylonjs/scene";
  46779. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46780. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46781. /**
  46782. * Button which can be used to enter a different mode of XR
  46783. */
  46784. export class WebXREnterExitUIButton {
  46785. /** button element */
  46786. element: HTMLElement;
  46787. /** XR initialization options for the button */
  46788. sessionMode: XRSessionMode;
  46789. /** Reference space type */
  46790. referenceSpaceType: XRReferenceSpaceType;
  46791. /**
  46792. * Creates a WebXREnterExitUIButton
  46793. * @param element button element
  46794. * @param sessionMode XR initialization session mode
  46795. * @param referenceSpaceType the type of reference space to be used
  46796. */
  46797. constructor(
  46798. /** button element */
  46799. element: HTMLElement,
  46800. /** XR initialization options for the button */
  46801. sessionMode: XRSessionMode,
  46802. /** Reference space type */
  46803. referenceSpaceType: XRReferenceSpaceType);
  46804. /**
  46805. * Extendable function which can be used to update the button's visuals when the state changes
  46806. * @param activeButton the current active button in the UI
  46807. */
  46808. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46809. }
  46810. /**
  46811. * Options to create the webXR UI
  46812. */
  46813. export class WebXREnterExitUIOptions {
  46814. /**
  46815. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46816. */
  46817. customButtons?: Array<WebXREnterExitUIButton>;
  46818. /**
  46819. * A reference space type to use when creating the default button.
  46820. * Default is local-floor
  46821. */
  46822. referenceSpaceType?: XRReferenceSpaceType;
  46823. /**
  46824. * Context to enter xr with
  46825. */
  46826. renderTarget?: Nullable<WebXRRenderTarget>;
  46827. /**
  46828. * A session mode to use when creating the default button.
  46829. * Default is immersive-vr
  46830. */
  46831. sessionMode?: XRSessionMode;
  46832. /**
  46833. * A list of optional features to init the session with
  46834. */
  46835. optionalFeatures?: string[];
  46836. }
  46837. /**
  46838. * UI to allow the user to enter/exit XR mode
  46839. */
  46840. export class WebXREnterExitUI implements IDisposable {
  46841. private scene;
  46842. /** version of the options passed to this UI */
  46843. options: WebXREnterExitUIOptions;
  46844. private _activeButton;
  46845. private _buttons;
  46846. private _overlay;
  46847. /**
  46848. * Fired every time the active button is changed.
  46849. *
  46850. * When xr is entered via a button that launches xr that button will be the callback parameter
  46851. *
  46852. * When exiting xr the callback parameter will be null)
  46853. */
  46854. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46855. /**
  46856. *
  46857. * @param scene babylon scene object to use
  46858. * @param options (read-only) version of the options passed to this UI
  46859. */
  46860. private constructor();
  46861. /**
  46862. * Creates UI to allow the user to enter/exit XR mode
  46863. * @param scene the scene to add the ui to
  46864. * @param helper the xr experience helper to enter/exit xr with
  46865. * @param options options to configure the UI
  46866. * @returns the created ui
  46867. */
  46868. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46869. /**
  46870. * Disposes of the XR UI component
  46871. */
  46872. dispose(): void;
  46873. private _updateButtons;
  46874. }
  46875. }
  46876. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46877. import { Vector3 } from "babylonjs/Maths/math.vector";
  46878. import { Color4 } from "babylonjs/Maths/math.color";
  46879. import { Nullable } from "babylonjs/types";
  46880. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46881. import { Scene } from "babylonjs/scene";
  46882. /**
  46883. * Class containing static functions to help procedurally build meshes
  46884. */
  46885. export class LinesBuilder {
  46886. /**
  46887. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46888. * * 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
  46889. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46890. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46891. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46892. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46893. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46894. * * 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
  46895. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46898. * @param name defines the name of the new line system
  46899. * @param options defines the options used to create the line system
  46900. * @param scene defines the hosting scene
  46901. * @returns a new line system mesh
  46902. */
  46903. static CreateLineSystem(name: string, options: {
  46904. lines: Vector3[][];
  46905. updatable?: boolean;
  46906. instance?: Nullable<LinesMesh>;
  46907. colors?: Nullable<Color4[][]>;
  46908. useVertexAlpha?: boolean;
  46909. }, scene: Nullable<Scene>): LinesMesh;
  46910. /**
  46911. * Creates a line mesh
  46912. * 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
  46913. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46914. * * The parameter `points` is an array successive Vector3
  46915. * * 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
  46916. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46917. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46918. * * When updating an instance, remember that only point positions can change, not the number of points
  46919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46921. * @param name defines the name of the new line system
  46922. * @param options defines the options used to create the line system
  46923. * @param scene defines the hosting scene
  46924. * @returns a new line mesh
  46925. */
  46926. static CreateLines(name: string, options: {
  46927. points: Vector3[];
  46928. updatable?: boolean;
  46929. instance?: Nullable<LinesMesh>;
  46930. colors?: Color4[];
  46931. useVertexAlpha?: boolean;
  46932. }, scene?: Nullable<Scene>): LinesMesh;
  46933. /**
  46934. * Creates a dashed line mesh
  46935. * * 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
  46936. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46937. * * The parameter `points` is an array successive Vector3
  46938. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46939. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46940. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46941. * * 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
  46942. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46943. * * When updating an instance, remember that only point positions can change, not the number of points
  46944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46945. * @param name defines the name of the mesh
  46946. * @param options defines the options used to create the mesh
  46947. * @param scene defines the hosting scene
  46948. * @returns the dashed line mesh
  46949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46950. */
  46951. static CreateDashedLines(name: string, options: {
  46952. points: Vector3[];
  46953. dashSize?: number;
  46954. gapSize?: number;
  46955. dashNb?: number;
  46956. updatable?: boolean;
  46957. instance?: LinesMesh;
  46958. useVertexAlpha?: boolean;
  46959. }, scene?: Nullable<Scene>): LinesMesh;
  46960. }
  46961. }
  46962. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46963. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46964. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46965. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46967. import { Vector3 } from "babylonjs/Maths/math.vector";
  46968. import { Material } from "babylonjs/Materials/material";
  46969. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46970. import { Scene } from "babylonjs/scene";
  46971. /**
  46972. * The options container for the teleportation module
  46973. */
  46974. export interface IWebXRTeleportationOptions {
  46975. /**
  46976. * if provided, this scene will be used to render meshes.
  46977. */
  46978. customUtilityLayerScene?: Scene;
  46979. /**
  46980. * Values to configure the default target mesh
  46981. */
  46982. defaultTargetMeshOptions?: {
  46983. /**
  46984. * Fill color of the teleportation area
  46985. */
  46986. teleportationFillColor?: string;
  46987. /**
  46988. * Border color for the teleportation area
  46989. */
  46990. teleportationBorderColor?: string;
  46991. /**
  46992. * Disable the mesh's animation sequence
  46993. */
  46994. disableAnimation?: boolean;
  46995. /**
  46996. * Disable lighting on the material or the ring and arrow
  46997. */
  46998. disableLighting?: boolean;
  46999. /**
  47000. * Override the default material of the torus and arrow
  47001. */
  47002. torusArrowMaterial?: Material;
  47003. };
  47004. /**
  47005. * A list of meshes to use as floor meshes.
  47006. * Meshes can be added and removed after initializing the feature using the
  47007. * addFloorMesh and removeFloorMesh functions
  47008. * If empty, rotation will still work
  47009. */
  47010. floorMeshes?: AbstractMesh[];
  47011. /**
  47012. * use this rendering group id for the meshes (optional)
  47013. */
  47014. renderingGroupId?: number;
  47015. /**
  47016. * Should teleportation move only to snap points
  47017. */
  47018. snapPointsOnly?: boolean;
  47019. /**
  47020. * An array of points to which the teleportation will snap to.
  47021. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47022. */
  47023. snapPositions?: Vector3[];
  47024. /**
  47025. * How close should the teleportation ray be in order to snap to position.
  47026. * Default to 0.8 units (meters)
  47027. */
  47028. snapToPositionRadius?: number;
  47029. /**
  47030. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47031. * If you want to support rotation, make sure your mesh has a direction indicator.
  47032. *
  47033. * When left untouched, the default mesh will be initialized.
  47034. */
  47035. teleportationTargetMesh?: AbstractMesh;
  47036. /**
  47037. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47038. */
  47039. timeToTeleport?: number;
  47040. /**
  47041. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47042. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47043. */
  47044. useMainComponentOnly?: boolean;
  47045. /**
  47046. * Should meshes created here be added to a utility layer or the main scene
  47047. */
  47048. useUtilityLayer?: boolean;
  47049. /**
  47050. * Babylon XR Input class for controller
  47051. */
  47052. xrInput: WebXRInput;
  47053. }
  47054. /**
  47055. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47056. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47057. * the input of the attached controllers.
  47058. */
  47059. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47060. private _options;
  47061. private _controllers;
  47062. private _currentTeleportationControllerId;
  47063. private _floorMeshes;
  47064. private _quadraticBezierCurve;
  47065. private _selectionFeature;
  47066. private _snapToPositions;
  47067. private _snappedToPoint;
  47068. private _teleportationRingMaterial?;
  47069. private _tmpRay;
  47070. private _tmpVector;
  47071. /**
  47072. * The module's name
  47073. */
  47074. static readonly Name: string;
  47075. /**
  47076. * The (Babylon) version of this module.
  47077. * This is an integer representing the implementation version.
  47078. * This number does not correspond to the webxr specs version
  47079. */
  47080. static readonly Version: number;
  47081. /**
  47082. * Is movement backwards enabled
  47083. */
  47084. backwardsMovementEnabled: boolean;
  47085. /**
  47086. * Distance to travel when moving backwards
  47087. */
  47088. backwardsTeleportationDistance: number;
  47089. /**
  47090. * The distance from the user to the inspection point in the direction of the controller
  47091. * A higher number will allow the user to move further
  47092. * defaults to 5 (meters, in xr units)
  47093. */
  47094. parabolicCheckRadius: number;
  47095. /**
  47096. * Should the module support parabolic ray on top of direct ray
  47097. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47098. * Very helpful when moving between floors / different heights
  47099. */
  47100. parabolicRayEnabled: boolean;
  47101. /**
  47102. * How much rotation should be applied when rotating right and left
  47103. */
  47104. rotationAngle: number;
  47105. /**
  47106. * Is rotation enabled when moving forward?
  47107. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47108. */
  47109. rotationEnabled: boolean;
  47110. /**
  47111. * constructs a new anchor system
  47112. * @param _xrSessionManager an instance of WebXRSessionManager
  47113. * @param _options configuration object for this feature
  47114. */
  47115. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47116. /**
  47117. * Get the snapPointsOnly flag
  47118. */
  47119. get snapPointsOnly(): boolean;
  47120. /**
  47121. * Sets the snapPointsOnly flag
  47122. * @param snapToPoints should teleportation be exclusively to snap points
  47123. */
  47124. set snapPointsOnly(snapToPoints: boolean);
  47125. /**
  47126. * Add a new mesh to the floor meshes array
  47127. * @param mesh the mesh to use as floor mesh
  47128. */
  47129. addFloorMesh(mesh: AbstractMesh): void;
  47130. /**
  47131. * Add a new snap-to point to fix teleportation to this position
  47132. * @param newSnapPoint The new Snap-To point
  47133. */
  47134. addSnapPoint(newSnapPoint: Vector3): void;
  47135. attach(): boolean;
  47136. detach(): boolean;
  47137. dispose(): void;
  47138. /**
  47139. * Remove a mesh from the floor meshes array
  47140. * @param mesh the mesh to remove
  47141. */
  47142. removeFloorMesh(mesh: AbstractMesh): void;
  47143. /**
  47144. * Remove a mesh from the floor meshes array using its name
  47145. * @param name the mesh name to remove
  47146. */
  47147. removeFloorMeshByName(name: string): void;
  47148. /**
  47149. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  47150. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47151. * @returns was the point found and removed or not
  47152. */
  47153. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47154. /**
  47155. * This function sets a selection feature that will be disabled when
  47156. * the forward ray is shown and will be reattached when hidden.
  47157. * This is used to remove the selection rays when moving.
  47158. * @param selectionFeature the feature to disable when forward movement is enabled
  47159. */
  47160. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47161. protected _onXRFrame(_xrFrame: XRFrame): void;
  47162. private _attachController;
  47163. private _createDefaultTargetMesh;
  47164. private _detachController;
  47165. private _findClosestSnapPointWithRadius;
  47166. private _setTargetMeshPosition;
  47167. private _setTargetMeshVisibility;
  47168. private _showParabolicPath;
  47169. private _teleportForward;
  47170. }
  47171. }
  47172. declare module "babylonjs/XR/webXRDefaultExperience" {
  47173. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47174. import { Scene } from "babylonjs/scene";
  47175. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47176. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47177. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47178. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47180. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47181. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47182. /**
  47183. * Options for the default xr helper
  47184. */
  47185. export class WebXRDefaultExperienceOptions {
  47186. /**
  47187. * Enable or disable default UI to enter XR
  47188. */
  47189. disableDefaultUI?: boolean;
  47190. /**
  47191. * Should teleportation not initialize. defaults to false.
  47192. */
  47193. disableTeleportation?: boolean;
  47194. /**
  47195. * Floor meshes that will be used for teleport
  47196. */
  47197. floorMeshes?: Array<AbstractMesh>;
  47198. /**
  47199. * If set to true, the first frame will not be used to reset position
  47200. * The first frame is mainly used when copying transformation from the old camera
  47201. * Mainly used in AR
  47202. */
  47203. ignoreNativeCameraTransformation?: boolean;
  47204. /**
  47205. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47206. */
  47207. inputOptions?: IWebXRInputOptions;
  47208. /**
  47209. * optional configuration for the output canvas
  47210. */
  47211. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47212. /**
  47213. * optional UI options. This can be used among other to change session mode and reference space type
  47214. */
  47215. uiOptions?: WebXREnterExitUIOptions;
  47216. /**
  47217. * When loading teleportation and pointer select, use stable versions instead of latest.
  47218. */
  47219. useStablePlugins?: boolean;
  47220. /**
  47221. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47222. */
  47223. renderingGroupId?: number;
  47224. /**
  47225. * A list of optional features to init the session with
  47226. * If set to true, all features we support will be added
  47227. */
  47228. optionalFeatures?: boolean | string[];
  47229. }
  47230. /**
  47231. * Default experience which provides a similar setup to the previous webVRExperience
  47232. */
  47233. export class WebXRDefaultExperience {
  47234. /**
  47235. * Base experience
  47236. */
  47237. baseExperience: WebXRExperienceHelper;
  47238. /**
  47239. * Enables ui for entering/exiting xr
  47240. */
  47241. enterExitUI: WebXREnterExitUI;
  47242. /**
  47243. * Input experience extension
  47244. */
  47245. input: WebXRInput;
  47246. /**
  47247. * Enables laser pointer and selection
  47248. */
  47249. pointerSelection: WebXRControllerPointerSelection;
  47250. /**
  47251. * Default target xr should render to
  47252. */
  47253. renderTarget: WebXRRenderTarget;
  47254. /**
  47255. * Enables teleportation
  47256. */
  47257. teleportation: WebXRMotionControllerTeleportation;
  47258. private constructor();
  47259. /**
  47260. * Creates the default xr experience
  47261. * @param scene scene
  47262. * @param options options for basic configuration
  47263. * @returns resulting WebXRDefaultExperience
  47264. */
  47265. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47266. /**
  47267. * DIsposes of the experience helper
  47268. */
  47269. dispose(): void;
  47270. }
  47271. }
  47272. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47273. import { Observable } from "babylonjs/Misc/observable";
  47274. import { Nullable } from "babylonjs/types";
  47275. import { Camera } from "babylonjs/Cameras/camera";
  47276. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47277. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47278. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47279. import { Scene } from "babylonjs/scene";
  47280. import { Vector3 } from "babylonjs/Maths/math.vector";
  47281. import { Color3 } from "babylonjs/Maths/math.color";
  47282. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47284. import { Mesh } from "babylonjs/Meshes/mesh";
  47285. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47286. import { EasingFunction } from "babylonjs/Animations/easing";
  47287. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47288. import "babylonjs/Meshes/Builders/groundBuilder";
  47289. import "babylonjs/Meshes/Builders/torusBuilder";
  47290. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47291. import "babylonjs/Gamepads/gamepadSceneComponent";
  47292. import "babylonjs/Animations/animatable";
  47293. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47294. /**
  47295. * Options to modify the vr teleportation behavior.
  47296. */
  47297. export interface VRTeleportationOptions {
  47298. /**
  47299. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47300. */
  47301. floorMeshName?: string;
  47302. /**
  47303. * A list of meshes to be used as the teleportation floor. (default: empty)
  47304. */
  47305. floorMeshes?: Mesh[];
  47306. /**
  47307. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47308. */
  47309. teleportationMode?: number;
  47310. /**
  47311. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47312. */
  47313. teleportationTime?: number;
  47314. /**
  47315. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47316. */
  47317. teleportationSpeed?: number;
  47318. /**
  47319. * The easing function used in the animation or null for Linear. (default CircleEase)
  47320. */
  47321. easingFunction?: EasingFunction;
  47322. }
  47323. /**
  47324. * Options to modify the vr experience helper's behavior.
  47325. */
  47326. export interface VRExperienceHelperOptions extends WebVROptions {
  47327. /**
  47328. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47329. */
  47330. createDeviceOrientationCamera?: boolean;
  47331. /**
  47332. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47333. */
  47334. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47335. /**
  47336. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47337. */
  47338. laserToggle?: boolean;
  47339. /**
  47340. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47341. */
  47342. floorMeshes?: Mesh[];
  47343. /**
  47344. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47345. */
  47346. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47347. /**
  47348. * Defines if WebXR should be used instead of WebVR (if available)
  47349. */
  47350. useXR?: boolean;
  47351. }
  47352. /**
  47353. * Event containing information after VR has been entered
  47354. */
  47355. export class OnAfterEnteringVRObservableEvent {
  47356. /**
  47357. * If entering vr was successful
  47358. */
  47359. success: boolean;
  47360. }
  47361. /**
  47362. * Helps to quickly add VR support to an existing scene.
  47363. * See http://doc.babylonjs.com/how_to/webvr_helper
  47364. */
  47365. export class VRExperienceHelper {
  47366. /** Options to modify the vr experience helper's behavior. */
  47367. webVROptions: VRExperienceHelperOptions;
  47368. private _scene;
  47369. private _position;
  47370. private _btnVR;
  47371. private _btnVRDisplayed;
  47372. private _webVRsupported;
  47373. private _webVRready;
  47374. private _webVRrequesting;
  47375. private _webVRpresenting;
  47376. private _hasEnteredVR;
  47377. private _fullscreenVRpresenting;
  47378. private _inputElement;
  47379. private _webVRCamera;
  47380. private _vrDeviceOrientationCamera;
  47381. private _deviceOrientationCamera;
  47382. private _existingCamera;
  47383. private _onKeyDown;
  47384. private _onVrDisplayPresentChange;
  47385. private _onVRDisplayChanged;
  47386. private _onVRRequestPresentStart;
  47387. private _onVRRequestPresentComplete;
  47388. /**
  47389. * 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)
  47390. */
  47391. enableGazeEvenWhenNoPointerLock: boolean;
  47392. /**
  47393. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47394. */
  47395. exitVROnDoubleTap: boolean;
  47396. /**
  47397. * Observable raised right before entering VR.
  47398. */
  47399. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47400. /**
  47401. * Observable raised when entering VR has completed.
  47402. */
  47403. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47404. /**
  47405. * Observable raised when exiting VR.
  47406. */
  47407. onExitingVRObservable: Observable<VRExperienceHelper>;
  47408. /**
  47409. * Observable raised when controller mesh is loaded.
  47410. */
  47411. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47412. /** Return this.onEnteringVRObservable
  47413. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47414. */
  47415. get onEnteringVR(): Observable<VRExperienceHelper>;
  47416. /** Return this.onExitingVRObservable
  47417. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47418. */
  47419. get onExitingVR(): Observable<VRExperienceHelper>;
  47420. /** Return this.onControllerMeshLoadedObservable
  47421. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47422. */
  47423. get onControllerMeshLoaded(): Observable<WebVRController>;
  47424. private _rayLength;
  47425. private _useCustomVRButton;
  47426. private _teleportationRequested;
  47427. private _teleportActive;
  47428. private _floorMeshName;
  47429. private _floorMeshesCollection;
  47430. private _teleportationMode;
  47431. private _teleportationTime;
  47432. private _teleportationSpeed;
  47433. private _teleportationEasing;
  47434. private _rotationAllowed;
  47435. private _teleportBackwardsVector;
  47436. private _teleportationTarget;
  47437. private _isDefaultTeleportationTarget;
  47438. private _postProcessMove;
  47439. private _teleportationFillColor;
  47440. private _teleportationBorderColor;
  47441. private _rotationAngle;
  47442. private _haloCenter;
  47443. private _cameraGazer;
  47444. private _padSensibilityUp;
  47445. private _padSensibilityDown;
  47446. private _leftController;
  47447. private _rightController;
  47448. private _gazeColor;
  47449. private _laserColor;
  47450. private _pickedLaserColor;
  47451. private _pickedGazeColor;
  47452. /**
  47453. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47454. */
  47455. onNewMeshSelected: Observable<AbstractMesh>;
  47456. /**
  47457. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47458. * This observable will provide the mesh and the controller used to select the mesh
  47459. */
  47460. onMeshSelectedWithController: Observable<{
  47461. mesh: AbstractMesh;
  47462. controller: WebVRController;
  47463. }>;
  47464. /**
  47465. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47466. */
  47467. onNewMeshPicked: Observable<PickingInfo>;
  47468. private _circleEase;
  47469. /**
  47470. * Observable raised before camera teleportation
  47471. */
  47472. onBeforeCameraTeleport: Observable<Vector3>;
  47473. /**
  47474. * Observable raised after camera teleportation
  47475. */
  47476. onAfterCameraTeleport: Observable<Vector3>;
  47477. /**
  47478. * Observable raised when current selected mesh gets unselected
  47479. */
  47480. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47481. private _raySelectionPredicate;
  47482. /**
  47483. * To be optionaly changed by user to define custom ray selection
  47484. */
  47485. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47486. /**
  47487. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47488. */
  47489. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47490. /**
  47491. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47492. */
  47493. teleportationEnabled: boolean;
  47494. private _defaultHeight;
  47495. private _teleportationInitialized;
  47496. private _interactionsEnabled;
  47497. private _interactionsRequested;
  47498. private _displayGaze;
  47499. private _displayLaserPointer;
  47500. /**
  47501. * The mesh used to display where the user is going to teleport.
  47502. */
  47503. get teleportationTarget(): Mesh;
  47504. /**
  47505. * Sets the mesh to be used to display where the user is going to teleport.
  47506. */
  47507. set teleportationTarget(value: Mesh);
  47508. /**
  47509. * 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
  47510. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47511. * See http://doc.babylonjs.com/resources/baking_transformations
  47512. */
  47513. get gazeTrackerMesh(): Mesh;
  47514. set gazeTrackerMesh(value: Mesh);
  47515. /**
  47516. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47517. */
  47518. updateGazeTrackerScale: boolean;
  47519. /**
  47520. * If the gaze trackers color should be updated when selecting meshes
  47521. */
  47522. updateGazeTrackerColor: boolean;
  47523. /**
  47524. * If the controller laser color should be updated when selecting meshes
  47525. */
  47526. updateControllerLaserColor: boolean;
  47527. /**
  47528. * The gaze tracking mesh corresponding to the left controller
  47529. */
  47530. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47531. /**
  47532. * The gaze tracking mesh corresponding to the right controller
  47533. */
  47534. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47535. /**
  47536. * If the ray of the gaze should be displayed.
  47537. */
  47538. get displayGaze(): boolean;
  47539. /**
  47540. * Sets if the ray of the gaze should be displayed.
  47541. */
  47542. set displayGaze(value: boolean);
  47543. /**
  47544. * If the ray of the LaserPointer should be displayed.
  47545. */
  47546. get displayLaserPointer(): boolean;
  47547. /**
  47548. * Sets if the ray of the LaserPointer should be displayed.
  47549. */
  47550. set displayLaserPointer(value: boolean);
  47551. /**
  47552. * The deviceOrientationCamera used as the camera when not in VR.
  47553. */
  47554. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47555. /**
  47556. * Based on the current WebVR support, returns the current VR camera used.
  47557. */
  47558. get currentVRCamera(): Nullable<Camera>;
  47559. /**
  47560. * The webVRCamera which is used when in VR.
  47561. */
  47562. get webVRCamera(): WebVRFreeCamera;
  47563. /**
  47564. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47565. */
  47566. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47567. /**
  47568. * The html button that is used to trigger entering into VR.
  47569. */
  47570. get vrButton(): Nullable<HTMLButtonElement>;
  47571. private get _teleportationRequestInitiated();
  47572. /**
  47573. * Defines whether or not Pointer lock should be requested when switching to
  47574. * full screen.
  47575. */
  47576. requestPointerLockOnFullScreen: boolean;
  47577. /**
  47578. * If asking to force XR, this will be populated with the default xr experience
  47579. */
  47580. xr: WebXRDefaultExperience;
  47581. /**
  47582. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47583. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47584. */
  47585. xrTestDone: boolean;
  47586. /**
  47587. * Instantiates a VRExperienceHelper.
  47588. * Helps to quickly add VR support to an existing scene.
  47589. * @param scene The scene the VRExperienceHelper belongs to.
  47590. * @param webVROptions Options to modify the vr experience helper's behavior.
  47591. */
  47592. constructor(scene: Scene,
  47593. /** Options to modify the vr experience helper's behavior. */
  47594. webVROptions?: VRExperienceHelperOptions);
  47595. private completeVRInit;
  47596. private _onDefaultMeshLoaded;
  47597. private _onResize;
  47598. private _onFullscreenChange;
  47599. /**
  47600. * Gets a value indicating if we are currently in VR mode.
  47601. */
  47602. get isInVRMode(): boolean;
  47603. private onVrDisplayPresentChange;
  47604. private onVRDisplayChanged;
  47605. private moveButtonToBottomRight;
  47606. private displayVRButton;
  47607. private updateButtonVisibility;
  47608. private _cachedAngularSensibility;
  47609. /**
  47610. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47611. * Otherwise, will use the fullscreen API.
  47612. */
  47613. enterVR(): void;
  47614. /**
  47615. * Attempt to exit VR, or fullscreen.
  47616. */
  47617. exitVR(): void;
  47618. /**
  47619. * The position of the vr experience helper.
  47620. */
  47621. get position(): Vector3;
  47622. /**
  47623. * Sets the position of the vr experience helper.
  47624. */
  47625. set position(value: Vector3);
  47626. /**
  47627. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47628. */
  47629. enableInteractions(): void;
  47630. private get _noControllerIsActive();
  47631. private beforeRender;
  47632. private _isTeleportationFloor;
  47633. /**
  47634. * Adds a floor mesh to be used for teleportation.
  47635. * @param floorMesh the mesh to be used for teleportation.
  47636. */
  47637. addFloorMesh(floorMesh: Mesh): void;
  47638. /**
  47639. * Removes a floor mesh from being used for teleportation.
  47640. * @param floorMesh the mesh to be removed.
  47641. */
  47642. removeFloorMesh(floorMesh: Mesh): void;
  47643. /**
  47644. * Enables interactions and teleportation using the VR controllers and gaze.
  47645. * @param vrTeleportationOptions options to modify teleportation behavior.
  47646. */
  47647. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47648. private _onNewGamepadConnected;
  47649. private _tryEnableInteractionOnController;
  47650. private _onNewGamepadDisconnected;
  47651. private _enableInteractionOnController;
  47652. private _checkTeleportWithRay;
  47653. private _checkRotate;
  47654. private _checkTeleportBackwards;
  47655. private _enableTeleportationOnController;
  47656. private _createTeleportationCircles;
  47657. private _displayTeleportationTarget;
  47658. private _hideTeleportationTarget;
  47659. private _rotateCamera;
  47660. private _moveTeleportationSelectorTo;
  47661. private _workingVector;
  47662. private _workingQuaternion;
  47663. private _workingMatrix;
  47664. /**
  47665. * Time Constant Teleportation Mode
  47666. */
  47667. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47668. /**
  47669. * Speed Constant Teleportation Mode
  47670. */
  47671. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47672. /**
  47673. * Teleports the users feet to the desired location
  47674. * @param location The location where the user's feet should be placed
  47675. */
  47676. teleportCamera(location: Vector3): void;
  47677. private _convertNormalToDirectionOfRay;
  47678. private _castRayAndSelectObject;
  47679. private _notifySelectedMeshUnselected;
  47680. /**
  47681. * Permanently set new colors for the laser pointer
  47682. * @param color the new laser color
  47683. * @param pickedColor the new laser color when picked mesh detected
  47684. */
  47685. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47686. /**
  47687. * Set lighting enabled / disabled on the laser pointer of both controllers
  47688. * @param enabled should the lighting be enabled on the laser pointer
  47689. */
  47690. setLaserLightingState(enabled?: boolean): void;
  47691. /**
  47692. * Permanently set new colors for the gaze pointer
  47693. * @param color the new gaze color
  47694. * @param pickedColor the new gaze color when picked mesh detected
  47695. */
  47696. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47697. /**
  47698. * Sets the color of the laser ray from the vr controllers.
  47699. * @param color new color for the ray.
  47700. */
  47701. changeLaserColor(color: Color3): void;
  47702. /**
  47703. * Sets the color of the ray from the vr headsets gaze.
  47704. * @param color new color for the ray.
  47705. */
  47706. changeGazeColor(color: Color3): void;
  47707. /**
  47708. * Exits VR and disposes of the vr experience helper
  47709. */
  47710. dispose(): void;
  47711. /**
  47712. * Gets the name of the VRExperienceHelper class
  47713. * @returns "VRExperienceHelper"
  47714. */
  47715. getClassName(): string;
  47716. }
  47717. }
  47718. declare module "babylonjs/Cameras/VR/index" {
  47719. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47720. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47721. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47722. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47723. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47724. export * from "babylonjs/Cameras/VR/webVRCamera";
  47725. }
  47726. declare module "babylonjs/Cameras/RigModes/index" {
  47727. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47728. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47729. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47730. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47731. }
  47732. declare module "babylonjs/Cameras/index" {
  47733. export * from "babylonjs/Cameras/Inputs/index";
  47734. export * from "babylonjs/Cameras/cameraInputsManager";
  47735. export * from "babylonjs/Cameras/camera";
  47736. export * from "babylonjs/Cameras/targetCamera";
  47737. export * from "babylonjs/Cameras/freeCamera";
  47738. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47739. export * from "babylonjs/Cameras/touchCamera";
  47740. export * from "babylonjs/Cameras/arcRotateCamera";
  47741. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47742. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47743. export * from "babylonjs/Cameras/flyCamera";
  47744. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47745. export * from "babylonjs/Cameras/followCamera";
  47746. export * from "babylonjs/Cameras/followCameraInputsManager";
  47747. export * from "babylonjs/Cameras/gamepadCamera";
  47748. export * from "babylonjs/Cameras/Stereoscopic/index";
  47749. export * from "babylonjs/Cameras/universalCamera";
  47750. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47751. export * from "babylonjs/Cameras/VR/index";
  47752. export * from "babylonjs/Cameras/RigModes/index";
  47753. }
  47754. declare module "babylonjs/Collisions/index" {
  47755. export * from "babylonjs/Collisions/collider";
  47756. export * from "babylonjs/Collisions/collisionCoordinator";
  47757. export * from "babylonjs/Collisions/pickingInfo";
  47758. export * from "babylonjs/Collisions/intersectionInfo";
  47759. export * from "babylonjs/Collisions/meshCollisionData";
  47760. }
  47761. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47762. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47763. import { Vector3 } from "babylonjs/Maths/math.vector";
  47764. import { Ray } from "babylonjs/Culling/ray";
  47765. import { Plane } from "babylonjs/Maths/math.plane";
  47766. /**
  47767. * Contains an array of blocks representing the octree
  47768. */
  47769. export interface IOctreeContainer<T> {
  47770. /**
  47771. * Blocks within the octree
  47772. */
  47773. blocks: Array<OctreeBlock<T>>;
  47774. }
  47775. /**
  47776. * Class used to store a cell in an octree
  47777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47778. */
  47779. export class OctreeBlock<T> {
  47780. /**
  47781. * Gets the content of the current block
  47782. */
  47783. entries: T[];
  47784. /**
  47785. * Gets the list of block children
  47786. */
  47787. blocks: Array<OctreeBlock<T>>;
  47788. private _depth;
  47789. private _maxDepth;
  47790. private _capacity;
  47791. private _minPoint;
  47792. private _maxPoint;
  47793. private _boundingVectors;
  47794. private _creationFunc;
  47795. /**
  47796. * Creates a new block
  47797. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47798. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47799. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47800. * @param depth defines the current depth of this block in the octree
  47801. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47802. * @param creationFunc defines a callback to call when an element is added to the block
  47803. */
  47804. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47805. /**
  47806. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47807. */
  47808. get capacity(): number;
  47809. /**
  47810. * Gets the minimum vector (in world space) of the block's bounding box
  47811. */
  47812. get minPoint(): Vector3;
  47813. /**
  47814. * Gets the maximum vector (in world space) of the block's bounding box
  47815. */
  47816. get maxPoint(): Vector3;
  47817. /**
  47818. * Add a new element to this block
  47819. * @param entry defines the element to add
  47820. */
  47821. addEntry(entry: T): void;
  47822. /**
  47823. * Remove an element from this block
  47824. * @param entry defines the element to remove
  47825. */
  47826. removeEntry(entry: T): void;
  47827. /**
  47828. * Add an array of elements to this block
  47829. * @param entries defines the array of elements to add
  47830. */
  47831. addEntries(entries: T[]): void;
  47832. /**
  47833. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47834. * @param frustumPlanes defines the frustum planes to test
  47835. * @param selection defines the array to store current content if selection is positive
  47836. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47837. */
  47838. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47839. /**
  47840. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47841. * @param sphereCenter defines the bounding sphere center
  47842. * @param sphereRadius defines the bounding sphere radius
  47843. * @param selection defines the array to store current content if selection is positive
  47844. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47845. */
  47846. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47847. /**
  47848. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47849. * @param ray defines the ray to test with
  47850. * @param selection defines the array to store current content if selection is positive
  47851. */
  47852. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47853. /**
  47854. * Subdivide the content into child blocks (this block will then be empty)
  47855. */
  47856. createInnerBlocks(): void;
  47857. /**
  47858. * @hidden
  47859. */
  47860. 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;
  47861. }
  47862. }
  47863. declare module "babylonjs/Culling/Octrees/octree" {
  47864. import { SmartArray } from "babylonjs/Misc/smartArray";
  47865. import { Vector3 } from "babylonjs/Maths/math.vector";
  47866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47868. import { Ray } from "babylonjs/Culling/ray";
  47869. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47870. import { Plane } from "babylonjs/Maths/math.plane";
  47871. /**
  47872. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47874. */
  47875. export class Octree<T> {
  47876. /** 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.) */
  47877. maxDepth: number;
  47878. /**
  47879. * Blocks within the octree containing objects
  47880. */
  47881. blocks: Array<OctreeBlock<T>>;
  47882. /**
  47883. * Content stored in the octree
  47884. */
  47885. dynamicContent: T[];
  47886. private _maxBlockCapacity;
  47887. private _selectionContent;
  47888. private _creationFunc;
  47889. /**
  47890. * Creates a octree
  47891. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47892. * @param creationFunc function to be used to instatiate the octree
  47893. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47894. * @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.)
  47895. */
  47896. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47897. /** 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.) */
  47898. maxDepth?: number);
  47899. /**
  47900. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47901. * @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);
  47902. * @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);
  47903. * @param entries meshes to be added to the octree blocks
  47904. */
  47905. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47906. /**
  47907. * Adds a mesh to the octree
  47908. * @param entry Mesh to add to the octree
  47909. */
  47910. addMesh(entry: T): void;
  47911. /**
  47912. * Remove an element from the octree
  47913. * @param entry defines the element to remove
  47914. */
  47915. removeMesh(entry: T): void;
  47916. /**
  47917. * Selects an array of meshes within the frustum
  47918. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47919. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47920. * @returns array of meshes within the frustum
  47921. */
  47922. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47923. /**
  47924. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47925. * @param sphereCenter defines the bounding sphere center
  47926. * @param sphereRadius defines the bounding sphere radius
  47927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47928. * @returns an array of objects that intersect the sphere
  47929. */
  47930. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47931. /**
  47932. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47933. * @param ray defines the ray to test with
  47934. * @returns array of intersected objects
  47935. */
  47936. intersectsRay(ray: Ray): SmartArray<T>;
  47937. /**
  47938. * Adds a mesh into the octree block if it intersects the block
  47939. */
  47940. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47941. /**
  47942. * Adds a submesh into the octree block if it intersects the block
  47943. */
  47944. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47945. }
  47946. }
  47947. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47948. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47949. import { Scene } from "babylonjs/scene";
  47950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47952. import { Ray } from "babylonjs/Culling/ray";
  47953. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47954. import { Collider } from "babylonjs/Collisions/collider";
  47955. module "babylonjs/scene" {
  47956. interface Scene {
  47957. /**
  47958. * @hidden
  47959. * Backing Filed
  47960. */
  47961. _selectionOctree: Octree<AbstractMesh>;
  47962. /**
  47963. * Gets the octree used to boost mesh selection (picking)
  47964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47965. */
  47966. selectionOctree: Octree<AbstractMesh>;
  47967. /**
  47968. * Creates or updates the octree used to boost selection (picking)
  47969. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47970. * @param maxCapacity defines the maximum capacity per leaf
  47971. * @param maxDepth defines the maximum depth of the octree
  47972. * @returns an octree of AbstractMesh
  47973. */
  47974. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47975. }
  47976. }
  47977. module "babylonjs/Meshes/abstractMesh" {
  47978. interface AbstractMesh {
  47979. /**
  47980. * @hidden
  47981. * Backing Field
  47982. */
  47983. _submeshesOctree: Octree<SubMesh>;
  47984. /**
  47985. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47986. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47987. * @param maxCapacity defines the maximum size of each block (64 by default)
  47988. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47989. * @returns the new octree
  47990. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47992. */
  47993. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47994. }
  47995. }
  47996. /**
  47997. * Defines the octree scene component responsible to manage any octrees
  47998. * in a given scene.
  47999. */
  48000. export class OctreeSceneComponent {
  48001. /**
  48002. * The component name help to identify the component in the list of scene components.
  48003. */
  48004. readonly name: string;
  48005. /**
  48006. * The scene the component belongs to.
  48007. */
  48008. scene: Scene;
  48009. /**
  48010. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48011. */
  48012. readonly checksIsEnabled: boolean;
  48013. /**
  48014. * Creates a new instance of the component for the given scene
  48015. * @param scene Defines the scene to register the component in
  48016. */
  48017. constructor(scene: Scene);
  48018. /**
  48019. * Registers the component in a given scene
  48020. */
  48021. register(): void;
  48022. /**
  48023. * Return the list of active meshes
  48024. * @returns the list of active meshes
  48025. */
  48026. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48027. /**
  48028. * Return the list of active sub meshes
  48029. * @param mesh The mesh to get the candidates sub meshes from
  48030. * @returns the list of active sub meshes
  48031. */
  48032. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48033. private _tempRay;
  48034. /**
  48035. * Return the list of sub meshes intersecting with a given local ray
  48036. * @param mesh defines the mesh to find the submesh for
  48037. * @param localRay defines the ray in local space
  48038. * @returns the list of intersecting sub meshes
  48039. */
  48040. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48041. /**
  48042. * Return the list of sub meshes colliding with a collider
  48043. * @param mesh defines the mesh to find the submesh for
  48044. * @param collider defines the collider to evaluate the collision against
  48045. * @returns the list of colliding sub meshes
  48046. */
  48047. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48048. /**
  48049. * Rebuilds the elements related to this component in case of
  48050. * context lost for instance.
  48051. */
  48052. rebuild(): void;
  48053. /**
  48054. * Disposes the component and the associated ressources.
  48055. */
  48056. dispose(): void;
  48057. }
  48058. }
  48059. declare module "babylonjs/Culling/Octrees/index" {
  48060. export * from "babylonjs/Culling/Octrees/octree";
  48061. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48062. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48063. }
  48064. declare module "babylonjs/Culling/index" {
  48065. export * from "babylonjs/Culling/boundingBox";
  48066. export * from "babylonjs/Culling/boundingInfo";
  48067. export * from "babylonjs/Culling/boundingSphere";
  48068. export * from "babylonjs/Culling/Octrees/index";
  48069. export * from "babylonjs/Culling/ray";
  48070. }
  48071. declare module "babylonjs/Gizmos/gizmo" {
  48072. import { Nullable } from "babylonjs/types";
  48073. import { IDisposable } from "babylonjs/scene";
  48074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48075. import { Mesh } from "babylonjs/Meshes/mesh";
  48076. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48077. /**
  48078. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48079. */
  48080. export class Gizmo implements IDisposable {
  48081. /** The utility layer the gizmo will be added to */
  48082. gizmoLayer: UtilityLayerRenderer;
  48083. /**
  48084. * The root mesh of the gizmo
  48085. */
  48086. _rootMesh: Mesh;
  48087. private _attachedMesh;
  48088. /**
  48089. * Ratio for the scale of the gizmo (Default: 1)
  48090. */
  48091. scaleRatio: number;
  48092. /**
  48093. * If a custom mesh has been set (Default: false)
  48094. */
  48095. protected _customMeshSet: boolean;
  48096. /**
  48097. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48098. * * When set, interactions will be enabled
  48099. */
  48100. get attachedMesh(): Nullable<AbstractMesh>;
  48101. set attachedMesh(value: Nullable<AbstractMesh>);
  48102. /**
  48103. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48104. * @param mesh The mesh to replace the default mesh of the gizmo
  48105. */
  48106. setCustomMesh(mesh: Mesh): void;
  48107. /**
  48108. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48109. */
  48110. updateGizmoRotationToMatchAttachedMesh: boolean;
  48111. /**
  48112. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48113. */
  48114. updateGizmoPositionToMatchAttachedMesh: boolean;
  48115. /**
  48116. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48117. */
  48118. updateScale: boolean;
  48119. protected _interactionsEnabled: boolean;
  48120. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48121. private _beforeRenderObserver;
  48122. private _tempVector;
  48123. /**
  48124. * Creates a gizmo
  48125. * @param gizmoLayer The utility layer the gizmo will be added to
  48126. */
  48127. constructor(
  48128. /** The utility layer the gizmo will be added to */
  48129. gizmoLayer?: UtilityLayerRenderer);
  48130. /**
  48131. * Updates the gizmo to match the attached mesh's position/rotation
  48132. */
  48133. protected _update(): void;
  48134. /**
  48135. * Disposes of the gizmo
  48136. */
  48137. dispose(): void;
  48138. }
  48139. }
  48140. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48141. import { Observable } from "babylonjs/Misc/observable";
  48142. import { Nullable } from "babylonjs/types";
  48143. import { Vector3 } from "babylonjs/Maths/math.vector";
  48144. import { Color3 } from "babylonjs/Maths/math.color";
  48145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48147. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48148. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48149. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48150. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48151. import { Scene } from "babylonjs/scene";
  48152. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48153. /**
  48154. * Single plane drag gizmo
  48155. */
  48156. export class PlaneDragGizmo extends Gizmo {
  48157. /**
  48158. * Drag behavior responsible for the gizmos dragging interactions
  48159. */
  48160. dragBehavior: PointerDragBehavior;
  48161. private _pointerObserver;
  48162. /**
  48163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48164. */
  48165. snapDistance: number;
  48166. /**
  48167. * Event that fires each time the gizmo snaps to a new location.
  48168. * * snapDistance is the the change in distance
  48169. */
  48170. onSnapObservable: Observable<{
  48171. snapDistance: number;
  48172. }>;
  48173. private _plane;
  48174. private _coloredMaterial;
  48175. private _hoverMaterial;
  48176. private _isEnabled;
  48177. private _parent;
  48178. /** @hidden */
  48179. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48180. /** @hidden */
  48181. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48182. /**
  48183. * Creates a PlaneDragGizmo
  48184. * @param gizmoLayer The utility layer the gizmo will be added to
  48185. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48186. * @param color The color of the gizmo
  48187. */
  48188. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48189. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48190. /**
  48191. * If the gizmo is enabled
  48192. */
  48193. set isEnabled(value: boolean);
  48194. get isEnabled(): boolean;
  48195. /**
  48196. * Disposes of the gizmo
  48197. */
  48198. dispose(): void;
  48199. }
  48200. }
  48201. declare module "babylonjs/Gizmos/positionGizmo" {
  48202. import { Observable } from "babylonjs/Misc/observable";
  48203. import { Nullable } from "babylonjs/types";
  48204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48205. import { Mesh } from "babylonjs/Meshes/mesh";
  48206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48207. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48208. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48209. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48210. /**
  48211. * Gizmo that enables dragging a mesh along 3 axis
  48212. */
  48213. export class PositionGizmo extends Gizmo {
  48214. /**
  48215. * Internal gizmo used for interactions on the x axis
  48216. */
  48217. xGizmo: AxisDragGizmo;
  48218. /**
  48219. * Internal gizmo used for interactions on the y axis
  48220. */
  48221. yGizmo: AxisDragGizmo;
  48222. /**
  48223. * Internal gizmo used for interactions on the z axis
  48224. */
  48225. zGizmo: AxisDragGizmo;
  48226. /**
  48227. * Internal gizmo used for interactions on the yz plane
  48228. */
  48229. xPlaneGizmo: PlaneDragGizmo;
  48230. /**
  48231. * Internal gizmo used for interactions on the xz plane
  48232. */
  48233. yPlaneGizmo: PlaneDragGizmo;
  48234. /**
  48235. * Internal gizmo used for interactions on the xy plane
  48236. */
  48237. zPlaneGizmo: PlaneDragGizmo;
  48238. /**
  48239. * private variables
  48240. */
  48241. private _meshAttached;
  48242. private _updateGizmoRotationToMatchAttachedMesh;
  48243. private _snapDistance;
  48244. private _scaleRatio;
  48245. /** Fires an event when any of it's sub gizmos are dragged */
  48246. onDragStartObservable: Observable<unknown>;
  48247. /** Fires an event when any of it's sub gizmos are released from dragging */
  48248. onDragEndObservable: Observable<unknown>;
  48249. /**
  48250. * If set to true, planar drag is enabled
  48251. */
  48252. private _planarGizmoEnabled;
  48253. get attachedMesh(): Nullable<AbstractMesh>;
  48254. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48255. /**
  48256. * Creates a PositionGizmo
  48257. * @param gizmoLayer The utility layer the gizmo will be added to
  48258. */
  48259. constructor(gizmoLayer?: UtilityLayerRenderer);
  48260. /**
  48261. * If the planar drag gizmo is enabled
  48262. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48263. */
  48264. set planarGizmoEnabled(value: boolean);
  48265. get planarGizmoEnabled(): boolean;
  48266. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48267. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48268. /**
  48269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48270. */
  48271. set snapDistance(value: number);
  48272. get snapDistance(): number;
  48273. /**
  48274. * Ratio for the scale of the gizmo (Default: 1)
  48275. */
  48276. set scaleRatio(value: number);
  48277. get scaleRatio(): number;
  48278. /**
  48279. * Disposes of the gizmo
  48280. */
  48281. dispose(): void;
  48282. /**
  48283. * CustomMeshes are not supported by this gizmo
  48284. * @param mesh The mesh to replace the default mesh of the gizmo
  48285. */
  48286. setCustomMesh(mesh: Mesh): void;
  48287. }
  48288. }
  48289. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48290. import { Observable } from "babylonjs/Misc/observable";
  48291. import { Nullable } from "babylonjs/types";
  48292. import { Vector3 } from "babylonjs/Maths/math.vector";
  48293. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48295. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48296. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48297. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48298. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48299. import { Scene } from "babylonjs/scene";
  48300. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48301. import { Color3 } from "babylonjs/Maths/math.color";
  48302. /**
  48303. * Single axis drag gizmo
  48304. */
  48305. export class AxisDragGizmo extends Gizmo {
  48306. /**
  48307. * Drag behavior responsible for the gizmos dragging interactions
  48308. */
  48309. dragBehavior: PointerDragBehavior;
  48310. private _pointerObserver;
  48311. /**
  48312. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48313. */
  48314. snapDistance: number;
  48315. /**
  48316. * Event that fires each time the gizmo snaps to a new location.
  48317. * * snapDistance is the the change in distance
  48318. */
  48319. onSnapObservable: Observable<{
  48320. snapDistance: number;
  48321. }>;
  48322. private _isEnabled;
  48323. private _parent;
  48324. private _arrow;
  48325. private _coloredMaterial;
  48326. private _hoverMaterial;
  48327. /** @hidden */
  48328. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48329. /** @hidden */
  48330. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48331. /**
  48332. * Creates an AxisDragGizmo
  48333. * @param gizmoLayer The utility layer the gizmo will be added to
  48334. * @param dragAxis The axis which the gizmo will be able to drag on
  48335. * @param color The color of the gizmo
  48336. */
  48337. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48338. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48339. /**
  48340. * If the gizmo is enabled
  48341. */
  48342. set isEnabled(value: boolean);
  48343. get isEnabled(): boolean;
  48344. /**
  48345. * Disposes of the gizmo
  48346. */
  48347. dispose(): void;
  48348. }
  48349. }
  48350. declare module "babylonjs/Debug/axesViewer" {
  48351. import { Vector3 } from "babylonjs/Maths/math.vector";
  48352. import { Nullable } from "babylonjs/types";
  48353. import { Scene } from "babylonjs/scene";
  48354. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48355. /**
  48356. * The Axes viewer will show 3 axes in a specific point in space
  48357. */
  48358. export class AxesViewer {
  48359. private _xAxis;
  48360. private _yAxis;
  48361. private _zAxis;
  48362. private _scaleLinesFactor;
  48363. private _instanced;
  48364. /**
  48365. * Gets the hosting scene
  48366. */
  48367. scene: Scene;
  48368. /**
  48369. * Gets or sets a number used to scale line length
  48370. */
  48371. scaleLines: number;
  48372. /** Gets the node hierarchy used to render x-axis */
  48373. get xAxis(): TransformNode;
  48374. /** Gets the node hierarchy used to render y-axis */
  48375. get yAxis(): TransformNode;
  48376. /** Gets the node hierarchy used to render z-axis */
  48377. get zAxis(): TransformNode;
  48378. /**
  48379. * Creates a new AxesViewer
  48380. * @param scene defines the hosting scene
  48381. * @param scaleLines defines a number used to scale line length (1 by default)
  48382. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48383. * @param xAxis defines the node hierarchy used to render the x-axis
  48384. * @param yAxis defines the node hierarchy used to render the y-axis
  48385. * @param zAxis defines the node hierarchy used to render the z-axis
  48386. */
  48387. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48388. /**
  48389. * Force the viewer to update
  48390. * @param position defines the position of the viewer
  48391. * @param xaxis defines the x axis of the viewer
  48392. * @param yaxis defines the y axis of the viewer
  48393. * @param zaxis defines the z axis of the viewer
  48394. */
  48395. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48396. /**
  48397. * Creates an instance of this axes viewer.
  48398. * @returns a new axes viewer with instanced meshes
  48399. */
  48400. createInstance(): AxesViewer;
  48401. /** Releases resources */
  48402. dispose(): void;
  48403. private static _SetRenderingGroupId;
  48404. }
  48405. }
  48406. declare module "babylonjs/Debug/boneAxesViewer" {
  48407. import { Nullable } from "babylonjs/types";
  48408. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48409. import { Vector3 } from "babylonjs/Maths/math.vector";
  48410. import { Mesh } from "babylonjs/Meshes/mesh";
  48411. import { Bone } from "babylonjs/Bones/bone";
  48412. import { Scene } from "babylonjs/scene";
  48413. /**
  48414. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48415. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48416. */
  48417. export class BoneAxesViewer extends AxesViewer {
  48418. /**
  48419. * Gets or sets the target mesh where to display the axes viewer
  48420. */
  48421. mesh: Nullable<Mesh>;
  48422. /**
  48423. * Gets or sets the target bone where to display the axes viewer
  48424. */
  48425. bone: Nullable<Bone>;
  48426. /** Gets current position */
  48427. pos: Vector3;
  48428. /** Gets direction of X axis */
  48429. xaxis: Vector3;
  48430. /** Gets direction of Y axis */
  48431. yaxis: Vector3;
  48432. /** Gets direction of Z axis */
  48433. zaxis: Vector3;
  48434. /**
  48435. * Creates a new BoneAxesViewer
  48436. * @param scene defines the hosting scene
  48437. * @param bone defines the target bone
  48438. * @param mesh defines the target mesh
  48439. * @param scaleLines defines a scaling factor for line length (1 by default)
  48440. */
  48441. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48442. /**
  48443. * Force the viewer to update
  48444. */
  48445. update(): void;
  48446. /** Releases resources */
  48447. dispose(): void;
  48448. }
  48449. }
  48450. declare module "babylonjs/Debug/debugLayer" {
  48451. import { Scene } from "babylonjs/scene";
  48452. /**
  48453. * Interface used to define scene explorer extensibility option
  48454. */
  48455. export interface IExplorerExtensibilityOption {
  48456. /**
  48457. * Define the option label
  48458. */
  48459. label: string;
  48460. /**
  48461. * Defines the action to execute on click
  48462. */
  48463. action: (entity: any) => void;
  48464. }
  48465. /**
  48466. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48467. */
  48468. export interface IExplorerExtensibilityGroup {
  48469. /**
  48470. * Defines a predicate to test if a given type mut be extended
  48471. */
  48472. predicate: (entity: any) => boolean;
  48473. /**
  48474. * Gets the list of options added to a type
  48475. */
  48476. entries: IExplorerExtensibilityOption[];
  48477. }
  48478. /**
  48479. * Interface used to define the options to use to create the Inspector
  48480. */
  48481. export interface IInspectorOptions {
  48482. /**
  48483. * Display in overlay mode (default: false)
  48484. */
  48485. overlay?: boolean;
  48486. /**
  48487. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48488. */
  48489. globalRoot?: HTMLElement;
  48490. /**
  48491. * Display the Scene explorer
  48492. */
  48493. showExplorer?: boolean;
  48494. /**
  48495. * Display the property inspector
  48496. */
  48497. showInspector?: boolean;
  48498. /**
  48499. * Display in embed mode (both panes on the right)
  48500. */
  48501. embedMode?: boolean;
  48502. /**
  48503. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48504. */
  48505. handleResize?: boolean;
  48506. /**
  48507. * Allow the panes to popup (default: true)
  48508. */
  48509. enablePopup?: boolean;
  48510. /**
  48511. * Allow the panes to be closed by users (default: true)
  48512. */
  48513. enableClose?: boolean;
  48514. /**
  48515. * Optional list of extensibility entries
  48516. */
  48517. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48518. /**
  48519. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48520. */
  48521. inspectorURL?: string;
  48522. /**
  48523. * Optional initial tab (default to DebugLayerTab.Properties)
  48524. */
  48525. initialTab?: DebugLayerTab;
  48526. }
  48527. module "babylonjs/scene" {
  48528. interface Scene {
  48529. /**
  48530. * @hidden
  48531. * Backing field
  48532. */
  48533. _debugLayer: DebugLayer;
  48534. /**
  48535. * Gets the debug layer (aka Inspector) associated with the scene
  48536. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48537. */
  48538. debugLayer: DebugLayer;
  48539. }
  48540. }
  48541. /**
  48542. * Enum of inspector action tab
  48543. */
  48544. export enum DebugLayerTab {
  48545. /**
  48546. * Properties tag (default)
  48547. */
  48548. Properties = 0,
  48549. /**
  48550. * Debug tab
  48551. */
  48552. Debug = 1,
  48553. /**
  48554. * Statistics tab
  48555. */
  48556. Statistics = 2,
  48557. /**
  48558. * Tools tab
  48559. */
  48560. Tools = 3,
  48561. /**
  48562. * Settings tab
  48563. */
  48564. Settings = 4
  48565. }
  48566. /**
  48567. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48568. * what is happening in your scene
  48569. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48570. */
  48571. export class DebugLayer {
  48572. /**
  48573. * Define the url to get the inspector script from.
  48574. * By default it uses the babylonjs CDN.
  48575. * @ignoreNaming
  48576. */
  48577. static InspectorURL: string;
  48578. private _scene;
  48579. private BJSINSPECTOR;
  48580. private _onPropertyChangedObservable?;
  48581. /**
  48582. * Observable triggered when a property is changed through the inspector.
  48583. */
  48584. get onPropertyChangedObservable(): any;
  48585. /**
  48586. * Instantiates a new debug layer.
  48587. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48588. * what is happening in your scene
  48589. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48590. * @param scene Defines the scene to inspect
  48591. */
  48592. constructor(scene: Scene);
  48593. /** Creates the inspector window. */
  48594. private _createInspector;
  48595. /**
  48596. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48597. * @param entity defines the entity to select
  48598. * @param lineContainerTitle defines the specific block to highlight
  48599. */
  48600. select(entity: any, lineContainerTitle?: string): void;
  48601. /** Get the inspector from bundle or global */
  48602. private _getGlobalInspector;
  48603. /**
  48604. * Get if the inspector is visible or not.
  48605. * @returns true if visible otherwise, false
  48606. */
  48607. isVisible(): boolean;
  48608. /**
  48609. * Hide the inspector and close its window.
  48610. */
  48611. hide(): void;
  48612. /**
  48613. * Update the scene in the inspector
  48614. */
  48615. setAsActiveScene(): void;
  48616. /**
  48617. * Launch the debugLayer.
  48618. * @param config Define the configuration of the inspector
  48619. * @return a promise fulfilled when the debug layer is visible
  48620. */
  48621. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48622. }
  48623. }
  48624. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48625. import { Nullable } from "babylonjs/types";
  48626. import { Scene } from "babylonjs/scene";
  48627. import { Vector4 } from "babylonjs/Maths/math.vector";
  48628. import { Color4 } from "babylonjs/Maths/math.color";
  48629. import { Mesh } from "babylonjs/Meshes/mesh";
  48630. /**
  48631. * Class containing static functions to help procedurally build meshes
  48632. */
  48633. export class BoxBuilder {
  48634. /**
  48635. * Creates a box mesh
  48636. * * The parameter `size` sets the size (float) of each box side (default 1)
  48637. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48638. * * 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)
  48639. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48643. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48644. * @param name defines the name of the mesh
  48645. * @param options defines the options used to create the mesh
  48646. * @param scene defines the hosting scene
  48647. * @returns the box mesh
  48648. */
  48649. static CreateBox(name: string, options: {
  48650. size?: number;
  48651. width?: number;
  48652. height?: number;
  48653. depth?: number;
  48654. faceUV?: Vector4[];
  48655. faceColors?: Color4[];
  48656. sideOrientation?: number;
  48657. frontUVs?: Vector4;
  48658. backUVs?: Vector4;
  48659. wrap?: boolean;
  48660. topBaseAt?: number;
  48661. bottomBaseAt?: number;
  48662. updatable?: boolean;
  48663. }, scene?: Nullable<Scene>): Mesh;
  48664. }
  48665. }
  48666. declare module "babylonjs/Debug/physicsViewer" {
  48667. import { Nullable } from "babylonjs/types";
  48668. import { Scene } from "babylonjs/scene";
  48669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48670. import { Mesh } from "babylonjs/Meshes/mesh";
  48671. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48672. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48673. /**
  48674. * Used to show the physics impostor around the specific mesh
  48675. */
  48676. export class PhysicsViewer {
  48677. /** @hidden */
  48678. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48679. /** @hidden */
  48680. protected _meshes: Array<Nullable<AbstractMesh>>;
  48681. /** @hidden */
  48682. protected _scene: Nullable<Scene>;
  48683. /** @hidden */
  48684. protected _numMeshes: number;
  48685. /** @hidden */
  48686. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48687. private _renderFunction;
  48688. private _utilityLayer;
  48689. private _debugBoxMesh;
  48690. private _debugSphereMesh;
  48691. private _debugCylinderMesh;
  48692. private _debugMaterial;
  48693. private _debugMeshMeshes;
  48694. /**
  48695. * Creates a new PhysicsViewer
  48696. * @param scene defines the hosting scene
  48697. */
  48698. constructor(scene: Scene);
  48699. /** @hidden */
  48700. protected _updateDebugMeshes(): void;
  48701. /**
  48702. * Renders a specified physic impostor
  48703. * @param impostor defines the impostor to render
  48704. * @param targetMesh defines the mesh represented by the impostor
  48705. * @returns the new debug mesh used to render the impostor
  48706. */
  48707. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48708. /**
  48709. * Hides a specified physic impostor
  48710. * @param impostor defines the impostor to hide
  48711. */
  48712. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48713. private _getDebugMaterial;
  48714. private _getDebugBoxMesh;
  48715. private _getDebugSphereMesh;
  48716. private _getDebugCylinderMesh;
  48717. private _getDebugMeshMesh;
  48718. private _getDebugMesh;
  48719. /** Releases all resources */
  48720. dispose(): void;
  48721. }
  48722. }
  48723. declare module "babylonjs/Debug/rayHelper" {
  48724. import { Nullable } from "babylonjs/types";
  48725. import { Ray } from "babylonjs/Culling/ray";
  48726. import { Vector3 } from "babylonjs/Maths/math.vector";
  48727. import { Color3 } from "babylonjs/Maths/math.color";
  48728. import { Scene } from "babylonjs/scene";
  48729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48730. import "babylonjs/Meshes/Builders/linesBuilder";
  48731. /**
  48732. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48733. * in order to better appreciate the issue one might have.
  48734. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48735. */
  48736. export class RayHelper {
  48737. /**
  48738. * Defines the ray we are currently tryin to visualize.
  48739. */
  48740. ray: Nullable<Ray>;
  48741. private _renderPoints;
  48742. private _renderLine;
  48743. private _renderFunction;
  48744. private _scene;
  48745. private _updateToMeshFunction;
  48746. private _attachedToMesh;
  48747. private _meshSpaceDirection;
  48748. private _meshSpaceOrigin;
  48749. /**
  48750. * Helper function to create a colored helper in a scene in one line.
  48751. * @param ray Defines the ray we are currently tryin to visualize
  48752. * @param scene Defines the scene the ray is used in
  48753. * @param color Defines the color we want to see the ray in
  48754. * @returns The newly created ray helper.
  48755. */
  48756. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48757. /**
  48758. * Instantiate a new ray helper.
  48759. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48760. * in order to better appreciate the issue one might have.
  48761. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48762. * @param ray Defines the ray we are currently tryin to visualize
  48763. */
  48764. constructor(ray: Ray);
  48765. /**
  48766. * Shows the ray we are willing to debug.
  48767. * @param scene Defines the scene the ray needs to be rendered in
  48768. * @param color Defines the color the ray needs to be rendered in
  48769. */
  48770. show(scene: Scene, color?: Color3): void;
  48771. /**
  48772. * Hides the ray we are debugging.
  48773. */
  48774. hide(): void;
  48775. private _render;
  48776. /**
  48777. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48778. * @param mesh Defines the mesh we want the helper attached to
  48779. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48780. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48781. * @param length Defines the length of the ray
  48782. */
  48783. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48784. /**
  48785. * Detach the ray helper from the mesh it has previously been attached to.
  48786. */
  48787. detachFromMesh(): void;
  48788. private _updateToMesh;
  48789. /**
  48790. * Dispose the helper and release its associated resources.
  48791. */
  48792. dispose(): void;
  48793. }
  48794. }
  48795. declare module "babylonjs/Debug/skeletonViewer" {
  48796. import { Color3 } from "babylonjs/Maths/math.color";
  48797. import { Scene } from "babylonjs/scene";
  48798. import { Nullable } from "babylonjs/types";
  48799. import { Skeleton } from "babylonjs/Bones/skeleton";
  48800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48801. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48802. /**
  48803. * Class used to render a debug view of a given skeleton
  48804. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48805. */
  48806. export class SkeletonViewer {
  48807. /** defines the skeleton to render */
  48808. skeleton: Skeleton;
  48809. /** defines the mesh attached to the skeleton */
  48810. mesh: AbstractMesh;
  48811. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48812. autoUpdateBonesMatrices: boolean;
  48813. /** defines the rendering group id to use with the viewer */
  48814. renderingGroupId: number;
  48815. /** Gets or sets the color used to render the skeleton */
  48816. color: Color3;
  48817. private _scene;
  48818. private _debugLines;
  48819. private _debugMesh;
  48820. private _isEnabled;
  48821. private _renderFunction;
  48822. private _utilityLayer;
  48823. /**
  48824. * Returns the mesh used to render the bones
  48825. */
  48826. get debugMesh(): Nullable<LinesMesh>;
  48827. /**
  48828. * Creates a new SkeletonViewer
  48829. * @param skeleton defines the skeleton to render
  48830. * @param mesh defines the mesh attached to the skeleton
  48831. * @param scene defines the hosting scene
  48832. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48833. * @param renderingGroupId defines the rendering group id to use with the viewer
  48834. */
  48835. constructor(
  48836. /** defines the skeleton to render */
  48837. skeleton: Skeleton,
  48838. /** defines the mesh attached to the skeleton */
  48839. mesh: AbstractMesh, scene: Scene,
  48840. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48841. autoUpdateBonesMatrices?: boolean,
  48842. /** defines the rendering group id to use with the viewer */
  48843. renderingGroupId?: number);
  48844. /** Gets or sets a boolean indicating if the viewer is enabled */
  48845. set isEnabled(value: boolean);
  48846. get isEnabled(): boolean;
  48847. private _getBonePosition;
  48848. private _getLinesForBonesWithLength;
  48849. private _getLinesForBonesNoLength;
  48850. /** Update the viewer to sync with current skeleton state */
  48851. update(): void;
  48852. /** Release associated resources */
  48853. dispose(): void;
  48854. }
  48855. }
  48856. declare module "babylonjs/Debug/index" {
  48857. export * from "babylonjs/Debug/axesViewer";
  48858. export * from "babylonjs/Debug/boneAxesViewer";
  48859. export * from "babylonjs/Debug/debugLayer";
  48860. export * from "babylonjs/Debug/physicsViewer";
  48861. export * from "babylonjs/Debug/rayHelper";
  48862. export * from "babylonjs/Debug/skeletonViewer";
  48863. }
  48864. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48865. import { Observable } from "babylonjs/Misc/observable";
  48866. import { Engine } from "babylonjs/Engines/engine";
  48867. import { IDisposable } from "babylonjs/scene";
  48868. import { Nullable } from "babylonjs/types";
  48869. /**
  48870. * This class will take all inputs from Keyboard, Pointer, and
  48871. * any Gamepads and provide a polling system that all devices
  48872. * will use. This class assumes that there will only be one
  48873. * pointer device and one keyboard.
  48874. */
  48875. export class DeviceInputSystem implements IDisposable {
  48876. /** POINTER_DEVICE */
  48877. static readonly POINTER_DEVICE: string;
  48878. /** KEYBOARD_DEVICE */
  48879. static readonly KEYBOARD_DEVICE: string;
  48880. /**
  48881. * Observable to be triggered when a device is connected
  48882. */
  48883. onDeviceConnectedObservable: Observable<string>;
  48884. /**
  48885. * Observable to be triggered when a device is disconnected
  48886. */
  48887. onDeviceDisconnectedObservable: Observable<string>;
  48888. private _inputs;
  48889. private _gamepads;
  48890. private _keyboardActive;
  48891. private _pointerActive;
  48892. private _elementToAttachTo;
  48893. private _keyboardDownEvent;
  48894. private _keyboardUpEvent;
  48895. private _pointerMoveEvent;
  48896. private _pointerDownEvent;
  48897. private _pointerUpEvent;
  48898. private _gamepadConnectedEvent;
  48899. private _gamepadDisconnectedEvent;
  48900. private static _MAX_KEYCODES;
  48901. private static _MAX_POINTER_INPUTS;
  48902. /**
  48903. * Default Constructor
  48904. * @param engine - engine to pull input element from
  48905. */
  48906. constructor(engine: Engine);
  48907. /**
  48908. * Checks for current device input value, given an id and input index
  48909. * @param deviceName Id of connected device
  48910. * @param inputIndex Index of device input
  48911. * @returns Current value of input
  48912. */
  48913. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48914. /**
  48915. * Dispose of all the eventlisteners and clears the observables
  48916. */
  48917. dispose(): void;
  48918. /**
  48919. * Add device and inputs to device map
  48920. * @param deviceName Assigned name of device (may be SN)
  48921. * @param numberOfInputs Number of input entries to create for given device
  48922. */
  48923. private _registerDevice;
  48924. /**
  48925. * Given a specific device name, remove that device from the device map
  48926. * @param deviceName Name of device to be removed
  48927. */
  48928. private _unregisterDevice;
  48929. /**
  48930. * Handle all actions that come from keyboard interaction
  48931. */
  48932. private _handleKeyActions;
  48933. /**
  48934. * Handle all actions that come from pointer interaction
  48935. */
  48936. private _handlePointerActions;
  48937. /**
  48938. * Handle all actions that come from gamepad interaction
  48939. */
  48940. private _handleGamepadActions;
  48941. /**
  48942. * Update all non-event based devices with each frame
  48943. */
  48944. private _updateDevice;
  48945. }
  48946. }
  48947. declare module "babylonjs/DeviceInput/index" {
  48948. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48949. }
  48950. declare module "babylonjs/Engines/nullEngine" {
  48951. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48952. import { Engine } from "babylonjs/Engines/engine";
  48953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48954. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48956. import { Effect } from "babylonjs/Materials/effect";
  48957. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48959. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48960. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48961. /**
  48962. * Options to create the null engine
  48963. */
  48964. export class NullEngineOptions {
  48965. /**
  48966. * Render width (Default: 512)
  48967. */
  48968. renderWidth: number;
  48969. /**
  48970. * Render height (Default: 256)
  48971. */
  48972. renderHeight: number;
  48973. /**
  48974. * Texture size (Default: 512)
  48975. */
  48976. textureSize: number;
  48977. /**
  48978. * If delta time between frames should be constant
  48979. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48980. */
  48981. deterministicLockstep: boolean;
  48982. /**
  48983. * Maximum about of steps between frames (Default: 4)
  48984. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48985. */
  48986. lockstepMaxSteps: number;
  48987. }
  48988. /**
  48989. * The null engine class provides support for headless version of babylon.js.
  48990. * This can be used in server side scenario or for testing purposes
  48991. */
  48992. export class NullEngine extends Engine {
  48993. private _options;
  48994. /**
  48995. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48996. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48997. * @returns true if engine is in deterministic lock step mode
  48998. */
  48999. isDeterministicLockStep(): boolean;
  49000. /**
  49001. * Gets the max steps when engine is running in deterministic lock step
  49002. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49003. * @returns the max steps
  49004. */
  49005. getLockstepMaxSteps(): number;
  49006. /**
  49007. * Gets the current hardware scaling level.
  49008. * By default the hardware scaling level is computed from the window device ratio.
  49009. * 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.
  49010. * @returns a number indicating the current hardware scaling level
  49011. */
  49012. getHardwareScalingLevel(): number;
  49013. constructor(options?: NullEngineOptions);
  49014. /**
  49015. * Creates a vertex buffer
  49016. * @param vertices the data for the vertex buffer
  49017. * @returns the new WebGL static buffer
  49018. */
  49019. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49020. /**
  49021. * Creates a new index buffer
  49022. * @param indices defines the content of the index buffer
  49023. * @param updatable defines if the index buffer must be updatable
  49024. * @returns a new webGL buffer
  49025. */
  49026. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49027. /**
  49028. * Clear the current render buffer or the current render target (if any is set up)
  49029. * @param color defines the color to use
  49030. * @param backBuffer defines if the back buffer must be cleared
  49031. * @param depth defines if the depth buffer must be cleared
  49032. * @param stencil defines if the stencil buffer must be cleared
  49033. */
  49034. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49035. /**
  49036. * Gets the current render width
  49037. * @param useScreen defines if screen size must be used (or the current render target if any)
  49038. * @returns a number defining the current render width
  49039. */
  49040. getRenderWidth(useScreen?: boolean): number;
  49041. /**
  49042. * Gets the current render height
  49043. * @param useScreen defines if screen size must be used (or the current render target if any)
  49044. * @returns a number defining the current render height
  49045. */
  49046. getRenderHeight(useScreen?: boolean): number;
  49047. /**
  49048. * Set the WebGL's viewport
  49049. * @param viewport defines the viewport element to be used
  49050. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49051. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49052. */
  49053. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49054. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49055. /**
  49056. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49057. * @param pipelineContext defines the pipeline context to use
  49058. * @param uniformsNames defines the list of uniform names
  49059. * @returns an array of webGL uniform locations
  49060. */
  49061. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49062. /**
  49063. * Gets the lsit of active attributes for a given webGL program
  49064. * @param pipelineContext defines the pipeline context to use
  49065. * @param attributesNames defines the list of attribute names to get
  49066. * @returns an array of indices indicating the offset of each attribute
  49067. */
  49068. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49069. /**
  49070. * Binds an effect to the webGL context
  49071. * @param effect defines the effect to bind
  49072. */
  49073. bindSamplers(effect: Effect): void;
  49074. /**
  49075. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49076. * @param effect defines the effect to activate
  49077. */
  49078. enableEffect(effect: Effect): void;
  49079. /**
  49080. * Set various states to the webGL context
  49081. * @param culling defines backface culling state
  49082. * @param zOffset defines the value to apply to zOffset (0 by default)
  49083. * @param force defines if states must be applied even if cache is up to date
  49084. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49085. */
  49086. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49087. /**
  49088. * Set the value of an uniform to an array of int32
  49089. * @param uniform defines the webGL uniform location where to store the value
  49090. * @param array defines the array of int32 to store
  49091. */
  49092. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49093. /**
  49094. * Set the value of an uniform to an array of int32 (stored as vec2)
  49095. * @param uniform defines the webGL uniform location where to store the value
  49096. * @param array defines the array of int32 to store
  49097. */
  49098. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49099. /**
  49100. * Set the value of an uniform to an array of int32 (stored as vec3)
  49101. * @param uniform defines the webGL uniform location where to store the value
  49102. * @param array defines the array of int32 to store
  49103. */
  49104. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49105. /**
  49106. * Set the value of an uniform to an array of int32 (stored as vec4)
  49107. * @param uniform defines the webGL uniform location where to store the value
  49108. * @param array defines the array of int32 to store
  49109. */
  49110. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49111. /**
  49112. * Set the value of an uniform to an array of float32
  49113. * @param uniform defines the webGL uniform location where to store the value
  49114. * @param array defines the array of float32 to store
  49115. */
  49116. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49117. /**
  49118. * Set the value of an uniform to an array of float32 (stored as vec2)
  49119. * @param uniform defines the webGL uniform location where to store the value
  49120. * @param array defines the array of float32 to store
  49121. */
  49122. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49123. /**
  49124. * Set the value of an uniform to an array of float32 (stored as vec3)
  49125. * @param uniform defines the webGL uniform location where to store the value
  49126. * @param array defines the array of float32 to store
  49127. */
  49128. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49129. /**
  49130. * Set the value of an uniform to an array of float32 (stored as vec4)
  49131. * @param uniform defines the webGL uniform location where to store the value
  49132. * @param array defines the array of float32 to store
  49133. */
  49134. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49135. /**
  49136. * Set the value of an uniform to an array of number
  49137. * @param uniform defines the webGL uniform location where to store the value
  49138. * @param array defines the array of number to store
  49139. */
  49140. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49141. /**
  49142. * Set the value of an uniform to an array of number (stored as vec2)
  49143. * @param uniform defines the webGL uniform location where to store the value
  49144. * @param array defines the array of number to store
  49145. */
  49146. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49147. /**
  49148. * Set the value of an uniform to an array of number (stored as vec3)
  49149. * @param uniform defines the webGL uniform location where to store the value
  49150. * @param array defines the array of number to store
  49151. */
  49152. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49153. /**
  49154. * Set the value of an uniform to an array of number (stored as vec4)
  49155. * @param uniform defines the webGL uniform location where to store the value
  49156. * @param array defines the array of number to store
  49157. */
  49158. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49159. /**
  49160. * Set the value of an uniform to an array of float32 (stored as matrices)
  49161. * @param uniform defines the webGL uniform location where to store the value
  49162. * @param matrices defines the array of float32 to store
  49163. */
  49164. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49165. /**
  49166. * Set the value of an uniform to a matrix (3x3)
  49167. * @param uniform defines the webGL uniform location where to store the value
  49168. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49169. */
  49170. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49171. /**
  49172. * Set the value of an uniform to a matrix (2x2)
  49173. * @param uniform defines the webGL uniform location where to store the value
  49174. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49175. */
  49176. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49177. /**
  49178. * Set the value of an uniform to a number (float)
  49179. * @param uniform defines the webGL uniform location where to store the value
  49180. * @param value defines the float number to store
  49181. */
  49182. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49183. /**
  49184. * Set the value of an uniform to a vec2
  49185. * @param uniform defines the webGL uniform location where to store the value
  49186. * @param x defines the 1st component of the value
  49187. * @param y defines the 2nd component of the value
  49188. */
  49189. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49190. /**
  49191. * Set the value of an uniform to a vec3
  49192. * @param uniform defines the webGL uniform location where to store the value
  49193. * @param x defines the 1st component of the value
  49194. * @param y defines the 2nd component of the value
  49195. * @param z defines the 3rd component of the value
  49196. */
  49197. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49198. /**
  49199. * Set the value of an uniform to a boolean
  49200. * @param uniform defines the webGL uniform location where to store the value
  49201. * @param bool defines the boolean to store
  49202. */
  49203. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49204. /**
  49205. * Set the value of an uniform to a vec4
  49206. * @param uniform defines the webGL uniform location where to store the value
  49207. * @param x defines the 1st component of the value
  49208. * @param y defines the 2nd component of the value
  49209. * @param z defines the 3rd component of the value
  49210. * @param w defines the 4th component of the value
  49211. */
  49212. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49213. /**
  49214. * Sets the current alpha mode
  49215. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49216. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49217. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49218. */
  49219. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49220. /**
  49221. * Bind webGl buffers directly to the webGL context
  49222. * @param vertexBuffers defines the vertex buffer to bind
  49223. * @param indexBuffer defines the index buffer to bind
  49224. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49225. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49226. * @param effect defines the effect associated with the vertex buffer
  49227. */
  49228. bindBuffers(vertexBuffers: {
  49229. [key: string]: VertexBuffer;
  49230. }, indexBuffer: DataBuffer, effect: Effect): void;
  49231. /**
  49232. * Force the entire cache to be cleared
  49233. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49234. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49235. */
  49236. wipeCaches(bruteForce?: boolean): void;
  49237. /**
  49238. * Send a draw order
  49239. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49240. * @param indexStart defines the starting index
  49241. * @param indexCount defines the number of index to draw
  49242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49243. */
  49244. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49245. /**
  49246. * Draw a list of indexed primitives
  49247. * @param fillMode defines the primitive to use
  49248. * @param indexStart defines the starting index
  49249. * @param indexCount defines the number of index to draw
  49250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49251. */
  49252. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49253. /**
  49254. * Draw a list of unindexed primitives
  49255. * @param fillMode defines the primitive to use
  49256. * @param verticesStart defines the index of first vertex to draw
  49257. * @param verticesCount defines the count of vertices to draw
  49258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49259. */
  49260. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49261. /** @hidden */
  49262. _createTexture(): WebGLTexture;
  49263. /** @hidden */
  49264. _releaseTexture(texture: InternalTexture): void;
  49265. /**
  49266. * Usually called from Texture.ts.
  49267. * Passed information to create a WebGLTexture
  49268. * @param urlArg defines a value which contains one of the following:
  49269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49273. * @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)
  49274. * @param scene needed for loading to the correct scene
  49275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49276. * @param onLoad optional callback to be called upon successful completion
  49277. * @param onError optional callback to be called upon failure
  49278. * @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
  49279. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49281. * @param forcedExtension defines the extension to use to pick the right loader
  49282. * @param mimeType defines an optional mime type
  49283. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49284. */
  49285. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49286. /**
  49287. * Creates a new render target texture
  49288. * @param size defines the size of the texture
  49289. * @param options defines the options used to create the texture
  49290. * @returns a new render target texture stored in an InternalTexture
  49291. */
  49292. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49293. /**
  49294. * Update the sampling mode of a given texture
  49295. * @param samplingMode defines the required sampling mode
  49296. * @param texture defines the texture to update
  49297. */
  49298. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49299. /**
  49300. * Binds the frame buffer to the specified texture.
  49301. * @param texture The texture to render to or null for the default canvas
  49302. * @param faceIndex The face of the texture to render to in case of cube texture
  49303. * @param requiredWidth The width of the target to render to
  49304. * @param requiredHeight The height of the target to render to
  49305. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49306. * @param lodLevel defines le lod level to bind to the frame buffer
  49307. */
  49308. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49309. /**
  49310. * Unbind the current render target texture from the webGL context
  49311. * @param texture defines the render target texture to unbind
  49312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49314. */
  49315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49316. /**
  49317. * Creates a dynamic vertex buffer
  49318. * @param vertices the data for the dynamic vertex buffer
  49319. * @returns the new WebGL dynamic buffer
  49320. */
  49321. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49322. /**
  49323. * Update the content of a dynamic texture
  49324. * @param texture defines the texture to update
  49325. * @param canvas defines the canvas containing the source
  49326. * @param invertY defines if data must be stored with Y axis inverted
  49327. * @param premulAlpha defines if alpha is stored as premultiplied
  49328. * @param format defines the format of the data
  49329. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49330. */
  49331. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49332. /**
  49333. * Gets a boolean indicating if all created effects are ready
  49334. * @returns true if all effects are ready
  49335. */
  49336. areAllEffectsReady(): boolean;
  49337. /**
  49338. * @hidden
  49339. * Get the current error code of the webGL context
  49340. * @returns the error code
  49341. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49342. */
  49343. getError(): number;
  49344. /** @hidden */
  49345. _getUnpackAlignement(): number;
  49346. /** @hidden */
  49347. _unpackFlipY(value: boolean): void;
  49348. /**
  49349. * Update a dynamic index buffer
  49350. * @param indexBuffer defines the target index buffer
  49351. * @param indices defines the data to update
  49352. * @param offset defines the offset in the target index buffer where update should start
  49353. */
  49354. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49355. /**
  49356. * Updates a dynamic vertex buffer.
  49357. * @param vertexBuffer the vertex buffer to update
  49358. * @param vertices the data used to update the vertex buffer
  49359. * @param byteOffset the byte offset of the data (optional)
  49360. * @param byteLength the byte length of the data (optional)
  49361. */
  49362. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49363. /** @hidden */
  49364. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49365. /** @hidden */
  49366. _bindTexture(channel: number, texture: InternalTexture): void;
  49367. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49368. /**
  49369. * 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
  49370. */
  49371. releaseEffects(): void;
  49372. displayLoadingUI(): void;
  49373. hideLoadingUI(): void;
  49374. /** @hidden */
  49375. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49376. /** @hidden */
  49377. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49378. /** @hidden */
  49379. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49380. /** @hidden */
  49381. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49382. }
  49383. }
  49384. declare module "babylonjs/Instrumentation/timeToken" {
  49385. import { Nullable } from "babylonjs/types";
  49386. /**
  49387. * @hidden
  49388. **/
  49389. export class _TimeToken {
  49390. _startTimeQuery: Nullable<WebGLQuery>;
  49391. _endTimeQuery: Nullable<WebGLQuery>;
  49392. _timeElapsedQuery: Nullable<WebGLQuery>;
  49393. _timeElapsedQueryEnded: boolean;
  49394. }
  49395. }
  49396. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49397. import { Nullable, int } from "babylonjs/types";
  49398. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49399. /** @hidden */
  49400. export class _OcclusionDataStorage {
  49401. /** @hidden */
  49402. occlusionInternalRetryCounter: number;
  49403. /** @hidden */
  49404. isOcclusionQueryInProgress: boolean;
  49405. /** @hidden */
  49406. isOccluded: boolean;
  49407. /** @hidden */
  49408. occlusionRetryCount: number;
  49409. /** @hidden */
  49410. occlusionType: number;
  49411. /** @hidden */
  49412. occlusionQueryAlgorithmType: number;
  49413. }
  49414. module "babylonjs/Engines/engine" {
  49415. interface Engine {
  49416. /**
  49417. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49418. * @return the new query
  49419. */
  49420. createQuery(): WebGLQuery;
  49421. /**
  49422. * Delete and release a webGL query
  49423. * @param query defines the query to delete
  49424. * @return the current engine
  49425. */
  49426. deleteQuery(query: WebGLQuery): Engine;
  49427. /**
  49428. * Check if a given query has resolved and got its value
  49429. * @param query defines the query to check
  49430. * @returns true if the query got its value
  49431. */
  49432. isQueryResultAvailable(query: WebGLQuery): boolean;
  49433. /**
  49434. * Gets the value of a given query
  49435. * @param query defines the query to check
  49436. * @returns the value of the query
  49437. */
  49438. getQueryResult(query: WebGLQuery): number;
  49439. /**
  49440. * Initiates an occlusion query
  49441. * @param algorithmType defines the algorithm to use
  49442. * @param query defines the query to use
  49443. * @returns the current engine
  49444. * @see http://doc.babylonjs.com/features/occlusionquery
  49445. */
  49446. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49447. /**
  49448. * Ends an occlusion query
  49449. * @see http://doc.babylonjs.com/features/occlusionquery
  49450. * @param algorithmType defines the algorithm to use
  49451. * @returns the current engine
  49452. */
  49453. endOcclusionQuery(algorithmType: number): Engine;
  49454. /**
  49455. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49456. * Please note that only one query can be issued at a time
  49457. * @returns a time token used to track the time span
  49458. */
  49459. startTimeQuery(): Nullable<_TimeToken>;
  49460. /**
  49461. * Ends a time query
  49462. * @param token defines the token used to measure the time span
  49463. * @returns the time spent (in ns)
  49464. */
  49465. endTimeQuery(token: _TimeToken): int;
  49466. /** @hidden */
  49467. _currentNonTimestampToken: Nullable<_TimeToken>;
  49468. /** @hidden */
  49469. _createTimeQuery(): WebGLQuery;
  49470. /** @hidden */
  49471. _deleteTimeQuery(query: WebGLQuery): void;
  49472. /** @hidden */
  49473. _getGlAlgorithmType(algorithmType: number): number;
  49474. /** @hidden */
  49475. _getTimeQueryResult(query: WebGLQuery): any;
  49476. /** @hidden */
  49477. _getTimeQueryAvailability(query: WebGLQuery): any;
  49478. }
  49479. }
  49480. module "babylonjs/Meshes/abstractMesh" {
  49481. interface AbstractMesh {
  49482. /**
  49483. * Backing filed
  49484. * @hidden
  49485. */
  49486. __occlusionDataStorage: _OcclusionDataStorage;
  49487. /**
  49488. * Access property
  49489. * @hidden
  49490. */
  49491. _occlusionDataStorage: _OcclusionDataStorage;
  49492. /**
  49493. * 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.
  49494. * The default value is -1 which means don't break the query and wait till the result
  49495. * @see http://doc.babylonjs.com/features/occlusionquery
  49496. */
  49497. occlusionRetryCount: number;
  49498. /**
  49499. * 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:
  49500. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49501. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49502. * * 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.
  49503. * @see http://doc.babylonjs.com/features/occlusionquery
  49504. */
  49505. occlusionType: number;
  49506. /**
  49507. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49508. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49509. * * 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.
  49510. * @see http://doc.babylonjs.com/features/occlusionquery
  49511. */
  49512. occlusionQueryAlgorithmType: number;
  49513. /**
  49514. * 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
  49515. * @see http://doc.babylonjs.com/features/occlusionquery
  49516. */
  49517. isOccluded: boolean;
  49518. /**
  49519. * Flag to check the progress status of the query
  49520. * @see http://doc.babylonjs.com/features/occlusionquery
  49521. */
  49522. isOcclusionQueryInProgress: boolean;
  49523. }
  49524. }
  49525. }
  49526. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49527. import { Nullable } from "babylonjs/types";
  49528. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49529. /** @hidden */
  49530. export var _forceTransformFeedbackToBundle: boolean;
  49531. module "babylonjs/Engines/engine" {
  49532. interface Engine {
  49533. /**
  49534. * Creates a webGL transform feedback object
  49535. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49536. * @returns the webGL transform feedback object
  49537. */
  49538. createTransformFeedback(): WebGLTransformFeedback;
  49539. /**
  49540. * Delete a webGL transform feedback object
  49541. * @param value defines the webGL transform feedback object to delete
  49542. */
  49543. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49544. /**
  49545. * Bind a webGL transform feedback object to the webgl context
  49546. * @param value defines the webGL transform feedback object to bind
  49547. */
  49548. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49549. /**
  49550. * Begins a transform feedback operation
  49551. * @param usePoints defines if points or triangles must be used
  49552. */
  49553. beginTransformFeedback(usePoints: boolean): void;
  49554. /**
  49555. * Ends a transform feedback operation
  49556. */
  49557. endTransformFeedback(): void;
  49558. /**
  49559. * Specify the varyings to use with transform feedback
  49560. * @param program defines the associated webGL program
  49561. * @param value defines the list of strings representing the varying names
  49562. */
  49563. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49564. /**
  49565. * Bind a webGL buffer for a transform feedback operation
  49566. * @param value defines the webGL buffer to bind
  49567. */
  49568. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49569. }
  49570. }
  49571. }
  49572. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Engine } from "babylonjs/Engines/engine";
  49575. import { Texture } from "babylonjs/Materials/Textures/texture";
  49576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49577. import "babylonjs/Engines/Extensions/engine.multiRender";
  49578. /**
  49579. * Creation options of the multi render target texture.
  49580. */
  49581. export interface IMultiRenderTargetOptions {
  49582. /**
  49583. * Define if the texture needs to create mip maps after render.
  49584. */
  49585. generateMipMaps?: boolean;
  49586. /**
  49587. * Define the types of all the draw buffers we want to create
  49588. */
  49589. types?: number[];
  49590. /**
  49591. * Define the sampling modes of all the draw buffers we want to create
  49592. */
  49593. samplingModes?: number[];
  49594. /**
  49595. * Define if a depth buffer is required
  49596. */
  49597. generateDepthBuffer?: boolean;
  49598. /**
  49599. * Define if a stencil buffer is required
  49600. */
  49601. generateStencilBuffer?: boolean;
  49602. /**
  49603. * Define if a depth texture is required instead of a depth buffer
  49604. */
  49605. generateDepthTexture?: boolean;
  49606. /**
  49607. * Define the number of desired draw buffers
  49608. */
  49609. textureCount?: number;
  49610. /**
  49611. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49612. */
  49613. doNotChangeAspectRatio?: boolean;
  49614. /**
  49615. * Define the default type of the buffers we are creating
  49616. */
  49617. defaultType?: number;
  49618. }
  49619. /**
  49620. * A multi render target, like a render target provides the ability to render to a texture.
  49621. * Unlike the render target, it can render to several draw buffers in one draw.
  49622. * This is specially interesting in deferred rendering or for any effects requiring more than
  49623. * just one color from a single pass.
  49624. */
  49625. export class MultiRenderTarget extends RenderTargetTexture {
  49626. private _internalTextures;
  49627. private _textures;
  49628. private _multiRenderTargetOptions;
  49629. /**
  49630. * Get if draw buffers are currently supported by the used hardware and browser.
  49631. */
  49632. get isSupported(): boolean;
  49633. /**
  49634. * Get the list of textures generated by the multi render target.
  49635. */
  49636. get textures(): Texture[];
  49637. /**
  49638. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49639. */
  49640. get depthTexture(): Texture;
  49641. /**
  49642. * Set the wrapping mode on U of all the textures we are rendering to.
  49643. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49644. */
  49645. set wrapU(wrap: number);
  49646. /**
  49647. * Set the wrapping mode on V of all the textures we are rendering to.
  49648. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49649. */
  49650. set wrapV(wrap: number);
  49651. /**
  49652. * Instantiate a new multi render target texture.
  49653. * A multi render target, like a render target provides the ability to render to a texture.
  49654. * Unlike the render target, it can render to several draw buffers in one draw.
  49655. * This is specially interesting in deferred rendering or for any effects requiring more than
  49656. * just one color from a single pass.
  49657. * @param name Define the name of the texture
  49658. * @param size Define the size of the buffers to render to
  49659. * @param count Define the number of target we are rendering into
  49660. * @param scene Define the scene the texture belongs to
  49661. * @param options Define the options used to create the multi render target
  49662. */
  49663. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49664. /** @hidden */
  49665. _rebuild(): void;
  49666. private _createInternalTextures;
  49667. private _createTextures;
  49668. /**
  49669. * Define the number of samples used if MSAA is enabled.
  49670. */
  49671. get samples(): number;
  49672. set samples(value: number);
  49673. /**
  49674. * Resize all the textures in the multi render target.
  49675. * Be carrefull as it will recreate all the data in the new texture.
  49676. * @param size Define the new size
  49677. */
  49678. resize(size: any): void;
  49679. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49680. /**
  49681. * Dispose the render targets and their associated resources
  49682. */
  49683. dispose(): void;
  49684. /**
  49685. * Release all the underlying texture used as draw buffers.
  49686. */
  49687. releaseInternalTextures(): void;
  49688. }
  49689. }
  49690. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49692. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49693. import { Nullable } from "babylonjs/types";
  49694. module "babylonjs/Engines/thinEngine" {
  49695. interface ThinEngine {
  49696. /**
  49697. * Unbind a list of render target textures from the webGL context
  49698. * This is used only when drawBuffer extension or webGL2 are active
  49699. * @param textures defines the render target textures to unbind
  49700. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49701. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49702. */
  49703. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49704. /**
  49705. * Create a multi render target texture
  49706. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49707. * @param size defines the size of the texture
  49708. * @param options defines the creation options
  49709. * @returns the cube texture as an InternalTexture
  49710. */
  49711. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49712. /**
  49713. * Update the sample count for a given multiple render target texture
  49714. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49715. * @param textures defines the textures to update
  49716. * @param samples defines the sample count to set
  49717. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49718. */
  49719. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49720. }
  49721. }
  49722. }
  49723. declare module "babylonjs/Engines/Extensions/engine.views" {
  49724. import { Camera } from "babylonjs/Cameras/camera";
  49725. import { Nullable } from "babylonjs/types";
  49726. /**
  49727. * Class used to define an additional view for the engine
  49728. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49729. */
  49730. export class EngineView {
  49731. /** Defines the canvas where to render the view */
  49732. target: HTMLCanvasElement;
  49733. /** Defines an optional camera used to render the view (will use active camera else) */
  49734. camera?: Camera;
  49735. }
  49736. module "babylonjs/Engines/engine" {
  49737. interface Engine {
  49738. /**
  49739. * Gets or sets the HTML element to use for attaching events
  49740. */
  49741. inputElement: Nullable<HTMLElement>;
  49742. /**
  49743. * Gets the current engine view
  49744. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49745. */
  49746. activeView: Nullable<EngineView>;
  49747. /** Gets or sets the list of views */
  49748. views: EngineView[];
  49749. /**
  49750. * Register a new child canvas
  49751. * @param canvas defines the canvas to register
  49752. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49753. * @returns the associated view
  49754. */
  49755. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49756. /**
  49757. * Remove a registered child canvas
  49758. * @param canvas defines the canvas to remove
  49759. * @returns the current engine
  49760. */
  49761. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49762. }
  49763. }
  49764. }
  49765. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49766. import { Nullable } from "babylonjs/types";
  49767. module "babylonjs/Engines/engine" {
  49768. interface Engine {
  49769. /** @hidden */
  49770. _excludedCompressedTextures: string[];
  49771. /** @hidden */
  49772. _textureFormatInUse: string;
  49773. /**
  49774. * Gets the list of texture formats supported
  49775. */
  49776. readonly texturesSupported: Array<string>;
  49777. /**
  49778. * Gets the texture format in use
  49779. */
  49780. readonly textureFormatInUse: Nullable<string>;
  49781. /**
  49782. * Set the compressed texture extensions or file names to skip.
  49783. *
  49784. * @param skippedFiles defines the list of those texture files you want to skip
  49785. * Example: [".dds", ".env", "myfile.png"]
  49786. */
  49787. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49788. /**
  49789. * Set the compressed texture format to use, based on the formats you have, and the formats
  49790. * supported by the hardware / browser.
  49791. *
  49792. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49793. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49794. * to API arguments needed to compressed textures. This puts the burden on the container
  49795. * generator to house the arcane code for determining these for current & future formats.
  49796. *
  49797. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49798. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49799. *
  49800. * Note: The result of this call is not taken into account when a texture is base64.
  49801. *
  49802. * @param formatsAvailable defines the list of those format families you have created
  49803. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49804. *
  49805. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49806. * @returns The extension selected.
  49807. */
  49808. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49809. }
  49810. }
  49811. }
  49812. declare module "babylonjs/Engines/Extensions/index" {
  49813. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49814. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49815. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49816. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49817. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49818. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49819. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49820. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49821. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49822. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49823. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49824. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49825. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49826. export * from "babylonjs/Engines/Extensions/engine.views";
  49827. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  49828. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49829. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49830. }
  49831. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49832. import { Nullable } from "babylonjs/types";
  49833. /**
  49834. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49835. */
  49836. export interface CubeMapInfo {
  49837. /**
  49838. * The pixel array for the front face.
  49839. * This is stored in format, left to right, up to down format.
  49840. */
  49841. front: Nullable<ArrayBufferView>;
  49842. /**
  49843. * The pixel array for the back face.
  49844. * This is stored in format, left to right, up to down format.
  49845. */
  49846. back: Nullable<ArrayBufferView>;
  49847. /**
  49848. * The pixel array for the left face.
  49849. * This is stored in format, left to right, up to down format.
  49850. */
  49851. left: Nullable<ArrayBufferView>;
  49852. /**
  49853. * The pixel array for the right face.
  49854. * This is stored in format, left to right, up to down format.
  49855. */
  49856. right: Nullable<ArrayBufferView>;
  49857. /**
  49858. * The pixel array for the up face.
  49859. * This is stored in format, left to right, up to down format.
  49860. */
  49861. up: Nullable<ArrayBufferView>;
  49862. /**
  49863. * The pixel array for the down face.
  49864. * This is stored in format, left to right, up to down format.
  49865. */
  49866. down: Nullable<ArrayBufferView>;
  49867. /**
  49868. * The size of the cubemap stored.
  49869. *
  49870. * Each faces will be size * size pixels.
  49871. */
  49872. size: number;
  49873. /**
  49874. * The format of the texture.
  49875. *
  49876. * RGBA, RGB.
  49877. */
  49878. format: number;
  49879. /**
  49880. * The type of the texture data.
  49881. *
  49882. * UNSIGNED_INT, FLOAT.
  49883. */
  49884. type: number;
  49885. /**
  49886. * Specifies whether the texture is in gamma space.
  49887. */
  49888. gammaSpace: boolean;
  49889. }
  49890. /**
  49891. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49892. */
  49893. export class PanoramaToCubeMapTools {
  49894. private static FACE_LEFT;
  49895. private static FACE_RIGHT;
  49896. private static FACE_FRONT;
  49897. private static FACE_BACK;
  49898. private static FACE_DOWN;
  49899. private static FACE_UP;
  49900. /**
  49901. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49902. *
  49903. * @param float32Array The source data.
  49904. * @param inputWidth The width of the input panorama.
  49905. * @param inputHeight The height of the input panorama.
  49906. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49907. * @return The cubemap data
  49908. */
  49909. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49910. private static CreateCubemapTexture;
  49911. private static CalcProjectionSpherical;
  49912. }
  49913. }
  49914. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49915. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49917. import { Nullable } from "babylonjs/types";
  49918. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49919. /**
  49920. * Helper class dealing with the extraction of spherical polynomial dataArray
  49921. * from a cube map.
  49922. */
  49923. export class CubeMapToSphericalPolynomialTools {
  49924. private static FileFaces;
  49925. /**
  49926. * Converts a texture to the according Spherical Polynomial data.
  49927. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49928. *
  49929. * @param texture The texture to extract the information from.
  49930. * @return The Spherical Polynomial data.
  49931. */
  49932. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49933. /**
  49934. * Converts a cubemap to the according Spherical Polynomial data.
  49935. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49936. *
  49937. * @param cubeInfo The Cube map to extract the information from.
  49938. * @return The Spherical Polynomial data.
  49939. */
  49940. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49941. }
  49942. }
  49943. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49944. import { Nullable } from "babylonjs/types";
  49945. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49946. module "babylonjs/Materials/Textures/baseTexture" {
  49947. interface BaseTexture {
  49948. /**
  49949. * Get the polynomial representation of the texture data.
  49950. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49951. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49952. */
  49953. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49954. }
  49955. }
  49956. }
  49957. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49959. /** @hidden */
  49960. export var rgbdEncodePixelShader: {
  49961. name: string;
  49962. shader: string;
  49963. };
  49964. }
  49965. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49966. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49967. /** @hidden */
  49968. export var rgbdDecodePixelShader: {
  49969. name: string;
  49970. shader: string;
  49971. };
  49972. }
  49973. declare module "babylonjs/Misc/environmentTextureTools" {
  49974. import { Nullable } from "babylonjs/types";
  49975. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49978. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49979. import "babylonjs/Engines/Extensions/engine.readTexture";
  49980. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49981. import "babylonjs/Shaders/rgbdEncode.fragment";
  49982. import "babylonjs/Shaders/rgbdDecode.fragment";
  49983. /**
  49984. * Raw texture data and descriptor sufficient for WebGL texture upload
  49985. */
  49986. export interface EnvironmentTextureInfo {
  49987. /**
  49988. * Version of the environment map
  49989. */
  49990. version: number;
  49991. /**
  49992. * Width of image
  49993. */
  49994. width: number;
  49995. /**
  49996. * Irradiance information stored in the file.
  49997. */
  49998. irradiance: any;
  49999. /**
  50000. * Specular information stored in the file.
  50001. */
  50002. specular: any;
  50003. }
  50004. /**
  50005. * Defines One Image in the file. It requires only the position in the file
  50006. * as well as the length.
  50007. */
  50008. interface BufferImageData {
  50009. /**
  50010. * Length of the image data.
  50011. */
  50012. length: number;
  50013. /**
  50014. * Position of the data from the null terminator delimiting the end of the JSON.
  50015. */
  50016. position: number;
  50017. }
  50018. /**
  50019. * Defines the specular data enclosed in the file.
  50020. * This corresponds to the version 1 of the data.
  50021. */
  50022. export interface EnvironmentTextureSpecularInfoV1 {
  50023. /**
  50024. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50025. */
  50026. specularDataPosition?: number;
  50027. /**
  50028. * This contains all the images data needed to reconstruct the cubemap.
  50029. */
  50030. mipmaps: Array<BufferImageData>;
  50031. /**
  50032. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50033. */
  50034. lodGenerationScale: number;
  50035. }
  50036. /**
  50037. * Sets of helpers addressing the serialization and deserialization of environment texture
  50038. * stored in a BabylonJS env file.
  50039. * Those files are usually stored as .env files.
  50040. */
  50041. export class EnvironmentTextureTools {
  50042. /**
  50043. * Magic number identifying the env file.
  50044. */
  50045. private static _MagicBytes;
  50046. /**
  50047. * Gets the environment info from an env file.
  50048. * @param data The array buffer containing the .env bytes.
  50049. * @returns the environment file info (the json header) if successfully parsed.
  50050. */
  50051. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50052. /**
  50053. * Creates an environment texture from a loaded cube texture.
  50054. * @param texture defines the cube texture to convert in env file
  50055. * @return a promise containing the environment data if succesfull.
  50056. */
  50057. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50058. /**
  50059. * Creates a JSON representation of the spherical data.
  50060. * @param texture defines the texture containing the polynomials
  50061. * @return the JSON representation of the spherical info
  50062. */
  50063. private static _CreateEnvTextureIrradiance;
  50064. /**
  50065. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50066. * @param data the image data
  50067. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50068. * @return the views described by info providing access to the underlying buffer
  50069. */
  50070. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50071. /**
  50072. * Uploads the texture info contained in the env file to the GPU.
  50073. * @param texture defines the internal texture to upload to
  50074. * @param data defines the data to load
  50075. * @param info defines the texture info retrieved through the GetEnvInfo method
  50076. * @returns a promise
  50077. */
  50078. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50079. private static _OnImageReadyAsync;
  50080. /**
  50081. * Uploads the levels of image data to the GPU.
  50082. * @param texture defines the internal texture to upload to
  50083. * @param imageData defines the array buffer views of image data [mipmap][face]
  50084. * @returns a promise
  50085. */
  50086. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50087. /**
  50088. * Uploads spherical polynomials information to the texture.
  50089. * @param texture defines the texture we are trying to upload the information to
  50090. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50091. */
  50092. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50093. /** @hidden */
  50094. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50095. }
  50096. }
  50097. declare module "babylonjs/Maths/math.vertexFormat" {
  50098. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50099. /**
  50100. * Contains position and normal vectors for a vertex
  50101. */
  50102. export class PositionNormalVertex {
  50103. /** the position of the vertex (defaut: 0,0,0) */
  50104. position: Vector3;
  50105. /** the normal of the vertex (defaut: 0,1,0) */
  50106. normal: Vector3;
  50107. /**
  50108. * Creates a PositionNormalVertex
  50109. * @param position the position of the vertex (defaut: 0,0,0)
  50110. * @param normal the normal of the vertex (defaut: 0,1,0)
  50111. */
  50112. constructor(
  50113. /** the position of the vertex (defaut: 0,0,0) */
  50114. position?: Vector3,
  50115. /** the normal of the vertex (defaut: 0,1,0) */
  50116. normal?: Vector3);
  50117. /**
  50118. * Clones the PositionNormalVertex
  50119. * @returns the cloned PositionNormalVertex
  50120. */
  50121. clone(): PositionNormalVertex;
  50122. }
  50123. /**
  50124. * Contains position, normal and uv vectors for a vertex
  50125. */
  50126. export class PositionNormalTextureVertex {
  50127. /** the position of the vertex (defaut: 0,0,0) */
  50128. position: Vector3;
  50129. /** the normal of the vertex (defaut: 0,1,0) */
  50130. normal: Vector3;
  50131. /** the uv of the vertex (default: 0,0) */
  50132. uv: Vector2;
  50133. /**
  50134. * Creates a PositionNormalTextureVertex
  50135. * @param position the position of the vertex (defaut: 0,0,0)
  50136. * @param normal the normal of the vertex (defaut: 0,1,0)
  50137. * @param uv the uv of the vertex (default: 0,0)
  50138. */
  50139. constructor(
  50140. /** the position of the vertex (defaut: 0,0,0) */
  50141. position?: Vector3,
  50142. /** the normal of the vertex (defaut: 0,1,0) */
  50143. normal?: Vector3,
  50144. /** the uv of the vertex (default: 0,0) */
  50145. uv?: Vector2);
  50146. /**
  50147. * Clones the PositionNormalTextureVertex
  50148. * @returns the cloned PositionNormalTextureVertex
  50149. */
  50150. clone(): PositionNormalTextureVertex;
  50151. }
  50152. }
  50153. declare module "babylonjs/Maths/math" {
  50154. export * from "babylonjs/Maths/math.axis";
  50155. export * from "babylonjs/Maths/math.color";
  50156. export * from "babylonjs/Maths/math.constants";
  50157. export * from "babylonjs/Maths/math.frustum";
  50158. export * from "babylonjs/Maths/math.path";
  50159. export * from "babylonjs/Maths/math.plane";
  50160. export * from "babylonjs/Maths/math.size";
  50161. export * from "babylonjs/Maths/math.vector";
  50162. export * from "babylonjs/Maths/math.vertexFormat";
  50163. export * from "babylonjs/Maths/math.viewport";
  50164. }
  50165. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50166. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50167. /** @hidden */
  50168. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50169. private _genericAttributeLocation;
  50170. private _varyingLocationCount;
  50171. private _varyingLocationMap;
  50172. private _replacements;
  50173. private _textureCount;
  50174. private _uniforms;
  50175. lineProcessor(line: string): string;
  50176. attributeProcessor(attribute: string): string;
  50177. varyingProcessor(varying: string, isFragment: boolean): string;
  50178. uniformProcessor(uniform: string): string;
  50179. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50180. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50181. }
  50182. }
  50183. declare module "babylonjs/Engines/nativeEngine" {
  50184. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50185. import { Engine } from "babylonjs/Engines/engine";
  50186. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50189. import { Effect } from "babylonjs/Materials/effect";
  50190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50191. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50192. import { IColor4Like } from "babylonjs/Maths/math.like";
  50193. import { Scene } from "babylonjs/scene";
  50194. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50195. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50196. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50197. /**
  50198. * Container for accessors for natively-stored mesh data buffers.
  50199. */
  50200. class NativeDataBuffer extends DataBuffer {
  50201. /**
  50202. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50203. */
  50204. nativeIndexBuffer?: any;
  50205. /**
  50206. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50207. */
  50208. nativeVertexBuffer?: any;
  50209. }
  50210. /** @hidden */
  50211. class NativeTexture extends InternalTexture {
  50212. getInternalTexture(): InternalTexture;
  50213. getViewCount(): number;
  50214. }
  50215. /** @hidden */
  50216. export class NativeEngine extends Engine {
  50217. private readonly _native;
  50218. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50219. private readonly INVALID_HANDLE;
  50220. getHardwareScalingLevel(): number;
  50221. constructor();
  50222. dispose(): void;
  50223. /**
  50224. * Can be used to override the current requestAnimationFrame requester.
  50225. * @hidden
  50226. */
  50227. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50228. /**
  50229. * Override default engine behavior.
  50230. * @param color
  50231. * @param backBuffer
  50232. * @param depth
  50233. * @param stencil
  50234. */
  50235. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50236. /**
  50237. * Gets host document
  50238. * @returns the host document object
  50239. */
  50240. getHostDocument(): Nullable<Document>;
  50241. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50242. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50243. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50244. recordVertexArrayObject(vertexBuffers: {
  50245. [key: string]: VertexBuffer;
  50246. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50247. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50248. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50249. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50250. /**
  50251. * Draw a list of indexed primitives
  50252. * @param fillMode defines the primitive to use
  50253. * @param indexStart defines the starting index
  50254. * @param indexCount defines the number of index to draw
  50255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50256. */
  50257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50258. /**
  50259. * Draw a list of unindexed primitives
  50260. * @param fillMode defines the primitive to use
  50261. * @param verticesStart defines the index of first vertex to draw
  50262. * @param verticesCount defines the count of vertices to draw
  50263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50264. */
  50265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50266. createPipelineContext(): IPipelineContext;
  50267. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50268. /** @hidden */
  50269. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50270. /** @hidden */
  50271. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50272. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50273. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50274. protected _setProgram(program: WebGLProgram): void;
  50275. _releaseEffect(effect: Effect): void;
  50276. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50277. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50278. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50279. bindSamplers(effect: Effect): void;
  50280. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50281. getRenderWidth(useScreen?: boolean): number;
  50282. getRenderHeight(useScreen?: boolean): number;
  50283. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50284. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50285. /**
  50286. * Set the z offset to apply to current rendering
  50287. * @param value defines the offset to apply
  50288. */
  50289. setZOffset(value: number): void;
  50290. /**
  50291. * Gets the current value of the zOffset
  50292. * @returns the current zOffset state
  50293. */
  50294. getZOffset(): number;
  50295. /**
  50296. * Enable or disable depth buffering
  50297. * @param enable defines the state to set
  50298. */
  50299. setDepthBuffer(enable: boolean): void;
  50300. /**
  50301. * Gets a boolean indicating if depth writing is enabled
  50302. * @returns the current depth writing state
  50303. */
  50304. getDepthWrite(): boolean;
  50305. /**
  50306. * Enable or disable depth writing
  50307. * @param enable defines the state to set
  50308. */
  50309. setDepthWrite(enable: boolean): void;
  50310. /**
  50311. * Enable or disable color writing
  50312. * @param enable defines the state to set
  50313. */
  50314. setColorWrite(enable: boolean): void;
  50315. /**
  50316. * Gets a boolean indicating if color writing is enabled
  50317. * @returns the current color writing state
  50318. */
  50319. getColorWrite(): boolean;
  50320. /**
  50321. * Sets alpha constants used by some alpha blending modes
  50322. * @param r defines the red component
  50323. * @param g defines the green component
  50324. * @param b defines the blue component
  50325. * @param a defines the alpha component
  50326. */
  50327. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50328. /**
  50329. * Sets the current alpha mode
  50330. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50331. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50332. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50333. */
  50334. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50335. /**
  50336. * Gets the current alpha mode
  50337. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50338. * @returns the current alpha mode
  50339. */
  50340. getAlphaMode(): number;
  50341. setInt(uniform: WebGLUniformLocation, int: number): void;
  50342. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50343. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50344. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50345. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50346. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50347. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50348. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50349. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50350. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50351. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50352. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50353. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50354. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50355. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50356. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50357. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50358. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50359. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50360. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50361. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50362. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50363. wipeCaches(bruteForce?: boolean): void;
  50364. _createTexture(): WebGLTexture;
  50365. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50366. /**
  50367. * Usually called from Texture.ts.
  50368. * Passed information to create a WebGLTexture
  50369. * @param url defines a value which contains one of the following:
  50370. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50371. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50372. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50373. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50374. * @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)
  50375. * @param scene needed for loading to the correct scene
  50376. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50377. * @param onLoad optional callback to be called upon successful completion
  50378. * @param onError optional callback to be called upon failure
  50379. * @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
  50380. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50381. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50382. * @param forcedExtension defines the extension to use to pick the right loader
  50383. * @param mimeType defines an optional mime type
  50384. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50385. */
  50386. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  50387. /**
  50388. * Creates a cube texture
  50389. * @param rootUrl defines the url where the files to load is located
  50390. * @param scene defines the current scene
  50391. * @param files defines the list of files to load (1 per face)
  50392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50393. * @param onLoad defines an optional callback raised when the texture is loaded
  50394. * @param onError defines an optional callback raised if there is an issue to load the texture
  50395. * @param format defines the format of the data
  50396. * @param forcedExtension defines the extension to use to pick the right loader
  50397. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50398. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50399. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50400. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50401. * @returns the cube texture as an InternalTexture
  50402. */
  50403. 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;
  50404. private _getSamplingFilter;
  50405. private static _GetNativeTextureFormat;
  50406. createRenderTargetTexture(size: number | {
  50407. width: number;
  50408. height: number;
  50409. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50410. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50411. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50412. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50413. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50414. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50415. /**
  50416. * Updates a dynamic vertex buffer.
  50417. * @param vertexBuffer the vertex buffer to update
  50418. * @param data the data used to update the vertex buffer
  50419. * @param byteOffset the byte offset of the data (optional)
  50420. * @param byteLength the byte length of the data (optional)
  50421. */
  50422. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50423. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50424. private _updateAnisotropicLevel;
  50425. private _getAddressMode;
  50426. /** @hidden */
  50427. _bindTexture(channel: number, texture: InternalTexture): void;
  50428. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50429. releaseEffects(): void;
  50430. /** @hidden */
  50431. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50432. /** @hidden */
  50433. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50434. /** @hidden */
  50435. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50436. /** @hidden */
  50437. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50438. }
  50439. }
  50440. declare module "babylonjs/Engines/index" {
  50441. export * from "babylonjs/Engines/constants";
  50442. export * from "babylonjs/Engines/engineCapabilities";
  50443. export * from "babylonjs/Engines/instancingAttributeInfo";
  50444. export * from "babylonjs/Engines/thinEngine";
  50445. export * from "babylonjs/Engines/engine";
  50446. export * from "babylonjs/Engines/engineStore";
  50447. export * from "babylonjs/Engines/nullEngine";
  50448. export * from "babylonjs/Engines/Extensions/index";
  50449. export * from "babylonjs/Engines/IPipelineContext";
  50450. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50451. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50452. export * from "babylonjs/Engines/nativeEngine";
  50453. }
  50454. declare module "babylonjs/Events/clipboardEvents" {
  50455. /**
  50456. * Gather the list of clipboard event types as constants.
  50457. */
  50458. export class ClipboardEventTypes {
  50459. /**
  50460. * The clipboard event is fired when a copy command is active (pressed).
  50461. */
  50462. static readonly COPY: number;
  50463. /**
  50464. * The clipboard event is fired when a cut command is active (pressed).
  50465. */
  50466. static readonly CUT: number;
  50467. /**
  50468. * The clipboard event is fired when a paste command is active (pressed).
  50469. */
  50470. static readonly PASTE: number;
  50471. }
  50472. /**
  50473. * This class is used to store clipboard related info for the onClipboardObservable event.
  50474. */
  50475. export class ClipboardInfo {
  50476. /**
  50477. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50478. */
  50479. type: number;
  50480. /**
  50481. * Defines the related dom event
  50482. */
  50483. event: ClipboardEvent;
  50484. /**
  50485. *Creates an instance of ClipboardInfo.
  50486. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50487. * @param event Defines the related dom event
  50488. */
  50489. constructor(
  50490. /**
  50491. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50492. */
  50493. type: number,
  50494. /**
  50495. * Defines the related dom event
  50496. */
  50497. event: ClipboardEvent);
  50498. /**
  50499. * Get the clipboard event's type from the keycode.
  50500. * @param keyCode Defines the keyCode for the current keyboard event.
  50501. * @return {number}
  50502. */
  50503. static GetTypeFromCharacter(keyCode: number): number;
  50504. }
  50505. }
  50506. declare module "babylonjs/Events/index" {
  50507. export * from "babylonjs/Events/keyboardEvents";
  50508. export * from "babylonjs/Events/pointerEvents";
  50509. export * from "babylonjs/Events/clipboardEvents";
  50510. }
  50511. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50512. import { Scene } from "babylonjs/scene";
  50513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50514. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50515. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50516. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50517. /**
  50518. * Google Daydream controller
  50519. */
  50520. export class DaydreamController extends WebVRController {
  50521. /**
  50522. * Base Url for the controller model.
  50523. */
  50524. static MODEL_BASE_URL: string;
  50525. /**
  50526. * File name for the controller model.
  50527. */
  50528. static MODEL_FILENAME: string;
  50529. /**
  50530. * Gamepad Id prefix used to identify Daydream Controller.
  50531. */
  50532. static readonly GAMEPAD_ID_PREFIX: string;
  50533. /**
  50534. * Creates a new DaydreamController from a gamepad
  50535. * @param vrGamepad the gamepad that the controller should be created from
  50536. */
  50537. constructor(vrGamepad: any);
  50538. /**
  50539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50540. * @param scene scene in which to add meshes
  50541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50542. */
  50543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50544. /**
  50545. * Called once for each button that changed state since the last frame
  50546. * @param buttonIdx Which button index changed
  50547. * @param state New state of the button
  50548. * @param changes Which properties on the state changed since last frame
  50549. */
  50550. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50551. }
  50552. }
  50553. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50554. import { Scene } from "babylonjs/scene";
  50555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50556. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50557. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50558. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50559. /**
  50560. * Gear VR Controller
  50561. */
  50562. export class GearVRController extends WebVRController {
  50563. /**
  50564. * Base Url for the controller model.
  50565. */
  50566. static MODEL_BASE_URL: string;
  50567. /**
  50568. * File name for the controller model.
  50569. */
  50570. static MODEL_FILENAME: string;
  50571. /**
  50572. * Gamepad Id prefix used to identify this controller.
  50573. */
  50574. static readonly GAMEPAD_ID_PREFIX: string;
  50575. private readonly _buttonIndexToObservableNameMap;
  50576. /**
  50577. * Creates a new GearVRController from a gamepad
  50578. * @param vrGamepad the gamepad that the controller should be created from
  50579. */
  50580. constructor(vrGamepad: any);
  50581. /**
  50582. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50583. * @param scene scene in which to add meshes
  50584. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50585. */
  50586. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50587. /**
  50588. * Called once for each button that changed state since the last frame
  50589. * @param buttonIdx Which button index changed
  50590. * @param state New state of the button
  50591. * @param changes Which properties on the state changed since last frame
  50592. */
  50593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50594. }
  50595. }
  50596. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50597. import { Scene } from "babylonjs/scene";
  50598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50599. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50600. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50601. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50602. /**
  50603. * Generic Controller
  50604. */
  50605. export class GenericController extends WebVRController {
  50606. /**
  50607. * Base Url for the controller model.
  50608. */
  50609. static readonly MODEL_BASE_URL: string;
  50610. /**
  50611. * File name for the controller model.
  50612. */
  50613. static readonly MODEL_FILENAME: string;
  50614. /**
  50615. * Creates a new GenericController from a gamepad
  50616. * @param vrGamepad the gamepad that the controller should be created from
  50617. */
  50618. constructor(vrGamepad: any);
  50619. /**
  50620. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50621. * @param scene scene in which to add meshes
  50622. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50623. */
  50624. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50625. /**
  50626. * Called once for each button that changed state since the last frame
  50627. * @param buttonIdx Which button index changed
  50628. * @param state New state of the button
  50629. * @param changes Which properties on the state changed since last frame
  50630. */
  50631. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50632. }
  50633. }
  50634. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50635. import { Observable } from "babylonjs/Misc/observable";
  50636. import { Scene } from "babylonjs/scene";
  50637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50638. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50639. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50640. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50641. /**
  50642. * Oculus Touch Controller
  50643. */
  50644. export class OculusTouchController extends WebVRController {
  50645. /**
  50646. * Base Url for the controller model.
  50647. */
  50648. static MODEL_BASE_URL: string;
  50649. /**
  50650. * File name for the left controller model.
  50651. */
  50652. static MODEL_LEFT_FILENAME: string;
  50653. /**
  50654. * File name for the right controller model.
  50655. */
  50656. static MODEL_RIGHT_FILENAME: string;
  50657. /**
  50658. * Base Url for the Quest controller model.
  50659. */
  50660. static QUEST_MODEL_BASE_URL: string;
  50661. /**
  50662. * @hidden
  50663. * If the controllers are running on a device that needs the updated Quest controller models
  50664. */
  50665. static _IsQuest: boolean;
  50666. /**
  50667. * Fired when the secondary trigger on this controller is modified
  50668. */
  50669. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50670. /**
  50671. * Fired when the thumb rest on this controller is modified
  50672. */
  50673. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50674. /**
  50675. * Creates a new OculusTouchController from a gamepad
  50676. * @param vrGamepad the gamepad that the controller should be created from
  50677. */
  50678. constructor(vrGamepad: any);
  50679. /**
  50680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50681. * @param scene scene in which to add meshes
  50682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50683. */
  50684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50685. /**
  50686. * Fired when the A button on this controller is modified
  50687. */
  50688. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50689. /**
  50690. * Fired when the B button on this controller is modified
  50691. */
  50692. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50693. /**
  50694. * Fired when the X button on this controller is modified
  50695. */
  50696. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50697. /**
  50698. * Fired when the Y button on this controller is modified
  50699. */
  50700. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50701. /**
  50702. * Called once for each button that changed state since the last frame
  50703. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50704. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50705. * 2) secondary trigger (same)
  50706. * 3) A (right) X (left), touch, pressed = value
  50707. * 4) B / Y
  50708. * 5) thumb rest
  50709. * @param buttonIdx Which button index changed
  50710. * @param state New state of the button
  50711. * @param changes Which properties on the state changed since last frame
  50712. */
  50713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50714. }
  50715. }
  50716. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50717. import { Scene } from "babylonjs/scene";
  50718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50720. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50721. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50722. import { Observable } from "babylonjs/Misc/observable";
  50723. /**
  50724. * Vive Controller
  50725. */
  50726. export class ViveController extends WebVRController {
  50727. /**
  50728. * Base Url for the controller model.
  50729. */
  50730. static MODEL_BASE_URL: string;
  50731. /**
  50732. * File name for the controller model.
  50733. */
  50734. static MODEL_FILENAME: string;
  50735. /**
  50736. * Creates a new ViveController from a gamepad
  50737. * @param vrGamepad the gamepad that the controller should be created from
  50738. */
  50739. constructor(vrGamepad: any);
  50740. /**
  50741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50742. * @param scene scene in which to add meshes
  50743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50744. */
  50745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50746. /**
  50747. * Fired when the left button on this controller is modified
  50748. */
  50749. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50750. /**
  50751. * Fired when the right button on this controller is modified
  50752. */
  50753. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50754. /**
  50755. * Fired when the menu button on this controller is modified
  50756. */
  50757. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50758. /**
  50759. * Called once for each button that changed state since the last frame
  50760. * Vive mapping:
  50761. * 0: touchpad
  50762. * 1: trigger
  50763. * 2: left AND right buttons
  50764. * 3: menu button
  50765. * @param buttonIdx Which button index changed
  50766. * @param state New state of the button
  50767. * @param changes Which properties on the state changed since last frame
  50768. */
  50769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50770. }
  50771. }
  50772. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50773. import { Observable } from "babylonjs/Misc/observable";
  50774. import { Scene } from "babylonjs/scene";
  50775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50776. import { Ray } from "babylonjs/Culling/ray";
  50777. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50778. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50779. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50780. /**
  50781. * Defines the WindowsMotionController object that the state of the windows motion controller
  50782. */
  50783. export class WindowsMotionController extends WebVRController {
  50784. /**
  50785. * The base url used to load the left and right controller models
  50786. */
  50787. static MODEL_BASE_URL: string;
  50788. /**
  50789. * The name of the left controller model file
  50790. */
  50791. static MODEL_LEFT_FILENAME: string;
  50792. /**
  50793. * The name of the right controller model file
  50794. */
  50795. static MODEL_RIGHT_FILENAME: string;
  50796. /**
  50797. * The controller name prefix for this controller type
  50798. */
  50799. static readonly GAMEPAD_ID_PREFIX: string;
  50800. /**
  50801. * The controller id pattern for this controller type
  50802. */
  50803. private static readonly GAMEPAD_ID_PATTERN;
  50804. private _loadedMeshInfo;
  50805. protected readonly _mapping: {
  50806. buttons: string[];
  50807. buttonMeshNames: {
  50808. trigger: string;
  50809. menu: string;
  50810. grip: string;
  50811. thumbstick: string;
  50812. trackpad: string;
  50813. };
  50814. buttonObservableNames: {
  50815. trigger: string;
  50816. menu: string;
  50817. grip: string;
  50818. thumbstick: string;
  50819. trackpad: string;
  50820. };
  50821. axisMeshNames: string[];
  50822. pointingPoseMeshName: string;
  50823. };
  50824. /**
  50825. * Fired when the trackpad on this controller is clicked
  50826. */
  50827. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50828. /**
  50829. * Fired when the trackpad on this controller is modified
  50830. */
  50831. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50832. /**
  50833. * The current x and y values of this controller's trackpad
  50834. */
  50835. trackpad: StickValues;
  50836. /**
  50837. * Creates a new WindowsMotionController from a gamepad
  50838. * @param vrGamepad the gamepad that the controller should be created from
  50839. */
  50840. constructor(vrGamepad: any);
  50841. /**
  50842. * Fired when the trigger on this controller is modified
  50843. */
  50844. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50845. /**
  50846. * Fired when the menu button on this controller is modified
  50847. */
  50848. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50849. /**
  50850. * Fired when the grip button on this controller is modified
  50851. */
  50852. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50853. /**
  50854. * Fired when the thumbstick button on this controller is modified
  50855. */
  50856. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50857. /**
  50858. * Fired when the touchpad button on this controller is modified
  50859. */
  50860. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50861. /**
  50862. * Fired when the touchpad values on this controller are modified
  50863. */
  50864. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50865. protected _updateTrackpad(): void;
  50866. /**
  50867. * Called once per frame by the engine.
  50868. */
  50869. update(): void;
  50870. /**
  50871. * Called once for each button that changed state since the last frame
  50872. * @param buttonIdx Which button index changed
  50873. * @param state New state of the button
  50874. * @param changes Which properties on the state changed since last frame
  50875. */
  50876. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50877. /**
  50878. * Moves the buttons on the controller mesh based on their current state
  50879. * @param buttonName the name of the button to move
  50880. * @param buttonValue the value of the button which determines the buttons new position
  50881. */
  50882. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50883. /**
  50884. * Moves the axis on the controller mesh based on its current state
  50885. * @param axis the index of the axis
  50886. * @param axisValue the value of the axis which determines the meshes new position
  50887. * @hidden
  50888. */
  50889. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50890. /**
  50891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50892. * @param scene scene in which to add meshes
  50893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50894. */
  50895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50896. /**
  50897. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50898. * can be transformed by button presses and axes values, based on this._mapping.
  50899. *
  50900. * @param scene scene in which the meshes exist
  50901. * @param meshes list of meshes that make up the controller model to process
  50902. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50903. */
  50904. private processModel;
  50905. private createMeshInfo;
  50906. /**
  50907. * Gets the ray of the controller in the direction the controller is pointing
  50908. * @param length the length the resulting ray should be
  50909. * @returns a ray in the direction the controller is pointing
  50910. */
  50911. getForwardRay(length?: number): Ray;
  50912. /**
  50913. * Disposes of the controller
  50914. */
  50915. dispose(): void;
  50916. }
  50917. /**
  50918. * This class represents a new windows motion controller in XR.
  50919. */
  50920. export class XRWindowsMotionController extends WindowsMotionController {
  50921. /**
  50922. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50923. */
  50924. protected readonly _mapping: {
  50925. buttons: string[];
  50926. buttonMeshNames: {
  50927. trigger: string;
  50928. menu: string;
  50929. grip: string;
  50930. thumbstick: string;
  50931. trackpad: string;
  50932. };
  50933. buttonObservableNames: {
  50934. trigger: string;
  50935. menu: string;
  50936. grip: string;
  50937. thumbstick: string;
  50938. trackpad: string;
  50939. };
  50940. axisMeshNames: string[];
  50941. pointingPoseMeshName: string;
  50942. };
  50943. /**
  50944. * Construct a new XR-Based windows motion controller
  50945. *
  50946. * @param gamepadInfo the gamepad object from the browser
  50947. */
  50948. constructor(gamepadInfo: any);
  50949. /**
  50950. * holds the thumbstick values (X,Y)
  50951. */
  50952. thumbstickValues: StickValues;
  50953. /**
  50954. * Fired when the thumbstick on this controller is clicked
  50955. */
  50956. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50957. /**
  50958. * Fired when the thumbstick on this controller is modified
  50959. */
  50960. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50961. /**
  50962. * Fired when the touchpad button on this controller is modified
  50963. */
  50964. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50965. /**
  50966. * Fired when the touchpad values on this controller are modified
  50967. */
  50968. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50969. /**
  50970. * Fired when the thumbstick button on this controller is modified
  50971. * here to prevent breaking changes
  50972. */
  50973. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50974. /**
  50975. * updating the thumbstick(!) and not the trackpad.
  50976. * This is named this way due to the difference between WebVR and XR and to avoid
  50977. * changing the parent class.
  50978. */
  50979. protected _updateTrackpad(): void;
  50980. /**
  50981. * Disposes the class with joy
  50982. */
  50983. dispose(): void;
  50984. }
  50985. }
  50986. declare module "babylonjs/Gamepads/Controllers/index" {
  50987. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50988. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50989. export * from "babylonjs/Gamepads/Controllers/genericController";
  50990. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50991. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50992. export * from "babylonjs/Gamepads/Controllers/viveController";
  50993. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50994. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50995. }
  50996. declare module "babylonjs/Gamepads/index" {
  50997. export * from "babylonjs/Gamepads/Controllers/index";
  50998. export * from "babylonjs/Gamepads/gamepad";
  50999. export * from "babylonjs/Gamepads/gamepadManager";
  51000. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  51001. export * from "babylonjs/Gamepads/xboxGamepad";
  51002. export * from "babylonjs/Gamepads/dualShockGamepad";
  51003. }
  51004. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  51005. import { Scene } from "babylonjs/scene";
  51006. import { Vector4 } from "babylonjs/Maths/math.vector";
  51007. import { Color4 } from "babylonjs/Maths/math.color";
  51008. import { Mesh } from "babylonjs/Meshes/mesh";
  51009. import { Nullable } from "babylonjs/types";
  51010. /**
  51011. * Class containing static functions to help procedurally build meshes
  51012. */
  51013. export class PolyhedronBuilder {
  51014. /**
  51015. * Creates a polyhedron mesh
  51016. * * 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
  51017. * * The parameter `size` (positive float, default 1) sets the polygon size
  51018. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51019. * * 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`
  51020. * * 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
  51021. * * 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)`)
  51022. * * 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
  51023. * * 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
  51024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51027. * @param name defines the name of the mesh
  51028. * @param options defines the options used to create the mesh
  51029. * @param scene defines the hosting scene
  51030. * @returns the polyhedron mesh
  51031. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51032. */
  51033. static CreatePolyhedron(name: string, options: {
  51034. type?: number;
  51035. size?: number;
  51036. sizeX?: number;
  51037. sizeY?: number;
  51038. sizeZ?: number;
  51039. custom?: any;
  51040. faceUV?: Vector4[];
  51041. faceColors?: Color4[];
  51042. flat?: boolean;
  51043. updatable?: boolean;
  51044. sideOrientation?: number;
  51045. frontUVs?: Vector4;
  51046. backUVs?: Vector4;
  51047. }, scene?: Nullable<Scene>): Mesh;
  51048. }
  51049. }
  51050. declare module "babylonjs/Gizmos/scaleGizmo" {
  51051. import { Observable } from "babylonjs/Misc/observable";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51054. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51055. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  51056. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51057. /**
  51058. * Gizmo that enables scaling a mesh along 3 axis
  51059. */
  51060. export class ScaleGizmo extends Gizmo {
  51061. /**
  51062. * Internal gizmo used for interactions on the x axis
  51063. */
  51064. xGizmo: AxisScaleGizmo;
  51065. /**
  51066. * Internal gizmo used for interactions on the y axis
  51067. */
  51068. yGizmo: AxisScaleGizmo;
  51069. /**
  51070. * Internal gizmo used for interactions on the z axis
  51071. */
  51072. zGizmo: AxisScaleGizmo;
  51073. /**
  51074. * Internal gizmo used to scale all axis equally
  51075. */
  51076. uniformScaleGizmo: AxisScaleGizmo;
  51077. private _meshAttached;
  51078. private _updateGizmoRotationToMatchAttachedMesh;
  51079. private _snapDistance;
  51080. private _scaleRatio;
  51081. private _uniformScalingMesh;
  51082. private _octahedron;
  51083. private _sensitivity;
  51084. /** Fires an event when any of it's sub gizmos are dragged */
  51085. onDragStartObservable: Observable<unknown>;
  51086. /** Fires an event when any of it's sub gizmos are released from dragging */
  51087. onDragEndObservable: Observable<unknown>;
  51088. get attachedMesh(): Nullable<AbstractMesh>;
  51089. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51090. /**
  51091. * Creates a ScaleGizmo
  51092. * @param gizmoLayer The utility layer the gizmo will be added to
  51093. */
  51094. constructor(gizmoLayer?: UtilityLayerRenderer);
  51095. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51096. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51097. /**
  51098. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51099. */
  51100. set snapDistance(value: number);
  51101. get snapDistance(): number;
  51102. /**
  51103. * Ratio for the scale of the gizmo (Default: 1)
  51104. */
  51105. set scaleRatio(value: number);
  51106. get scaleRatio(): number;
  51107. /**
  51108. * Sensitivity factor for dragging (Default: 1)
  51109. */
  51110. set sensitivity(value: number);
  51111. get sensitivity(): number;
  51112. /**
  51113. * Disposes of the gizmo
  51114. */
  51115. dispose(): void;
  51116. }
  51117. }
  51118. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51119. import { Observable } from "babylonjs/Misc/observable";
  51120. import { Nullable } from "babylonjs/types";
  51121. import { Vector3 } from "babylonjs/Maths/math.vector";
  51122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51123. import { Mesh } from "babylonjs/Meshes/mesh";
  51124. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51125. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51126. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51127. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51128. import { Color3 } from "babylonjs/Maths/math.color";
  51129. /**
  51130. * Single axis scale gizmo
  51131. */
  51132. export class AxisScaleGizmo extends Gizmo {
  51133. /**
  51134. * Drag behavior responsible for the gizmos dragging interactions
  51135. */
  51136. dragBehavior: PointerDragBehavior;
  51137. private _pointerObserver;
  51138. /**
  51139. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51140. */
  51141. snapDistance: number;
  51142. /**
  51143. * Event that fires each time the gizmo snaps to a new location.
  51144. * * snapDistance is the the change in distance
  51145. */
  51146. onSnapObservable: Observable<{
  51147. snapDistance: number;
  51148. }>;
  51149. /**
  51150. * If the scaling operation should be done on all axis (default: false)
  51151. */
  51152. uniformScaling: boolean;
  51153. /**
  51154. * Custom sensitivity value for the drag strength
  51155. */
  51156. sensitivity: number;
  51157. private _isEnabled;
  51158. private _parent;
  51159. private _arrow;
  51160. private _coloredMaterial;
  51161. private _hoverMaterial;
  51162. /**
  51163. * Creates an AxisScaleGizmo
  51164. * @param gizmoLayer The utility layer the gizmo will be added to
  51165. * @param dragAxis The axis which the gizmo will be able to scale on
  51166. * @param color The color of the gizmo
  51167. */
  51168. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51170. /**
  51171. * If the gizmo is enabled
  51172. */
  51173. set isEnabled(value: boolean);
  51174. get isEnabled(): boolean;
  51175. /**
  51176. * Disposes of the gizmo
  51177. */
  51178. dispose(): void;
  51179. /**
  51180. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51181. * @param mesh The mesh to replace the default mesh of the gizmo
  51182. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51183. */
  51184. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51185. }
  51186. }
  51187. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51188. import { Observable } from "babylonjs/Misc/observable";
  51189. import { Nullable } from "babylonjs/types";
  51190. import { Vector3 } from "babylonjs/Maths/math.vector";
  51191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51192. import { Mesh } from "babylonjs/Meshes/mesh";
  51193. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51194. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51195. import { Color3 } from "babylonjs/Maths/math.color";
  51196. import "babylonjs/Meshes/Builders/boxBuilder";
  51197. /**
  51198. * Bounding box gizmo
  51199. */
  51200. export class BoundingBoxGizmo extends Gizmo {
  51201. private _lineBoundingBox;
  51202. private _rotateSpheresParent;
  51203. private _scaleBoxesParent;
  51204. private _boundingDimensions;
  51205. private _renderObserver;
  51206. private _pointerObserver;
  51207. private _scaleDragSpeed;
  51208. private _tmpQuaternion;
  51209. private _tmpVector;
  51210. private _tmpRotationMatrix;
  51211. /**
  51212. * 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)
  51213. */
  51214. ignoreChildren: boolean;
  51215. /**
  51216. * 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)
  51217. */
  51218. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51219. /**
  51220. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51221. */
  51222. rotationSphereSize: number;
  51223. /**
  51224. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51225. */
  51226. scaleBoxSize: number;
  51227. /**
  51228. * 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)
  51229. */
  51230. fixedDragMeshScreenSize: boolean;
  51231. /**
  51232. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51233. */
  51234. fixedDragMeshScreenSizeDistanceFactor: number;
  51235. /**
  51236. * Fired when a rotation sphere or scale box is dragged
  51237. */
  51238. onDragStartObservable: Observable<{}>;
  51239. /**
  51240. * Fired when a scale box is dragged
  51241. */
  51242. onScaleBoxDragObservable: Observable<{}>;
  51243. /**
  51244. * Fired when a scale box drag is ended
  51245. */
  51246. onScaleBoxDragEndObservable: Observable<{}>;
  51247. /**
  51248. * Fired when a rotation sphere is dragged
  51249. */
  51250. onRotationSphereDragObservable: Observable<{}>;
  51251. /**
  51252. * Fired when a rotation sphere drag is ended
  51253. */
  51254. onRotationSphereDragEndObservable: Observable<{}>;
  51255. /**
  51256. * 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)
  51257. */
  51258. scalePivot: Nullable<Vector3>;
  51259. /**
  51260. * Mesh used as a pivot to rotate the attached mesh
  51261. */
  51262. private _anchorMesh;
  51263. private _existingMeshScale;
  51264. private _dragMesh;
  51265. private pointerDragBehavior;
  51266. private coloredMaterial;
  51267. private hoverColoredMaterial;
  51268. /**
  51269. * Sets the color of the bounding box gizmo
  51270. * @param color the color to set
  51271. */
  51272. setColor(color: Color3): void;
  51273. /**
  51274. * Creates an BoundingBoxGizmo
  51275. * @param gizmoLayer The utility layer the gizmo will be added to
  51276. * @param color The color of the gizmo
  51277. */
  51278. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51280. private _selectNode;
  51281. /**
  51282. * Updates the bounding box information for the Gizmo
  51283. */
  51284. updateBoundingBox(): void;
  51285. private _updateRotationSpheres;
  51286. private _updateScaleBoxes;
  51287. /**
  51288. * Enables rotation on the specified axis and disables rotation on the others
  51289. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51290. */
  51291. setEnabledRotationAxis(axis: string): void;
  51292. /**
  51293. * Enables/disables scaling
  51294. * @param enable if scaling should be enabled
  51295. * @param homogeneousScaling defines if scaling should only be homogeneous
  51296. */
  51297. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51298. private _updateDummy;
  51299. /**
  51300. * Enables a pointer drag behavior on the bounding box of the gizmo
  51301. */
  51302. enableDragBehavior(): void;
  51303. /**
  51304. * Disposes of the gizmo
  51305. */
  51306. dispose(): void;
  51307. /**
  51308. * 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)
  51309. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51310. * @returns the bounding box mesh with the passed in mesh as a child
  51311. */
  51312. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51313. /**
  51314. * CustomMeshes are not supported by this gizmo
  51315. * @param mesh The mesh to replace the default mesh of the gizmo
  51316. */
  51317. setCustomMesh(mesh: Mesh): void;
  51318. }
  51319. }
  51320. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51321. import { Observable } from "babylonjs/Misc/observable";
  51322. import { Nullable } from "babylonjs/types";
  51323. import { Vector3 } from "babylonjs/Maths/math.vector";
  51324. import { Color3 } from "babylonjs/Maths/math.color";
  51325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51326. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51329. import "babylonjs/Meshes/Builders/linesBuilder";
  51330. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51331. /**
  51332. * Single plane rotation gizmo
  51333. */
  51334. export class PlaneRotationGizmo extends Gizmo {
  51335. /**
  51336. * Drag behavior responsible for the gizmos dragging interactions
  51337. */
  51338. dragBehavior: PointerDragBehavior;
  51339. private _pointerObserver;
  51340. /**
  51341. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51342. */
  51343. snapDistance: number;
  51344. /**
  51345. * Event that fires each time the gizmo snaps to a new location.
  51346. * * snapDistance is the the change in distance
  51347. */
  51348. onSnapObservable: Observable<{
  51349. snapDistance: number;
  51350. }>;
  51351. private _isEnabled;
  51352. private _parent;
  51353. /**
  51354. * Creates a PlaneRotationGizmo
  51355. * @param gizmoLayer The utility layer the gizmo will be added to
  51356. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51357. * @param color The color of the gizmo
  51358. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51359. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51360. */
  51361. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51363. /**
  51364. * If the gizmo is enabled
  51365. */
  51366. set isEnabled(value: boolean);
  51367. get isEnabled(): boolean;
  51368. /**
  51369. * Disposes of the gizmo
  51370. */
  51371. dispose(): void;
  51372. }
  51373. }
  51374. declare module "babylonjs/Gizmos/rotationGizmo" {
  51375. import { Observable } from "babylonjs/Misc/observable";
  51376. import { Nullable } from "babylonjs/types";
  51377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51378. import { Mesh } from "babylonjs/Meshes/mesh";
  51379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51380. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51382. /**
  51383. * Gizmo that enables rotating a mesh along 3 axis
  51384. */
  51385. export class RotationGizmo extends Gizmo {
  51386. /**
  51387. * Internal gizmo used for interactions on the x axis
  51388. */
  51389. xGizmo: PlaneRotationGizmo;
  51390. /**
  51391. * Internal gizmo used for interactions on the y axis
  51392. */
  51393. yGizmo: PlaneRotationGizmo;
  51394. /**
  51395. * Internal gizmo used for interactions on the z axis
  51396. */
  51397. zGizmo: PlaneRotationGizmo;
  51398. /** Fires an event when any of it's sub gizmos are dragged */
  51399. onDragStartObservable: Observable<unknown>;
  51400. /** Fires an event when any of it's sub gizmos are released from dragging */
  51401. onDragEndObservable: Observable<unknown>;
  51402. private _meshAttached;
  51403. get attachedMesh(): Nullable<AbstractMesh>;
  51404. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51405. /**
  51406. * Creates a RotationGizmo
  51407. * @param gizmoLayer The utility layer the gizmo will be added to
  51408. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51409. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51410. */
  51411. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51412. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51413. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51414. /**
  51415. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51416. */
  51417. set snapDistance(value: number);
  51418. get snapDistance(): number;
  51419. /**
  51420. * Ratio for the scale of the gizmo (Default: 1)
  51421. */
  51422. set scaleRatio(value: number);
  51423. get scaleRatio(): number;
  51424. /**
  51425. * Disposes of the gizmo
  51426. */
  51427. dispose(): void;
  51428. /**
  51429. * CustomMeshes are not supported by this gizmo
  51430. * @param mesh The mesh to replace the default mesh of the gizmo
  51431. */
  51432. setCustomMesh(mesh: Mesh): void;
  51433. }
  51434. }
  51435. declare module "babylonjs/Gizmos/gizmoManager" {
  51436. import { Observable } from "babylonjs/Misc/observable";
  51437. import { Nullable } from "babylonjs/types";
  51438. import { Scene, IDisposable } from "babylonjs/scene";
  51439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51441. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51442. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51443. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51444. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51445. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51446. /**
  51447. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51448. */
  51449. export class GizmoManager implements IDisposable {
  51450. private scene;
  51451. /**
  51452. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51453. */
  51454. gizmos: {
  51455. positionGizmo: Nullable<PositionGizmo>;
  51456. rotationGizmo: Nullable<RotationGizmo>;
  51457. scaleGizmo: Nullable<ScaleGizmo>;
  51458. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51459. };
  51460. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51461. clearGizmoOnEmptyPointerEvent: boolean;
  51462. /** Fires an event when the manager is attached to a mesh */
  51463. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51464. private _gizmosEnabled;
  51465. private _pointerObserver;
  51466. private _attachedMesh;
  51467. private _boundingBoxColor;
  51468. private _defaultUtilityLayer;
  51469. private _defaultKeepDepthUtilityLayer;
  51470. /**
  51471. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51472. */
  51473. boundingBoxDragBehavior: SixDofDragBehavior;
  51474. /**
  51475. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51476. */
  51477. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51478. /**
  51479. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51480. */
  51481. usePointerToAttachGizmos: boolean;
  51482. /**
  51483. * Utility layer that the bounding box gizmo belongs to
  51484. */
  51485. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51486. /**
  51487. * Utility layer that all gizmos besides bounding box belong to
  51488. */
  51489. get utilityLayer(): UtilityLayerRenderer;
  51490. /**
  51491. * Instatiates a gizmo manager
  51492. * @param scene the scene to overlay the gizmos on top of
  51493. */
  51494. constructor(scene: Scene);
  51495. /**
  51496. * Attaches a set of gizmos to the specified mesh
  51497. * @param mesh The mesh the gizmo's should be attached to
  51498. */
  51499. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51500. /**
  51501. * If the position gizmo is enabled
  51502. */
  51503. set positionGizmoEnabled(value: boolean);
  51504. get positionGizmoEnabled(): boolean;
  51505. /**
  51506. * If the rotation gizmo is enabled
  51507. */
  51508. set rotationGizmoEnabled(value: boolean);
  51509. get rotationGizmoEnabled(): boolean;
  51510. /**
  51511. * If the scale gizmo is enabled
  51512. */
  51513. set scaleGizmoEnabled(value: boolean);
  51514. get scaleGizmoEnabled(): boolean;
  51515. /**
  51516. * If the boundingBox gizmo is enabled
  51517. */
  51518. set boundingBoxGizmoEnabled(value: boolean);
  51519. get boundingBoxGizmoEnabled(): boolean;
  51520. /**
  51521. * Disposes of the gizmo manager
  51522. */
  51523. dispose(): void;
  51524. }
  51525. }
  51526. declare module "babylonjs/Lights/directionalLight" {
  51527. import { Camera } from "babylonjs/Cameras/camera";
  51528. import { Scene } from "babylonjs/scene";
  51529. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51531. import { Light } from "babylonjs/Lights/light";
  51532. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51533. import { Effect } from "babylonjs/Materials/effect";
  51534. /**
  51535. * A directional light is defined by a direction (what a surprise!).
  51536. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51537. * 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.
  51538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51539. */
  51540. export class DirectionalLight extends ShadowLight {
  51541. private _shadowFrustumSize;
  51542. /**
  51543. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51544. */
  51545. get shadowFrustumSize(): number;
  51546. /**
  51547. * Specifies a fix frustum size for the shadow generation.
  51548. */
  51549. set shadowFrustumSize(value: number);
  51550. private _shadowOrthoScale;
  51551. /**
  51552. * Gets the shadow projection scale against the optimal computed one.
  51553. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51554. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51555. */
  51556. get shadowOrthoScale(): number;
  51557. /**
  51558. * Sets the shadow projection scale against the optimal computed one.
  51559. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51560. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51561. */
  51562. set shadowOrthoScale(value: number);
  51563. /**
  51564. * Automatically compute the projection matrix to best fit (including all the casters)
  51565. * on each frame.
  51566. */
  51567. autoUpdateExtends: boolean;
  51568. /**
  51569. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51570. * on each frame. autoUpdateExtends must be set to true for this to work
  51571. */
  51572. autoCalcShadowZBounds: boolean;
  51573. private _orthoLeft;
  51574. private _orthoRight;
  51575. private _orthoTop;
  51576. private _orthoBottom;
  51577. /**
  51578. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51579. * The directional light is emitted from everywhere in the given direction.
  51580. * It can cast shadows.
  51581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51582. * @param name The friendly name of the light
  51583. * @param direction The direction of the light
  51584. * @param scene The scene the light belongs to
  51585. */
  51586. constructor(name: string, direction: Vector3, scene: Scene);
  51587. /**
  51588. * Returns the string "DirectionalLight".
  51589. * @return The class name
  51590. */
  51591. getClassName(): string;
  51592. /**
  51593. * Returns the integer 1.
  51594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51595. */
  51596. getTypeID(): number;
  51597. /**
  51598. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51599. * Returns the DirectionalLight Shadow projection matrix.
  51600. */
  51601. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51602. /**
  51603. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51604. * Returns the DirectionalLight Shadow projection matrix.
  51605. */
  51606. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51607. /**
  51608. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51609. * Returns the DirectionalLight Shadow projection matrix.
  51610. */
  51611. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51612. protected _buildUniformLayout(): void;
  51613. /**
  51614. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51615. * @param effect The effect to update
  51616. * @param lightIndex The index of the light in the effect to update
  51617. * @returns The directional light
  51618. */
  51619. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51620. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51621. /**
  51622. * Gets the minZ used for shadow according to both the scene and the light.
  51623. *
  51624. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51625. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51626. * @param activeCamera The camera we are returning the min for
  51627. * @returns the depth min z
  51628. */
  51629. getDepthMinZ(activeCamera: Camera): number;
  51630. /**
  51631. * Gets the maxZ used for shadow according to both the scene and the light.
  51632. *
  51633. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51634. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51635. * @param activeCamera The camera we are returning the max for
  51636. * @returns the depth max z
  51637. */
  51638. getDepthMaxZ(activeCamera: Camera): number;
  51639. /**
  51640. * Prepares the list of defines specific to the light type.
  51641. * @param defines the list of defines
  51642. * @param lightIndex defines the index of the light for the effect
  51643. */
  51644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51645. }
  51646. }
  51647. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51648. import { Mesh } from "babylonjs/Meshes/mesh";
  51649. /**
  51650. * Class containing static functions to help procedurally build meshes
  51651. */
  51652. export class HemisphereBuilder {
  51653. /**
  51654. * Creates a hemisphere mesh
  51655. * @param name defines the name of the mesh
  51656. * @param options defines the options used to create the mesh
  51657. * @param scene defines the hosting scene
  51658. * @returns the hemisphere mesh
  51659. */
  51660. static CreateHemisphere(name: string, options: {
  51661. segments?: number;
  51662. diameter?: number;
  51663. sideOrientation?: number;
  51664. }, scene: any): Mesh;
  51665. }
  51666. }
  51667. declare module "babylonjs/Lights/spotLight" {
  51668. import { Nullable } from "babylonjs/types";
  51669. import { Scene } from "babylonjs/scene";
  51670. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51672. import { Effect } from "babylonjs/Materials/effect";
  51673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51674. import { Light } from "babylonjs/Lights/light";
  51675. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51676. /**
  51677. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51678. * These values define a cone of light starting from the position, emitting toward the direction.
  51679. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51680. * and the exponent defines the speed of the decay of the light with distance (reach).
  51681. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51682. */
  51683. export class SpotLight extends ShadowLight {
  51684. private _angle;
  51685. private _innerAngle;
  51686. private _cosHalfAngle;
  51687. private _lightAngleScale;
  51688. private _lightAngleOffset;
  51689. /**
  51690. * Gets the cone angle of the spot light in Radians.
  51691. */
  51692. get angle(): number;
  51693. /**
  51694. * Sets the cone angle of the spot light in Radians.
  51695. */
  51696. set angle(value: number);
  51697. /**
  51698. * Only used in gltf falloff mode, this defines the angle where
  51699. * the directional falloff will start before cutting at angle which could be seen
  51700. * as outer angle.
  51701. */
  51702. get innerAngle(): number;
  51703. /**
  51704. * Only used in gltf falloff mode, this defines the angle where
  51705. * the directional falloff will start before cutting at angle which could be seen
  51706. * as outer angle.
  51707. */
  51708. set innerAngle(value: number);
  51709. private _shadowAngleScale;
  51710. /**
  51711. * Allows scaling the angle of the light for shadow generation only.
  51712. */
  51713. get shadowAngleScale(): number;
  51714. /**
  51715. * Allows scaling the angle of the light for shadow generation only.
  51716. */
  51717. set shadowAngleScale(value: number);
  51718. /**
  51719. * The light decay speed with the distance from the emission spot.
  51720. */
  51721. exponent: number;
  51722. private _projectionTextureMatrix;
  51723. /**
  51724. * Allows reading the projecton texture
  51725. */
  51726. get projectionTextureMatrix(): Matrix;
  51727. protected _projectionTextureLightNear: number;
  51728. /**
  51729. * Gets the near clip of the Spotlight for texture projection.
  51730. */
  51731. get projectionTextureLightNear(): number;
  51732. /**
  51733. * Sets the near clip of the Spotlight for texture projection.
  51734. */
  51735. set projectionTextureLightNear(value: number);
  51736. protected _projectionTextureLightFar: number;
  51737. /**
  51738. * Gets the far clip of the Spotlight for texture projection.
  51739. */
  51740. get projectionTextureLightFar(): number;
  51741. /**
  51742. * Sets the far clip of the Spotlight for texture projection.
  51743. */
  51744. set projectionTextureLightFar(value: number);
  51745. protected _projectionTextureUpDirection: Vector3;
  51746. /**
  51747. * Gets the Up vector of the Spotlight for texture projection.
  51748. */
  51749. get projectionTextureUpDirection(): Vector3;
  51750. /**
  51751. * Sets the Up vector of the Spotlight for texture projection.
  51752. */
  51753. set projectionTextureUpDirection(value: Vector3);
  51754. private _projectionTexture;
  51755. /**
  51756. * Gets the projection texture of the light.
  51757. */
  51758. get projectionTexture(): Nullable<BaseTexture>;
  51759. /**
  51760. * Sets the projection texture of the light.
  51761. */
  51762. set projectionTexture(value: Nullable<BaseTexture>);
  51763. private _projectionTextureViewLightDirty;
  51764. private _projectionTextureProjectionLightDirty;
  51765. private _projectionTextureDirty;
  51766. private _projectionTextureViewTargetVector;
  51767. private _projectionTextureViewLightMatrix;
  51768. private _projectionTextureProjectionLightMatrix;
  51769. private _projectionTextureScalingMatrix;
  51770. /**
  51771. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51772. * It can cast shadows.
  51773. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51774. * @param name The light friendly name
  51775. * @param position The position of the spot light in the scene
  51776. * @param direction The direction of the light in the scene
  51777. * @param angle The cone angle of the light in Radians
  51778. * @param exponent The light decay speed with the distance from the emission spot
  51779. * @param scene The scene the lights belongs to
  51780. */
  51781. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51782. /**
  51783. * Returns the string "SpotLight".
  51784. * @returns the class name
  51785. */
  51786. getClassName(): string;
  51787. /**
  51788. * Returns the integer 2.
  51789. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51790. */
  51791. getTypeID(): number;
  51792. /**
  51793. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51794. */
  51795. protected _setDirection(value: Vector3): void;
  51796. /**
  51797. * Overrides the position setter to recompute the projection texture view light Matrix.
  51798. */
  51799. protected _setPosition(value: Vector3): void;
  51800. /**
  51801. * 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.
  51802. * Returns the SpotLight.
  51803. */
  51804. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51805. protected _computeProjectionTextureViewLightMatrix(): void;
  51806. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51807. /**
  51808. * Main function for light texture projection matrix computing.
  51809. */
  51810. protected _computeProjectionTextureMatrix(): void;
  51811. protected _buildUniformLayout(): void;
  51812. private _computeAngleValues;
  51813. /**
  51814. * Sets the passed Effect "effect" with the Light textures.
  51815. * @param effect The effect to update
  51816. * @param lightIndex The index of the light in the effect to update
  51817. * @returns The light
  51818. */
  51819. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51820. /**
  51821. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51822. * @param effect The effect to update
  51823. * @param lightIndex The index of the light in the effect to update
  51824. * @returns The spot light
  51825. */
  51826. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51827. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51828. /**
  51829. * Disposes the light and the associated resources.
  51830. */
  51831. dispose(): void;
  51832. /**
  51833. * Prepares the list of defines specific to the light type.
  51834. * @param defines the list of defines
  51835. * @param lightIndex defines the index of the light for the effect
  51836. */
  51837. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51838. }
  51839. }
  51840. declare module "babylonjs/Gizmos/lightGizmo" {
  51841. import { Nullable } from "babylonjs/types";
  51842. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51844. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51845. import { Light } from "babylonjs/Lights/light";
  51846. /**
  51847. * Gizmo that enables viewing a light
  51848. */
  51849. export class LightGizmo extends Gizmo {
  51850. private _lightMesh;
  51851. private _material;
  51852. private _cachedPosition;
  51853. private _cachedForward;
  51854. private _attachedMeshParent;
  51855. /**
  51856. * Creates a LightGizmo
  51857. * @param gizmoLayer The utility layer the gizmo will be added to
  51858. */
  51859. constructor(gizmoLayer?: UtilityLayerRenderer);
  51860. private _light;
  51861. /**
  51862. * The light that the gizmo is attached to
  51863. */
  51864. set light(light: Nullable<Light>);
  51865. get light(): Nullable<Light>;
  51866. /**
  51867. * Gets the material used to render the light gizmo
  51868. */
  51869. get material(): StandardMaterial;
  51870. /**
  51871. * @hidden
  51872. * Updates the gizmo to match the attached mesh's position/rotation
  51873. */
  51874. protected _update(): void;
  51875. private static _Scale;
  51876. /**
  51877. * Creates the lines for a light mesh
  51878. */
  51879. private static _CreateLightLines;
  51880. /**
  51881. * Disposes of the light gizmo
  51882. */
  51883. dispose(): void;
  51884. private static _CreateHemisphericLightMesh;
  51885. private static _CreatePointLightMesh;
  51886. private static _CreateSpotLightMesh;
  51887. private static _CreateDirectionalLightMesh;
  51888. }
  51889. }
  51890. declare module "babylonjs/Gizmos/index" {
  51891. export * from "babylonjs/Gizmos/axisDragGizmo";
  51892. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51893. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51894. export * from "babylonjs/Gizmos/gizmo";
  51895. export * from "babylonjs/Gizmos/gizmoManager";
  51896. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51897. export * from "babylonjs/Gizmos/positionGizmo";
  51898. export * from "babylonjs/Gizmos/rotationGizmo";
  51899. export * from "babylonjs/Gizmos/scaleGizmo";
  51900. export * from "babylonjs/Gizmos/lightGizmo";
  51901. export * from "babylonjs/Gizmos/planeDragGizmo";
  51902. }
  51903. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51904. /** @hidden */
  51905. export var backgroundFragmentDeclaration: {
  51906. name: string;
  51907. shader: string;
  51908. };
  51909. }
  51910. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51911. /** @hidden */
  51912. export var backgroundUboDeclaration: {
  51913. name: string;
  51914. shader: string;
  51915. };
  51916. }
  51917. declare module "babylonjs/Shaders/background.fragment" {
  51918. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51919. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51920. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51921. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51922. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51923. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51925. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51926. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51927. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51929. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51930. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51931. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51932. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51933. /** @hidden */
  51934. export var backgroundPixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51940. /** @hidden */
  51941. export var backgroundVertexDeclaration: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/Shaders/background.vertex" {
  51947. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51948. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51950. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51951. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51952. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51953. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51954. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51955. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51956. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51957. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51959. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51960. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51961. /** @hidden */
  51962. export var backgroundVertexShader: {
  51963. name: string;
  51964. shader: string;
  51965. };
  51966. }
  51967. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51968. import { Nullable, int, float } from "babylonjs/types";
  51969. import { Scene } from "babylonjs/scene";
  51970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51973. import { Mesh } from "babylonjs/Meshes/mesh";
  51974. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51975. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51976. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51978. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51979. import { Color3 } from "babylonjs/Maths/math.color";
  51980. import "babylonjs/Shaders/background.fragment";
  51981. import "babylonjs/Shaders/background.vertex";
  51982. /**
  51983. * Background material used to create an efficient environement around your scene.
  51984. */
  51985. export class BackgroundMaterial extends PushMaterial {
  51986. /**
  51987. * Standard reflectance value at parallel view angle.
  51988. */
  51989. static StandardReflectance0: number;
  51990. /**
  51991. * Standard reflectance value at grazing angle.
  51992. */
  51993. static StandardReflectance90: number;
  51994. protected _primaryColor: Color3;
  51995. /**
  51996. * Key light Color (multiply against the environement texture)
  51997. */
  51998. primaryColor: Color3;
  51999. protected __perceptualColor: Nullable<Color3>;
  52000. /**
  52001. * Experimental Internal Use Only.
  52002. *
  52003. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52004. * This acts as a helper to set the primary color to a more "human friendly" value.
  52005. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52006. * output color as close as possible from the chosen value.
  52007. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52008. * part of lighting setup.)
  52009. */
  52010. get _perceptualColor(): Nullable<Color3>;
  52011. set _perceptualColor(value: Nullable<Color3>);
  52012. protected _primaryColorShadowLevel: float;
  52013. /**
  52014. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52015. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52016. */
  52017. get primaryColorShadowLevel(): float;
  52018. set primaryColorShadowLevel(value: float);
  52019. protected _primaryColorHighlightLevel: float;
  52020. /**
  52021. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52022. * The primary color is used at the level chosen to define what the white area would look.
  52023. */
  52024. get primaryColorHighlightLevel(): float;
  52025. set primaryColorHighlightLevel(value: float);
  52026. protected _reflectionTexture: Nullable<BaseTexture>;
  52027. /**
  52028. * Reflection Texture used in the material.
  52029. * Should be author in a specific way for the best result (refer to the documentation).
  52030. */
  52031. reflectionTexture: Nullable<BaseTexture>;
  52032. protected _reflectionBlur: float;
  52033. /**
  52034. * Reflection Texture level of blur.
  52035. *
  52036. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52037. * texture twice.
  52038. */
  52039. reflectionBlur: float;
  52040. protected _diffuseTexture: Nullable<BaseTexture>;
  52041. /**
  52042. * Diffuse Texture used in the material.
  52043. * Should be author in a specific way for the best result (refer to the documentation).
  52044. */
  52045. diffuseTexture: Nullable<BaseTexture>;
  52046. protected _shadowLights: Nullable<IShadowLight[]>;
  52047. /**
  52048. * Specify the list of lights casting shadow on the material.
  52049. * All scene shadow lights will be included if null.
  52050. */
  52051. shadowLights: Nullable<IShadowLight[]>;
  52052. protected _shadowLevel: float;
  52053. /**
  52054. * Helps adjusting the shadow to a softer level if required.
  52055. * 0 means black shadows and 1 means no shadows.
  52056. */
  52057. shadowLevel: float;
  52058. protected _sceneCenter: Vector3;
  52059. /**
  52060. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52061. * It is usually zero but might be interesting to modify according to your setup.
  52062. */
  52063. sceneCenter: Vector3;
  52064. protected _opacityFresnel: boolean;
  52065. /**
  52066. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52067. * This helps ensuring a nice transition when the camera goes under the ground.
  52068. */
  52069. opacityFresnel: boolean;
  52070. protected _reflectionFresnel: boolean;
  52071. /**
  52072. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52073. * This helps adding a mirror texture on the ground.
  52074. */
  52075. reflectionFresnel: boolean;
  52076. protected _reflectionFalloffDistance: number;
  52077. /**
  52078. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52079. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52080. */
  52081. reflectionFalloffDistance: number;
  52082. protected _reflectionAmount: number;
  52083. /**
  52084. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52085. */
  52086. reflectionAmount: number;
  52087. protected _reflectionReflectance0: number;
  52088. /**
  52089. * This specifies the weight of the reflection at grazing angle.
  52090. */
  52091. reflectionReflectance0: number;
  52092. protected _reflectionReflectance90: number;
  52093. /**
  52094. * This specifies the weight of the reflection at a perpendicular point of view.
  52095. */
  52096. reflectionReflectance90: number;
  52097. /**
  52098. * Sets the reflection reflectance fresnel values according to the default standard
  52099. * empirically know to work well :-)
  52100. */
  52101. set reflectionStandardFresnelWeight(value: number);
  52102. protected _useRGBColor: boolean;
  52103. /**
  52104. * Helps to directly use the maps channels instead of their level.
  52105. */
  52106. useRGBColor: boolean;
  52107. protected _enableNoise: boolean;
  52108. /**
  52109. * This helps reducing the banding effect that could occur on the background.
  52110. */
  52111. enableNoise: boolean;
  52112. /**
  52113. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52114. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52115. * Recommended to be keep at 1.0 except for special cases.
  52116. */
  52117. get fovMultiplier(): number;
  52118. set fovMultiplier(value: number);
  52119. private _fovMultiplier;
  52120. /**
  52121. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52122. */
  52123. useEquirectangularFOV: boolean;
  52124. private _maxSimultaneousLights;
  52125. /**
  52126. * Number of Simultaneous lights allowed on the material.
  52127. */
  52128. maxSimultaneousLights: int;
  52129. /**
  52130. * Default configuration related to image processing available in the Background Material.
  52131. */
  52132. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52133. /**
  52134. * Keep track of the image processing observer to allow dispose and replace.
  52135. */
  52136. private _imageProcessingObserver;
  52137. /**
  52138. * Attaches a new image processing configuration to the PBR Material.
  52139. * @param configuration (if null the scene configuration will be use)
  52140. */
  52141. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52142. /**
  52143. * Gets the image processing configuration used either in this material.
  52144. */
  52145. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52146. /**
  52147. * Sets the Default image processing configuration used either in the this material.
  52148. *
  52149. * If sets to null, the scene one is in use.
  52150. */
  52151. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52152. /**
  52153. * Gets wether the color curves effect is enabled.
  52154. */
  52155. get cameraColorCurvesEnabled(): boolean;
  52156. /**
  52157. * Sets wether the color curves effect is enabled.
  52158. */
  52159. set cameraColorCurvesEnabled(value: boolean);
  52160. /**
  52161. * Gets wether the color grading effect is enabled.
  52162. */
  52163. get cameraColorGradingEnabled(): boolean;
  52164. /**
  52165. * Gets wether the color grading effect is enabled.
  52166. */
  52167. set cameraColorGradingEnabled(value: boolean);
  52168. /**
  52169. * Gets wether tonemapping is enabled or not.
  52170. */
  52171. get cameraToneMappingEnabled(): boolean;
  52172. /**
  52173. * Sets wether tonemapping is enabled or not
  52174. */
  52175. set cameraToneMappingEnabled(value: boolean);
  52176. /**
  52177. * The camera exposure used on this material.
  52178. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52179. * This corresponds to a photographic exposure.
  52180. */
  52181. get cameraExposure(): float;
  52182. /**
  52183. * The camera exposure used on this material.
  52184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52185. * This corresponds to a photographic exposure.
  52186. */
  52187. set cameraExposure(value: float);
  52188. /**
  52189. * Gets The camera contrast used on this material.
  52190. */
  52191. get cameraContrast(): float;
  52192. /**
  52193. * Sets The camera contrast used on this material.
  52194. */
  52195. set cameraContrast(value: float);
  52196. /**
  52197. * Gets the Color Grading 2D Lookup Texture.
  52198. */
  52199. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52200. /**
  52201. * Sets the Color Grading 2D Lookup Texture.
  52202. */
  52203. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52204. /**
  52205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52207. * 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;
  52208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52209. */
  52210. get cameraColorCurves(): Nullable<ColorCurves>;
  52211. /**
  52212. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52213. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52214. * 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;
  52215. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52216. */
  52217. set cameraColorCurves(value: Nullable<ColorCurves>);
  52218. /**
  52219. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52220. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52221. */
  52222. switchToBGR: boolean;
  52223. private _renderTargets;
  52224. private _reflectionControls;
  52225. private _white;
  52226. private _primaryShadowColor;
  52227. private _primaryHighlightColor;
  52228. /**
  52229. * Instantiates a Background Material in the given scene
  52230. * @param name The friendly name of the material
  52231. * @param scene The scene to add the material to
  52232. */
  52233. constructor(name: string, scene: Scene);
  52234. /**
  52235. * Gets a boolean indicating that current material needs to register RTT
  52236. */
  52237. get hasRenderTargetTextures(): boolean;
  52238. /**
  52239. * The entire material has been created in order to prevent overdraw.
  52240. * @returns false
  52241. */
  52242. needAlphaTesting(): boolean;
  52243. /**
  52244. * The entire material has been created in order to prevent overdraw.
  52245. * @returns true if blending is enable
  52246. */
  52247. needAlphaBlending(): boolean;
  52248. /**
  52249. * Checks wether the material is ready to be rendered for a given mesh.
  52250. * @param mesh The mesh to render
  52251. * @param subMesh The submesh to check against
  52252. * @param useInstances Specify wether or not the material is used with instances
  52253. * @returns true if all the dependencies are ready (Textures, Effects...)
  52254. */
  52255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52256. /**
  52257. * Compute the primary color according to the chosen perceptual color.
  52258. */
  52259. private _computePrimaryColorFromPerceptualColor;
  52260. /**
  52261. * Compute the highlights and shadow colors according to their chosen levels.
  52262. */
  52263. private _computePrimaryColors;
  52264. /**
  52265. * Build the uniform buffer used in the material.
  52266. */
  52267. buildUniformLayout(): void;
  52268. /**
  52269. * Unbind the material.
  52270. */
  52271. unbind(): void;
  52272. /**
  52273. * Bind only the world matrix to the material.
  52274. * @param world The world matrix to bind.
  52275. */
  52276. bindOnlyWorldMatrix(world: Matrix): void;
  52277. /**
  52278. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52279. * @param world The world matrix to bind.
  52280. * @param subMesh The submesh to bind for.
  52281. */
  52282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52283. /**
  52284. * Checks to see if a texture is used in the material.
  52285. * @param texture - Base texture to use.
  52286. * @returns - Boolean specifying if a texture is used in the material.
  52287. */
  52288. hasTexture(texture: BaseTexture): boolean;
  52289. /**
  52290. * Dispose the material.
  52291. * @param forceDisposeEffect Force disposal of the associated effect.
  52292. * @param forceDisposeTextures Force disposal of the associated textures.
  52293. */
  52294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52295. /**
  52296. * Clones the material.
  52297. * @param name The cloned name.
  52298. * @returns The cloned material.
  52299. */
  52300. clone(name: string): BackgroundMaterial;
  52301. /**
  52302. * Serializes the current material to its JSON representation.
  52303. * @returns The JSON representation.
  52304. */
  52305. serialize(): any;
  52306. /**
  52307. * Gets the class name of the material
  52308. * @returns "BackgroundMaterial"
  52309. */
  52310. getClassName(): string;
  52311. /**
  52312. * Parse a JSON input to create back a background material.
  52313. * @param source The JSON data to parse
  52314. * @param scene The scene to create the parsed material in
  52315. * @param rootUrl The root url of the assets the material depends upon
  52316. * @returns the instantiated BackgroundMaterial.
  52317. */
  52318. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52319. }
  52320. }
  52321. declare module "babylonjs/Helpers/environmentHelper" {
  52322. import { Observable } from "babylonjs/Misc/observable";
  52323. import { Nullable } from "babylonjs/types";
  52324. import { Scene } from "babylonjs/scene";
  52325. import { Vector3 } from "babylonjs/Maths/math.vector";
  52326. import { Color3 } from "babylonjs/Maths/math.color";
  52327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52328. import { Mesh } from "babylonjs/Meshes/mesh";
  52329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52330. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52331. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52332. import "babylonjs/Meshes/Builders/planeBuilder";
  52333. import "babylonjs/Meshes/Builders/boxBuilder";
  52334. /**
  52335. * Represents the different options available during the creation of
  52336. * a Environment helper.
  52337. *
  52338. * This can control the default ground, skybox and image processing setup of your scene.
  52339. */
  52340. export interface IEnvironmentHelperOptions {
  52341. /**
  52342. * Specifies whether or not to create a ground.
  52343. * True by default.
  52344. */
  52345. createGround: boolean;
  52346. /**
  52347. * Specifies the ground size.
  52348. * 15 by default.
  52349. */
  52350. groundSize: number;
  52351. /**
  52352. * The texture used on the ground for the main color.
  52353. * Comes from the BabylonJS CDN by default.
  52354. *
  52355. * Remarks: Can be either a texture or a url.
  52356. */
  52357. groundTexture: string | BaseTexture;
  52358. /**
  52359. * The color mixed in the ground texture by default.
  52360. * BabylonJS clearColor by default.
  52361. */
  52362. groundColor: Color3;
  52363. /**
  52364. * Specifies the ground opacity.
  52365. * 1 by default.
  52366. */
  52367. groundOpacity: number;
  52368. /**
  52369. * Enables the ground to receive shadows.
  52370. * True by default.
  52371. */
  52372. enableGroundShadow: boolean;
  52373. /**
  52374. * Helps preventing the shadow to be fully black on the ground.
  52375. * 0.5 by default.
  52376. */
  52377. groundShadowLevel: number;
  52378. /**
  52379. * Creates a mirror texture attach to the ground.
  52380. * false by default.
  52381. */
  52382. enableGroundMirror: boolean;
  52383. /**
  52384. * Specifies the ground mirror size ratio.
  52385. * 0.3 by default as the default kernel is 64.
  52386. */
  52387. groundMirrorSizeRatio: number;
  52388. /**
  52389. * Specifies the ground mirror blur kernel size.
  52390. * 64 by default.
  52391. */
  52392. groundMirrorBlurKernel: number;
  52393. /**
  52394. * Specifies the ground mirror visibility amount.
  52395. * 1 by default
  52396. */
  52397. groundMirrorAmount: number;
  52398. /**
  52399. * Specifies the ground mirror reflectance weight.
  52400. * This uses the standard weight of the background material to setup the fresnel effect
  52401. * of the mirror.
  52402. * 1 by default.
  52403. */
  52404. groundMirrorFresnelWeight: number;
  52405. /**
  52406. * Specifies the ground mirror Falloff distance.
  52407. * This can helps reducing the size of the reflection.
  52408. * 0 by Default.
  52409. */
  52410. groundMirrorFallOffDistance: number;
  52411. /**
  52412. * Specifies the ground mirror texture type.
  52413. * Unsigned Int by Default.
  52414. */
  52415. groundMirrorTextureType: number;
  52416. /**
  52417. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52418. * the shown objects.
  52419. */
  52420. groundYBias: number;
  52421. /**
  52422. * Specifies whether or not to create a skybox.
  52423. * True by default.
  52424. */
  52425. createSkybox: boolean;
  52426. /**
  52427. * Specifies the skybox size.
  52428. * 20 by default.
  52429. */
  52430. skyboxSize: number;
  52431. /**
  52432. * The texture used on the skybox for the main color.
  52433. * Comes from the BabylonJS CDN by default.
  52434. *
  52435. * Remarks: Can be either a texture or a url.
  52436. */
  52437. skyboxTexture: string | BaseTexture;
  52438. /**
  52439. * The color mixed in the skybox texture by default.
  52440. * BabylonJS clearColor by default.
  52441. */
  52442. skyboxColor: Color3;
  52443. /**
  52444. * The background rotation around the Y axis of the scene.
  52445. * This helps aligning the key lights of your scene with the background.
  52446. * 0 by default.
  52447. */
  52448. backgroundYRotation: number;
  52449. /**
  52450. * Compute automatically the size of the elements to best fit with the scene.
  52451. */
  52452. sizeAuto: boolean;
  52453. /**
  52454. * Default position of the rootMesh if autoSize is not true.
  52455. */
  52456. rootPosition: Vector3;
  52457. /**
  52458. * Sets up the image processing in the scene.
  52459. * true by default.
  52460. */
  52461. setupImageProcessing: boolean;
  52462. /**
  52463. * The texture used as your environment texture in the scene.
  52464. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52465. *
  52466. * Remarks: Can be either a texture or a url.
  52467. */
  52468. environmentTexture: string | BaseTexture;
  52469. /**
  52470. * The value of the exposure to apply to the scene.
  52471. * 0.6 by default if setupImageProcessing is true.
  52472. */
  52473. cameraExposure: number;
  52474. /**
  52475. * The value of the contrast to apply to the scene.
  52476. * 1.6 by default if setupImageProcessing is true.
  52477. */
  52478. cameraContrast: number;
  52479. /**
  52480. * Specifies whether or not tonemapping should be enabled in the scene.
  52481. * true by default if setupImageProcessing is true.
  52482. */
  52483. toneMappingEnabled: boolean;
  52484. }
  52485. /**
  52486. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52487. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52488. * It also helps with the default setup of your imageProcessing configuration.
  52489. */
  52490. export class EnvironmentHelper {
  52491. /**
  52492. * Default ground texture URL.
  52493. */
  52494. private static _groundTextureCDNUrl;
  52495. /**
  52496. * Default skybox texture URL.
  52497. */
  52498. private static _skyboxTextureCDNUrl;
  52499. /**
  52500. * Default environment texture URL.
  52501. */
  52502. private static _environmentTextureCDNUrl;
  52503. /**
  52504. * Creates the default options for the helper.
  52505. */
  52506. private static _getDefaultOptions;
  52507. private _rootMesh;
  52508. /**
  52509. * Gets the root mesh created by the helper.
  52510. */
  52511. get rootMesh(): Mesh;
  52512. private _skybox;
  52513. /**
  52514. * Gets the skybox created by the helper.
  52515. */
  52516. get skybox(): Nullable<Mesh>;
  52517. private _skyboxTexture;
  52518. /**
  52519. * Gets the skybox texture created by the helper.
  52520. */
  52521. get skyboxTexture(): Nullable<BaseTexture>;
  52522. private _skyboxMaterial;
  52523. /**
  52524. * Gets the skybox material created by the helper.
  52525. */
  52526. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52527. private _ground;
  52528. /**
  52529. * Gets the ground mesh created by the helper.
  52530. */
  52531. get ground(): Nullable<Mesh>;
  52532. private _groundTexture;
  52533. /**
  52534. * Gets the ground texture created by the helper.
  52535. */
  52536. get groundTexture(): Nullable<BaseTexture>;
  52537. private _groundMirror;
  52538. /**
  52539. * Gets the ground mirror created by the helper.
  52540. */
  52541. get groundMirror(): Nullable<MirrorTexture>;
  52542. /**
  52543. * Gets the ground mirror render list to helps pushing the meshes
  52544. * you wish in the ground reflection.
  52545. */
  52546. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52547. private _groundMaterial;
  52548. /**
  52549. * Gets the ground material created by the helper.
  52550. */
  52551. get groundMaterial(): Nullable<BackgroundMaterial>;
  52552. /**
  52553. * Stores the creation options.
  52554. */
  52555. private readonly _scene;
  52556. private _options;
  52557. /**
  52558. * This observable will be notified with any error during the creation of the environment,
  52559. * mainly texture creation errors.
  52560. */
  52561. onErrorObservable: Observable<{
  52562. message?: string;
  52563. exception?: any;
  52564. }>;
  52565. /**
  52566. * constructor
  52567. * @param options Defines the options we want to customize the helper
  52568. * @param scene The scene to add the material to
  52569. */
  52570. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52571. /**
  52572. * Updates the background according to the new options
  52573. * @param options
  52574. */
  52575. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52576. /**
  52577. * Sets the primary color of all the available elements.
  52578. * @param color the main color to affect to the ground and the background
  52579. */
  52580. setMainColor(color: Color3): void;
  52581. /**
  52582. * Setup the image processing according to the specified options.
  52583. */
  52584. private _setupImageProcessing;
  52585. /**
  52586. * Setup the environment texture according to the specified options.
  52587. */
  52588. private _setupEnvironmentTexture;
  52589. /**
  52590. * Setup the background according to the specified options.
  52591. */
  52592. private _setupBackground;
  52593. /**
  52594. * Get the scene sizes according to the setup.
  52595. */
  52596. private _getSceneSize;
  52597. /**
  52598. * Setup the ground according to the specified options.
  52599. */
  52600. private _setupGround;
  52601. /**
  52602. * Setup the ground material according to the specified options.
  52603. */
  52604. private _setupGroundMaterial;
  52605. /**
  52606. * Setup the ground diffuse texture according to the specified options.
  52607. */
  52608. private _setupGroundDiffuseTexture;
  52609. /**
  52610. * Setup the ground mirror texture according to the specified options.
  52611. */
  52612. private _setupGroundMirrorTexture;
  52613. /**
  52614. * Setup the ground to receive the mirror texture.
  52615. */
  52616. private _setupMirrorInGroundMaterial;
  52617. /**
  52618. * Setup the skybox according to the specified options.
  52619. */
  52620. private _setupSkybox;
  52621. /**
  52622. * Setup the skybox material according to the specified options.
  52623. */
  52624. private _setupSkyboxMaterial;
  52625. /**
  52626. * Setup the skybox reflection texture according to the specified options.
  52627. */
  52628. private _setupSkyboxReflectionTexture;
  52629. private _errorHandler;
  52630. /**
  52631. * Dispose all the elements created by the Helper.
  52632. */
  52633. dispose(): void;
  52634. }
  52635. }
  52636. declare module "babylonjs/Helpers/photoDome" {
  52637. import { Observable } from "babylonjs/Misc/observable";
  52638. import { Nullable } from "babylonjs/types";
  52639. import { Scene } from "babylonjs/scene";
  52640. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52641. import { Mesh } from "babylonjs/Meshes/mesh";
  52642. import { Texture } from "babylonjs/Materials/Textures/texture";
  52643. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52644. import "babylonjs/Meshes/Builders/sphereBuilder";
  52645. /**
  52646. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52647. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52648. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52649. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52650. */
  52651. export class PhotoDome extends TransformNode {
  52652. /**
  52653. * Define the image as a Monoscopic panoramic 360 image.
  52654. */
  52655. static readonly MODE_MONOSCOPIC: number;
  52656. /**
  52657. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52658. */
  52659. static readonly MODE_TOPBOTTOM: number;
  52660. /**
  52661. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52662. */
  52663. static readonly MODE_SIDEBYSIDE: number;
  52664. private _useDirectMapping;
  52665. /**
  52666. * The texture being displayed on the sphere
  52667. */
  52668. protected _photoTexture: Texture;
  52669. /**
  52670. * Gets or sets the texture being displayed on the sphere
  52671. */
  52672. get photoTexture(): Texture;
  52673. set photoTexture(value: Texture);
  52674. /**
  52675. * Observable raised when an error occured while loading the 360 image
  52676. */
  52677. onLoadErrorObservable: Observable<string>;
  52678. /**
  52679. * The skybox material
  52680. */
  52681. protected _material: BackgroundMaterial;
  52682. /**
  52683. * The surface used for the skybox
  52684. */
  52685. protected _mesh: Mesh;
  52686. /**
  52687. * Gets the mesh used for the skybox.
  52688. */
  52689. get mesh(): Mesh;
  52690. /**
  52691. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52692. * Also see the options.resolution property.
  52693. */
  52694. get fovMultiplier(): number;
  52695. set fovMultiplier(value: number);
  52696. private _imageMode;
  52697. /**
  52698. * Gets or set the current video mode for the video. It can be:
  52699. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52700. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52701. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52702. */
  52703. get imageMode(): number;
  52704. set imageMode(value: number);
  52705. /**
  52706. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52707. * @param name Element's name, child elements will append suffixes for their own names.
  52708. * @param urlsOfPhoto defines the url of the photo to display
  52709. * @param options defines an object containing optional or exposed sub element properties
  52710. * @param onError defines a callback called when an error occured while loading the texture
  52711. */
  52712. constructor(name: string, urlOfPhoto: string, options: {
  52713. resolution?: number;
  52714. size?: number;
  52715. useDirectMapping?: boolean;
  52716. faceForward?: boolean;
  52717. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52718. private _onBeforeCameraRenderObserver;
  52719. private _changeImageMode;
  52720. /**
  52721. * Releases resources associated with this node.
  52722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52724. */
  52725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52726. }
  52727. }
  52728. declare module "babylonjs/Misc/rgbdTextureTools" {
  52729. import "babylonjs/Shaders/rgbdDecode.fragment";
  52730. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52731. import { Texture } from "babylonjs/Materials/Textures/texture";
  52732. /**
  52733. * Class used to host RGBD texture specific utilities
  52734. */
  52735. export class RGBDTextureTools {
  52736. /**
  52737. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52738. * @param texture the texture to expand.
  52739. */
  52740. static ExpandRGBDTexture(texture: Texture): void;
  52741. }
  52742. }
  52743. declare module "babylonjs/Misc/brdfTextureTools" {
  52744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52745. import { Scene } from "babylonjs/scene";
  52746. /**
  52747. * Class used to host texture specific utilities
  52748. */
  52749. export class BRDFTextureTools {
  52750. /**
  52751. * Prevents texture cache collision
  52752. */
  52753. private static _instanceNumber;
  52754. /**
  52755. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52756. * @param scene defines the hosting scene
  52757. * @returns the environment BRDF texture
  52758. */
  52759. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52760. private static _environmentBRDFBase64Texture;
  52761. }
  52762. }
  52763. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52764. import { Nullable } from "babylonjs/types";
  52765. import { Color3 } from "babylonjs/Maths/math.color";
  52766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52767. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52769. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52770. import { Engine } from "babylonjs/Engines/engine";
  52771. import { Scene } from "babylonjs/scene";
  52772. /**
  52773. * @hidden
  52774. */
  52775. export interface IMaterialClearCoatDefines {
  52776. CLEARCOAT: boolean;
  52777. CLEARCOAT_DEFAULTIOR: boolean;
  52778. CLEARCOAT_TEXTURE: boolean;
  52779. CLEARCOAT_TEXTUREDIRECTUV: number;
  52780. CLEARCOAT_BUMP: boolean;
  52781. CLEARCOAT_BUMPDIRECTUV: number;
  52782. CLEARCOAT_TINT: boolean;
  52783. CLEARCOAT_TINT_TEXTURE: boolean;
  52784. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52785. /** @hidden */
  52786. _areTexturesDirty: boolean;
  52787. }
  52788. /**
  52789. * Define the code related to the clear coat parameters of the pbr material.
  52790. */
  52791. export class PBRClearCoatConfiguration {
  52792. /**
  52793. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52794. * The default fits with a polyurethane material.
  52795. */
  52796. private static readonly _DefaultIndexOfRefraction;
  52797. private _isEnabled;
  52798. /**
  52799. * Defines if the clear coat is enabled in the material.
  52800. */
  52801. isEnabled: boolean;
  52802. /**
  52803. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52804. */
  52805. intensity: number;
  52806. /**
  52807. * Defines the clear coat layer roughness.
  52808. */
  52809. roughness: number;
  52810. private _indexOfRefraction;
  52811. /**
  52812. * Defines the index of refraction of the clear coat.
  52813. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52814. * The default fits with a polyurethane material.
  52815. * Changing the default value is more performance intensive.
  52816. */
  52817. indexOfRefraction: number;
  52818. private _texture;
  52819. /**
  52820. * Stores the clear coat values in a texture.
  52821. */
  52822. texture: Nullable<BaseTexture>;
  52823. private _bumpTexture;
  52824. /**
  52825. * Define the clear coat specific bump texture.
  52826. */
  52827. bumpTexture: Nullable<BaseTexture>;
  52828. private _isTintEnabled;
  52829. /**
  52830. * Defines if the clear coat tint is enabled in the material.
  52831. */
  52832. isTintEnabled: boolean;
  52833. /**
  52834. * Defines the clear coat tint of the material.
  52835. * This is only use if tint is enabled
  52836. */
  52837. tintColor: Color3;
  52838. /**
  52839. * Defines the distance at which the tint color should be found in the
  52840. * clear coat media.
  52841. * This is only use if tint is enabled
  52842. */
  52843. tintColorAtDistance: number;
  52844. /**
  52845. * Defines the clear coat layer thickness.
  52846. * This is only use if tint is enabled
  52847. */
  52848. tintThickness: number;
  52849. private _tintTexture;
  52850. /**
  52851. * Stores the clear tint values in a texture.
  52852. * rgb is tint
  52853. * a is a thickness factor
  52854. */
  52855. tintTexture: Nullable<BaseTexture>;
  52856. /** @hidden */
  52857. private _internalMarkAllSubMeshesAsTexturesDirty;
  52858. /** @hidden */
  52859. _markAllSubMeshesAsTexturesDirty(): void;
  52860. /**
  52861. * Instantiate a new istance of clear coat configuration.
  52862. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52863. */
  52864. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52865. /**
  52866. * Gets wehter the submesh is ready to be used or not.
  52867. * @param defines the list of "defines" to update.
  52868. * @param scene defines the scene the material belongs to.
  52869. * @param engine defines the engine the material belongs to.
  52870. * @param disableBumpMap defines wether the material disables bump or not.
  52871. * @returns - boolean indicating that the submesh is ready or not.
  52872. */
  52873. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52874. /**
  52875. * Checks to see if a texture is used in the material.
  52876. * @param defines the list of "defines" to update.
  52877. * @param scene defines the scene to the material belongs to.
  52878. */
  52879. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52880. /**
  52881. * Binds the material data.
  52882. * @param uniformBuffer defines the Uniform buffer to fill in.
  52883. * @param scene defines the scene the material belongs to.
  52884. * @param engine defines the engine the material belongs to.
  52885. * @param disableBumpMap defines wether the material disables bump or not.
  52886. * @param isFrozen defines wether the material is frozen or not.
  52887. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52888. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52889. */
  52890. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52891. /**
  52892. * Checks to see if a texture is used in the material.
  52893. * @param texture - Base texture to use.
  52894. * @returns - Boolean specifying if a texture is used in the material.
  52895. */
  52896. hasTexture(texture: BaseTexture): boolean;
  52897. /**
  52898. * Returns an array of the actively used textures.
  52899. * @param activeTextures Array of BaseTextures
  52900. */
  52901. getActiveTextures(activeTextures: BaseTexture[]): void;
  52902. /**
  52903. * Returns the animatable textures.
  52904. * @param animatables Array of animatable textures.
  52905. */
  52906. getAnimatables(animatables: IAnimatable[]): void;
  52907. /**
  52908. * Disposes the resources of the material.
  52909. * @param forceDisposeTextures - Forces the disposal of all textures.
  52910. */
  52911. dispose(forceDisposeTextures?: boolean): void;
  52912. /**
  52913. * Get the current class name of the texture useful for serialization or dynamic coding.
  52914. * @returns "PBRClearCoatConfiguration"
  52915. */
  52916. getClassName(): string;
  52917. /**
  52918. * Add fallbacks to the effect fallbacks list.
  52919. * @param defines defines the Base texture to use.
  52920. * @param fallbacks defines the current fallback list.
  52921. * @param currentRank defines the current fallback rank.
  52922. * @returns the new fallback rank.
  52923. */
  52924. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52925. /**
  52926. * Add the required uniforms to the current list.
  52927. * @param uniforms defines the current uniform list.
  52928. */
  52929. static AddUniforms(uniforms: string[]): void;
  52930. /**
  52931. * Add the required samplers to the current list.
  52932. * @param samplers defines the current sampler list.
  52933. */
  52934. static AddSamplers(samplers: string[]): void;
  52935. /**
  52936. * Add the required uniforms to the current buffer.
  52937. * @param uniformBuffer defines the current uniform buffer.
  52938. */
  52939. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52940. /**
  52941. * Makes a duplicate of the current configuration into another one.
  52942. * @param clearCoatConfiguration define the config where to copy the info
  52943. */
  52944. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52945. /**
  52946. * Serializes this clear coat configuration.
  52947. * @returns - An object with the serialized config.
  52948. */
  52949. serialize(): any;
  52950. /**
  52951. * Parses a anisotropy Configuration from a serialized object.
  52952. * @param source - Serialized object.
  52953. * @param scene Defines the scene we are parsing for
  52954. * @param rootUrl Defines the rootUrl to load from
  52955. */
  52956. parse(source: any, scene: Scene, rootUrl: string): void;
  52957. }
  52958. }
  52959. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52960. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52962. import { Vector2 } from "babylonjs/Maths/math.vector";
  52963. import { Scene } from "babylonjs/scene";
  52964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52965. import { Nullable } from "babylonjs/types";
  52966. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52967. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52968. /**
  52969. * @hidden
  52970. */
  52971. export interface IMaterialAnisotropicDefines {
  52972. ANISOTROPIC: boolean;
  52973. ANISOTROPIC_TEXTURE: boolean;
  52974. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52975. MAINUV1: boolean;
  52976. _areTexturesDirty: boolean;
  52977. _needUVs: boolean;
  52978. }
  52979. /**
  52980. * Define the code related to the anisotropic parameters of the pbr material.
  52981. */
  52982. export class PBRAnisotropicConfiguration {
  52983. private _isEnabled;
  52984. /**
  52985. * Defines if the anisotropy is enabled in the material.
  52986. */
  52987. isEnabled: boolean;
  52988. /**
  52989. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52990. */
  52991. intensity: number;
  52992. /**
  52993. * Defines if the effect is along the tangents, bitangents or in between.
  52994. * By default, the effect is "strectching" the highlights along the tangents.
  52995. */
  52996. direction: Vector2;
  52997. private _texture;
  52998. /**
  52999. * Stores the anisotropy values in a texture.
  53000. * rg is direction (like normal from -1 to 1)
  53001. * b is a intensity
  53002. */
  53003. texture: Nullable<BaseTexture>;
  53004. /** @hidden */
  53005. private _internalMarkAllSubMeshesAsTexturesDirty;
  53006. /** @hidden */
  53007. _markAllSubMeshesAsTexturesDirty(): void;
  53008. /**
  53009. * Instantiate a new istance of anisotropy configuration.
  53010. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53011. */
  53012. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53013. /**
  53014. * Specifies that the submesh is ready to be used.
  53015. * @param defines the list of "defines" to update.
  53016. * @param scene defines the scene the material belongs to.
  53017. * @returns - boolean indicating that the submesh is ready or not.
  53018. */
  53019. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53020. /**
  53021. * Checks to see if a texture is used in the material.
  53022. * @param defines the list of "defines" to update.
  53023. * @param mesh the mesh we are preparing the defines for.
  53024. * @param scene defines the scene the material belongs to.
  53025. */
  53026. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53027. /**
  53028. * Binds the material data.
  53029. * @param uniformBuffer defines the Uniform buffer to fill in.
  53030. * @param scene defines the scene the material belongs to.
  53031. * @param isFrozen defines wether the material is frozen or not.
  53032. */
  53033. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53034. /**
  53035. * Checks to see if a texture is used in the material.
  53036. * @param texture - Base texture to use.
  53037. * @returns - Boolean specifying if a texture is used in the material.
  53038. */
  53039. hasTexture(texture: BaseTexture): boolean;
  53040. /**
  53041. * Returns an array of the actively used textures.
  53042. * @param activeTextures Array of BaseTextures
  53043. */
  53044. getActiveTextures(activeTextures: BaseTexture[]): void;
  53045. /**
  53046. * Returns the animatable textures.
  53047. * @param animatables Array of animatable textures.
  53048. */
  53049. getAnimatables(animatables: IAnimatable[]): void;
  53050. /**
  53051. * Disposes the resources of the material.
  53052. * @param forceDisposeTextures - Forces the disposal of all textures.
  53053. */
  53054. dispose(forceDisposeTextures?: boolean): void;
  53055. /**
  53056. * Get the current class name of the texture useful for serialization or dynamic coding.
  53057. * @returns "PBRAnisotropicConfiguration"
  53058. */
  53059. getClassName(): string;
  53060. /**
  53061. * Add fallbacks to the effect fallbacks list.
  53062. * @param defines defines the Base texture to use.
  53063. * @param fallbacks defines the current fallback list.
  53064. * @param currentRank defines the current fallback rank.
  53065. * @returns the new fallback rank.
  53066. */
  53067. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53068. /**
  53069. * Add the required uniforms to the current list.
  53070. * @param uniforms defines the current uniform list.
  53071. */
  53072. static AddUniforms(uniforms: string[]): void;
  53073. /**
  53074. * Add the required uniforms to the current buffer.
  53075. * @param uniformBuffer defines the current uniform buffer.
  53076. */
  53077. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53078. /**
  53079. * Add the required samplers to the current list.
  53080. * @param samplers defines the current sampler list.
  53081. */
  53082. static AddSamplers(samplers: string[]): void;
  53083. /**
  53084. * Makes a duplicate of the current configuration into another one.
  53085. * @param anisotropicConfiguration define the config where to copy the info
  53086. */
  53087. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53088. /**
  53089. * Serializes this anisotropy configuration.
  53090. * @returns - An object with the serialized config.
  53091. */
  53092. serialize(): any;
  53093. /**
  53094. * Parses a anisotropy Configuration from a serialized object.
  53095. * @param source - Serialized object.
  53096. * @param scene Defines the scene we are parsing for
  53097. * @param rootUrl Defines the rootUrl to load from
  53098. */
  53099. parse(source: any, scene: Scene, rootUrl: string): void;
  53100. }
  53101. }
  53102. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53103. import { Scene } from "babylonjs/scene";
  53104. /**
  53105. * @hidden
  53106. */
  53107. export interface IMaterialBRDFDefines {
  53108. BRDF_V_HEIGHT_CORRELATED: boolean;
  53109. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53110. SPHERICAL_HARMONICS: boolean;
  53111. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53112. /** @hidden */
  53113. _areMiscDirty: boolean;
  53114. }
  53115. /**
  53116. * Define the code related to the BRDF parameters of the pbr material.
  53117. */
  53118. export class PBRBRDFConfiguration {
  53119. /**
  53120. * Default value used for the energy conservation.
  53121. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53122. */
  53123. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53124. /**
  53125. * Default value used for the Smith Visibility Height Correlated mode.
  53126. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53127. */
  53128. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53129. /**
  53130. * Default value used for the IBL diffuse part.
  53131. * This can help switching back to the polynomials mode globally which is a tiny bit
  53132. * less GPU intensive at the drawback of a lower quality.
  53133. */
  53134. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53135. /**
  53136. * Default value used for activating energy conservation for the specular workflow.
  53137. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53138. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53139. */
  53140. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53141. private _useEnergyConservation;
  53142. /**
  53143. * Defines if the material uses energy conservation.
  53144. */
  53145. useEnergyConservation: boolean;
  53146. private _useSmithVisibilityHeightCorrelated;
  53147. /**
  53148. * LEGACY Mode set to false
  53149. * Defines if the material uses height smith correlated visibility term.
  53150. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53151. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53152. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53153. * Not relying on height correlated will also disable energy conservation.
  53154. */
  53155. useSmithVisibilityHeightCorrelated: boolean;
  53156. private _useSphericalHarmonics;
  53157. /**
  53158. * LEGACY Mode set to false
  53159. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53160. * diffuse part of the IBL.
  53161. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53162. * to the ground truth.
  53163. */
  53164. useSphericalHarmonics: boolean;
  53165. private _useSpecularGlossinessInputEnergyConservation;
  53166. /**
  53167. * Defines if the material uses energy conservation, when the specular workflow is active.
  53168. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53169. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53170. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53171. */
  53172. useSpecularGlossinessInputEnergyConservation: boolean;
  53173. /** @hidden */
  53174. private _internalMarkAllSubMeshesAsMiscDirty;
  53175. /** @hidden */
  53176. _markAllSubMeshesAsMiscDirty(): void;
  53177. /**
  53178. * Instantiate a new istance of clear coat configuration.
  53179. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53180. */
  53181. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53182. /**
  53183. * Checks to see if a texture is used in the material.
  53184. * @param defines the list of "defines" to update.
  53185. */
  53186. prepareDefines(defines: IMaterialBRDFDefines): void;
  53187. /**
  53188. * Get the current class name of the texture useful for serialization or dynamic coding.
  53189. * @returns "PBRClearCoatConfiguration"
  53190. */
  53191. getClassName(): string;
  53192. /**
  53193. * Makes a duplicate of the current configuration into another one.
  53194. * @param brdfConfiguration define the config where to copy the info
  53195. */
  53196. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53197. /**
  53198. * Serializes this BRDF configuration.
  53199. * @returns - An object with the serialized config.
  53200. */
  53201. serialize(): any;
  53202. /**
  53203. * Parses a anisotropy Configuration from a serialized object.
  53204. * @param source - Serialized object.
  53205. * @param scene Defines the scene we are parsing for
  53206. * @param rootUrl Defines the rootUrl to load from
  53207. */
  53208. parse(source: any, scene: Scene, rootUrl: string): void;
  53209. }
  53210. }
  53211. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53213. import { Color3 } from "babylonjs/Maths/math.color";
  53214. import { Scene } from "babylonjs/scene";
  53215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53216. import { Nullable } from "babylonjs/types";
  53217. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53218. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53219. /**
  53220. * @hidden
  53221. */
  53222. export interface IMaterialSheenDefines {
  53223. SHEEN: boolean;
  53224. SHEEN_TEXTURE: boolean;
  53225. SHEEN_TEXTUREDIRECTUV: number;
  53226. SHEEN_LINKWITHALBEDO: boolean;
  53227. SHEEN_ROUGHNESS: boolean;
  53228. SHEEN_ALBEDOSCALING: boolean;
  53229. /** @hidden */
  53230. _areTexturesDirty: boolean;
  53231. }
  53232. /**
  53233. * Define the code related to the Sheen parameters of the pbr material.
  53234. */
  53235. export class PBRSheenConfiguration {
  53236. private _isEnabled;
  53237. /**
  53238. * Defines if the material uses sheen.
  53239. */
  53240. isEnabled: boolean;
  53241. private _linkSheenWithAlbedo;
  53242. /**
  53243. * Defines if the sheen is linked to the sheen color.
  53244. */
  53245. linkSheenWithAlbedo: boolean;
  53246. /**
  53247. * Defines the sheen intensity.
  53248. */
  53249. intensity: number;
  53250. /**
  53251. * Defines the sheen color.
  53252. */
  53253. color: Color3;
  53254. private _texture;
  53255. /**
  53256. * Stores the sheen tint values in a texture.
  53257. * rgb is tint
  53258. * a is a intensity
  53259. */
  53260. texture: Nullable<BaseTexture>;
  53261. private _roughness;
  53262. /**
  53263. * Defines the sheen roughness.
  53264. * It is not taken into account if linkSheenWithAlbedo is true.
  53265. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53266. */
  53267. roughness: Nullable<number>;
  53268. private _albedoScaling;
  53269. /**
  53270. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53271. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53272. * making it easier to setup and tweak the effect
  53273. */
  53274. albedoScaling: boolean;
  53275. /** @hidden */
  53276. private _internalMarkAllSubMeshesAsTexturesDirty;
  53277. /** @hidden */
  53278. _markAllSubMeshesAsTexturesDirty(): void;
  53279. /**
  53280. * Instantiate a new istance of clear coat configuration.
  53281. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53282. */
  53283. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53284. /**
  53285. * Specifies that the submesh is ready to be used.
  53286. * @param defines the list of "defines" to update.
  53287. * @param scene defines the scene the material belongs to.
  53288. * @returns - boolean indicating that the submesh is ready or not.
  53289. */
  53290. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53291. /**
  53292. * Checks to see if a texture is used in the material.
  53293. * @param defines the list of "defines" to update.
  53294. * @param scene defines the scene the material belongs to.
  53295. */
  53296. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53297. /**
  53298. * Binds the material data.
  53299. * @param uniformBuffer defines the Uniform buffer to fill in.
  53300. * @param scene defines the scene the material belongs to.
  53301. * @param isFrozen defines wether the material is frozen or not.
  53302. */
  53303. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53304. /**
  53305. * Checks to see if a texture is used in the material.
  53306. * @param texture - Base texture to use.
  53307. * @returns - Boolean specifying if a texture is used in the material.
  53308. */
  53309. hasTexture(texture: BaseTexture): boolean;
  53310. /**
  53311. * Returns an array of the actively used textures.
  53312. * @param activeTextures Array of BaseTextures
  53313. */
  53314. getActiveTextures(activeTextures: BaseTexture[]): void;
  53315. /**
  53316. * Returns the animatable textures.
  53317. * @param animatables Array of animatable textures.
  53318. */
  53319. getAnimatables(animatables: IAnimatable[]): void;
  53320. /**
  53321. * Disposes the resources of the material.
  53322. * @param forceDisposeTextures - Forces the disposal of all textures.
  53323. */
  53324. dispose(forceDisposeTextures?: boolean): void;
  53325. /**
  53326. * Get the current class name of the texture useful for serialization or dynamic coding.
  53327. * @returns "PBRSheenConfiguration"
  53328. */
  53329. getClassName(): string;
  53330. /**
  53331. * Add fallbacks to the effect fallbacks list.
  53332. * @param defines defines the Base texture to use.
  53333. * @param fallbacks defines the current fallback list.
  53334. * @param currentRank defines the current fallback rank.
  53335. * @returns the new fallback rank.
  53336. */
  53337. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53338. /**
  53339. * Add the required uniforms to the current list.
  53340. * @param uniforms defines the current uniform list.
  53341. */
  53342. static AddUniforms(uniforms: string[]): void;
  53343. /**
  53344. * Add the required uniforms to the current buffer.
  53345. * @param uniformBuffer defines the current uniform buffer.
  53346. */
  53347. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53348. /**
  53349. * Add the required samplers to the current list.
  53350. * @param samplers defines the current sampler list.
  53351. */
  53352. static AddSamplers(samplers: string[]): void;
  53353. /**
  53354. * Makes a duplicate of the current configuration into another one.
  53355. * @param sheenConfiguration define the config where to copy the info
  53356. */
  53357. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53358. /**
  53359. * Serializes this BRDF configuration.
  53360. * @returns - An object with the serialized config.
  53361. */
  53362. serialize(): any;
  53363. /**
  53364. * Parses a anisotropy Configuration from a serialized object.
  53365. * @param source - Serialized object.
  53366. * @param scene Defines the scene we are parsing for
  53367. * @param rootUrl Defines the rootUrl to load from
  53368. */
  53369. parse(source: any, scene: Scene, rootUrl: string): void;
  53370. }
  53371. }
  53372. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53373. import { Nullable } from "babylonjs/types";
  53374. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53375. import { Color3 } from "babylonjs/Maths/math.color";
  53376. import { SmartArray } from "babylonjs/Misc/smartArray";
  53377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53379. import { Effect } from "babylonjs/Materials/effect";
  53380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53381. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53382. import { Engine } from "babylonjs/Engines/engine";
  53383. import { Scene } from "babylonjs/scene";
  53384. /**
  53385. * @hidden
  53386. */
  53387. export interface IMaterialSubSurfaceDefines {
  53388. SUBSURFACE: boolean;
  53389. SS_REFRACTION: boolean;
  53390. SS_TRANSLUCENCY: boolean;
  53391. SS_SCATERRING: boolean;
  53392. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53393. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53394. SS_REFRACTIONMAP_3D: boolean;
  53395. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53396. SS_LODINREFRACTIONALPHA: boolean;
  53397. SS_GAMMAREFRACTION: boolean;
  53398. SS_RGBDREFRACTION: boolean;
  53399. SS_LINEARSPECULARREFRACTION: boolean;
  53400. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53401. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53402. /** @hidden */
  53403. _areTexturesDirty: boolean;
  53404. }
  53405. /**
  53406. * Define the code related to the sub surface parameters of the pbr material.
  53407. */
  53408. export class PBRSubSurfaceConfiguration {
  53409. private _isRefractionEnabled;
  53410. /**
  53411. * Defines if the refraction is enabled in the material.
  53412. */
  53413. isRefractionEnabled: boolean;
  53414. private _isTranslucencyEnabled;
  53415. /**
  53416. * Defines if the translucency is enabled in the material.
  53417. */
  53418. isTranslucencyEnabled: boolean;
  53419. private _isScatteringEnabled;
  53420. /**
  53421. * Defines the refraction intensity of the material.
  53422. * The refraction when enabled replaces the Diffuse part of the material.
  53423. * The intensity helps transitionning between diffuse and refraction.
  53424. */
  53425. refractionIntensity: number;
  53426. /**
  53427. * Defines the translucency intensity of the material.
  53428. * When translucency has been enabled, this defines how much of the "translucency"
  53429. * is addded to the diffuse part of the material.
  53430. */
  53431. translucencyIntensity: number;
  53432. /**
  53433. * Defines the scattering intensity of the material.
  53434. * When scattering has been enabled, this defines how much of the "scattered light"
  53435. * is addded to the diffuse part of the material.
  53436. */
  53437. scatteringIntensity: number;
  53438. private _thicknessTexture;
  53439. /**
  53440. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53441. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53442. * 0 would mean minimumThickness
  53443. * 1 would mean maximumThickness
  53444. * The other channels might be use as a mask to vary the different effects intensity.
  53445. */
  53446. thicknessTexture: Nullable<BaseTexture>;
  53447. private _refractionTexture;
  53448. /**
  53449. * Defines the texture to use for refraction.
  53450. */
  53451. refractionTexture: Nullable<BaseTexture>;
  53452. private _indexOfRefraction;
  53453. /**
  53454. * Defines the index of refraction used in the material.
  53455. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53456. */
  53457. indexOfRefraction: number;
  53458. private _invertRefractionY;
  53459. /**
  53460. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53461. */
  53462. invertRefractionY: boolean;
  53463. private _linkRefractionWithTransparency;
  53464. /**
  53465. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53466. * Materials half opaque for instance using refraction could benefit from this control.
  53467. */
  53468. linkRefractionWithTransparency: boolean;
  53469. /**
  53470. * Defines the minimum thickness stored in the thickness map.
  53471. * If no thickness map is defined, this value will be used to simulate thickness.
  53472. */
  53473. minimumThickness: number;
  53474. /**
  53475. * Defines the maximum thickness stored in the thickness map.
  53476. */
  53477. maximumThickness: number;
  53478. /**
  53479. * Defines the volume tint of the material.
  53480. * This is used for both translucency and scattering.
  53481. */
  53482. tintColor: Color3;
  53483. /**
  53484. * Defines the distance at which the tint color should be found in the media.
  53485. * This is used for refraction only.
  53486. */
  53487. tintColorAtDistance: number;
  53488. /**
  53489. * Defines how far each channel transmit through the media.
  53490. * It is defined as a color to simplify it selection.
  53491. */
  53492. diffusionDistance: Color3;
  53493. private _useMaskFromThicknessTexture;
  53494. /**
  53495. * Stores the intensity of the different subsurface effects in the thickness texture.
  53496. * * the green channel is the translucency intensity.
  53497. * * the blue channel is the scattering intensity.
  53498. * * the alpha channel is the refraction intensity.
  53499. */
  53500. useMaskFromThicknessTexture: boolean;
  53501. /** @hidden */
  53502. private _internalMarkAllSubMeshesAsTexturesDirty;
  53503. /** @hidden */
  53504. _markAllSubMeshesAsTexturesDirty(): void;
  53505. /**
  53506. * Instantiate a new istance of sub surface configuration.
  53507. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53508. */
  53509. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53510. /**
  53511. * Gets wehter the submesh is ready to be used or not.
  53512. * @param defines the list of "defines" to update.
  53513. * @param scene defines the scene the material belongs to.
  53514. * @returns - boolean indicating that the submesh is ready or not.
  53515. */
  53516. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53517. /**
  53518. * Checks to see if a texture is used in the material.
  53519. * @param defines the list of "defines" to update.
  53520. * @param scene defines the scene to the material belongs to.
  53521. */
  53522. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53523. /**
  53524. * Binds the material data.
  53525. * @param uniformBuffer defines the Uniform buffer to fill in.
  53526. * @param scene defines the scene the material belongs to.
  53527. * @param engine defines the engine the material belongs to.
  53528. * @param isFrozen defines wether the material is frozen or not.
  53529. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53530. */
  53531. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53532. /**
  53533. * Unbinds the material from the mesh.
  53534. * @param activeEffect defines the effect that should be unbound from.
  53535. * @returns true if unbound, otherwise false
  53536. */
  53537. unbind(activeEffect: Effect): boolean;
  53538. /**
  53539. * Returns the texture used for refraction or null if none is used.
  53540. * @param scene defines the scene the material belongs to.
  53541. * @returns - Refraction texture if present. If no refraction texture and refraction
  53542. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53543. */
  53544. private _getRefractionTexture;
  53545. /**
  53546. * Returns true if alpha blending should be disabled.
  53547. */
  53548. get disableAlphaBlending(): boolean;
  53549. /**
  53550. * Fills the list of render target textures.
  53551. * @param renderTargets the list of render targets to update
  53552. */
  53553. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53554. /**
  53555. * Checks to see if a texture is used in the material.
  53556. * @param texture - Base texture to use.
  53557. * @returns - Boolean specifying if a texture is used in the material.
  53558. */
  53559. hasTexture(texture: BaseTexture): boolean;
  53560. /**
  53561. * Gets a boolean indicating that current material needs to register RTT
  53562. * @returns true if this uses a render target otherwise false.
  53563. */
  53564. hasRenderTargetTextures(): boolean;
  53565. /**
  53566. * Returns an array of the actively used textures.
  53567. * @param activeTextures Array of BaseTextures
  53568. */
  53569. getActiveTextures(activeTextures: BaseTexture[]): void;
  53570. /**
  53571. * Returns the animatable textures.
  53572. * @param animatables Array of animatable textures.
  53573. */
  53574. getAnimatables(animatables: IAnimatable[]): void;
  53575. /**
  53576. * Disposes the resources of the material.
  53577. * @param forceDisposeTextures - Forces the disposal of all textures.
  53578. */
  53579. dispose(forceDisposeTextures?: boolean): void;
  53580. /**
  53581. * Get the current class name of the texture useful for serialization or dynamic coding.
  53582. * @returns "PBRSubSurfaceConfiguration"
  53583. */
  53584. getClassName(): string;
  53585. /**
  53586. * Add fallbacks to the effect fallbacks list.
  53587. * @param defines defines the Base texture to use.
  53588. * @param fallbacks defines the current fallback list.
  53589. * @param currentRank defines the current fallback rank.
  53590. * @returns the new fallback rank.
  53591. */
  53592. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53593. /**
  53594. * Add the required uniforms to the current list.
  53595. * @param uniforms defines the current uniform list.
  53596. */
  53597. static AddUniforms(uniforms: string[]): void;
  53598. /**
  53599. * Add the required samplers to the current list.
  53600. * @param samplers defines the current sampler list.
  53601. */
  53602. static AddSamplers(samplers: string[]): void;
  53603. /**
  53604. * Add the required uniforms to the current buffer.
  53605. * @param uniformBuffer defines the current uniform buffer.
  53606. */
  53607. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53608. /**
  53609. * Makes a duplicate of the current configuration into another one.
  53610. * @param configuration define the config where to copy the info
  53611. */
  53612. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53613. /**
  53614. * Serializes this Sub Surface configuration.
  53615. * @returns - An object with the serialized config.
  53616. */
  53617. serialize(): any;
  53618. /**
  53619. * Parses a anisotropy Configuration from a serialized object.
  53620. * @param source - Serialized object.
  53621. * @param scene Defines the scene we are parsing for
  53622. * @param rootUrl Defines the rootUrl to load from
  53623. */
  53624. parse(source: any, scene: Scene, rootUrl: string): void;
  53625. }
  53626. }
  53627. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53628. /** @hidden */
  53629. export var pbrFragmentDeclaration: {
  53630. name: string;
  53631. shader: string;
  53632. };
  53633. }
  53634. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53635. /** @hidden */
  53636. export var pbrUboDeclaration: {
  53637. name: string;
  53638. shader: string;
  53639. };
  53640. }
  53641. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53642. /** @hidden */
  53643. export var pbrFragmentExtraDeclaration: {
  53644. name: string;
  53645. shader: string;
  53646. };
  53647. }
  53648. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53649. /** @hidden */
  53650. export var pbrFragmentSamplersDeclaration: {
  53651. name: string;
  53652. shader: string;
  53653. };
  53654. }
  53655. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53656. /** @hidden */
  53657. export var pbrHelperFunctions: {
  53658. name: string;
  53659. shader: string;
  53660. };
  53661. }
  53662. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53663. /** @hidden */
  53664. export var harmonicsFunctions: {
  53665. name: string;
  53666. shader: string;
  53667. };
  53668. }
  53669. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53670. /** @hidden */
  53671. export var pbrDirectLightingSetupFunctions: {
  53672. name: string;
  53673. shader: string;
  53674. };
  53675. }
  53676. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53677. /** @hidden */
  53678. export var pbrDirectLightingFalloffFunctions: {
  53679. name: string;
  53680. shader: string;
  53681. };
  53682. }
  53683. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53684. /** @hidden */
  53685. export var pbrBRDFFunctions: {
  53686. name: string;
  53687. shader: string;
  53688. };
  53689. }
  53690. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53691. /** @hidden */
  53692. export var pbrDirectLightingFunctions: {
  53693. name: string;
  53694. shader: string;
  53695. };
  53696. }
  53697. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53698. /** @hidden */
  53699. export var pbrIBLFunctions: {
  53700. name: string;
  53701. shader: string;
  53702. };
  53703. }
  53704. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53705. /** @hidden */
  53706. export var pbrBlockAlbedoOpacity: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53712. /** @hidden */
  53713. export var pbrBlockReflectivity: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53719. /** @hidden */
  53720. export var pbrBlockAmbientOcclusion: {
  53721. name: string;
  53722. shader: string;
  53723. };
  53724. }
  53725. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53726. /** @hidden */
  53727. export var pbrBlockAlphaFresnel: {
  53728. name: string;
  53729. shader: string;
  53730. };
  53731. }
  53732. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53733. /** @hidden */
  53734. export var pbrBlockAnisotropic: {
  53735. name: string;
  53736. shader: string;
  53737. };
  53738. }
  53739. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53740. /** @hidden */
  53741. export var pbrBlockReflection: {
  53742. name: string;
  53743. shader: string;
  53744. };
  53745. }
  53746. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53747. /** @hidden */
  53748. export var pbrBlockSheen: {
  53749. name: string;
  53750. shader: string;
  53751. };
  53752. }
  53753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53754. /** @hidden */
  53755. export var pbrBlockClearcoat: {
  53756. name: string;
  53757. shader: string;
  53758. };
  53759. }
  53760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53761. /** @hidden */
  53762. export var pbrBlockSubSurface: {
  53763. name: string;
  53764. shader: string;
  53765. };
  53766. }
  53767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53768. /** @hidden */
  53769. export var pbrBlockNormalGeometric: {
  53770. name: string;
  53771. shader: string;
  53772. };
  53773. }
  53774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53775. /** @hidden */
  53776. export var pbrBlockNormalFinal: {
  53777. name: string;
  53778. shader: string;
  53779. };
  53780. }
  53781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53782. /** @hidden */
  53783. export var pbrBlockGeometryInfo: {
  53784. name: string;
  53785. shader: string;
  53786. };
  53787. }
  53788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53789. /** @hidden */
  53790. export var pbrBlockReflectance0: {
  53791. name: string;
  53792. shader: string;
  53793. };
  53794. }
  53795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53796. /** @hidden */
  53797. export var pbrBlockReflectance: {
  53798. name: string;
  53799. shader: string;
  53800. };
  53801. }
  53802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53803. /** @hidden */
  53804. export var pbrBlockDirectLighting: {
  53805. name: string;
  53806. shader: string;
  53807. };
  53808. }
  53809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53810. /** @hidden */
  53811. export var pbrBlockFinalLitComponents: {
  53812. name: string;
  53813. shader: string;
  53814. };
  53815. }
  53816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53817. /** @hidden */
  53818. export var pbrBlockFinalUnlitComponents: {
  53819. name: string;
  53820. shader: string;
  53821. };
  53822. }
  53823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53824. /** @hidden */
  53825. export var pbrBlockFinalColorComposition: {
  53826. name: string;
  53827. shader: string;
  53828. };
  53829. }
  53830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53831. /** @hidden */
  53832. export var pbrBlockImageProcessing: {
  53833. name: string;
  53834. shader: string;
  53835. };
  53836. }
  53837. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53838. /** @hidden */
  53839. export var pbrDebug: {
  53840. name: string;
  53841. shader: string;
  53842. };
  53843. }
  53844. declare module "babylonjs/Shaders/pbr.fragment" {
  53845. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53846. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53847. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53848. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53849. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53850. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53851. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53853. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53854. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53856. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53857. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53858. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53859. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53860. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53861. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53862. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53863. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53864. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53865. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53866. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53867. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53868. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53869. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53870. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53871. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53872. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53873. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53874. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53875. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53876. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53877. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53878. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53879. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53880. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53881. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53882. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53883. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53884. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53885. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53886. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53887. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53888. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53889. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53890. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53891. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53892. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53893. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53894. /** @hidden */
  53895. export var pbrPixelShader: {
  53896. name: string;
  53897. shader: string;
  53898. };
  53899. }
  53900. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53901. /** @hidden */
  53902. export var pbrVertexDeclaration: {
  53903. name: string;
  53904. shader: string;
  53905. };
  53906. }
  53907. declare module "babylonjs/Shaders/pbr.vertex" {
  53908. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53909. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53910. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53911. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53912. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53913. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53914. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53915. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53916. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53917. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53918. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53919. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53921. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53923. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53924. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53925. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53926. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53927. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53928. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53929. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53930. /** @hidden */
  53931. export var pbrVertexShader: {
  53932. name: string;
  53933. shader: string;
  53934. };
  53935. }
  53936. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53937. import { Nullable } from "babylonjs/types";
  53938. import { Scene } from "babylonjs/scene";
  53939. import { Matrix } from "babylonjs/Maths/math.vector";
  53940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53942. import { Mesh } from "babylonjs/Meshes/mesh";
  53943. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53944. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53945. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53946. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53947. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53948. import { Color3 } from "babylonjs/Maths/math.color";
  53949. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53950. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53951. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53952. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53954. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53955. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53956. import "babylonjs/Shaders/pbr.fragment";
  53957. import "babylonjs/Shaders/pbr.vertex";
  53958. /**
  53959. * Manages the defines for the PBR Material.
  53960. * @hidden
  53961. */
  53962. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53963. PBR: boolean;
  53964. MAINUV1: boolean;
  53965. MAINUV2: boolean;
  53966. UV1: boolean;
  53967. UV2: boolean;
  53968. ALBEDO: boolean;
  53969. GAMMAALBEDO: boolean;
  53970. ALBEDODIRECTUV: number;
  53971. VERTEXCOLOR: boolean;
  53972. AMBIENT: boolean;
  53973. AMBIENTDIRECTUV: number;
  53974. AMBIENTINGRAYSCALE: boolean;
  53975. OPACITY: boolean;
  53976. VERTEXALPHA: boolean;
  53977. OPACITYDIRECTUV: number;
  53978. OPACITYRGB: boolean;
  53979. ALPHATEST: boolean;
  53980. DEPTHPREPASS: boolean;
  53981. ALPHABLEND: boolean;
  53982. ALPHAFROMALBEDO: boolean;
  53983. ALPHATESTVALUE: string;
  53984. SPECULAROVERALPHA: boolean;
  53985. RADIANCEOVERALPHA: boolean;
  53986. ALPHAFRESNEL: boolean;
  53987. LINEARALPHAFRESNEL: boolean;
  53988. PREMULTIPLYALPHA: boolean;
  53989. EMISSIVE: boolean;
  53990. EMISSIVEDIRECTUV: number;
  53991. REFLECTIVITY: boolean;
  53992. REFLECTIVITYDIRECTUV: number;
  53993. SPECULARTERM: boolean;
  53994. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53995. MICROSURFACEAUTOMATIC: boolean;
  53996. LODBASEDMICROSFURACE: boolean;
  53997. MICROSURFACEMAP: boolean;
  53998. MICROSURFACEMAPDIRECTUV: number;
  53999. METALLICWORKFLOW: boolean;
  54000. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54001. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54002. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54003. AOSTOREINMETALMAPRED: boolean;
  54004. METALLICF0FACTORFROMMETALLICMAP: boolean;
  54005. ENVIRONMENTBRDF: boolean;
  54006. ENVIRONMENTBRDF_RGBD: boolean;
  54007. NORMAL: boolean;
  54008. TANGENT: boolean;
  54009. BUMP: boolean;
  54010. BUMPDIRECTUV: number;
  54011. OBJECTSPACE_NORMALMAP: boolean;
  54012. PARALLAX: boolean;
  54013. PARALLAXOCCLUSION: boolean;
  54014. NORMALXYSCALE: boolean;
  54015. LIGHTMAP: boolean;
  54016. LIGHTMAPDIRECTUV: number;
  54017. USELIGHTMAPASSHADOWMAP: boolean;
  54018. GAMMALIGHTMAP: boolean;
  54019. RGBDLIGHTMAP: boolean;
  54020. REFLECTION: boolean;
  54021. REFLECTIONMAP_3D: boolean;
  54022. REFLECTIONMAP_SPHERICAL: boolean;
  54023. REFLECTIONMAP_PLANAR: boolean;
  54024. REFLECTIONMAP_CUBIC: boolean;
  54025. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54026. REFLECTIONMAP_PROJECTION: boolean;
  54027. REFLECTIONMAP_SKYBOX: boolean;
  54028. REFLECTIONMAP_EXPLICIT: boolean;
  54029. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54030. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54031. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54032. INVERTCUBICMAP: boolean;
  54033. USESPHERICALFROMREFLECTIONMAP: boolean;
  54034. USEIRRADIANCEMAP: boolean;
  54035. SPHERICAL_HARMONICS: boolean;
  54036. USESPHERICALINVERTEX: boolean;
  54037. REFLECTIONMAP_OPPOSITEZ: boolean;
  54038. LODINREFLECTIONALPHA: boolean;
  54039. GAMMAREFLECTION: boolean;
  54040. RGBDREFLECTION: boolean;
  54041. LINEARSPECULARREFLECTION: boolean;
  54042. RADIANCEOCCLUSION: boolean;
  54043. HORIZONOCCLUSION: boolean;
  54044. INSTANCES: boolean;
  54045. NUM_BONE_INFLUENCERS: number;
  54046. BonesPerMesh: number;
  54047. BONETEXTURE: boolean;
  54048. NONUNIFORMSCALING: boolean;
  54049. MORPHTARGETS: boolean;
  54050. MORPHTARGETS_NORMAL: boolean;
  54051. MORPHTARGETS_TANGENT: boolean;
  54052. MORPHTARGETS_UV: boolean;
  54053. NUM_MORPH_INFLUENCERS: number;
  54054. IMAGEPROCESSING: boolean;
  54055. VIGNETTE: boolean;
  54056. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54057. VIGNETTEBLENDMODEOPAQUE: boolean;
  54058. TONEMAPPING: boolean;
  54059. TONEMAPPING_ACES: boolean;
  54060. CONTRAST: boolean;
  54061. COLORCURVES: boolean;
  54062. COLORGRADING: boolean;
  54063. COLORGRADING3D: boolean;
  54064. SAMPLER3DGREENDEPTH: boolean;
  54065. SAMPLER3DBGRMAP: boolean;
  54066. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54067. EXPOSURE: boolean;
  54068. MULTIVIEW: boolean;
  54069. USEPHYSICALLIGHTFALLOFF: boolean;
  54070. USEGLTFLIGHTFALLOFF: boolean;
  54071. TWOSIDEDLIGHTING: boolean;
  54072. SHADOWFLOAT: boolean;
  54073. CLIPPLANE: boolean;
  54074. CLIPPLANE2: boolean;
  54075. CLIPPLANE3: boolean;
  54076. CLIPPLANE4: boolean;
  54077. CLIPPLANE5: boolean;
  54078. CLIPPLANE6: boolean;
  54079. POINTSIZE: boolean;
  54080. FOG: boolean;
  54081. LOGARITHMICDEPTH: boolean;
  54082. FORCENORMALFORWARD: boolean;
  54083. SPECULARAA: boolean;
  54084. CLEARCOAT: boolean;
  54085. CLEARCOAT_DEFAULTIOR: boolean;
  54086. CLEARCOAT_TEXTURE: boolean;
  54087. CLEARCOAT_TEXTUREDIRECTUV: number;
  54088. CLEARCOAT_BUMP: boolean;
  54089. CLEARCOAT_BUMPDIRECTUV: number;
  54090. CLEARCOAT_TINT: boolean;
  54091. CLEARCOAT_TINT_TEXTURE: boolean;
  54092. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54093. ANISOTROPIC: boolean;
  54094. ANISOTROPIC_TEXTURE: boolean;
  54095. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54096. BRDF_V_HEIGHT_CORRELATED: boolean;
  54097. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54098. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54099. SHEEN: boolean;
  54100. SHEEN_TEXTURE: boolean;
  54101. SHEEN_TEXTUREDIRECTUV: number;
  54102. SHEEN_LINKWITHALBEDO: boolean;
  54103. SHEEN_ROUGHNESS: boolean;
  54104. SHEEN_ALBEDOSCALING: boolean;
  54105. SUBSURFACE: boolean;
  54106. SS_REFRACTION: boolean;
  54107. SS_TRANSLUCENCY: boolean;
  54108. SS_SCATERRING: boolean;
  54109. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54110. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54111. SS_REFRACTIONMAP_3D: boolean;
  54112. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54113. SS_LODINREFRACTIONALPHA: boolean;
  54114. SS_GAMMAREFRACTION: boolean;
  54115. SS_RGBDREFRACTION: boolean;
  54116. SS_LINEARSPECULARREFRACTION: boolean;
  54117. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54118. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54119. UNLIT: boolean;
  54120. DEBUGMODE: number;
  54121. /**
  54122. * Initializes the PBR Material defines.
  54123. */
  54124. constructor();
  54125. /**
  54126. * Resets the PBR Material defines.
  54127. */
  54128. reset(): void;
  54129. }
  54130. /**
  54131. * The Physically based material base class of BJS.
  54132. *
  54133. * This offers the main features of a standard PBR material.
  54134. * For more information, please refer to the documentation :
  54135. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54136. */
  54137. export abstract class PBRBaseMaterial extends PushMaterial {
  54138. /**
  54139. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54140. */
  54141. static readonly PBRMATERIAL_OPAQUE: number;
  54142. /**
  54143. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54144. */
  54145. static readonly PBRMATERIAL_ALPHATEST: number;
  54146. /**
  54147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54148. */
  54149. static readonly PBRMATERIAL_ALPHABLEND: number;
  54150. /**
  54151. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54152. * They are also discarded below the alpha cutoff threshold to improve performances.
  54153. */
  54154. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54155. /**
  54156. * Defines the default value of how much AO map is occluding the analytical lights
  54157. * (point spot...).
  54158. */
  54159. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54160. /**
  54161. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54162. */
  54163. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54164. /**
  54165. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54166. * to enhance interoperability with other engines.
  54167. */
  54168. static readonly LIGHTFALLOFF_GLTF: number;
  54169. /**
  54170. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54171. * to enhance interoperability with other materials.
  54172. */
  54173. static readonly LIGHTFALLOFF_STANDARD: number;
  54174. /**
  54175. * Intensity of the direct lights e.g. the four lights available in your scene.
  54176. * This impacts both the direct diffuse and specular highlights.
  54177. */
  54178. protected _directIntensity: number;
  54179. /**
  54180. * Intensity of the emissive part of the material.
  54181. * This helps controlling the emissive effect without modifying the emissive color.
  54182. */
  54183. protected _emissiveIntensity: number;
  54184. /**
  54185. * Intensity of the environment e.g. how much the environment will light the object
  54186. * either through harmonics for rough material or through the refelction for shiny ones.
  54187. */
  54188. protected _environmentIntensity: number;
  54189. /**
  54190. * This is a special control allowing the reduction of the specular highlights coming from the
  54191. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54192. */
  54193. protected _specularIntensity: number;
  54194. /**
  54195. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54196. */
  54197. private _lightingInfos;
  54198. /**
  54199. * Debug Control allowing disabling the bump map on this material.
  54200. */
  54201. protected _disableBumpMap: boolean;
  54202. /**
  54203. * AKA Diffuse Texture in standard nomenclature.
  54204. */
  54205. protected _albedoTexture: Nullable<BaseTexture>;
  54206. /**
  54207. * AKA Occlusion Texture in other nomenclature.
  54208. */
  54209. protected _ambientTexture: Nullable<BaseTexture>;
  54210. /**
  54211. * AKA Occlusion Texture Intensity in other nomenclature.
  54212. */
  54213. protected _ambientTextureStrength: number;
  54214. /**
  54215. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54216. * 1 means it completely occludes it
  54217. * 0 mean it has no impact
  54218. */
  54219. protected _ambientTextureImpactOnAnalyticalLights: number;
  54220. /**
  54221. * Stores the alpha values in a texture.
  54222. */
  54223. protected _opacityTexture: Nullable<BaseTexture>;
  54224. /**
  54225. * Stores the reflection values in a texture.
  54226. */
  54227. protected _reflectionTexture: Nullable<BaseTexture>;
  54228. /**
  54229. * Stores the emissive values in a texture.
  54230. */
  54231. protected _emissiveTexture: Nullable<BaseTexture>;
  54232. /**
  54233. * AKA Specular texture in other nomenclature.
  54234. */
  54235. protected _reflectivityTexture: Nullable<BaseTexture>;
  54236. /**
  54237. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54238. */
  54239. protected _metallicTexture: Nullable<BaseTexture>;
  54240. /**
  54241. * Specifies the metallic scalar of the metallic/roughness workflow.
  54242. * Can also be used to scale the metalness values of the metallic texture.
  54243. */
  54244. protected _metallic: Nullable<number>;
  54245. /**
  54246. * Specifies the roughness scalar of the metallic/roughness workflow.
  54247. * Can also be used to scale the roughness values of the metallic texture.
  54248. */
  54249. protected _roughness: Nullable<number>;
  54250. /**
  54251. * Specifies the an F0 factor to help configuring the material F0.
  54252. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54253. * to 0.5 the previously hard coded value stays the same.
  54254. * Can also be used to scale the F0 values of the metallic texture.
  54255. */
  54256. protected _metallicF0Factor: number;
  54257. /**
  54258. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54259. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54260. * your expectation as it multiplies with the texture data.
  54261. */
  54262. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54263. /**
  54264. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54265. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54266. */
  54267. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54268. /**
  54269. * Stores surface normal data used to displace a mesh in a texture.
  54270. */
  54271. protected _bumpTexture: Nullable<BaseTexture>;
  54272. /**
  54273. * Stores the pre-calculated light information of a mesh in a texture.
  54274. */
  54275. protected _lightmapTexture: Nullable<BaseTexture>;
  54276. /**
  54277. * The color of a material in ambient lighting.
  54278. */
  54279. protected _ambientColor: Color3;
  54280. /**
  54281. * AKA Diffuse Color in other nomenclature.
  54282. */
  54283. protected _albedoColor: Color3;
  54284. /**
  54285. * AKA Specular Color in other nomenclature.
  54286. */
  54287. protected _reflectivityColor: Color3;
  54288. /**
  54289. * The color applied when light is reflected from a material.
  54290. */
  54291. protected _reflectionColor: Color3;
  54292. /**
  54293. * The color applied when light is emitted from a material.
  54294. */
  54295. protected _emissiveColor: Color3;
  54296. /**
  54297. * AKA Glossiness in other nomenclature.
  54298. */
  54299. protected _microSurface: number;
  54300. /**
  54301. * Specifies that the material will use the light map as a show map.
  54302. */
  54303. protected _useLightmapAsShadowmap: boolean;
  54304. /**
  54305. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54306. * makes the reflect vector face the model (under horizon).
  54307. */
  54308. protected _useHorizonOcclusion: boolean;
  54309. /**
  54310. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54311. * too much the area relying on ambient texture to define their ambient occlusion.
  54312. */
  54313. protected _useRadianceOcclusion: boolean;
  54314. /**
  54315. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54316. */
  54317. protected _useAlphaFromAlbedoTexture: boolean;
  54318. /**
  54319. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54320. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54321. */
  54322. protected _useSpecularOverAlpha: boolean;
  54323. /**
  54324. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54325. */
  54326. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54327. /**
  54328. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54329. */
  54330. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54331. /**
  54332. * Specifies if the metallic texture contains the roughness information in its green channel.
  54333. */
  54334. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54335. /**
  54336. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54337. */
  54338. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54339. /**
  54340. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54341. */
  54342. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54343. /**
  54344. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54345. */
  54346. protected _useAmbientInGrayScale: boolean;
  54347. /**
  54348. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54349. * The material will try to infer what glossiness each pixel should be.
  54350. */
  54351. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54352. /**
  54353. * Defines the falloff type used in this material.
  54354. * It by default is Physical.
  54355. */
  54356. protected _lightFalloff: number;
  54357. /**
  54358. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54359. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54360. */
  54361. protected _useRadianceOverAlpha: boolean;
  54362. /**
  54363. * Allows using an object space normal map (instead of tangent space).
  54364. */
  54365. protected _useObjectSpaceNormalMap: boolean;
  54366. /**
  54367. * Allows using the bump map in parallax mode.
  54368. */
  54369. protected _useParallax: boolean;
  54370. /**
  54371. * Allows using the bump map in parallax occlusion mode.
  54372. */
  54373. protected _useParallaxOcclusion: boolean;
  54374. /**
  54375. * Controls the scale bias of the parallax mode.
  54376. */
  54377. protected _parallaxScaleBias: number;
  54378. /**
  54379. * If sets to true, disables all the lights affecting the material.
  54380. */
  54381. protected _disableLighting: boolean;
  54382. /**
  54383. * Number of Simultaneous lights allowed on the material.
  54384. */
  54385. protected _maxSimultaneousLights: number;
  54386. /**
  54387. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54388. */
  54389. protected _invertNormalMapX: boolean;
  54390. /**
  54391. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54392. */
  54393. protected _invertNormalMapY: boolean;
  54394. /**
  54395. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54396. */
  54397. protected _twoSidedLighting: boolean;
  54398. /**
  54399. * Defines the alpha limits in alpha test mode.
  54400. */
  54401. protected _alphaCutOff: number;
  54402. /**
  54403. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54404. */
  54405. protected _forceAlphaTest: boolean;
  54406. /**
  54407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54408. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54409. */
  54410. protected _useAlphaFresnel: boolean;
  54411. /**
  54412. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54413. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54414. */
  54415. protected _useLinearAlphaFresnel: boolean;
  54416. /**
  54417. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54418. * from cos thetav and roughness:
  54419. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54420. */
  54421. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54422. /**
  54423. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54424. */
  54425. protected _forceIrradianceInFragment: boolean;
  54426. /**
  54427. * Force normal to face away from face.
  54428. */
  54429. protected _forceNormalForward: boolean;
  54430. /**
  54431. * Enables specular anti aliasing in the PBR shader.
  54432. * It will both interacts on the Geometry for analytical and IBL lighting.
  54433. * It also prefilter the roughness map based on the bump values.
  54434. */
  54435. protected _enableSpecularAntiAliasing: boolean;
  54436. /**
  54437. * Default configuration related to image processing available in the PBR Material.
  54438. */
  54439. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54440. /**
  54441. * Keep track of the image processing observer to allow dispose and replace.
  54442. */
  54443. private _imageProcessingObserver;
  54444. /**
  54445. * Attaches a new image processing configuration to the PBR Material.
  54446. * @param configuration
  54447. */
  54448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54449. /**
  54450. * Stores the available render targets.
  54451. */
  54452. private _renderTargets;
  54453. /**
  54454. * Sets the global ambient color for the material used in lighting calculations.
  54455. */
  54456. private _globalAmbientColor;
  54457. /**
  54458. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54459. */
  54460. private _useLogarithmicDepth;
  54461. /**
  54462. * If set to true, no lighting calculations will be applied.
  54463. */
  54464. private _unlit;
  54465. private _debugMode;
  54466. /**
  54467. * @hidden
  54468. * This is reserved for the inspector.
  54469. * Defines the material debug mode.
  54470. * It helps seeing only some components of the material while troubleshooting.
  54471. */
  54472. debugMode: number;
  54473. /**
  54474. * @hidden
  54475. * This is reserved for the inspector.
  54476. * Specify from where on screen the debug mode should start.
  54477. * The value goes from -1 (full screen) to 1 (not visible)
  54478. * It helps with side by side comparison against the final render
  54479. * This defaults to -1
  54480. */
  54481. private debugLimit;
  54482. /**
  54483. * @hidden
  54484. * This is reserved for the inspector.
  54485. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54486. * You can use the factor to better multiply the final value.
  54487. */
  54488. private debugFactor;
  54489. /**
  54490. * Defines the clear coat layer parameters for the material.
  54491. */
  54492. readonly clearCoat: PBRClearCoatConfiguration;
  54493. /**
  54494. * Defines the anisotropic parameters for the material.
  54495. */
  54496. readonly anisotropy: PBRAnisotropicConfiguration;
  54497. /**
  54498. * Defines the BRDF parameters for the material.
  54499. */
  54500. readonly brdf: PBRBRDFConfiguration;
  54501. /**
  54502. * Defines the Sheen parameters for the material.
  54503. */
  54504. readonly sheen: PBRSheenConfiguration;
  54505. /**
  54506. * Defines the SubSurface parameters for the material.
  54507. */
  54508. readonly subSurface: PBRSubSurfaceConfiguration;
  54509. protected _rebuildInParallel: boolean;
  54510. /**
  54511. * Instantiates a new PBRMaterial instance.
  54512. *
  54513. * @param name The material name
  54514. * @param scene The scene the material will be use in.
  54515. */
  54516. constructor(name: string, scene: Scene);
  54517. /**
  54518. * Gets a boolean indicating that current material needs to register RTT
  54519. */
  54520. get hasRenderTargetTextures(): boolean;
  54521. /**
  54522. * Gets the name of the material class.
  54523. */
  54524. getClassName(): string;
  54525. /**
  54526. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54527. */
  54528. get useLogarithmicDepth(): boolean;
  54529. /**
  54530. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54531. */
  54532. set useLogarithmicDepth(value: boolean);
  54533. /**
  54534. * Returns true if alpha blending should be disabled.
  54535. */
  54536. protected get _disableAlphaBlending(): boolean;
  54537. /**
  54538. * Specifies whether or not this material should be rendered in alpha blend mode.
  54539. */
  54540. needAlphaBlending(): boolean;
  54541. /**
  54542. * Specifies whether or not this material should be rendered in alpha test mode.
  54543. */
  54544. needAlphaTesting(): boolean;
  54545. /**
  54546. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54547. */
  54548. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54549. /**
  54550. * Gets the texture used for the alpha test.
  54551. */
  54552. getAlphaTestTexture(): Nullable<BaseTexture>;
  54553. /**
  54554. * Specifies that the submesh is ready to be used.
  54555. * @param mesh - BJS mesh.
  54556. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54557. * @param useInstances - Specifies that instances should be used.
  54558. * @returns - boolean indicating that the submesh is ready or not.
  54559. */
  54560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54561. /**
  54562. * Specifies if the material uses metallic roughness workflow.
  54563. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54564. */
  54565. isMetallicWorkflow(): boolean;
  54566. private _prepareEffect;
  54567. private _prepareDefines;
  54568. /**
  54569. * Force shader compilation
  54570. */
  54571. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54572. /**
  54573. * Initializes the uniform buffer layout for the shader.
  54574. */
  54575. buildUniformLayout(): void;
  54576. /**
  54577. * Unbinds the material from the mesh
  54578. */
  54579. unbind(): void;
  54580. /**
  54581. * Binds the submesh data.
  54582. * @param world - The world matrix.
  54583. * @param mesh - The BJS mesh.
  54584. * @param subMesh - A submesh of the BJS mesh.
  54585. */
  54586. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54587. /**
  54588. * Returns the animatable textures.
  54589. * @returns - Array of animatable textures.
  54590. */
  54591. getAnimatables(): IAnimatable[];
  54592. /**
  54593. * Returns the texture used for reflections.
  54594. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54595. */
  54596. private _getReflectionTexture;
  54597. /**
  54598. * Returns an array of the actively used textures.
  54599. * @returns - Array of BaseTextures
  54600. */
  54601. getActiveTextures(): BaseTexture[];
  54602. /**
  54603. * Checks to see if a texture is used in the material.
  54604. * @param texture - Base texture to use.
  54605. * @returns - Boolean specifying if a texture is used in the material.
  54606. */
  54607. hasTexture(texture: BaseTexture): boolean;
  54608. /**
  54609. * Disposes the resources of the material.
  54610. * @param forceDisposeEffect - Forces the disposal of effects.
  54611. * @param forceDisposeTextures - Forces the disposal of all textures.
  54612. */
  54613. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54614. }
  54615. }
  54616. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54617. import { Nullable } from "babylonjs/types";
  54618. import { Scene } from "babylonjs/scene";
  54619. import { Color3 } from "babylonjs/Maths/math.color";
  54620. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54621. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54623. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54624. /**
  54625. * The Physically based material of BJS.
  54626. *
  54627. * This offers the main features of a standard PBR material.
  54628. * For more information, please refer to the documentation :
  54629. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54630. */
  54631. export class PBRMaterial extends PBRBaseMaterial {
  54632. /**
  54633. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54634. */
  54635. static readonly PBRMATERIAL_OPAQUE: number;
  54636. /**
  54637. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54638. */
  54639. static readonly PBRMATERIAL_ALPHATEST: number;
  54640. /**
  54641. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54642. */
  54643. static readonly PBRMATERIAL_ALPHABLEND: number;
  54644. /**
  54645. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54646. * They are also discarded below the alpha cutoff threshold to improve performances.
  54647. */
  54648. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54649. /**
  54650. * Defines the default value of how much AO map is occluding the analytical lights
  54651. * (point spot...).
  54652. */
  54653. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54654. /**
  54655. * Intensity of the direct lights e.g. the four lights available in your scene.
  54656. * This impacts both the direct diffuse and specular highlights.
  54657. */
  54658. directIntensity: number;
  54659. /**
  54660. * Intensity of the emissive part of the material.
  54661. * This helps controlling the emissive effect without modifying the emissive color.
  54662. */
  54663. emissiveIntensity: number;
  54664. /**
  54665. * Intensity of the environment e.g. how much the environment will light the object
  54666. * either through harmonics for rough material or through the refelction for shiny ones.
  54667. */
  54668. environmentIntensity: number;
  54669. /**
  54670. * This is a special control allowing the reduction of the specular highlights coming from the
  54671. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54672. */
  54673. specularIntensity: number;
  54674. /**
  54675. * Debug Control allowing disabling the bump map on this material.
  54676. */
  54677. disableBumpMap: boolean;
  54678. /**
  54679. * AKA Diffuse Texture in standard nomenclature.
  54680. */
  54681. albedoTexture: BaseTexture;
  54682. /**
  54683. * AKA Occlusion Texture in other nomenclature.
  54684. */
  54685. ambientTexture: BaseTexture;
  54686. /**
  54687. * AKA Occlusion Texture Intensity in other nomenclature.
  54688. */
  54689. ambientTextureStrength: number;
  54690. /**
  54691. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54692. * 1 means it completely occludes it
  54693. * 0 mean it has no impact
  54694. */
  54695. ambientTextureImpactOnAnalyticalLights: number;
  54696. /**
  54697. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54698. */
  54699. opacityTexture: BaseTexture;
  54700. /**
  54701. * Stores the reflection values in a texture.
  54702. */
  54703. reflectionTexture: Nullable<BaseTexture>;
  54704. /**
  54705. * Stores the emissive values in a texture.
  54706. */
  54707. emissiveTexture: BaseTexture;
  54708. /**
  54709. * AKA Specular texture in other nomenclature.
  54710. */
  54711. reflectivityTexture: BaseTexture;
  54712. /**
  54713. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54714. */
  54715. metallicTexture: BaseTexture;
  54716. /**
  54717. * Specifies the metallic scalar of the metallic/roughness workflow.
  54718. * Can also be used to scale the metalness values of the metallic texture.
  54719. */
  54720. metallic: Nullable<number>;
  54721. /**
  54722. * Specifies the roughness scalar of the metallic/roughness workflow.
  54723. * Can also be used to scale the roughness values of the metallic texture.
  54724. */
  54725. roughness: Nullable<number>;
  54726. /**
  54727. * Specifies the an F0 factor to help configuring the material F0.
  54728. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54729. * to 0.5 the previously hard coded value stays the same.
  54730. * Can also be used to scale the F0 values of the metallic texture.
  54731. */
  54732. metallicF0Factor: number;
  54733. /**
  54734. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54735. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54736. * your expectation as it multiplies with the texture data.
  54737. */
  54738. useMetallicF0FactorFromMetallicTexture: boolean;
  54739. /**
  54740. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54741. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54742. */
  54743. microSurfaceTexture: BaseTexture;
  54744. /**
  54745. * Stores surface normal data used to displace a mesh in a texture.
  54746. */
  54747. bumpTexture: BaseTexture;
  54748. /**
  54749. * Stores the pre-calculated light information of a mesh in a texture.
  54750. */
  54751. lightmapTexture: BaseTexture;
  54752. /**
  54753. * Stores the refracted light information in a texture.
  54754. */
  54755. get refractionTexture(): Nullable<BaseTexture>;
  54756. set refractionTexture(value: Nullable<BaseTexture>);
  54757. /**
  54758. * The color of a material in ambient lighting.
  54759. */
  54760. ambientColor: Color3;
  54761. /**
  54762. * AKA Diffuse Color in other nomenclature.
  54763. */
  54764. albedoColor: Color3;
  54765. /**
  54766. * AKA Specular Color in other nomenclature.
  54767. */
  54768. reflectivityColor: Color3;
  54769. /**
  54770. * The color reflected from the material.
  54771. */
  54772. reflectionColor: Color3;
  54773. /**
  54774. * The color emitted from the material.
  54775. */
  54776. emissiveColor: Color3;
  54777. /**
  54778. * AKA Glossiness in other nomenclature.
  54779. */
  54780. microSurface: number;
  54781. /**
  54782. * source material index of refraction (IOR)' / 'destination material IOR.
  54783. */
  54784. get indexOfRefraction(): number;
  54785. set indexOfRefraction(value: number);
  54786. /**
  54787. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54788. */
  54789. get invertRefractionY(): boolean;
  54790. set invertRefractionY(value: boolean);
  54791. /**
  54792. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54793. * Materials half opaque for instance using refraction could benefit from this control.
  54794. */
  54795. get linkRefractionWithTransparency(): boolean;
  54796. set linkRefractionWithTransparency(value: boolean);
  54797. /**
  54798. * If true, the light map contains occlusion information instead of lighting info.
  54799. */
  54800. useLightmapAsShadowmap: boolean;
  54801. /**
  54802. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54803. */
  54804. useAlphaFromAlbedoTexture: boolean;
  54805. /**
  54806. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54807. */
  54808. forceAlphaTest: boolean;
  54809. /**
  54810. * Defines the alpha limits in alpha test mode.
  54811. */
  54812. alphaCutOff: number;
  54813. /**
  54814. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54815. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54816. */
  54817. useSpecularOverAlpha: boolean;
  54818. /**
  54819. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54820. */
  54821. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54822. /**
  54823. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54824. */
  54825. useRoughnessFromMetallicTextureAlpha: boolean;
  54826. /**
  54827. * Specifies if the metallic texture contains the roughness information in its green channel.
  54828. */
  54829. useRoughnessFromMetallicTextureGreen: boolean;
  54830. /**
  54831. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54832. */
  54833. useMetallnessFromMetallicTextureBlue: boolean;
  54834. /**
  54835. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54836. */
  54837. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54838. /**
  54839. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54840. */
  54841. useAmbientInGrayScale: boolean;
  54842. /**
  54843. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54844. * The material will try to infer what glossiness each pixel should be.
  54845. */
  54846. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54847. /**
  54848. * BJS is using an harcoded light falloff based on a manually sets up range.
  54849. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54850. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54851. */
  54852. get usePhysicalLightFalloff(): boolean;
  54853. /**
  54854. * BJS is using an harcoded light falloff based on a manually sets up range.
  54855. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54856. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54857. */
  54858. set usePhysicalLightFalloff(value: boolean);
  54859. /**
  54860. * In order to support the falloff compatibility with gltf, a special mode has been added
  54861. * to reproduce the gltf light falloff.
  54862. */
  54863. get useGLTFLightFalloff(): boolean;
  54864. /**
  54865. * In order to support the falloff compatibility with gltf, a special mode has been added
  54866. * to reproduce the gltf light falloff.
  54867. */
  54868. set useGLTFLightFalloff(value: boolean);
  54869. /**
  54870. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54871. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54872. */
  54873. useRadianceOverAlpha: boolean;
  54874. /**
  54875. * Allows using an object space normal map (instead of tangent space).
  54876. */
  54877. useObjectSpaceNormalMap: boolean;
  54878. /**
  54879. * Allows using the bump map in parallax mode.
  54880. */
  54881. useParallax: boolean;
  54882. /**
  54883. * Allows using the bump map in parallax occlusion mode.
  54884. */
  54885. useParallaxOcclusion: boolean;
  54886. /**
  54887. * Controls the scale bias of the parallax mode.
  54888. */
  54889. parallaxScaleBias: number;
  54890. /**
  54891. * If sets to true, disables all the lights affecting the material.
  54892. */
  54893. disableLighting: boolean;
  54894. /**
  54895. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54896. */
  54897. forceIrradianceInFragment: boolean;
  54898. /**
  54899. * Number of Simultaneous lights allowed on the material.
  54900. */
  54901. maxSimultaneousLights: number;
  54902. /**
  54903. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54904. */
  54905. invertNormalMapX: boolean;
  54906. /**
  54907. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54908. */
  54909. invertNormalMapY: boolean;
  54910. /**
  54911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54912. */
  54913. twoSidedLighting: boolean;
  54914. /**
  54915. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54916. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54917. */
  54918. useAlphaFresnel: boolean;
  54919. /**
  54920. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54921. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54922. */
  54923. useLinearAlphaFresnel: boolean;
  54924. /**
  54925. * Let user defines the brdf lookup texture used for IBL.
  54926. * A default 8bit version is embedded but you could point at :
  54927. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54928. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54929. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54930. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54931. */
  54932. environmentBRDFTexture: Nullable<BaseTexture>;
  54933. /**
  54934. * Force normal to face away from face.
  54935. */
  54936. forceNormalForward: boolean;
  54937. /**
  54938. * Enables specular anti aliasing in the PBR shader.
  54939. * It will both interacts on the Geometry for analytical and IBL lighting.
  54940. * It also prefilter the roughness map based on the bump values.
  54941. */
  54942. enableSpecularAntiAliasing: boolean;
  54943. /**
  54944. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54945. * makes the reflect vector face the model (under horizon).
  54946. */
  54947. useHorizonOcclusion: boolean;
  54948. /**
  54949. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54950. * too much the area relying on ambient texture to define their ambient occlusion.
  54951. */
  54952. useRadianceOcclusion: boolean;
  54953. /**
  54954. * If set to true, no lighting calculations will be applied.
  54955. */
  54956. unlit: boolean;
  54957. /**
  54958. * Gets the image processing configuration used either in this material.
  54959. */
  54960. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54961. /**
  54962. * Sets the Default image processing configuration used either in the this material.
  54963. *
  54964. * If sets to null, the scene one is in use.
  54965. */
  54966. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54967. /**
  54968. * Gets wether the color curves effect is enabled.
  54969. */
  54970. get cameraColorCurvesEnabled(): boolean;
  54971. /**
  54972. * Sets wether the color curves effect is enabled.
  54973. */
  54974. set cameraColorCurvesEnabled(value: boolean);
  54975. /**
  54976. * Gets wether the color grading effect is enabled.
  54977. */
  54978. get cameraColorGradingEnabled(): boolean;
  54979. /**
  54980. * Gets wether the color grading effect is enabled.
  54981. */
  54982. set cameraColorGradingEnabled(value: boolean);
  54983. /**
  54984. * Gets wether tonemapping is enabled or not.
  54985. */
  54986. get cameraToneMappingEnabled(): boolean;
  54987. /**
  54988. * Sets wether tonemapping is enabled or not
  54989. */
  54990. set cameraToneMappingEnabled(value: boolean);
  54991. /**
  54992. * The camera exposure used on this material.
  54993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54994. * This corresponds to a photographic exposure.
  54995. */
  54996. get cameraExposure(): number;
  54997. /**
  54998. * The camera exposure used on this material.
  54999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55000. * This corresponds to a photographic exposure.
  55001. */
  55002. set cameraExposure(value: number);
  55003. /**
  55004. * Gets The camera contrast used on this material.
  55005. */
  55006. get cameraContrast(): number;
  55007. /**
  55008. * Sets The camera contrast used on this material.
  55009. */
  55010. set cameraContrast(value: number);
  55011. /**
  55012. * Gets the Color Grading 2D Lookup Texture.
  55013. */
  55014. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55015. /**
  55016. * Sets the Color Grading 2D Lookup Texture.
  55017. */
  55018. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55019. /**
  55020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55022. * 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;
  55023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55024. */
  55025. get cameraColorCurves(): Nullable<ColorCurves>;
  55026. /**
  55027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55029. * 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;
  55030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55031. */
  55032. set cameraColorCurves(value: Nullable<ColorCurves>);
  55033. /**
  55034. * Instantiates a new PBRMaterial instance.
  55035. *
  55036. * @param name The material name
  55037. * @param scene The scene the material will be use in.
  55038. */
  55039. constructor(name: string, scene: Scene);
  55040. /**
  55041. * Returns the name of this material class.
  55042. */
  55043. getClassName(): string;
  55044. /**
  55045. * Makes a duplicate of the current material.
  55046. * @param name - name to use for the new material.
  55047. */
  55048. clone(name: string): PBRMaterial;
  55049. /**
  55050. * Serializes this PBR Material.
  55051. * @returns - An object with the serialized material.
  55052. */
  55053. serialize(): any;
  55054. /**
  55055. * Parses a PBR Material from a serialized object.
  55056. * @param source - Serialized object.
  55057. * @param scene - BJS scene instance.
  55058. * @param rootUrl - url for the scene object
  55059. * @returns - PBRMaterial
  55060. */
  55061. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55062. }
  55063. }
  55064. declare module "babylonjs/Misc/dds" {
  55065. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55067. import { Nullable } from "babylonjs/types";
  55068. import { Scene } from "babylonjs/scene";
  55069. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55070. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55071. /**
  55072. * Direct draw surface info
  55073. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55074. */
  55075. export interface DDSInfo {
  55076. /**
  55077. * Width of the texture
  55078. */
  55079. width: number;
  55080. /**
  55081. * Width of the texture
  55082. */
  55083. height: number;
  55084. /**
  55085. * Number of Mipmaps for the texture
  55086. * @see https://en.wikipedia.org/wiki/Mipmap
  55087. */
  55088. mipmapCount: number;
  55089. /**
  55090. * If the textures format is a known fourCC format
  55091. * @see https://www.fourcc.org/
  55092. */
  55093. isFourCC: boolean;
  55094. /**
  55095. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55096. */
  55097. isRGB: boolean;
  55098. /**
  55099. * If the texture is a lumincance format
  55100. */
  55101. isLuminance: boolean;
  55102. /**
  55103. * If this is a cube texture
  55104. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55105. */
  55106. isCube: boolean;
  55107. /**
  55108. * If the texture is a compressed format eg. FOURCC_DXT1
  55109. */
  55110. isCompressed: boolean;
  55111. /**
  55112. * The dxgiFormat of the texture
  55113. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55114. */
  55115. dxgiFormat: number;
  55116. /**
  55117. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55118. */
  55119. textureType: number;
  55120. /**
  55121. * Sphericle polynomial created for the dds texture
  55122. */
  55123. sphericalPolynomial?: SphericalPolynomial;
  55124. }
  55125. /**
  55126. * Class used to provide DDS decompression tools
  55127. */
  55128. export class DDSTools {
  55129. /**
  55130. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55131. */
  55132. static StoreLODInAlphaChannel: boolean;
  55133. /**
  55134. * Gets DDS information from an array buffer
  55135. * @param data defines the array buffer view to read data from
  55136. * @returns the DDS information
  55137. */
  55138. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55139. private static _FloatView;
  55140. private static _Int32View;
  55141. private static _ToHalfFloat;
  55142. private static _FromHalfFloat;
  55143. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55144. private static _GetHalfFloatRGBAArrayBuffer;
  55145. private static _GetFloatRGBAArrayBuffer;
  55146. private static _GetFloatAsUIntRGBAArrayBuffer;
  55147. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55148. private static _GetRGBAArrayBuffer;
  55149. private static _ExtractLongWordOrder;
  55150. private static _GetRGBArrayBuffer;
  55151. private static _GetLuminanceArrayBuffer;
  55152. /**
  55153. * Uploads DDS Levels to a Babylon Texture
  55154. * @hidden
  55155. */
  55156. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55157. }
  55158. module "babylonjs/Engines/thinEngine" {
  55159. interface ThinEngine {
  55160. /**
  55161. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55162. * @param rootUrl defines the url where the file to load is located
  55163. * @param scene defines the current scene
  55164. * @param lodScale defines scale to apply to the mip map selection
  55165. * @param lodOffset defines offset to apply to the mip map selection
  55166. * @param onLoad defines an optional callback raised when the texture is loaded
  55167. * @param onError defines an optional callback raised if there is an issue to load the texture
  55168. * @param format defines the format of the data
  55169. * @param forcedExtension defines the extension to use to pick the right loader
  55170. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55171. * @returns the cube texture as an InternalTexture
  55172. */
  55173. 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;
  55174. }
  55175. }
  55176. }
  55177. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55178. import { Nullable } from "babylonjs/types";
  55179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55180. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55181. /**
  55182. * Implementation of the DDS Texture Loader.
  55183. * @hidden
  55184. */
  55185. export class _DDSTextureLoader implements IInternalTextureLoader {
  55186. /**
  55187. * Defines wether the loader supports cascade loading the different faces.
  55188. */
  55189. readonly supportCascades: boolean;
  55190. /**
  55191. * This returns if the loader support the current file information.
  55192. * @param extension defines the file extension of the file being loaded
  55193. * @returns true if the loader can load the specified file
  55194. */
  55195. canLoad(extension: string): boolean;
  55196. /**
  55197. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55198. * @param data contains the texture data
  55199. * @param texture defines the BabylonJS internal texture
  55200. * @param createPolynomials will be true if polynomials have been requested
  55201. * @param onLoad defines the callback to trigger once the texture is ready
  55202. * @param onError defines the callback to trigger in case of error
  55203. */
  55204. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55205. /**
  55206. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55207. * @param data contains the texture data
  55208. * @param texture defines the BabylonJS internal texture
  55209. * @param callback defines the method to call once ready to upload
  55210. */
  55211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55212. }
  55213. }
  55214. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55215. import { Nullable } from "babylonjs/types";
  55216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55218. /**
  55219. * Implementation of the ENV Texture Loader.
  55220. * @hidden
  55221. */
  55222. export class _ENVTextureLoader implements IInternalTextureLoader {
  55223. /**
  55224. * Defines wether the loader supports cascade loading the different faces.
  55225. */
  55226. readonly supportCascades: boolean;
  55227. /**
  55228. * This returns if the loader support the current file information.
  55229. * @param extension defines the file extension of the file being loaded
  55230. * @returns true if the loader can load the specified file
  55231. */
  55232. canLoad(extension: string): boolean;
  55233. /**
  55234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55235. * @param data contains the texture data
  55236. * @param texture defines the BabylonJS internal texture
  55237. * @param createPolynomials will be true if polynomials have been requested
  55238. * @param onLoad defines the callback to trigger once the texture is ready
  55239. * @param onError defines the callback to trigger in case of error
  55240. */
  55241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55242. /**
  55243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55244. * @param data contains the texture data
  55245. * @param texture defines the BabylonJS internal texture
  55246. * @param callback defines the method to call once ready to upload
  55247. */
  55248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55249. }
  55250. }
  55251. declare module "babylonjs/Misc/khronosTextureContainer" {
  55252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55253. /**
  55254. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55255. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55256. */
  55257. export class KhronosTextureContainer {
  55258. /** contents of the KTX container file */
  55259. data: ArrayBufferView;
  55260. private static HEADER_LEN;
  55261. private static COMPRESSED_2D;
  55262. private static COMPRESSED_3D;
  55263. private static TEX_2D;
  55264. private static TEX_3D;
  55265. /**
  55266. * Gets the openGL type
  55267. */
  55268. glType: number;
  55269. /**
  55270. * Gets the openGL type size
  55271. */
  55272. glTypeSize: number;
  55273. /**
  55274. * Gets the openGL format
  55275. */
  55276. glFormat: number;
  55277. /**
  55278. * Gets the openGL internal format
  55279. */
  55280. glInternalFormat: number;
  55281. /**
  55282. * Gets the base internal format
  55283. */
  55284. glBaseInternalFormat: number;
  55285. /**
  55286. * Gets image width in pixel
  55287. */
  55288. pixelWidth: number;
  55289. /**
  55290. * Gets image height in pixel
  55291. */
  55292. pixelHeight: number;
  55293. /**
  55294. * Gets image depth in pixels
  55295. */
  55296. pixelDepth: number;
  55297. /**
  55298. * Gets the number of array elements
  55299. */
  55300. numberOfArrayElements: number;
  55301. /**
  55302. * Gets the number of faces
  55303. */
  55304. numberOfFaces: number;
  55305. /**
  55306. * Gets the number of mipmap levels
  55307. */
  55308. numberOfMipmapLevels: number;
  55309. /**
  55310. * Gets the bytes of key value data
  55311. */
  55312. bytesOfKeyValueData: number;
  55313. /**
  55314. * Gets the load type
  55315. */
  55316. loadType: number;
  55317. /**
  55318. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55319. */
  55320. isInvalid: boolean;
  55321. /**
  55322. * Creates a new KhronosTextureContainer
  55323. * @param data contents of the KTX container file
  55324. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55325. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55326. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55327. */
  55328. constructor(
  55329. /** contents of the KTX container file */
  55330. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55331. /**
  55332. * Uploads KTX content to a Babylon Texture.
  55333. * It is assumed that the texture has already been created & is currently bound
  55334. * @hidden
  55335. */
  55336. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55337. private _upload2DCompressedLevels;
  55338. /**
  55339. * Checks if the given data starts with a KTX file identifier.
  55340. * @param data the data to check
  55341. * @returns true if the data is a KTX file or false otherwise
  55342. */
  55343. static IsValid(data: ArrayBufferView): boolean;
  55344. }
  55345. }
  55346. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55347. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55348. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55349. /**
  55350. * Class for loading KTX2 files
  55351. * !!! Experimental Extension Subject to Changes !!!
  55352. * @hidden
  55353. */
  55354. export class KhronosTextureContainer2 {
  55355. private static _ModulePromise;
  55356. private static _TranscodeFormat;
  55357. constructor(engine: ThinEngine);
  55358. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55359. private _determineTranscodeFormat;
  55360. /**
  55361. * Checks if the given data starts with a KTX2 file identifier.
  55362. * @param data the data to check
  55363. * @returns true if the data is a KTX2 file or false otherwise
  55364. */
  55365. static IsValid(data: ArrayBufferView): boolean;
  55366. }
  55367. }
  55368. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55369. import { Nullable } from "babylonjs/types";
  55370. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55371. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55372. /**
  55373. * Implementation of the KTX Texture Loader.
  55374. * @hidden
  55375. */
  55376. export class _KTXTextureLoader implements IInternalTextureLoader {
  55377. /**
  55378. * Defines wether the loader supports cascade loading the different faces.
  55379. */
  55380. readonly supportCascades: boolean;
  55381. /**
  55382. * This returns if the loader support the current file information.
  55383. * @param extension defines the file extension of the file being loaded
  55384. * @returns true if the loader can load the specified file
  55385. */
  55386. canLoad(extension: string): boolean;
  55387. /**
  55388. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55389. * @param data contains the texture data
  55390. * @param texture defines the BabylonJS internal texture
  55391. * @param createPolynomials will be true if polynomials have been requested
  55392. * @param onLoad defines the callback to trigger once the texture is ready
  55393. * @param onError defines the callback to trigger in case of error
  55394. */
  55395. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55396. /**
  55397. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55398. * @param data contains the texture data
  55399. * @param texture defines the BabylonJS internal texture
  55400. * @param callback defines the method to call once ready to upload
  55401. */
  55402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55403. }
  55404. }
  55405. declare module "babylonjs/Helpers/sceneHelpers" {
  55406. import { Nullable } from "babylonjs/types";
  55407. import { Mesh } from "babylonjs/Meshes/mesh";
  55408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55409. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55410. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55411. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55412. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55413. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55414. import "babylonjs/Meshes/Builders/boxBuilder";
  55415. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55416. /** @hidden */
  55417. export var _forceSceneHelpersToBundle: boolean;
  55418. module "babylonjs/scene" {
  55419. interface Scene {
  55420. /**
  55421. * Creates a default light for the scene.
  55422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55423. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55424. */
  55425. createDefaultLight(replace?: boolean): void;
  55426. /**
  55427. * Creates a default camera for the scene.
  55428. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55430. * @param replace has default false, when true replaces the active camera in the scene
  55431. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55432. */
  55433. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55434. /**
  55435. * Creates a default camera and a default light.
  55436. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55437. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55438. * @param replace has the default false, when true replaces the active camera/light in the scene
  55439. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55440. */
  55441. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55442. /**
  55443. * Creates a new sky box
  55444. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55445. * @param environmentTexture defines the texture to use as environment texture
  55446. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55447. * @param scale defines the overall scale of the skybox
  55448. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55449. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55450. * @returns a new mesh holding the sky box
  55451. */
  55452. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55453. /**
  55454. * Creates a new environment
  55455. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55456. * @param options defines the options you can use to configure the environment
  55457. * @returns the new EnvironmentHelper
  55458. */
  55459. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55460. /**
  55461. * Creates a new VREXperienceHelper
  55462. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55463. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55464. * @returns a new VREXperienceHelper
  55465. */
  55466. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55467. /**
  55468. * Creates a new WebXRDefaultExperience
  55469. * @see http://doc.babylonjs.com/how_to/webxr
  55470. * @param options experience options
  55471. * @returns a promise for a new WebXRDefaultExperience
  55472. */
  55473. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55474. }
  55475. }
  55476. }
  55477. declare module "babylonjs/Helpers/videoDome" {
  55478. import { Scene } from "babylonjs/scene";
  55479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55480. import { Mesh } from "babylonjs/Meshes/mesh";
  55481. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55482. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55483. import "babylonjs/Meshes/Builders/sphereBuilder";
  55484. /**
  55485. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55486. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55487. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55488. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55489. */
  55490. export class VideoDome extends TransformNode {
  55491. /**
  55492. * Define the video source as a Monoscopic panoramic 360 video.
  55493. */
  55494. static readonly MODE_MONOSCOPIC: number;
  55495. /**
  55496. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55497. */
  55498. static readonly MODE_TOPBOTTOM: number;
  55499. /**
  55500. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55501. */
  55502. static readonly MODE_SIDEBYSIDE: number;
  55503. private _halfDome;
  55504. private _useDirectMapping;
  55505. /**
  55506. * The video texture being displayed on the sphere
  55507. */
  55508. protected _videoTexture: VideoTexture;
  55509. /**
  55510. * Gets the video texture being displayed on the sphere
  55511. */
  55512. get videoTexture(): VideoTexture;
  55513. /**
  55514. * The skybox material
  55515. */
  55516. protected _material: BackgroundMaterial;
  55517. /**
  55518. * The surface used for the skybox
  55519. */
  55520. protected _mesh: Mesh;
  55521. /**
  55522. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55523. */
  55524. private _halfDomeMask;
  55525. /**
  55526. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55527. * Also see the options.resolution property.
  55528. */
  55529. get fovMultiplier(): number;
  55530. set fovMultiplier(value: number);
  55531. private _videoMode;
  55532. /**
  55533. * Gets or set the current video mode for the video. It can be:
  55534. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55535. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55536. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55537. */
  55538. get videoMode(): number;
  55539. set videoMode(value: number);
  55540. /**
  55541. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55542. *
  55543. */
  55544. get halfDome(): boolean;
  55545. /**
  55546. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55547. */
  55548. set halfDome(enabled: boolean);
  55549. /**
  55550. * Oberserver used in Stereoscopic VR Mode.
  55551. */
  55552. private _onBeforeCameraRenderObserver;
  55553. /**
  55554. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55555. * @param name Element's name, child elements will append suffixes for their own names.
  55556. * @param urlsOrVideo defines the url(s) or the video element to use
  55557. * @param options An object containing optional or exposed sub element properties
  55558. */
  55559. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55560. resolution?: number;
  55561. clickToPlay?: boolean;
  55562. autoPlay?: boolean;
  55563. loop?: boolean;
  55564. size?: number;
  55565. poster?: string;
  55566. faceForward?: boolean;
  55567. useDirectMapping?: boolean;
  55568. halfDomeMode?: boolean;
  55569. }, scene: Scene);
  55570. private _changeVideoMode;
  55571. /**
  55572. * Releases resources associated with this node.
  55573. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55574. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55575. */
  55576. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55577. }
  55578. }
  55579. declare module "babylonjs/Helpers/index" {
  55580. export * from "babylonjs/Helpers/environmentHelper";
  55581. export * from "babylonjs/Helpers/photoDome";
  55582. export * from "babylonjs/Helpers/sceneHelpers";
  55583. export * from "babylonjs/Helpers/videoDome";
  55584. }
  55585. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55586. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55587. import { IDisposable } from "babylonjs/scene";
  55588. import { Engine } from "babylonjs/Engines/engine";
  55589. /**
  55590. * This class can be used to get instrumentation data from a Babylon engine
  55591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55592. */
  55593. export class EngineInstrumentation implements IDisposable {
  55594. /**
  55595. * Define the instrumented engine.
  55596. */
  55597. engine: Engine;
  55598. private _captureGPUFrameTime;
  55599. private _gpuFrameTimeToken;
  55600. private _gpuFrameTime;
  55601. private _captureShaderCompilationTime;
  55602. private _shaderCompilationTime;
  55603. private _onBeginFrameObserver;
  55604. private _onEndFrameObserver;
  55605. private _onBeforeShaderCompilationObserver;
  55606. private _onAfterShaderCompilationObserver;
  55607. /**
  55608. * Gets the perf counter used for GPU frame time
  55609. */
  55610. get gpuFrameTimeCounter(): PerfCounter;
  55611. /**
  55612. * Gets the GPU frame time capture status
  55613. */
  55614. get captureGPUFrameTime(): boolean;
  55615. /**
  55616. * Enable or disable the GPU frame time capture
  55617. */
  55618. set captureGPUFrameTime(value: boolean);
  55619. /**
  55620. * Gets the perf counter used for shader compilation time
  55621. */
  55622. get shaderCompilationTimeCounter(): PerfCounter;
  55623. /**
  55624. * Gets the shader compilation time capture status
  55625. */
  55626. get captureShaderCompilationTime(): boolean;
  55627. /**
  55628. * Enable or disable the shader compilation time capture
  55629. */
  55630. set captureShaderCompilationTime(value: boolean);
  55631. /**
  55632. * Instantiates a new engine instrumentation.
  55633. * This class can be used to get instrumentation data from a Babylon engine
  55634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55635. * @param engine Defines the engine to instrument
  55636. */
  55637. constructor(
  55638. /**
  55639. * Define the instrumented engine.
  55640. */
  55641. engine: Engine);
  55642. /**
  55643. * Dispose and release associated resources.
  55644. */
  55645. dispose(): void;
  55646. }
  55647. }
  55648. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55649. import { Scene, IDisposable } from "babylonjs/scene";
  55650. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55651. /**
  55652. * This class can be used to get instrumentation data from a Babylon engine
  55653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55654. */
  55655. export class SceneInstrumentation implements IDisposable {
  55656. /**
  55657. * Defines the scene to instrument
  55658. */
  55659. scene: Scene;
  55660. private _captureActiveMeshesEvaluationTime;
  55661. private _activeMeshesEvaluationTime;
  55662. private _captureRenderTargetsRenderTime;
  55663. private _renderTargetsRenderTime;
  55664. private _captureFrameTime;
  55665. private _frameTime;
  55666. private _captureRenderTime;
  55667. private _renderTime;
  55668. private _captureInterFrameTime;
  55669. private _interFrameTime;
  55670. private _captureParticlesRenderTime;
  55671. private _particlesRenderTime;
  55672. private _captureSpritesRenderTime;
  55673. private _spritesRenderTime;
  55674. private _capturePhysicsTime;
  55675. private _physicsTime;
  55676. private _captureAnimationsTime;
  55677. private _animationsTime;
  55678. private _captureCameraRenderTime;
  55679. private _cameraRenderTime;
  55680. private _onBeforeActiveMeshesEvaluationObserver;
  55681. private _onAfterActiveMeshesEvaluationObserver;
  55682. private _onBeforeRenderTargetsRenderObserver;
  55683. private _onAfterRenderTargetsRenderObserver;
  55684. private _onAfterRenderObserver;
  55685. private _onBeforeDrawPhaseObserver;
  55686. private _onAfterDrawPhaseObserver;
  55687. private _onBeforeAnimationsObserver;
  55688. private _onBeforeParticlesRenderingObserver;
  55689. private _onAfterParticlesRenderingObserver;
  55690. private _onBeforeSpritesRenderingObserver;
  55691. private _onAfterSpritesRenderingObserver;
  55692. private _onBeforePhysicsObserver;
  55693. private _onAfterPhysicsObserver;
  55694. private _onAfterAnimationsObserver;
  55695. private _onBeforeCameraRenderObserver;
  55696. private _onAfterCameraRenderObserver;
  55697. /**
  55698. * Gets the perf counter used for active meshes evaluation time
  55699. */
  55700. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55701. /**
  55702. * Gets the active meshes evaluation time capture status
  55703. */
  55704. get captureActiveMeshesEvaluationTime(): boolean;
  55705. /**
  55706. * Enable or disable the active meshes evaluation time capture
  55707. */
  55708. set captureActiveMeshesEvaluationTime(value: boolean);
  55709. /**
  55710. * Gets the perf counter used for render targets render time
  55711. */
  55712. get renderTargetsRenderTimeCounter(): PerfCounter;
  55713. /**
  55714. * Gets the render targets render time capture status
  55715. */
  55716. get captureRenderTargetsRenderTime(): boolean;
  55717. /**
  55718. * Enable or disable the render targets render time capture
  55719. */
  55720. set captureRenderTargetsRenderTime(value: boolean);
  55721. /**
  55722. * Gets the perf counter used for particles render time
  55723. */
  55724. get particlesRenderTimeCounter(): PerfCounter;
  55725. /**
  55726. * Gets the particles render time capture status
  55727. */
  55728. get captureParticlesRenderTime(): boolean;
  55729. /**
  55730. * Enable or disable the particles render time capture
  55731. */
  55732. set captureParticlesRenderTime(value: boolean);
  55733. /**
  55734. * Gets the perf counter used for sprites render time
  55735. */
  55736. get spritesRenderTimeCounter(): PerfCounter;
  55737. /**
  55738. * Gets the sprites render time capture status
  55739. */
  55740. get captureSpritesRenderTime(): boolean;
  55741. /**
  55742. * Enable or disable the sprites render time capture
  55743. */
  55744. set captureSpritesRenderTime(value: boolean);
  55745. /**
  55746. * Gets the perf counter used for physics time
  55747. */
  55748. get physicsTimeCounter(): PerfCounter;
  55749. /**
  55750. * Gets the physics time capture status
  55751. */
  55752. get capturePhysicsTime(): boolean;
  55753. /**
  55754. * Enable or disable the physics time capture
  55755. */
  55756. set capturePhysicsTime(value: boolean);
  55757. /**
  55758. * Gets the perf counter used for animations time
  55759. */
  55760. get animationsTimeCounter(): PerfCounter;
  55761. /**
  55762. * Gets the animations time capture status
  55763. */
  55764. get captureAnimationsTime(): boolean;
  55765. /**
  55766. * Enable or disable the animations time capture
  55767. */
  55768. set captureAnimationsTime(value: boolean);
  55769. /**
  55770. * Gets the perf counter used for frame time capture
  55771. */
  55772. get frameTimeCounter(): PerfCounter;
  55773. /**
  55774. * Gets the frame time capture status
  55775. */
  55776. get captureFrameTime(): boolean;
  55777. /**
  55778. * Enable or disable the frame time capture
  55779. */
  55780. set captureFrameTime(value: boolean);
  55781. /**
  55782. * Gets the perf counter used for inter-frames time capture
  55783. */
  55784. get interFrameTimeCounter(): PerfCounter;
  55785. /**
  55786. * Gets the inter-frames time capture status
  55787. */
  55788. get captureInterFrameTime(): boolean;
  55789. /**
  55790. * Enable or disable the inter-frames time capture
  55791. */
  55792. set captureInterFrameTime(value: boolean);
  55793. /**
  55794. * Gets the perf counter used for render time capture
  55795. */
  55796. get renderTimeCounter(): PerfCounter;
  55797. /**
  55798. * Gets the render time capture status
  55799. */
  55800. get captureRenderTime(): boolean;
  55801. /**
  55802. * Enable or disable the render time capture
  55803. */
  55804. set captureRenderTime(value: boolean);
  55805. /**
  55806. * Gets the perf counter used for camera render time capture
  55807. */
  55808. get cameraRenderTimeCounter(): PerfCounter;
  55809. /**
  55810. * Gets the camera render time capture status
  55811. */
  55812. get captureCameraRenderTime(): boolean;
  55813. /**
  55814. * Enable or disable the camera render time capture
  55815. */
  55816. set captureCameraRenderTime(value: boolean);
  55817. /**
  55818. * Gets the perf counter used for draw calls
  55819. */
  55820. get drawCallsCounter(): PerfCounter;
  55821. /**
  55822. * Instantiates a new scene instrumentation.
  55823. * This class can be used to get instrumentation data from a Babylon engine
  55824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55825. * @param scene Defines the scene to instrument
  55826. */
  55827. constructor(
  55828. /**
  55829. * Defines the scene to instrument
  55830. */
  55831. scene: Scene);
  55832. /**
  55833. * Dispose and release associated resources.
  55834. */
  55835. dispose(): void;
  55836. }
  55837. }
  55838. declare module "babylonjs/Instrumentation/index" {
  55839. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55840. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55841. export * from "babylonjs/Instrumentation/timeToken";
  55842. }
  55843. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55844. /** @hidden */
  55845. export var glowMapGenerationPixelShader: {
  55846. name: string;
  55847. shader: string;
  55848. };
  55849. }
  55850. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55851. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55853. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55854. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55856. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55857. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55858. /** @hidden */
  55859. export var glowMapGenerationVertexShader: {
  55860. name: string;
  55861. shader: string;
  55862. };
  55863. }
  55864. declare module "babylonjs/Layers/effectLayer" {
  55865. import { Observable } from "babylonjs/Misc/observable";
  55866. import { Nullable } from "babylonjs/types";
  55867. import { Camera } from "babylonjs/Cameras/camera";
  55868. import { Scene } from "babylonjs/scene";
  55869. import { ISize } from "babylonjs/Maths/math.size";
  55870. import { Color4 } from "babylonjs/Maths/math.color";
  55871. import { Engine } from "babylonjs/Engines/engine";
  55872. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55874. import { Mesh } from "babylonjs/Meshes/mesh";
  55875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55878. import { Effect } from "babylonjs/Materials/effect";
  55879. import { Material } from "babylonjs/Materials/material";
  55880. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55881. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55882. /**
  55883. * Effect layer options. This helps customizing the behaviour
  55884. * of the effect layer.
  55885. */
  55886. export interface IEffectLayerOptions {
  55887. /**
  55888. * Multiplication factor apply to the canvas size to compute the render target size
  55889. * used to generated the objects (the smaller the faster).
  55890. */
  55891. mainTextureRatio: number;
  55892. /**
  55893. * Enforces a fixed size texture to ensure effect stability across devices.
  55894. */
  55895. mainTextureFixedSize?: number;
  55896. /**
  55897. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55898. */
  55899. alphaBlendingMode: number;
  55900. /**
  55901. * The camera attached to the layer.
  55902. */
  55903. camera: Nullable<Camera>;
  55904. /**
  55905. * The rendering group to draw the layer in.
  55906. */
  55907. renderingGroupId: number;
  55908. }
  55909. /**
  55910. * The effect layer Helps adding post process effect blended with the main pass.
  55911. *
  55912. * This can be for instance use to generate glow or higlight effects on the scene.
  55913. *
  55914. * The effect layer class can not be used directly and is intented to inherited from to be
  55915. * customized per effects.
  55916. */
  55917. export abstract class EffectLayer {
  55918. private _vertexBuffers;
  55919. private _indexBuffer;
  55920. private _cachedDefines;
  55921. private _effectLayerMapGenerationEffect;
  55922. private _effectLayerOptions;
  55923. private _mergeEffect;
  55924. protected _scene: Scene;
  55925. protected _engine: Engine;
  55926. protected _maxSize: number;
  55927. protected _mainTextureDesiredSize: ISize;
  55928. protected _mainTexture: RenderTargetTexture;
  55929. protected _shouldRender: boolean;
  55930. protected _postProcesses: PostProcess[];
  55931. protected _textures: BaseTexture[];
  55932. protected _emissiveTextureAndColor: {
  55933. texture: Nullable<BaseTexture>;
  55934. color: Color4;
  55935. };
  55936. /**
  55937. * The name of the layer
  55938. */
  55939. name: string;
  55940. /**
  55941. * The clear color of the texture used to generate the glow map.
  55942. */
  55943. neutralColor: Color4;
  55944. /**
  55945. * Specifies whether the highlight layer is enabled or not.
  55946. */
  55947. isEnabled: boolean;
  55948. /**
  55949. * Gets the camera attached to the layer.
  55950. */
  55951. get camera(): Nullable<Camera>;
  55952. /**
  55953. * Gets the rendering group id the layer should render in.
  55954. */
  55955. get renderingGroupId(): number;
  55956. set renderingGroupId(renderingGroupId: number);
  55957. /**
  55958. * An event triggered when the effect layer has been disposed.
  55959. */
  55960. onDisposeObservable: Observable<EffectLayer>;
  55961. /**
  55962. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55963. */
  55964. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55965. /**
  55966. * An event triggered when the generated texture is being merged in the scene.
  55967. */
  55968. onBeforeComposeObservable: Observable<EffectLayer>;
  55969. /**
  55970. * An event triggered when the mesh is rendered into the effect render target.
  55971. */
  55972. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55973. /**
  55974. * An event triggered after the mesh has been rendered into the effect render target.
  55975. */
  55976. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55977. /**
  55978. * An event triggered when the generated texture has been merged in the scene.
  55979. */
  55980. onAfterComposeObservable: Observable<EffectLayer>;
  55981. /**
  55982. * An event triggered when the efffect layer changes its size.
  55983. */
  55984. onSizeChangedObservable: Observable<EffectLayer>;
  55985. /** @hidden */
  55986. static _SceneComponentInitialization: (scene: Scene) => void;
  55987. /**
  55988. * Instantiates a new effect Layer and references it in the scene.
  55989. * @param name The name of the layer
  55990. * @param scene The scene to use the layer in
  55991. */
  55992. constructor(
  55993. /** The Friendly of the effect in the scene */
  55994. name: string, scene: Scene);
  55995. /**
  55996. * Get the effect name of the layer.
  55997. * @return The effect name
  55998. */
  55999. abstract getEffectName(): string;
  56000. /**
  56001. * Checks for the readiness of the element composing the layer.
  56002. * @param subMesh the mesh to check for
  56003. * @param useInstances specify whether or not to use instances to render the mesh
  56004. * @return true if ready otherwise, false
  56005. */
  56006. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56007. /**
  56008. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56009. * @returns true if the effect requires stencil during the main canvas render pass.
  56010. */
  56011. abstract needStencil(): boolean;
  56012. /**
  56013. * Create the merge effect. This is the shader use to blit the information back
  56014. * to the main canvas at the end of the scene rendering.
  56015. * @returns The effect containing the shader used to merge the effect on the main canvas
  56016. */
  56017. protected abstract _createMergeEffect(): Effect;
  56018. /**
  56019. * Creates the render target textures and post processes used in the effect layer.
  56020. */
  56021. protected abstract _createTextureAndPostProcesses(): void;
  56022. /**
  56023. * Implementation specific of rendering the generating effect on the main canvas.
  56024. * @param effect The effect used to render through
  56025. */
  56026. protected abstract _internalRender(effect: Effect): void;
  56027. /**
  56028. * Sets the required values for both the emissive texture and and the main color.
  56029. */
  56030. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56031. /**
  56032. * Free any resources and references associated to a mesh.
  56033. * Internal use
  56034. * @param mesh The mesh to free.
  56035. */
  56036. abstract _disposeMesh(mesh: Mesh): void;
  56037. /**
  56038. * Serializes this layer (Glow or Highlight for example)
  56039. * @returns a serialized layer object
  56040. */
  56041. abstract serialize?(): any;
  56042. /**
  56043. * Initializes the effect layer with the required options.
  56044. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56045. */
  56046. protected _init(options: Partial<IEffectLayerOptions>): void;
  56047. /**
  56048. * Generates the index buffer of the full screen quad blending to the main canvas.
  56049. */
  56050. private _generateIndexBuffer;
  56051. /**
  56052. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56053. */
  56054. private _generateVertexBuffer;
  56055. /**
  56056. * Sets the main texture desired size which is the closest power of two
  56057. * of the engine canvas size.
  56058. */
  56059. private _setMainTextureSize;
  56060. /**
  56061. * Creates the main texture for the effect layer.
  56062. */
  56063. protected _createMainTexture(): void;
  56064. /**
  56065. * Adds specific effects defines.
  56066. * @param defines The defines to add specifics to.
  56067. */
  56068. protected _addCustomEffectDefines(defines: string[]): void;
  56069. /**
  56070. * Checks for the readiness of the element composing the layer.
  56071. * @param subMesh the mesh to check for
  56072. * @param useInstances specify whether or not to use instances to render the mesh
  56073. * @param emissiveTexture the associated emissive texture used to generate the glow
  56074. * @return true if ready otherwise, false
  56075. */
  56076. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56077. /**
  56078. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56079. */
  56080. render(): void;
  56081. /**
  56082. * Determine if a given mesh will be used in the current effect.
  56083. * @param mesh mesh to test
  56084. * @returns true if the mesh will be used
  56085. */
  56086. hasMesh(mesh: AbstractMesh): boolean;
  56087. /**
  56088. * Returns true if the layer contains information to display, otherwise false.
  56089. * @returns true if the glow layer should be rendered
  56090. */
  56091. shouldRender(): boolean;
  56092. /**
  56093. * Returns true if the mesh should render, otherwise false.
  56094. * @param mesh The mesh to render
  56095. * @returns true if it should render otherwise false
  56096. */
  56097. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56098. /**
  56099. * Returns true if the mesh can be rendered, otherwise false.
  56100. * @param mesh The mesh to render
  56101. * @param material The material used on the mesh
  56102. * @returns true if it can be rendered otherwise false
  56103. */
  56104. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56105. /**
  56106. * Returns true if the mesh should render, otherwise false.
  56107. * @param mesh The mesh to render
  56108. * @returns true if it should render otherwise false
  56109. */
  56110. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56111. /**
  56112. * Renders the submesh passed in parameter to the generation map.
  56113. */
  56114. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56115. /**
  56116. * Defines whether the current material of the mesh should be use to render the effect.
  56117. * @param mesh defines the current mesh to render
  56118. */
  56119. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56120. /**
  56121. * Rebuild the required buffers.
  56122. * @hidden Internal use only.
  56123. */
  56124. _rebuild(): void;
  56125. /**
  56126. * Dispose only the render target textures and post process.
  56127. */
  56128. private _disposeTextureAndPostProcesses;
  56129. /**
  56130. * Dispose the highlight layer and free resources.
  56131. */
  56132. dispose(): void;
  56133. /**
  56134. * Gets the class name of the effect layer
  56135. * @returns the string with the class name of the effect layer
  56136. */
  56137. getClassName(): string;
  56138. /**
  56139. * Creates an effect layer from parsed effect layer data
  56140. * @param parsedEffectLayer defines effect layer data
  56141. * @param scene defines the current scene
  56142. * @param rootUrl defines the root URL containing the effect layer information
  56143. * @returns a parsed effect Layer
  56144. */
  56145. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56146. }
  56147. }
  56148. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56149. import { Scene } from "babylonjs/scene";
  56150. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56151. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56152. import { AbstractScene } from "babylonjs/abstractScene";
  56153. module "babylonjs/abstractScene" {
  56154. interface AbstractScene {
  56155. /**
  56156. * The list of effect layers (highlights/glow) added to the scene
  56157. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56158. * @see http://doc.babylonjs.com/how_to/glow_layer
  56159. */
  56160. effectLayers: Array<EffectLayer>;
  56161. /**
  56162. * Removes the given effect layer from this scene.
  56163. * @param toRemove defines the effect layer to remove
  56164. * @returns the index of the removed effect layer
  56165. */
  56166. removeEffectLayer(toRemove: EffectLayer): number;
  56167. /**
  56168. * Adds the given effect layer to this scene
  56169. * @param newEffectLayer defines the effect layer to add
  56170. */
  56171. addEffectLayer(newEffectLayer: EffectLayer): void;
  56172. }
  56173. }
  56174. /**
  56175. * Defines the layer scene component responsible to manage any effect layers
  56176. * in a given scene.
  56177. */
  56178. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56179. /**
  56180. * The component name helpfull to identify the component in the list of scene components.
  56181. */
  56182. readonly name: string;
  56183. /**
  56184. * The scene the component belongs to.
  56185. */
  56186. scene: Scene;
  56187. private _engine;
  56188. private _renderEffects;
  56189. private _needStencil;
  56190. private _previousStencilState;
  56191. /**
  56192. * Creates a new instance of the component for the given scene
  56193. * @param scene Defines the scene to register the component in
  56194. */
  56195. constructor(scene: Scene);
  56196. /**
  56197. * Registers the component in a given scene
  56198. */
  56199. register(): void;
  56200. /**
  56201. * Rebuilds the elements related to this component in case of
  56202. * context lost for instance.
  56203. */
  56204. rebuild(): void;
  56205. /**
  56206. * Serializes the component data to the specified json object
  56207. * @param serializationObject The object to serialize to
  56208. */
  56209. serialize(serializationObject: any): void;
  56210. /**
  56211. * Adds all the elements from the container to the scene
  56212. * @param container the container holding the elements
  56213. */
  56214. addFromContainer(container: AbstractScene): void;
  56215. /**
  56216. * Removes all the elements in the container from the scene
  56217. * @param container contains the elements to remove
  56218. * @param dispose if the removed element should be disposed (default: false)
  56219. */
  56220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56221. /**
  56222. * Disposes the component and the associated ressources.
  56223. */
  56224. dispose(): void;
  56225. private _isReadyForMesh;
  56226. private _renderMainTexture;
  56227. private _setStencil;
  56228. private _setStencilBack;
  56229. private _draw;
  56230. private _drawCamera;
  56231. private _drawRenderingGroup;
  56232. }
  56233. }
  56234. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56235. /** @hidden */
  56236. export var glowMapMergePixelShader: {
  56237. name: string;
  56238. shader: string;
  56239. };
  56240. }
  56241. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56242. /** @hidden */
  56243. export var glowMapMergeVertexShader: {
  56244. name: string;
  56245. shader: string;
  56246. };
  56247. }
  56248. declare module "babylonjs/Layers/glowLayer" {
  56249. import { Nullable } from "babylonjs/types";
  56250. import { Camera } from "babylonjs/Cameras/camera";
  56251. import { Scene } from "babylonjs/scene";
  56252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56254. import { Mesh } from "babylonjs/Meshes/mesh";
  56255. import { Texture } from "babylonjs/Materials/Textures/texture";
  56256. import { Effect } from "babylonjs/Materials/effect";
  56257. import { Material } from "babylonjs/Materials/material";
  56258. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56259. import { Color4 } from "babylonjs/Maths/math.color";
  56260. import "babylonjs/Shaders/glowMapMerge.fragment";
  56261. import "babylonjs/Shaders/glowMapMerge.vertex";
  56262. import "babylonjs/Layers/effectLayerSceneComponent";
  56263. module "babylonjs/abstractScene" {
  56264. interface AbstractScene {
  56265. /**
  56266. * Return a the first highlight layer of the scene with a given name.
  56267. * @param name The name of the highlight layer to look for.
  56268. * @return The highlight layer if found otherwise null.
  56269. */
  56270. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56271. }
  56272. }
  56273. /**
  56274. * Glow layer options. This helps customizing the behaviour
  56275. * of the glow layer.
  56276. */
  56277. export interface IGlowLayerOptions {
  56278. /**
  56279. * Multiplication factor apply to the canvas size to compute the render target size
  56280. * used to generated the glowing objects (the smaller the faster).
  56281. */
  56282. mainTextureRatio: number;
  56283. /**
  56284. * Enforces a fixed size texture to ensure resize independant blur.
  56285. */
  56286. mainTextureFixedSize?: number;
  56287. /**
  56288. * How big is the kernel of the blur texture.
  56289. */
  56290. blurKernelSize: number;
  56291. /**
  56292. * The camera attached to the layer.
  56293. */
  56294. camera: Nullable<Camera>;
  56295. /**
  56296. * Enable MSAA by chosing the number of samples.
  56297. */
  56298. mainTextureSamples?: number;
  56299. /**
  56300. * The rendering group to draw the layer in.
  56301. */
  56302. renderingGroupId: number;
  56303. }
  56304. /**
  56305. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56306. *
  56307. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56308. *
  56309. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56310. */
  56311. export class GlowLayer extends EffectLayer {
  56312. /**
  56313. * Effect Name of the layer.
  56314. */
  56315. static readonly EffectName: string;
  56316. /**
  56317. * The default blur kernel size used for the glow.
  56318. */
  56319. static DefaultBlurKernelSize: number;
  56320. /**
  56321. * The default texture size ratio used for the glow.
  56322. */
  56323. static DefaultTextureRatio: number;
  56324. /**
  56325. * Sets the kernel size of the blur.
  56326. */
  56327. set blurKernelSize(value: number);
  56328. /**
  56329. * Gets the kernel size of the blur.
  56330. */
  56331. get blurKernelSize(): number;
  56332. /**
  56333. * Sets the glow intensity.
  56334. */
  56335. set intensity(value: number);
  56336. /**
  56337. * Gets the glow intensity.
  56338. */
  56339. get intensity(): number;
  56340. private _options;
  56341. private _intensity;
  56342. private _horizontalBlurPostprocess1;
  56343. private _verticalBlurPostprocess1;
  56344. private _horizontalBlurPostprocess2;
  56345. private _verticalBlurPostprocess2;
  56346. private _blurTexture1;
  56347. private _blurTexture2;
  56348. private _postProcesses1;
  56349. private _postProcesses2;
  56350. private _includedOnlyMeshes;
  56351. private _excludedMeshes;
  56352. private _meshesUsingTheirOwnMaterials;
  56353. /**
  56354. * Callback used to let the user override the color selection on a per mesh basis
  56355. */
  56356. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56357. /**
  56358. * Callback used to let the user override the texture selection on a per mesh basis
  56359. */
  56360. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56361. /**
  56362. * Instantiates a new glow Layer and references it to the scene.
  56363. * @param name The name of the layer
  56364. * @param scene The scene to use the layer in
  56365. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56366. */
  56367. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56368. /**
  56369. * Get the effect name of the layer.
  56370. * @return The effect name
  56371. */
  56372. getEffectName(): string;
  56373. /**
  56374. * Create the merge effect. This is the shader use to blit the information back
  56375. * to the main canvas at the end of the scene rendering.
  56376. */
  56377. protected _createMergeEffect(): Effect;
  56378. /**
  56379. * Creates the render target textures and post processes used in the glow layer.
  56380. */
  56381. protected _createTextureAndPostProcesses(): void;
  56382. /**
  56383. * Checks for the readiness of the element composing the layer.
  56384. * @param subMesh the mesh to check for
  56385. * @param useInstances specify wether or not to use instances to render the mesh
  56386. * @param emissiveTexture the associated emissive texture used to generate the glow
  56387. * @return true if ready otherwise, false
  56388. */
  56389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56390. /**
  56391. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56392. */
  56393. needStencil(): boolean;
  56394. /**
  56395. * Returns true if the mesh can be rendered, otherwise false.
  56396. * @param mesh The mesh to render
  56397. * @param material The material used on the mesh
  56398. * @returns true if it can be rendered otherwise false
  56399. */
  56400. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56401. /**
  56402. * Implementation specific of rendering the generating effect on the main canvas.
  56403. * @param effect The effect used to render through
  56404. */
  56405. protected _internalRender(effect: Effect): void;
  56406. /**
  56407. * Sets the required values for both the emissive texture and and the main color.
  56408. */
  56409. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56410. /**
  56411. * Returns true if the mesh should render, otherwise false.
  56412. * @param mesh The mesh to render
  56413. * @returns true if it should render otherwise false
  56414. */
  56415. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56416. /**
  56417. * Adds specific effects defines.
  56418. * @param defines The defines to add specifics to.
  56419. */
  56420. protected _addCustomEffectDefines(defines: string[]): void;
  56421. /**
  56422. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56423. * @param mesh The mesh to exclude from the glow layer
  56424. */
  56425. addExcludedMesh(mesh: Mesh): void;
  56426. /**
  56427. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56428. * @param mesh The mesh to remove
  56429. */
  56430. removeExcludedMesh(mesh: Mesh): void;
  56431. /**
  56432. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56433. * @param mesh The mesh to include in the glow layer
  56434. */
  56435. addIncludedOnlyMesh(mesh: Mesh): void;
  56436. /**
  56437. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56438. * @param mesh The mesh to remove
  56439. */
  56440. removeIncludedOnlyMesh(mesh: Mesh): void;
  56441. /**
  56442. * Determine if a given mesh will be used in the glow layer
  56443. * @param mesh The mesh to test
  56444. * @returns true if the mesh will be highlighted by the current glow layer
  56445. */
  56446. hasMesh(mesh: AbstractMesh): boolean;
  56447. /**
  56448. * Defines whether the current material of the mesh should be use to render the effect.
  56449. * @param mesh defines the current mesh to render
  56450. */
  56451. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56452. /**
  56453. * Add a mesh to be rendered through its own material and not with emissive only.
  56454. * @param mesh The mesh for which we need to use its material
  56455. */
  56456. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56457. /**
  56458. * Remove a mesh from being rendered through its own material and not with emissive only.
  56459. * @param mesh The mesh for which we need to not use its material
  56460. */
  56461. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56462. /**
  56463. * Free any resources and references associated to a mesh.
  56464. * Internal use
  56465. * @param mesh The mesh to free.
  56466. * @hidden
  56467. */
  56468. _disposeMesh(mesh: Mesh): void;
  56469. /**
  56470. * Gets the class name of the effect layer
  56471. * @returns the string with the class name of the effect layer
  56472. */
  56473. getClassName(): string;
  56474. /**
  56475. * Serializes this glow layer
  56476. * @returns a serialized glow layer object
  56477. */
  56478. serialize(): any;
  56479. /**
  56480. * Creates a Glow Layer from parsed glow layer data
  56481. * @param parsedGlowLayer defines glow layer data
  56482. * @param scene defines the current scene
  56483. * @param rootUrl defines the root URL containing the glow layer information
  56484. * @returns a parsed Glow Layer
  56485. */
  56486. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56487. }
  56488. }
  56489. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56490. /** @hidden */
  56491. export var glowBlurPostProcessPixelShader: {
  56492. name: string;
  56493. shader: string;
  56494. };
  56495. }
  56496. declare module "babylonjs/Layers/highlightLayer" {
  56497. import { Observable } from "babylonjs/Misc/observable";
  56498. import { Nullable } from "babylonjs/types";
  56499. import { Camera } from "babylonjs/Cameras/camera";
  56500. import { Scene } from "babylonjs/scene";
  56501. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56503. import { Mesh } from "babylonjs/Meshes/mesh";
  56504. import { Effect } from "babylonjs/Materials/effect";
  56505. import { Material } from "babylonjs/Materials/material";
  56506. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56507. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56508. import "babylonjs/Shaders/glowMapMerge.fragment";
  56509. import "babylonjs/Shaders/glowMapMerge.vertex";
  56510. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56511. module "babylonjs/abstractScene" {
  56512. interface AbstractScene {
  56513. /**
  56514. * Return a the first highlight layer of the scene with a given name.
  56515. * @param name The name of the highlight layer to look for.
  56516. * @return The highlight layer if found otherwise null.
  56517. */
  56518. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56519. }
  56520. }
  56521. /**
  56522. * Highlight layer options. This helps customizing the behaviour
  56523. * of the highlight layer.
  56524. */
  56525. export interface IHighlightLayerOptions {
  56526. /**
  56527. * Multiplication factor apply to the canvas size to compute the render target size
  56528. * used to generated the glowing objects (the smaller the faster).
  56529. */
  56530. mainTextureRatio: number;
  56531. /**
  56532. * Enforces a fixed size texture to ensure resize independant blur.
  56533. */
  56534. mainTextureFixedSize?: number;
  56535. /**
  56536. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56537. * of the picture to blur (the smaller the faster).
  56538. */
  56539. blurTextureSizeRatio: number;
  56540. /**
  56541. * How big in texel of the blur texture is the vertical blur.
  56542. */
  56543. blurVerticalSize: number;
  56544. /**
  56545. * How big in texel of the blur texture is the horizontal blur.
  56546. */
  56547. blurHorizontalSize: number;
  56548. /**
  56549. * Alpha blending mode used to apply the blur. Default is combine.
  56550. */
  56551. alphaBlendingMode: number;
  56552. /**
  56553. * The camera attached to the layer.
  56554. */
  56555. camera: Nullable<Camera>;
  56556. /**
  56557. * Should we display highlight as a solid stroke?
  56558. */
  56559. isStroke?: boolean;
  56560. /**
  56561. * The rendering group to draw the layer in.
  56562. */
  56563. renderingGroupId: number;
  56564. }
  56565. /**
  56566. * The highlight layer Helps adding a glow effect around a mesh.
  56567. *
  56568. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56569. * glowy meshes to your scene.
  56570. *
  56571. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56572. */
  56573. export class HighlightLayer extends EffectLayer {
  56574. name: string;
  56575. /**
  56576. * Effect Name of the highlight layer.
  56577. */
  56578. static readonly EffectName: string;
  56579. /**
  56580. * The neutral color used during the preparation of the glow effect.
  56581. * This is black by default as the blend operation is a blend operation.
  56582. */
  56583. static NeutralColor: Color4;
  56584. /**
  56585. * Stencil value used for glowing meshes.
  56586. */
  56587. static GlowingMeshStencilReference: number;
  56588. /**
  56589. * Stencil value used for the other meshes in the scene.
  56590. */
  56591. static NormalMeshStencilReference: number;
  56592. /**
  56593. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56594. */
  56595. innerGlow: boolean;
  56596. /**
  56597. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56598. */
  56599. outerGlow: boolean;
  56600. /**
  56601. * Specifies the horizontal size of the blur.
  56602. */
  56603. set blurHorizontalSize(value: number);
  56604. /**
  56605. * Specifies the vertical size of the blur.
  56606. */
  56607. set blurVerticalSize(value: number);
  56608. /**
  56609. * Gets the horizontal size of the blur.
  56610. */
  56611. get blurHorizontalSize(): number;
  56612. /**
  56613. * Gets the vertical size of the blur.
  56614. */
  56615. get blurVerticalSize(): number;
  56616. /**
  56617. * An event triggered when the highlight layer is being blurred.
  56618. */
  56619. onBeforeBlurObservable: Observable<HighlightLayer>;
  56620. /**
  56621. * An event triggered when the highlight layer has been blurred.
  56622. */
  56623. onAfterBlurObservable: Observable<HighlightLayer>;
  56624. private _instanceGlowingMeshStencilReference;
  56625. private _options;
  56626. private _downSamplePostprocess;
  56627. private _horizontalBlurPostprocess;
  56628. private _verticalBlurPostprocess;
  56629. private _blurTexture;
  56630. private _meshes;
  56631. private _excludedMeshes;
  56632. /**
  56633. * Instantiates a new highlight Layer and references it to the scene..
  56634. * @param name The name of the layer
  56635. * @param scene The scene to use the layer in
  56636. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56637. */
  56638. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56639. /**
  56640. * Get the effect name of the layer.
  56641. * @return The effect name
  56642. */
  56643. getEffectName(): string;
  56644. /**
  56645. * Create the merge effect. This is the shader use to blit the information back
  56646. * to the main canvas at the end of the scene rendering.
  56647. */
  56648. protected _createMergeEffect(): Effect;
  56649. /**
  56650. * Creates the render target textures and post processes used in the highlight layer.
  56651. */
  56652. protected _createTextureAndPostProcesses(): void;
  56653. /**
  56654. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56655. */
  56656. needStencil(): boolean;
  56657. /**
  56658. * Checks for the readiness of the element composing the layer.
  56659. * @param subMesh the mesh to check for
  56660. * @param useInstances specify wether or not to use instances to render the mesh
  56661. * @param emissiveTexture the associated emissive texture used to generate the glow
  56662. * @return true if ready otherwise, false
  56663. */
  56664. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56665. /**
  56666. * Implementation specific of rendering the generating effect on the main canvas.
  56667. * @param effect The effect used to render through
  56668. */
  56669. protected _internalRender(effect: Effect): void;
  56670. /**
  56671. * Returns true if the layer contains information to display, otherwise false.
  56672. */
  56673. shouldRender(): boolean;
  56674. /**
  56675. * Returns true if the mesh should render, otherwise false.
  56676. * @param mesh The mesh to render
  56677. * @returns true if it should render otherwise false
  56678. */
  56679. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56680. /**
  56681. * Adds specific effects defines.
  56682. * @param defines The defines to add specifics to.
  56683. */
  56684. protected _addCustomEffectDefines(defines: string[]): void;
  56685. /**
  56686. * Sets the required values for both the emissive texture and and the main color.
  56687. */
  56688. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56689. /**
  56690. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56691. * @param mesh The mesh to exclude from the highlight layer
  56692. */
  56693. addExcludedMesh(mesh: Mesh): void;
  56694. /**
  56695. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56696. * @param mesh The mesh to highlight
  56697. */
  56698. removeExcludedMesh(mesh: Mesh): void;
  56699. /**
  56700. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56701. * @param mesh mesh to test
  56702. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56703. */
  56704. hasMesh(mesh: AbstractMesh): boolean;
  56705. /**
  56706. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56707. * @param mesh The mesh to highlight
  56708. * @param color The color of the highlight
  56709. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56710. */
  56711. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56712. /**
  56713. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56714. * @param mesh The mesh to highlight
  56715. */
  56716. removeMesh(mesh: Mesh): void;
  56717. /**
  56718. * Remove all the meshes currently referenced in the highlight layer
  56719. */
  56720. removeAllMeshes(): void;
  56721. /**
  56722. * Force the stencil to the normal expected value for none glowing parts
  56723. */
  56724. private _defaultStencilReference;
  56725. /**
  56726. * Free any resources and references associated to a mesh.
  56727. * Internal use
  56728. * @param mesh The mesh to free.
  56729. * @hidden
  56730. */
  56731. _disposeMesh(mesh: Mesh): void;
  56732. /**
  56733. * Dispose the highlight layer and free resources.
  56734. */
  56735. dispose(): void;
  56736. /**
  56737. * Gets the class name of the effect layer
  56738. * @returns the string with the class name of the effect layer
  56739. */
  56740. getClassName(): string;
  56741. /**
  56742. * Serializes this Highlight layer
  56743. * @returns a serialized Highlight layer object
  56744. */
  56745. serialize(): any;
  56746. /**
  56747. * Creates a Highlight layer from parsed Highlight layer data
  56748. * @param parsedHightlightLayer defines the Highlight layer data
  56749. * @param scene defines the current scene
  56750. * @param rootUrl defines the root URL containing the Highlight layer information
  56751. * @returns a parsed Highlight layer
  56752. */
  56753. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56754. }
  56755. }
  56756. declare module "babylonjs/Layers/layerSceneComponent" {
  56757. import { Scene } from "babylonjs/scene";
  56758. import { ISceneComponent } from "babylonjs/sceneComponent";
  56759. import { Layer } from "babylonjs/Layers/layer";
  56760. import { AbstractScene } from "babylonjs/abstractScene";
  56761. module "babylonjs/abstractScene" {
  56762. interface AbstractScene {
  56763. /**
  56764. * The list of layers (background and foreground) of the scene
  56765. */
  56766. layers: Array<Layer>;
  56767. }
  56768. }
  56769. /**
  56770. * Defines the layer scene component responsible to manage any layers
  56771. * in a given scene.
  56772. */
  56773. export class LayerSceneComponent implements ISceneComponent {
  56774. /**
  56775. * The component name helpfull to identify the component in the list of scene components.
  56776. */
  56777. readonly name: string;
  56778. /**
  56779. * The scene the component belongs to.
  56780. */
  56781. scene: Scene;
  56782. private _engine;
  56783. /**
  56784. * Creates a new instance of the component for the given scene
  56785. * @param scene Defines the scene to register the component in
  56786. */
  56787. constructor(scene: Scene);
  56788. /**
  56789. * Registers the component in a given scene
  56790. */
  56791. register(): void;
  56792. /**
  56793. * Rebuilds the elements related to this component in case of
  56794. * context lost for instance.
  56795. */
  56796. rebuild(): void;
  56797. /**
  56798. * Disposes the component and the associated ressources.
  56799. */
  56800. dispose(): void;
  56801. private _draw;
  56802. private _drawCameraPredicate;
  56803. private _drawCameraBackground;
  56804. private _drawCameraForeground;
  56805. private _drawRenderTargetPredicate;
  56806. private _drawRenderTargetBackground;
  56807. private _drawRenderTargetForeground;
  56808. /**
  56809. * Adds all the elements from the container to the scene
  56810. * @param container the container holding the elements
  56811. */
  56812. addFromContainer(container: AbstractScene): void;
  56813. /**
  56814. * Removes all the elements in the container from the scene
  56815. * @param container contains the elements to remove
  56816. * @param dispose if the removed element should be disposed (default: false)
  56817. */
  56818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56819. }
  56820. }
  56821. declare module "babylonjs/Shaders/layer.fragment" {
  56822. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56823. /** @hidden */
  56824. export var layerPixelShader: {
  56825. name: string;
  56826. shader: string;
  56827. };
  56828. }
  56829. declare module "babylonjs/Shaders/layer.vertex" {
  56830. /** @hidden */
  56831. export var layerVertexShader: {
  56832. name: string;
  56833. shader: string;
  56834. };
  56835. }
  56836. declare module "babylonjs/Layers/layer" {
  56837. import { Observable } from "babylonjs/Misc/observable";
  56838. import { Nullable } from "babylonjs/types";
  56839. import { Scene } from "babylonjs/scene";
  56840. import { Vector2 } from "babylonjs/Maths/math.vector";
  56841. import { Color4 } from "babylonjs/Maths/math.color";
  56842. import { Texture } from "babylonjs/Materials/Textures/texture";
  56843. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56844. import "babylonjs/Shaders/layer.fragment";
  56845. import "babylonjs/Shaders/layer.vertex";
  56846. /**
  56847. * This represents a full screen 2d layer.
  56848. * This can be useful to display a picture in the background of your scene for instance.
  56849. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56850. */
  56851. export class Layer {
  56852. /**
  56853. * Define the name of the layer.
  56854. */
  56855. name: string;
  56856. /**
  56857. * Define the texture the layer should display.
  56858. */
  56859. texture: Nullable<Texture>;
  56860. /**
  56861. * Is the layer in background or foreground.
  56862. */
  56863. isBackground: boolean;
  56864. /**
  56865. * Define the color of the layer (instead of texture).
  56866. */
  56867. color: Color4;
  56868. /**
  56869. * Define the scale of the layer in order to zoom in out of the texture.
  56870. */
  56871. scale: Vector2;
  56872. /**
  56873. * Define an offset for the layer in order to shift the texture.
  56874. */
  56875. offset: Vector2;
  56876. /**
  56877. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56878. */
  56879. alphaBlendingMode: number;
  56880. /**
  56881. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56882. * Alpha test will not mix with the background color in case of transparency.
  56883. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56884. */
  56885. alphaTest: boolean;
  56886. /**
  56887. * Define a mask to restrict the layer to only some of the scene cameras.
  56888. */
  56889. layerMask: number;
  56890. /**
  56891. * Define the list of render target the layer is visible into.
  56892. */
  56893. renderTargetTextures: RenderTargetTexture[];
  56894. /**
  56895. * Define if the layer is only used in renderTarget or if it also
  56896. * renders in the main frame buffer of the canvas.
  56897. */
  56898. renderOnlyInRenderTargetTextures: boolean;
  56899. private _scene;
  56900. private _vertexBuffers;
  56901. private _indexBuffer;
  56902. private _effect;
  56903. private _previousDefines;
  56904. /**
  56905. * An event triggered when the layer is disposed.
  56906. */
  56907. onDisposeObservable: Observable<Layer>;
  56908. private _onDisposeObserver;
  56909. /**
  56910. * Back compatibility with callback before the onDisposeObservable existed.
  56911. * The set callback will be triggered when the layer has been disposed.
  56912. */
  56913. set onDispose(callback: () => void);
  56914. /**
  56915. * An event triggered before rendering the scene
  56916. */
  56917. onBeforeRenderObservable: Observable<Layer>;
  56918. private _onBeforeRenderObserver;
  56919. /**
  56920. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56921. * The set callback will be triggered just before rendering the layer.
  56922. */
  56923. set onBeforeRender(callback: () => void);
  56924. /**
  56925. * An event triggered after rendering the scene
  56926. */
  56927. onAfterRenderObservable: Observable<Layer>;
  56928. private _onAfterRenderObserver;
  56929. /**
  56930. * Back compatibility with callback before the onAfterRenderObservable existed.
  56931. * The set callback will be triggered just after rendering the layer.
  56932. */
  56933. set onAfterRender(callback: () => void);
  56934. /**
  56935. * Instantiates a new layer.
  56936. * This represents a full screen 2d layer.
  56937. * This can be useful to display a picture in the background of your scene for instance.
  56938. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56939. * @param name Define the name of the layer in the scene
  56940. * @param imgUrl Define the url of the texture to display in the layer
  56941. * @param scene Define the scene the layer belongs to
  56942. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56943. * @param color Defines a color for the layer
  56944. */
  56945. constructor(
  56946. /**
  56947. * Define the name of the layer.
  56948. */
  56949. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56950. private _createIndexBuffer;
  56951. /** @hidden */
  56952. _rebuild(): void;
  56953. /**
  56954. * Renders the layer in the scene.
  56955. */
  56956. render(): void;
  56957. /**
  56958. * Disposes and releases the associated ressources.
  56959. */
  56960. dispose(): void;
  56961. }
  56962. }
  56963. declare module "babylonjs/Layers/index" {
  56964. export * from "babylonjs/Layers/effectLayer";
  56965. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56966. export * from "babylonjs/Layers/glowLayer";
  56967. export * from "babylonjs/Layers/highlightLayer";
  56968. export * from "babylonjs/Layers/layer";
  56969. export * from "babylonjs/Layers/layerSceneComponent";
  56970. }
  56971. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56972. /** @hidden */
  56973. export var lensFlarePixelShader: {
  56974. name: string;
  56975. shader: string;
  56976. };
  56977. }
  56978. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56979. /** @hidden */
  56980. export var lensFlareVertexShader: {
  56981. name: string;
  56982. shader: string;
  56983. };
  56984. }
  56985. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56986. import { Scene } from "babylonjs/scene";
  56987. import { Vector3 } from "babylonjs/Maths/math.vector";
  56988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56989. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56990. import "babylonjs/Shaders/lensFlare.fragment";
  56991. import "babylonjs/Shaders/lensFlare.vertex";
  56992. import { Viewport } from "babylonjs/Maths/math.viewport";
  56993. /**
  56994. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56995. * It is usually composed of several `lensFlare`.
  56996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56997. */
  56998. export class LensFlareSystem {
  56999. /**
  57000. * Define the name of the lens flare system
  57001. */
  57002. name: string;
  57003. /**
  57004. * List of lens flares used in this system.
  57005. */
  57006. lensFlares: LensFlare[];
  57007. /**
  57008. * Define a limit from the border the lens flare can be visible.
  57009. */
  57010. borderLimit: number;
  57011. /**
  57012. * Define a viewport border we do not want to see the lens flare in.
  57013. */
  57014. viewportBorder: number;
  57015. /**
  57016. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57017. */
  57018. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57019. /**
  57020. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57021. */
  57022. layerMask: number;
  57023. /**
  57024. * Define the id of the lens flare system in the scene.
  57025. * (equal to name by default)
  57026. */
  57027. id: string;
  57028. private _scene;
  57029. private _emitter;
  57030. private _vertexBuffers;
  57031. private _indexBuffer;
  57032. private _effect;
  57033. private _positionX;
  57034. private _positionY;
  57035. private _isEnabled;
  57036. /** @hidden */
  57037. static _SceneComponentInitialization: (scene: Scene) => void;
  57038. /**
  57039. * Instantiates a lens flare system.
  57040. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57041. * It is usually composed of several `lensFlare`.
  57042. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57043. * @param name Define the name of the lens flare system in the scene
  57044. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57045. * @param scene Define the scene the lens flare system belongs to
  57046. */
  57047. constructor(
  57048. /**
  57049. * Define the name of the lens flare system
  57050. */
  57051. name: string, emitter: any, scene: Scene);
  57052. /**
  57053. * Define if the lens flare system is enabled.
  57054. */
  57055. get isEnabled(): boolean;
  57056. set isEnabled(value: boolean);
  57057. /**
  57058. * Get the scene the effects belongs to.
  57059. * @returns the scene holding the lens flare system
  57060. */
  57061. getScene(): Scene;
  57062. /**
  57063. * Get the emitter of the lens flare system.
  57064. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57065. * @returns the emitter of the lens flare system
  57066. */
  57067. getEmitter(): any;
  57068. /**
  57069. * Set the emitter of the lens flare system.
  57070. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57071. * @param newEmitter Define the new emitter of the system
  57072. */
  57073. setEmitter(newEmitter: any): void;
  57074. /**
  57075. * Get the lens flare system emitter position.
  57076. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57077. * @returns the position
  57078. */
  57079. getEmitterPosition(): Vector3;
  57080. /**
  57081. * @hidden
  57082. */
  57083. computeEffectivePosition(globalViewport: Viewport): boolean;
  57084. /** @hidden */
  57085. _isVisible(): boolean;
  57086. /**
  57087. * @hidden
  57088. */
  57089. render(): boolean;
  57090. /**
  57091. * Dispose and release the lens flare with its associated resources.
  57092. */
  57093. dispose(): void;
  57094. /**
  57095. * Parse a lens flare system from a JSON repressentation
  57096. * @param parsedLensFlareSystem Define the JSON to parse
  57097. * @param scene Define the scene the parsed system should be instantiated in
  57098. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57099. * @returns the parsed system
  57100. */
  57101. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57102. /**
  57103. * Serialize the current Lens Flare System into a JSON representation.
  57104. * @returns the serialized JSON
  57105. */
  57106. serialize(): any;
  57107. }
  57108. }
  57109. declare module "babylonjs/LensFlares/lensFlare" {
  57110. import { Nullable } from "babylonjs/types";
  57111. import { Color3 } from "babylonjs/Maths/math.color";
  57112. import { Texture } from "babylonjs/Materials/Textures/texture";
  57113. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57114. /**
  57115. * This represents one of the lens effect in a `lensFlareSystem`.
  57116. * It controls one of the indiviual texture used in the effect.
  57117. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57118. */
  57119. export class LensFlare {
  57120. /**
  57121. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57122. */
  57123. size: number;
  57124. /**
  57125. * 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.
  57126. */
  57127. position: number;
  57128. /**
  57129. * Define the lens color.
  57130. */
  57131. color: Color3;
  57132. /**
  57133. * Define the lens texture.
  57134. */
  57135. texture: Nullable<Texture>;
  57136. /**
  57137. * Define the alpha mode to render this particular lens.
  57138. */
  57139. alphaMode: number;
  57140. private _system;
  57141. /**
  57142. * Creates a new Lens Flare.
  57143. * This represents one of the lens effect in a `lensFlareSystem`.
  57144. * It controls one of the indiviual texture used in the effect.
  57145. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57146. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57147. * @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.
  57148. * @param color Define the lens color
  57149. * @param imgUrl Define the lens texture url
  57150. * @param system Define the `lensFlareSystem` this flare is part of
  57151. * @returns The newly created Lens Flare
  57152. */
  57153. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57154. /**
  57155. * Instantiates a new Lens Flare.
  57156. * This represents one of the lens effect in a `lensFlareSystem`.
  57157. * It controls one of the indiviual texture used in the effect.
  57158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57159. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57160. * @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.
  57161. * @param color Define the lens color
  57162. * @param imgUrl Define the lens texture url
  57163. * @param system Define the `lensFlareSystem` this flare is part of
  57164. */
  57165. constructor(
  57166. /**
  57167. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57168. */
  57169. size: number,
  57170. /**
  57171. * 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.
  57172. */
  57173. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57174. /**
  57175. * Dispose and release the lens flare with its associated resources.
  57176. */
  57177. dispose(): void;
  57178. }
  57179. }
  57180. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57181. import { Nullable } from "babylonjs/types";
  57182. import { Scene } from "babylonjs/scene";
  57183. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57184. import { AbstractScene } from "babylonjs/abstractScene";
  57185. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57186. module "babylonjs/abstractScene" {
  57187. interface AbstractScene {
  57188. /**
  57189. * The list of lens flare system added to the scene
  57190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57191. */
  57192. lensFlareSystems: Array<LensFlareSystem>;
  57193. /**
  57194. * Removes the given lens flare system from this scene.
  57195. * @param toRemove The lens flare system to remove
  57196. * @returns The index of the removed lens flare system
  57197. */
  57198. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57199. /**
  57200. * Adds the given lens flare system to this scene
  57201. * @param newLensFlareSystem The lens flare system to add
  57202. */
  57203. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57204. /**
  57205. * Gets a lens flare system using its name
  57206. * @param name defines the name to look for
  57207. * @returns the lens flare system or null if not found
  57208. */
  57209. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57210. /**
  57211. * Gets a lens flare system using its id
  57212. * @param id defines the id to look for
  57213. * @returns the lens flare system or null if not found
  57214. */
  57215. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57216. }
  57217. }
  57218. /**
  57219. * Defines the lens flare scene component responsible to manage any lens flares
  57220. * in a given scene.
  57221. */
  57222. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57223. /**
  57224. * The component name helpfull to identify the component in the list of scene components.
  57225. */
  57226. readonly name: string;
  57227. /**
  57228. * The scene the component belongs to.
  57229. */
  57230. scene: Scene;
  57231. /**
  57232. * Creates a new instance of the component for the given scene
  57233. * @param scene Defines the scene to register the component in
  57234. */
  57235. constructor(scene: Scene);
  57236. /**
  57237. * Registers the component in a given scene
  57238. */
  57239. register(): void;
  57240. /**
  57241. * Rebuilds the elements related to this component in case of
  57242. * context lost for instance.
  57243. */
  57244. rebuild(): void;
  57245. /**
  57246. * Adds all the elements from the container to the scene
  57247. * @param container the container holding the elements
  57248. */
  57249. addFromContainer(container: AbstractScene): void;
  57250. /**
  57251. * Removes all the elements in the container from the scene
  57252. * @param container contains the elements to remove
  57253. * @param dispose if the removed element should be disposed (default: false)
  57254. */
  57255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57256. /**
  57257. * Serializes the component data to the specified json object
  57258. * @param serializationObject The object to serialize to
  57259. */
  57260. serialize(serializationObject: any): void;
  57261. /**
  57262. * Disposes the component and the associated ressources.
  57263. */
  57264. dispose(): void;
  57265. private _draw;
  57266. }
  57267. }
  57268. declare module "babylonjs/LensFlares/index" {
  57269. export * from "babylonjs/LensFlares/lensFlare";
  57270. export * from "babylonjs/LensFlares/lensFlareSystem";
  57271. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57272. }
  57273. declare module "babylonjs/Shaders/depth.fragment" {
  57274. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57275. /** @hidden */
  57276. export var depthPixelShader: {
  57277. name: string;
  57278. shader: string;
  57279. };
  57280. }
  57281. declare module "babylonjs/Shaders/depth.vertex" {
  57282. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57283. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57284. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57285. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57287. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57288. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57289. /** @hidden */
  57290. export var depthVertexShader: {
  57291. name: string;
  57292. shader: string;
  57293. };
  57294. }
  57295. declare module "babylonjs/Rendering/depthRenderer" {
  57296. import { Nullable } from "babylonjs/types";
  57297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57298. import { Scene } from "babylonjs/scene";
  57299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57300. import { Camera } from "babylonjs/Cameras/camera";
  57301. import "babylonjs/Shaders/depth.fragment";
  57302. import "babylonjs/Shaders/depth.vertex";
  57303. /**
  57304. * This represents a depth renderer in Babylon.
  57305. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57306. */
  57307. export class DepthRenderer {
  57308. private _scene;
  57309. private _depthMap;
  57310. private _effect;
  57311. private readonly _storeNonLinearDepth;
  57312. private readonly _clearColor;
  57313. /** Get if the depth renderer is using packed depth or not */
  57314. readonly isPacked: boolean;
  57315. private _cachedDefines;
  57316. private _camera;
  57317. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57318. enabled: boolean;
  57319. /**
  57320. * Specifiess that the depth renderer will only be used within
  57321. * the camera it is created for.
  57322. * This can help forcing its rendering during the camera processing.
  57323. */
  57324. useOnlyInActiveCamera: boolean;
  57325. /** @hidden */
  57326. static _SceneComponentInitialization: (scene: Scene) => void;
  57327. /**
  57328. * Instantiates a depth renderer
  57329. * @param scene The scene the renderer belongs to
  57330. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57331. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57332. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57333. */
  57334. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57335. /**
  57336. * Creates the depth rendering effect and checks if the effect is ready.
  57337. * @param subMesh The submesh to be used to render the depth map of
  57338. * @param useInstances If multiple world instances should be used
  57339. * @returns if the depth renderer is ready to render the depth map
  57340. */
  57341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57342. /**
  57343. * Gets the texture which the depth map will be written to.
  57344. * @returns The depth map texture
  57345. */
  57346. getDepthMap(): RenderTargetTexture;
  57347. /**
  57348. * Disposes of the depth renderer.
  57349. */
  57350. dispose(): void;
  57351. }
  57352. }
  57353. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57354. /** @hidden */
  57355. export var minmaxReduxPixelShader: {
  57356. name: string;
  57357. shader: string;
  57358. };
  57359. }
  57360. declare module "babylonjs/Misc/minMaxReducer" {
  57361. import { Nullable } from "babylonjs/types";
  57362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57363. import { Camera } from "babylonjs/Cameras/camera";
  57364. import { Observer } from "babylonjs/Misc/observable";
  57365. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57366. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57367. import { Observable } from "babylonjs/Misc/observable";
  57368. import "babylonjs/Shaders/minmaxRedux.fragment";
  57369. /**
  57370. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57371. * and maximum values from all values of the texture.
  57372. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57373. * The source values are read from the red channel of the texture.
  57374. */
  57375. export class MinMaxReducer {
  57376. /**
  57377. * Observable triggered when the computation has been performed
  57378. */
  57379. onAfterReductionPerformed: Observable<{
  57380. min: number;
  57381. max: number;
  57382. }>;
  57383. protected _camera: Camera;
  57384. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57385. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57386. protected _postProcessManager: PostProcessManager;
  57387. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57388. protected _forceFullscreenViewport: boolean;
  57389. /**
  57390. * Creates a min/max reducer
  57391. * @param camera The camera to use for the post processes
  57392. */
  57393. constructor(camera: Camera);
  57394. /**
  57395. * Gets the texture used to read the values from.
  57396. */
  57397. get sourceTexture(): Nullable<RenderTargetTexture>;
  57398. /**
  57399. * Sets the source texture to read the values from.
  57400. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57401. * because in such textures '1' value must not be taken into account to compute the maximum
  57402. * as this value is used to clear the texture.
  57403. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57404. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57405. * @param depthRedux Indicates if the texture is a depth texture or not
  57406. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57407. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57408. */
  57409. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57410. /**
  57411. * Defines the refresh rate of the computation.
  57412. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57413. */
  57414. get refreshRate(): number;
  57415. set refreshRate(value: number);
  57416. protected _activated: boolean;
  57417. /**
  57418. * Gets the activation status of the reducer
  57419. */
  57420. get activated(): boolean;
  57421. /**
  57422. * Activates the reduction computation.
  57423. * When activated, the observers registered in onAfterReductionPerformed are
  57424. * called after the compuation is performed
  57425. */
  57426. activate(): void;
  57427. /**
  57428. * Deactivates the reduction computation.
  57429. */
  57430. deactivate(): void;
  57431. /**
  57432. * Disposes the min/max reducer
  57433. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57434. */
  57435. dispose(disposeAll?: boolean): void;
  57436. }
  57437. }
  57438. declare module "babylonjs/Misc/depthReducer" {
  57439. import { Nullable } from "babylonjs/types";
  57440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57441. import { Camera } from "babylonjs/Cameras/camera";
  57442. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57443. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57444. /**
  57445. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57446. */
  57447. export class DepthReducer extends MinMaxReducer {
  57448. private _depthRenderer;
  57449. private _depthRendererId;
  57450. /**
  57451. * Gets the depth renderer used for the computation.
  57452. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57453. */
  57454. get depthRenderer(): Nullable<DepthRenderer>;
  57455. /**
  57456. * Creates a depth reducer
  57457. * @param camera The camera used to render the depth texture
  57458. */
  57459. constructor(camera: Camera);
  57460. /**
  57461. * Sets the depth renderer to use to generate the depth map
  57462. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57463. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57464. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57465. */
  57466. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57467. /** @hidden */
  57468. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57469. /**
  57470. * Activates the reduction computation.
  57471. * When activated, the observers registered in onAfterReductionPerformed are
  57472. * called after the compuation is performed
  57473. */
  57474. activate(): void;
  57475. /**
  57476. * Deactivates the reduction computation.
  57477. */
  57478. deactivate(): void;
  57479. /**
  57480. * Disposes the depth reducer
  57481. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57482. */
  57483. dispose(disposeAll?: boolean): void;
  57484. }
  57485. }
  57486. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57487. import { Nullable } from "babylonjs/types";
  57488. import { Scene } from "babylonjs/scene";
  57489. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57492. import { Effect } from "babylonjs/Materials/effect";
  57493. import "babylonjs/Shaders/shadowMap.fragment";
  57494. import "babylonjs/Shaders/shadowMap.vertex";
  57495. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57496. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57497. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57498. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57499. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57500. /**
  57501. * A CSM implementation allowing casting shadows on large scenes.
  57502. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57503. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57504. */
  57505. export class CascadedShadowGenerator extends ShadowGenerator {
  57506. private static readonly frustumCornersNDCSpace;
  57507. /**
  57508. * Name of the CSM class
  57509. */
  57510. static CLASSNAME: string;
  57511. /**
  57512. * Defines the default number of cascades used by the CSM.
  57513. */
  57514. static readonly DEFAULT_CASCADES_COUNT: number;
  57515. /**
  57516. * Defines the minimum number of cascades used by the CSM.
  57517. */
  57518. static readonly MIN_CASCADES_COUNT: number;
  57519. /**
  57520. * Defines the maximum number of cascades used by the CSM.
  57521. */
  57522. static readonly MAX_CASCADES_COUNT: number;
  57523. protected _validateFilter(filter: number): number;
  57524. /**
  57525. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57526. */
  57527. penumbraDarkness: number;
  57528. private _numCascades;
  57529. /**
  57530. * Gets or set the number of cascades used by the CSM.
  57531. */
  57532. get numCascades(): number;
  57533. set numCascades(value: number);
  57534. /**
  57535. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57536. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57537. */
  57538. stabilizeCascades: boolean;
  57539. private _freezeShadowCastersBoundingInfo;
  57540. private _freezeShadowCastersBoundingInfoObservable;
  57541. /**
  57542. * Enables or disables the shadow casters bounding info computation.
  57543. * If your shadow casters don't move, you can disable this feature.
  57544. * If it is enabled, the bounding box computation is done every frame.
  57545. */
  57546. get freezeShadowCastersBoundingInfo(): boolean;
  57547. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57548. private _scbiMin;
  57549. private _scbiMax;
  57550. protected _computeShadowCastersBoundingInfo(): void;
  57551. protected _shadowCastersBoundingInfo: BoundingInfo;
  57552. /**
  57553. * Gets or sets the shadow casters bounding info.
  57554. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57555. * so that the system won't overwrite the bounds you provide
  57556. */
  57557. get shadowCastersBoundingInfo(): BoundingInfo;
  57558. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57559. protected _breaksAreDirty: boolean;
  57560. protected _minDistance: number;
  57561. protected _maxDistance: number;
  57562. /**
  57563. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57564. *
  57565. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57566. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57567. * @param min minimal distance for the breaks (default to 0.)
  57568. * @param max maximal distance for the breaks (default to 1.)
  57569. */
  57570. setMinMaxDistance(min: number, max: number): void;
  57571. /** Gets the minimal distance used in the cascade break computation */
  57572. get minDistance(): number;
  57573. /** Gets the maximal distance used in the cascade break computation */
  57574. get maxDistance(): number;
  57575. /**
  57576. * Gets the class name of that object
  57577. * @returns "CascadedShadowGenerator"
  57578. */
  57579. getClassName(): string;
  57580. private _cascadeMinExtents;
  57581. private _cascadeMaxExtents;
  57582. /**
  57583. * Gets a cascade minimum extents
  57584. * @param cascadeIndex index of the cascade
  57585. * @returns the minimum cascade extents
  57586. */
  57587. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57588. /**
  57589. * Gets a cascade maximum extents
  57590. * @param cascadeIndex index of the cascade
  57591. * @returns the maximum cascade extents
  57592. */
  57593. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57594. private _cascades;
  57595. private _currentLayer;
  57596. private _viewSpaceFrustumsZ;
  57597. private _viewMatrices;
  57598. private _projectionMatrices;
  57599. private _transformMatrices;
  57600. private _transformMatricesAsArray;
  57601. private _frustumLengths;
  57602. private _lightSizeUVCorrection;
  57603. private _depthCorrection;
  57604. private _frustumCornersWorldSpace;
  57605. private _frustumCenter;
  57606. private _shadowCameraPos;
  57607. private _shadowMaxZ;
  57608. /**
  57609. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57610. * It defaults to camera.maxZ
  57611. */
  57612. get shadowMaxZ(): number;
  57613. /**
  57614. * Sets the shadow max z distance.
  57615. */
  57616. set shadowMaxZ(value: number);
  57617. protected _debug: boolean;
  57618. /**
  57619. * Gets or sets the debug flag.
  57620. * When enabled, the cascades are materialized by different colors on the screen.
  57621. */
  57622. get debug(): boolean;
  57623. set debug(dbg: boolean);
  57624. private _depthClamp;
  57625. /**
  57626. * Gets or sets the depth clamping value.
  57627. *
  57628. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57629. * to account for the shadow casters far away.
  57630. *
  57631. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57632. */
  57633. get depthClamp(): boolean;
  57634. set depthClamp(value: boolean);
  57635. private _cascadeBlendPercentage;
  57636. /**
  57637. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57638. * It defaults to 0.1 (10% blending).
  57639. */
  57640. get cascadeBlendPercentage(): number;
  57641. set cascadeBlendPercentage(value: number);
  57642. private _lambda;
  57643. /**
  57644. * Gets or set the lambda parameter.
  57645. * This parameter is used to split the camera frustum and create the cascades.
  57646. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  57647. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57648. */
  57649. get lambda(): number;
  57650. set lambda(value: number);
  57651. /**
  57652. * Gets the view matrix corresponding to a given cascade
  57653. * @param cascadeNum cascade to retrieve the view matrix from
  57654. * @returns the cascade view matrix
  57655. */
  57656. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57657. /**
  57658. * Gets the projection matrix corresponding to a given cascade
  57659. * @param cascadeNum cascade to retrieve the projection matrix from
  57660. * @returns the cascade projection matrix
  57661. */
  57662. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57663. /**
  57664. * Gets the transformation matrix corresponding to a given cascade
  57665. * @param cascadeNum cascade to retrieve the transformation matrix from
  57666. * @returns the cascade transformation matrix
  57667. */
  57668. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57669. private _depthRenderer;
  57670. /**
  57671. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57672. *
  57673. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57674. *
  57675. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57676. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57677. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  57678. */
  57679. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57680. private _depthReducer;
  57681. private _autoCalcDepthBounds;
  57682. /**
  57683. * Gets or sets the autoCalcDepthBounds property.
  57684. *
  57685. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57686. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57687. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57688. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57689. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57690. */
  57691. get autoCalcDepthBounds(): boolean;
  57692. set autoCalcDepthBounds(value: boolean);
  57693. /**
  57694. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57695. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57696. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57697. * for setting the refresh rate on the renderer yourself!
  57698. */
  57699. get autoCalcDepthBoundsRefreshRate(): number;
  57700. set autoCalcDepthBoundsRefreshRate(value: number);
  57701. /**
  57702. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57703. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57704. * you change the camera near/far planes!
  57705. */
  57706. splitFrustum(): void;
  57707. private _splitFrustum;
  57708. private _computeMatrices;
  57709. private _computeFrustumInWorldSpace;
  57710. private _computeCascadeFrustum;
  57711. /**
  57712. * Support test.
  57713. */
  57714. static get IsSupported(): boolean;
  57715. /** @hidden */
  57716. static _SceneComponentInitialization: (scene: Scene) => void;
  57717. /**
  57718. * Creates a Cascaded Shadow Generator object.
  57719. * A ShadowGenerator is the required tool to use the shadows.
  57720. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57721. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57722. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57723. * @param light The directional light object generating the shadows.
  57724. * @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.
  57725. */
  57726. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57727. protected _initializeGenerator(): void;
  57728. protected _createTargetRenderTexture(): void;
  57729. protected _initializeShadowMap(): void;
  57730. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57731. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57732. /**
  57733. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57734. * @param defines Defines of the material we want to update
  57735. * @param lightIndex Index of the light in the enabled light list of the material
  57736. */
  57737. prepareDefines(defines: any, lightIndex: number): void;
  57738. /**
  57739. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57740. * defined in the generator but impacting the effect).
  57741. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57742. * @param effect The effect we are binfing the information for
  57743. */
  57744. bindShadowLight(lightIndex: string, effect: Effect): void;
  57745. /**
  57746. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57747. * (eq to view projection * shadow projection matrices)
  57748. * @returns The transform matrix used to create the shadow map
  57749. */
  57750. getTransformMatrix(): Matrix;
  57751. /**
  57752. * Disposes the ShadowGenerator.
  57753. * Returns nothing.
  57754. */
  57755. dispose(): void;
  57756. /**
  57757. * Serializes the shadow generator setup to a json object.
  57758. * @returns The serialized JSON object
  57759. */
  57760. serialize(): any;
  57761. /**
  57762. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57763. * @param parsedShadowGenerator The JSON object to parse
  57764. * @param scene The scene to create the shadow map for
  57765. * @returns The parsed shadow generator
  57766. */
  57767. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57768. }
  57769. }
  57770. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57771. import { Scene } from "babylonjs/scene";
  57772. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57773. import { AbstractScene } from "babylonjs/abstractScene";
  57774. /**
  57775. * Defines the shadow generator component responsible to manage any shadow generators
  57776. * in a given scene.
  57777. */
  57778. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57779. /**
  57780. * The component name helpfull to identify the component in the list of scene components.
  57781. */
  57782. readonly name: string;
  57783. /**
  57784. * The scene the component belongs to.
  57785. */
  57786. scene: Scene;
  57787. /**
  57788. * Creates a new instance of the component for the given scene
  57789. * @param scene Defines the scene to register the component in
  57790. */
  57791. constructor(scene: Scene);
  57792. /**
  57793. * Registers the component in a given scene
  57794. */
  57795. register(): void;
  57796. /**
  57797. * Rebuilds the elements related to this component in case of
  57798. * context lost for instance.
  57799. */
  57800. rebuild(): void;
  57801. /**
  57802. * Serializes the component data to the specified json object
  57803. * @param serializationObject The object to serialize to
  57804. */
  57805. serialize(serializationObject: any): void;
  57806. /**
  57807. * Adds all the elements from the container to the scene
  57808. * @param container the container holding the elements
  57809. */
  57810. addFromContainer(container: AbstractScene): void;
  57811. /**
  57812. * Removes all the elements in the container from the scene
  57813. * @param container contains the elements to remove
  57814. * @param dispose if the removed element should be disposed (default: false)
  57815. */
  57816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57817. /**
  57818. * Rebuilds the elements related to this component in case of
  57819. * context lost for instance.
  57820. */
  57821. dispose(): void;
  57822. private _gatherRenderTargets;
  57823. }
  57824. }
  57825. declare module "babylonjs/Lights/Shadows/index" {
  57826. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57827. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57828. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57829. }
  57830. declare module "babylonjs/Lights/pointLight" {
  57831. import { Scene } from "babylonjs/scene";
  57832. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57834. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57835. import { Effect } from "babylonjs/Materials/effect";
  57836. /**
  57837. * A point light is a light defined by an unique point in world space.
  57838. * The light is emitted in every direction from this point.
  57839. * A good example of a point light is a standard light bulb.
  57840. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57841. */
  57842. export class PointLight extends ShadowLight {
  57843. private _shadowAngle;
  57844. /**
  57845. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57846. * This specifies what angle the shadow will use to be created.
  57847. *
  57848. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57849. */
  57850. get shadowAngle(): number;
  57851. /**
  57852. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57853. * This specifies what angle the shadow will use to be created.
  57854. *
  57855. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57856. */
  57857. set shadowAngle(value: number);
  57858. /**
  57859. * Gets the direction if it has been set.
  57860. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57861. */
  57862. get direction(): Vector3;
  57863. /**
  57864. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57865. */
  57866. set direction(value: Vector3);
  57867. /**
  57868. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57869. * A PointLight emits the light in every direction.
  57870. * It can cast shadows.
  57871. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57872. * ```javascript
  57873. * var pointLight = new PointLight("pl", camera.position, scene);
  57874. * ```
  57875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57876. * @param name The light friendly name
  57877. * @param position The position of the point light in the scene
  57878. * @param scene The scene the lights belongs to
  57879. */
  57880. constructor(name: string, position: Vector3, scene: Scene);
  57881. /**
  57882. * Returns the string "PointLight"
  57883. * @returns the class name
  57884. */
  57885. getClassName(): string;
  57886. /**
  57887. * Returns the integer 0.
  57888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57889. */
  57890. getTypeID(): number;
  57891. /**
  57892. * Specifies wether or not the shadowmap should be a cube texture.
  57893. * @returns true if the shadowmap needs to be a cube texture.
  57894. */
  57895. needCube(): boolean;
  57896. /**
  57897. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57900. */
  57901. getShadowDirection(faceIndex?: number): Vector3;
  57902. /**
  57903. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57904. * - fov = PI / 2
  57905. * - aspect ratio : 1.0
  57906. * - z-near and far equal to the active camera minZ and maxZ.
  57907. * Returns the PointLight.
  57908. */
  57909. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57910. protected _buildUniformLayout(): void;
  57911. /**
  57912. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57913. * @param effect The effect to update
  57914. * @param lightIndex The index of the light in the effect to update
  57915. * @returns The point light
  57916. */
  57917. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57918. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57919. /**
  57920. * Prepares the list of defines specific to the light type.
  57921. * @param defines the list of defines
  57922. * @param lightIndex defines the index of the light for the effect
  57923. */
  57924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57925. }
  57926. }
  57927. declare module "babylonjs/Lights/index" {
  57928. export * from "babylonjs/Lights/light";
  57929. export * from "babylonjs/Lights/shadowLight";
  57930. export * from "babylonjs/Lights/Shadows/index";
  57931. export * from "babylonjs/Lights/directionalLight";
  57932. export * from "babylonjs/Lights/hemisphericLight";
  57933. export * from "babylonjs/Lights/pointLight";
  57934. export * from "babylonjs/Lights/spotLight";
  57935. }
  57936. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57937. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57938. /**
  57939. * Header information of HDR texture files.
  57940. */
  57941. export interface HDRInfo {
  57942. /**
  57943. * The height of the texture in pixels.
  57944. */
  57945. height: number;
  57946. /**
  57947. * The width of the texture in pixels.
  57948. */
  57949. width: number;
  57950. /**
  57951. * The index of the beginning of the data in the binary file.
  57952. */
  57953. dataPosition: number;
  57954. }
  57955. /**
  57956. * This groups tools to convert HDR texture to native colors array.
  57957. */
  57958. export class HDRTools {
  57959. private static Ldexp;
  57960. private static Rgbe2float;
  57961. private static readStringLine;
  57962. /**
  57963. * Reads header information from an RGBE texture stored in a native array.
  57964. * More information on this format are available here:
  57965. * https://en.wikipedia.org/wiki/RGBE_image_format
  57966. *
  57967. * @param uint8array The binary file stored in native array.
  57968. * @return The header information.
  57969. */
  57970. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57971. /**
  57972. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57973. * This RGBE texture needs to store the information as a panorama.
  57974. *
  57975. * More information on this format are available here:
  57976. * https://en.wikipedia.org/wiki/RGBE_image_format
  57977. *
  57978. * @param buffer The binary file stored in an array buffer.
  57979. * @param size The expected size of the extracted cubemap.
  57980. * @return The Cube Map information.
  57981. */
  57982. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57983. /**
  57984. * Returns the pixels data extracted from an RGBE texture.
  57985. * This pixels will be stored left to right up to down in the R G B order in one array.
  57986. *
  57987. * More information on this format are available here:
  57988. * https://en.wikipedia.org/wiki/RGBE_image_format
  57989. *
  57990. * @param uint8array The binary file stored in an array buffer.
  57991. * @param hdrInfo The header information of the file.
  57992. * @return The pixels data in RGB right to left up to down order.
  57993. */
  57994. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57995. private static RGBE_ReadPixels_RLE;
  57996. }
  57997. }
  57998. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57999. import { Nullable } from "babylonjs/types";
  58000. import { Scene } from "babylonjs/scene";
  58001. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58004. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58005. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58006. /**
  58007. * This represents a texture coming from an HDR input.
  58008. *
  58009. * The only supported format is currently panorama picture stored in RGBE format.
  58010. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58011. */
  58012. export class HDRCubeTexture extends BaseTexture {
  58013. private static _facesMapping;
  58014. private _generateHarmonics;
  58015. private _noMipmap;
  58016. private _textureMatrix;
  58017. private _size;
  58018. private _onLoad;
  58019. private _onError;
  58020. /**
  58021. * The texture URL.
  58022. */
  58023. url: string;
  58024. /**
  58025. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58026. */
  58027. coordinatesMode: number;
  58028. protected _isBlocking: boolean;
  58029. /**
  58030. * Sets wether or not the texture is blocking during loading.
  58031. */
  58032. set isBlocking(value: boolean);
  58033. /**
  58034. * Gets wether or not the texture is blocking during loading.
  58035. */
  58036. get isBlocking(): boolean;
  58037. protected _rotationY: number;
  58038. /**
  58039. * Sets texture matrix rotation angle around Y axis in radians.
  58040. */
  58041. set rotationY(value: number);
  58042. /**
  58043. * Gets texture matrix rotation angle around Y axis radians.
  58044. */
  58045. get rotationY(): number;
  58046. /**
  58047. * Gets or sets the center of the bounding box associated with the cube texture
  58048. * It must define where the camera used to render the texture was set
  58049. */
  58050. boundingBoxPosition: Vector3;
  58051. private _boundingBoxSize;
  58052. /**
  58053. * Gets or sets the size of the bounding box associated with the cube texture
  58054. * When defined, the cubemap will switch to local mode
  58055. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58056. * @example https://www.babylonjs-playground.com/#RNASML
  58057. */
  58058. set boundingBoxSize(value: Vector3);
  58059. get boundingBoxSize(): Vector3;
  58060. /**
  58061. * Instantiates an HDRTexture from the following parameters.
  58062. *
  58063. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58064. * @param sceneOrEngine The scene or engine the texture will be used in
  58065. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58066. * @param noMipmap Forces to not generate the mipmap if true
  58067. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58068. * @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)
  58069. * @param reserved Reserved flag for internal use.
  58070. */
  58071. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58072. /**
  58073. * Get the current class name of the texture useful for serialization or dynamic coding.
  58074. * @returns "HDRCubeTexture"
  58075. */
  58076. getClassName(): string;
  58077. /**
  58078. * Occurs when the file is raw .hdr file.
  58079. */
  58080. private loadTexture;
  58081. clone(): HDRCubeTexture;
  58082. delayLoad(): void;
  58083. /**
  58084. * Get the texture reflection matrix used to rotate/transform the reflection.
  58085. * @returns the reflection matrix
  58086. */
  58087. getReflectionTextureMatrix(): Matrix;
  58088. /**
  58089. * Set the texture reflection matrix used to rotate/transform the reflection.
  58090. * @param value Define the reflection matrix to set
  58091. */
  58092. setReflectionTextureMatrix(value: Matrix): void;
  58093. /**
  58094. * Parses a JSON representation of an HDR Texture in order to create the texture
  58095. * @param parsedTexture Define the JSON representation
  58096. * @param scene Define the scene the texture should be created in
  58097. * @param rootUrl Define the root url in case we need to load relative dependencies
  58098. * @returns the newly created texture after parsing
  58099. */
  58100. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58101. serialize(): any;
  58102. }
  58103. }
  58104. declare module "babylonjs/Physics/physicsEngine" {
  58105. import { Nullable } from "babylonjs/types";
  58106. import { Vector3 } from "babylonjs/Maths/math.vector";
  58107. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58108. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58109. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58110. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58111. /**
  58112. * Class used to control physics engine
  58113. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58114. */
  58115. export class PhysicsEngine implements IPhysicsEngine {
  58116. private _physicsPlugin;
  58117. /**
  58118. * Global value used to control the smallest number supported by the simulation
  58119. */
  58120. static Epsilon: number;
  58121. private _impostors;
  58122. private _joints;
  58123. private _subTimeStep;
  58124. /**
  58125. * Gets the gravity vector used by the simulation
  58126. */
  58127. gravity: Vector3;
  58128. /**
  58129. * Factory used to create the default physics plugin.
  58130. * @returns The default physics plugin
  58131. */
  58132. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58133. /**
  58134. * Creates a new Physics Engine
  58135. * @param gravity defines the gravity vector used by the simulation
  58136. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58137. */
  58138. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58139. /**
  58140. * Sets the gravity vector used by the simulation
  58141. * @param gravity defines the gravity vector to use
  58142. */
  58143. setGravity(gravity: Vector3): void;
  58144. /**
  58145. * Set the time step of the physics engine.
  58146. * Default is 1/60.
  58147. * To slow it down, enter 1/600 for example.
  58148. * To speed it up, 1/30
  58149. * @param newTimeStep defines the new timestep to apply to this world.
  58150. */
  58151. setTimeStep(newTimeStep?: number): void;
  58152. /**
  58153. * Get the time step of the physics engine.
  58154. * @returns the current time step
  58155. */
  58156. getTimeStep(): number;
  58157. /**
  58158. * Set the sub time step of the physics engine.
  58159. * Default is 0 meaning there is no sub steps
  58160. * To increase physics resolution precision, set a small value (like 1 ms)
  58161. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58162. */
  58163. setSubTimeStep(subTimeStep?: number): void;
  58164. /**
  58165. * Get the sub time step of the physics engine.
  58166. * @returns the current sub time step
  58167. */
  58168. getSubTimeStep(): number;
  58169. /**
  58170. * Release all resources
  58171. */
  58172. dispose(): void;
  58173. /**
  58174. * Gets the name of the current physics plugin
  58175. * @returns the name of the plugin
  58176. */
  58177. getPhysicsPluginName(): string;
  58178. /**
  58179. * Adding a new impostor for the impostor tracking.
  58180. * This will be done by the impostor itself.
  58181. * @param impostor the impostor to add
  58182. */
  58183. addImpostor(impostor: PhysicsImpostor): void;
  58184. /**
  58185. * Remove an impostor from the engine.
  58186. * This impostor and its mesh will not longer be updated by the physics engine.
  58187. * @param impostor the impostor to remove
  58188. */
  58189. removeImpostor(impostor: PhysicsImpostor): void;
  58190. /**
  58191. * Add a joint to the physics engine
  58192. * @param mainImpostor defines the main impostor to which the joint is added.
  58193. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58194. * @param joint defines the joint that will connect both impostors.
  58195. */
  58196. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58197. /**
  58198. * Removes a joint from the simulation
  58199. * @param mainImpostor defines the impostor used with the joint
  58200. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58201. * @param joint defines the joint to remove
  58202. */
  58203. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58204. /**
  58205. * Called by the scene. No need to call it.
  58206. * @param delta defines the timespam between frames
  58207. */
  58208. _step(delta: number): void;
  58209. /**
  58210. * Gets the current plugin used to run the simulation
  58211. * @returns current plugin
  58212. */
  58213. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58214. /**
  58215. * Gets the list of physic impostors
  58216. * @returns an array of PhysicsImpostor
  58217. */
  58218. getImpostors(): Array<PhysicsImpostor>;
  58219. /**
  58220. * Gets the impostor for a physics enabled object
  58221. * @param object defines the object impersonated by the impostor
  58222. * @returns the PhysicsImpostor or null if not found
  58223. */
  58224. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58225. /**
  58226. * Gets the impostor for a physics body object
  58227. * @param body defines physics body used by the impostor
  58228. * @returns the PhysicsImpostor or null if not found
  58229. */
  58230. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58231. /**
  58232. * Does a raycast in the physics world
  58233. * @param from when should the ray start?
  58234. * @param to when should the ray end?
  58235. * @returns PhysicsRaycastResult
  58236. */
  58237. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58238. }
  58239. }
  58240. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58241. import { Nullable } from "babylonjs/types";
  58242. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58244. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58245. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58246. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58247. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58248. /** @hidden */
  58249. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58250. private _useDeltaForWorldStep;
  58251. world: any;
  58252. name: string;
  58253. private _physicsMaterials;
  58254. private _fixedTimeStep;
  58255. private _cannonRaycastResult;
  58256. private _raycastResult;
  58257. private _physicsBodysToRemoveAfterStep;
  58258. BJSCANNON: any;
  58259. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58260. setGravity(gravity: Vector3): void;
  58261. setTimeStep(timeStep: number): void;
  58262. getTimeStep(): number;
  58263. executeStep(delta: number): void;
  58264. private _removeMarkedPhysicsBodiesFromWorld;
  58265. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58266. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58267. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58268. private _processChildMeshes;
  58269. removePhysicsBody(impostor: PhysicsImpostor): void;
  58270. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58271. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58272. private _addMaterial;
  58273. private _checkWithEpsilon;
  58274. private _createShape;
  58275. private _createHeightmap;
  58276. private _minus90X;
  58277. private _plus90X;
  58278. private _tmpPosition;
  58279. private _tmpDeltaPosition;
  58280. private _tmpUnityRotation;
  58281. private _updatePhysicsBodyTransformation;
  58282. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58283. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58284. isSupported(): boolean;
  58285. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58287. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58288. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58289. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58290. getBodyMass(impostor: PhysicsImpostor): number;
  58291. getBodyFriction(impostor: PhysicsImpostor): number;
  58292. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58293. getBodyRestitution(impostor: PhysicsImpostor): number;
  58294. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58295. sleepBody(impostor: PhysicsImpostor): void;
  58296. wakeUpBody(impostor: PhysicsImpostor): void;
  58297. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58298. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58299. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58301. getRadius(impostor: PhysicsImpostor): number;
  58302. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58303. dispose(): void;
  58304. private _extendNamespace;
  58305. /**
  58306. * Does a raycast in the physics world
  58307. * @param from when should the ray start?
  58308. * @param to when should the ray end?
  58309. * @returns PhysicsRaycastResult
  58310. */
  58311. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58312. }
  58313. }
  58314. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58315. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58316. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58317. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58320. import { Nullable } from "babylonjs/types";
  58321. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58322. /** @hidden */
  58323. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58324. private _useDeltaForWorldStep;
  58325. world: any;
  58326. name: string;
  58327. BJSOIMO: any;
  58328. private _raycastResult;
  58329. private _fixedTimeStep;
  58330. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58331. setGravity(gravity: Vector3): void;
  58332. setTimeStep(timeStep: number): void;
  58333. getTimeStep(): number;
  58334. private _tmpImpostorsArray;
  58335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58339. private _tmpPositionVector;
  58340. removePhysicsBody(impostor: PhysicsImpostor): void;
  58341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58343. isSupported(): boolean;
  58344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58351. getBodyMass(impostor: PhysicsImpostor): number;
  58352. getBodyFriction(impostor: PhysicsImpostor): number;
  58353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58354. getBodyRestitution(impostor: PhysicsImpostor): number;
  58355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58356. sleepBody(impostor: PhysicsImpostor): void;
  58357. wakeUpBody(impostor: PhysicsImpostor): void;
  58358. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58359. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58361. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58362. getRadius(impostor: PhysicsImpostor): number;
  58363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58364. dispose(): void;
  58365. /**
  58366. * Does a raycast in the physics world
  58367. * @param from when should the ray start?
  58368. * @param to when should the ray end?
  58369. * @returns PhysicsRaycastResult
  58370. */
  58371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58372. }
  58373. }
  58374. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58375. import { Nullable } from "babylonjs/types";
  58376. import { Scene } from "babylonjs/scene";
  58377. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58378. import { Color4 } from "babylonjs/Maths/math.color";
  58379. import { Mesh } from "babylonjs/Meshes/mesh";
  58380. /**
  58381. * Class containing static functions to help procedurally build meshes
  58382. */
  58383. export class RibbonBuilder {
  58384. /**
  58385. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58386. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58387. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58388. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58389. * * 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
  58390. * * 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
  58391. * * 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
  58392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58395. * * 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
  58396. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58397. * * 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
  58398. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58400. * @param name defines the name of the mesh
  58401. * @param options defines the options used to create the mesh
  58402. * @param scene defines the hosting scene
  58403. * @returns the ribbon mesh
  58404. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58406. */
  58407. static CreateRibbon(name: string, options: {
  58408. pathArray: Vector3[][];
  58409. closeArray?: boolean;
  58410. closePath?: boolean;
  58411. offset?: number;
  58412. updatable?: boolean;
  58413. sideOrientation?: number;
  58414. frontUVs?: Vector4;
  58415. backUVs?: Vector4;
  58416. instance?: Mesh;
  58417. invertUV?: boolean;
  58418. uvs?: Vector2[];
  58419. colors?: Color4[];
  58420. }, scene?: Nullable<Scene>): Mesh;
  58421. }
  58422. }
  58423. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58424. import { Nullable } from "babylonjs/types";
  58425. import { Scene } from "babylonjs/scene";
  58426. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58427. import { Mesh } from "babylonjs/Meshes/mesh";
  58428. /**
  58429. * Class containing static functions to help procedurally build meshes
  58430. */
  58431. export class ShapeBuilder {
  58432. /**
  58433. * 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.
  58434. * * 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.
  58435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58436. * * 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.
  58437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58438. * * 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
  58439. * * 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
  58440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58445. * @param name defines the name of the mesh
  58446. * @param options defines the options used to create the mesh
  58447. * @param scene defines the hosting scene
  58448. * @returns the extruded shape mesh
  58449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58451. */
  58452. static ExtrudeShape(name: string, options: {
  58453. shape: Vector3[];
  58454. path: Vector3[];
  58455. scale?: number;
  58456. rotation?: number;
  58457. cap?: number;
  58458. updatable?: boolean;
  58459. sideOrientation?: number;
  58460. frontUVs?: Vector4;
  58461. backUVs?: Vector4;
  58462. instance?: Mesh;
  58463. invertUV?: boolean;
  58464. }, scene?: Nullable<Scene>): Mesh;
  58465. /**
  58466. * Creates an custom extruded shape mesh.
  58467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58468. * * 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.
  58469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58470. * * 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
  58471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58472. * * 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
  58473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58476. * * 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
  58477. * * 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
  58478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58483. * @param name defines the name of the mesh
  58484. * @param options defines the options used to create the mesh
  58485. * @param scene defines the hosting scene
  58486. * @returns the custom extruded shape mesh
  58487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58490. */
  58491. static ExtrudeShapeCustom(name: string, options: {
  58492. shape: Vector3[];
  58493. path: Vector3[];
  58494. scaleFunction?: any;
  58495. rotationFunction?: any;
  58496. ribbonCloseArray?: boolean;
  58497. ribbonClosePath?: boolean;
  58498. cap?: number;
  58499. updatable?: boolean;
  58500. sideOrientation?: number;
  58501. frontUVs?: Vector4;
  58502. backUVs?: Vector4;
  58503. instance?: Mesh;
  58504. invertUV?: boolean;
  58505. }, scene?: Nullable<Scene>): Mesh;
  58506. private static _ExtrudeShapeGeneric;
  58507. }
  58508. }
  58509. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58510. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58511. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58513. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58514. import { Nullable } from "babylonjs/types";
  58515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58516. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58517. /**
  58518. * AmmoJS Physics plugin
  58519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58520. * @see https://github.com/kripken/ammo.js/
  58521. */
  58522. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58523. private _useDeltaForWorldStep;
  58524. /**
  58525. * Reference to the Ammo library
  58526. */
  58527. bjsAMMO: any;
  58528. /**
  58529. * Created ammoJS world which physics bodies are added to
  58530. */
  58531. world: any;
  58532. /**
  58533. * Name of the plugin
  58534. */
  58535. name: string;
  58536. private _timeStep;
  58537. private _fixedTimeStep;
  58538. private _maxSteps;
  58539. private _tmpQuaternion;
  58540. private _tmpAmmoTransform;
  58541. private _tmpAmmoQuaternion;
  58542. private _tmpAmmoConcreteContactResultCallback;
  58543. private _collisionConfiguration;
  58544. private _dispatcher;
  58545. private _overlappingPairCache;
  58546. private _solver;
  58547. private _softBodySolver;
  58548. private _tmpAmmoVectorA;
  58549. private _tmpAmmoVectorB;
  58550. private _tmpAmmoVectorC;
  58551. private _tmpAmmoVectorD;
  58552. private _tmpContactCallbackResult;
  58553. private _tmpAmmoVectorRCA;
  58554. private _tmpAmmoVectorRCB;
  58555. private _raycastResult;
  58556. private static readonly DISABLE_COLLISION_FLAG;
  58557. private static readonly KINEMATIC_FLAG;
  58558. private static readonly DISABLE_DEACTIVATION_FLAG;
  58559. /**
  58560. * Initializes the ammoJS plugin
  58561. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58562. * @param ammoInjection can be used to inject your own ammo reference
  58563. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58564. */
  58565. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58566. /**
  58567. * Sets the gravity of the physics world (m/(s^2))
  58568. * @param gravity Gravity to set
  58569. */
  58570. setGravity(gravity: Vector3): void;
  58571. /**
  58572. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58573. * @param timeStep timestep to use in seconds
  58574. */
  58575. setTimeStep(timeStep: number): void;
  58576. /**
  58577. * 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)
  58578. * @param fixedTimeStep fixedTimeStep to use in seconds
  58579. */
  58580. setFixedTimeStep(fixedTimeStep: number): void;
  58581. /**
  58582. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58583. * @param maxSteps the maximum number of steps by the physics engine per frame
  58584. */
  58585. setMaxSteps(maxSteps: number): void;
  58586. /**
  58587. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58588. * @returns the current timestep in seconds
  58589. */
  58590. getTimeStep(): number;
  58591. /**
  58592. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58593. */
  58594. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58595. private _isImpostorInContact;
  58596. private _isImpostorPairInContact;
  58597. private _stepSimulation;
  58598. /**
  58599. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58600. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58601. * After the step the babylon meshes are set to the position of the physics imposters
  58602. * @param delta amount of time to step forward
  58603. * @param impostors array of imposters to update before/after the step
  58604. */
  58605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58606. /**
  58607. * Update babylon mesh to match physics world object
  58608. * @param impostor imposter to match
  58609. */
  58610. private _afterSoftStep;
  58611. /**
  58612. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58613. * @param impostor imposter to match
  58614. */
  58615. private _ropeStep;
  58616. /**
  58617. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58618. * @param impostor imposter to match
  58619. */
  58620. private _softbodyOrClothStep;
  58621. private _tmpMatrix;
  58622. /**
  58623. * Applies an impulse on the imposter
  58624. * @param impostor imposter to apply impulse to
  58625. * @param force amount of force to be applied to the imposter
  58626. * @param contactPoint the location to apply the impulse on the imposter
  58627. */
  58628. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58629. /**
  58630. * Applies a force on the imposter
  58631. * @param impostor imposter to apply force
  58632. * @param force amount of force to be applied to the imposter
  58633. * @param contactPoint the location to apply the force on the imposter
  58634. */
  58635. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58636. /**
  58637. * Creates a physics body using the plugin
  58638. * @param impostor the imposter to create the physics body on
  58639. */
  58640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58641. /**
  58642. * Removes the physics body from the imposter and disposes of the body's memory
  58643. * @param impostor imposter to remove the physics body from
  58644. */
  58645. removePhysicsBody(impostor: PhysicsImpostor): void;
  58646. /**
  58647. * Generates a joint
  58648. * @param impostorJoint the imposter joint to create the joint with
  58649. */
  58650. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58651. /**
  58652. * Removes a joint
  58653. * @param impostorJoint the imposter joint to remove the joint from
  58654. */
  58655. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58656. private _addMeshVerts;
  58657. /**
  58658. * Initialise the soft body vertices to match its object's (mesh) vertices
  58659. * Softbody vertices (nodes) are in world space and to match this
  58660. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58661. * @param impostor to create the softbody for
  58662. */
  58663. private _softVertexData;
  58664. /**
  58665. * Create an impostor's soft body
  58666. * @param impostor to create the softbody for
  58667. */
  58668. private _createSoftbody;
  58669. /**
  58670. * Create cloth for an impostor
  58671. * @param impostor to create the softbody for
  58672. */
  58673. private _createCloth;
  58674. /**
  58675. * Create rope for an impostor
  58676. * @param impostor to create the softbody for
  58677. */
  58678. private _createRope;
  58679. /**
  58680. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58681. * @param impostor to create the custom physics shape for
  58682. */
  58683. private _createCustom;
  58684. private _addHullVerts;
  58685. private _createShape;
  58686. /**
  58687. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58688. * @param impostor imposter containing the physics body and babylon object
  58689. */
  58690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58691. /**
  58692. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58693. * @param impostor imposter containing the physics body and babylon object
  58694. * @param newPosition new position
  58695. * @param newRotation new rotation
  58696. */
  58697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58698. /**
  58699. * If this plugin is supported
  58700. * @returns true if its supported
  58701. */
  58702. isSupported(): boolean;
  58703. /**
  58704. * Sets the linear velocity of the physics body
  58705. * @param impostor imposter to set the velocity on
  58706. * @param velocity velocity to set
  58707. */
  58708. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58709. /**
  58710. * Sets the angular velocity of the physics body
  58711. * @param impostor imposter to set the velocity on
  58712. * @param velocity velocity to set
  58713. */
  58714. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58715. /**
  58716. * gets the linear velocity
  58717. * @param impostor imposter to get linear velocity from
  58718. * @returns linear velocity
  58719. */
  58720. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58721. /**
  58722. * gets the angular velocity
  58723. * @param impostor imposter to get angular velocity from
  58724. * @returns angular velocity
  58725. */
  58726. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58727. /**
  58728. * Sets the mass of physics body
  58729. * @param impostor imposter to set the mass on
  58730. * @param mass mass to set
  58731. */
  58732. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58733. /**
  58734. * Gets the mass of the physics body
  58735. * @param impostor imposter to get the mass from
  58736. * @returns mass
  58737. */
  58738. getBodyMass(impostor: PhysicsImpostor): number;
  58739. /**
  58740. * Gets friction of the impostor
  58741. * @param impostor impostor to get friction from
  58742. * @returns friction value
  58743. */
  58744. getBodyFriction(impostor: PhysicsImpostor): number;
  58745. /**
  58746. * Sets friction of the impostor
  58747. * @param impostor impostor to set friction on
  58748. * @param friction friction value
  58749. */
  58750. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58751. /**
  58752. * Gets restitution of the impostor
  58753. * @param impostor impostor to get restitution from
  58754. * @returns restitution value
  58755. */
  58756. getBodyRestitution(impostor: PhysicsImpostor): number;
  58757. /**
  58758. * Sets resitution of the impostor
  58759. * @param impostor impostor to set resitution on
  58760. * @param restitution resitution value
  58761. */
  58762. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58763. /**
  58764. * Gets pressure inside the impostor
  58765. * @param impostor impostor to get pressure from
  58766. * @returns pressure value
  58767. */
  58768. getBodyPressure(impostor: PhysicsImpostor): number;
  58769. /**
  58770. * Sets pressure inside a soft body impostor
  58771. * Cloth and rope must remain 0 pressure
  58772. * @param impostor impostor to set pressure on
  58773. * @param pressure pressure value
  58774. */
  58775. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58776. /**
  58777. * Gets stiffness of the impostor
  58778. * @param impostor impostor to get stiffness from
  58779. * @returns pressure value
  58780. */
  58781. getBodyStiffness(impostor: PhysicsImpostor): number;
  58782. /**
  58783. * Sets stiffness of the impostor
  58784. * @param impostor impostor to set stiffness on
  58785. * @param stiffness stiffness value from 0 to 1
  58786. */
  58787. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58788. /**
  58789. * Gets velocityIterations of the impostor
  58790. * @param impostor impostor to get velocity iterations from
  58791. * @returns velocityIterations value
  58792. */
  58793. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58794. /**
  58795. * Sets velocityIterations of the impostor
  58796. * @param impostor impostor to set velocity iterations on
  58797. * @param velocityIterations velocityIterations value
  58798. */
  58799. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58800. /**
  58801. * Gets positionIterations of the impostor
  58802. * @param impostor impostor to get position iterations from
  58803. * @returns positionIterations value
  58804. */
  58805. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58806. /**
  58807. * Sets positionIterations of the impostor
  58808. * @param impostor impostor to set position on
  58809. * @param positionIterations positionIterations value
  58810. */
  58811. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58812. /**
  58813. * Append an anchor to a cloth object
  58814. * @param impostor is the cloth impostor to add anchor to
  58815. * @param otherImpostor is the rigid impostor to anchor to
  58816. * @param width ratio across width from 0 to 1
  58817. * @param height ratio up height from 0 to 1
  58818. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58819. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58820. */
  58821. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58822. /**
  58823. * Append an hook to a rope object
  58824. * @param impostor is the rope impostor to add hook to
  58825. * @param otherImpostor is the rigid impostor to hook to
  58826. * @param length ratio along the rope from 0 to 1
  58827. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58828. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58829. */
  58830. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58831. /**
  58832. * Sleeps the physics body and stops it from being active
  58833. * @param impostor impostor to sleep
  58834. */
  58835. sleepBody(impostor: PhysicsImpostor): void;
  58836. /**
  58837. * Activates the physics body
  58838. * @param impostor impostor to activate
  58839. */
  58840. wakeUpBody(impostor: PhysicsImpostor): void;
  58841. /**
  58842. * Updates the distance parameters of the joint
  58843. * @param joint joint to update
  58844. * @param maxDistance maximum distance of the joint
  58845. * @param minDistance minimum distance of the joint
  58846. */
  58847. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58848. /**
  58849. * Sets a motor on the joint
  58850. * @param joint joint to set motor on
  58851. * @param speed speed of the motor
  58852. * @param maxForce maximum force of the motor
  58853. * @param motorIndex index of the motor
  58854. */
  58855. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58856. /**
  58857. * Sets the motors limit
  58858. * @param joint joint to set limit on
  58859. * @param upperLimit upper limit
  58860. * @param lowerLimit lower limit
  58861. */
  58862. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58863. /**
  58864. * Syncs the position and rotation of a mesh with the impostor
  58865. * @param mesh mesh to sync
  58866. * @param impostor impostor to update the mesh with
  58867. */
  58868. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58869. /**
  58870. * Gets the radius of the impostor
  58871. * @param impostor impostor to get radius from
  58872. * @returns the radius
  58873. */
  58874. getRadius(impostor: PhysicsImpostor): number;
  58875. /**
  58876. * Gets the box size of the impostor
  58877. * @param impostor impostor to get box size from
  58878. * @param result the resulting box size
  58879. */
  58880. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58881. /**
  58882. * Disposes of the impostor
  58883. */
  58884. dispose(): void;
  58885. /**
  58886. * Does a raycast in the physics world
  58887. * @param from when should the ray start?
  58888. * @param to when should the ray end?
  58889. * @returns PhysicsRaycastResult
  58890. */
  58891. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58892. }
  58893. }
  58894. declare module "babylonjs/Probes/reflectionProbe" {
  58895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58896. import { Vector3 } from "babylonjs/Maths/math.vector";
  58897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58898. import { Nullable } from "babylonjs/types";
  58899. import { Scene } from "babylonjs/scene";
  58900. module "babylonjs/abstractScene" {
  58901. interface AbstractScene {
  58902. /**
  58903. * The list of reflection probes added to the scene
  58904. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58905. */
  58906. reflectionProbes: Array<ReflectionProbe>;
  58907. /**
  58908. * Removes the given reflection probe from this scene.
  58909. * @param toRemove The reflection probe to remove
  58910. * @returns The index of the removed reflection probe
  58911. */
  58912. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58913. /**
  58914. * Adds the given reflection probe to this scene.
  58915. * @param newReflectionProbe The reflection probe to add
  58916. */
  58917. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58918. }
  58919. }
  58920. /**
  58921. * Class used to generate realtime reflection / refraction cube textures
  58922. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58923. */
  58924. export class ReflectionProbe {
  58925. /** defines the name of the probe */
  58926. name: string;
  58927. private _scene;
  58928. private _renderTargetTexture;
  58929. private _projectionMatrix;
  58930. private _viewMatrix;
  58931. private _target;
  58932. private _add;
  58933. private _attachedMesh;
  58934. private _invertYAxis;
  58935. /** Gets or sets probe position (center of the cube map) */
  58936. position: Vector3;
  58937. /**
  58938. * Creates a new reflection probe
  58939. * @param name defines the name of the probe
  58940. * @param size defines the texture resolution (for each face)
  58941. * @param scene defines the hosting scene
  58942. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58943. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58944. */
  58945. constructor(
  58946. /** defines the name of the probe */
  58947. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58948. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58949. get samples(): number;
  58950. set samples(value: number);
  58951. /** Gets or sets the refresh rate to use (on every frame by default) */
  58952. get refreshRate(): number;
  58953. set refreshRate(value: number);
  58954. /**
  58955. * Gets the hosting scene
  58956. * @returns a Scene
  58957. */
  58958. getScene(): Scene;
  58959. /** Gets the internal CubeTexture used to render to */
  58960. get cubeTexture(): RenderTargetTexture;
  58961. /** Gets the list of meshes to render */
  58962. get renderList(): Nullable<AbstractMesh[]>;
  58963. /**
  58964. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58965. * @param mesh defines the mesh to attach to
  58966. */
  58967. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58968. /**
  58969. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58970. * @param renderingGroupId The rendering group id corresponding to its index
  58971. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58972. */
  58973. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58974. /**
  58975. * Clean all associated resources
  58976. */
  58977. dispose(): void;
  58978. /**
  58979. * Converts the reflection probe information to a readable string for debug purpose.
  58980. * @param fullDetails Supports for multiple levels of logging within scene loading
  58981. * @returns the human readable reflection probe info
  58982. */
  58983. toString(fullDetails?: boolean): string;
  58984. /**
  58985. * Get the class name of the relfection probe.
  58986. * @returns "ReflectionProbe"
  58987. */
  58988. getClassName(): string;
  58989. /**
  58990. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58991. * @returns The JSON representation of the texture
  58992. */
  58993. serialize(): any;
  58994. /**
  58995. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58996. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58997. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58998. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58999. * @returns The parsed reflection probe if successful
  59000. */
  59001. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59002. }
  59003. }
  59004. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  59005. /** @hidden */
  59006. export var _BabylonLoaderRegistered: boolean;
  59007. /**
  59008. * Helps setting up some configuration for the babylon file loader.
  59009. */
  59010. export class BabylonFileLoaderConfiguration {
  59011. /**
  59012. * The loader does not allow injecting custom physix engine into the plugins.
  59013. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59014. * So you could set this variable to your engine import to make it work.
  59015. */
  59016. static LoaderInjectedPhysicsEngine: any;
  59017. }
  59018. }
  59019. declare module "babylonjs/Loading/Plugins/index" {
  59020. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  59021. }
  59022. declare module "babylonjs/Loading/index" {
  59023. export * from "babylonjs/Loading/loadingScreen";
  59024. export * from "babylonjs/Loading/Plugins/index";
  59025. export * from "babylonjs/Loading/sceneLoader";
  59026. export * from "babylonjs/Loading/sceneLoaderFlags";
  59027. }
  59028. declare module "babylonjs/Materials/Background/index" {
  59029. export * from "babylonjs/Materials/Background/backgroundMaterial";
  59030. }
  59031. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  59032. import { Scene } from "babylonjs/scene";
  59033. import { Color3 } from "babylonjs/Maths/math.color";
  59034. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59036. /**
  59037. * The Physically based simple base material of BJS.
  59038. *
  59039. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59040. * It is used as the base class for both the specGloss and metalRough conventions.
  59041. */
  59042. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59043. /**
  59044. * Number of Simultaneous lights allowed on the material.
  59045. */
  59046. maxSimultaneousLights: number;
  59047. /**
  59048. * If sets to true, disables all the lights affecting the material.
  59049. */
  59050. disableLighting: boolean;
  59051. /**
  59052. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59053. */
  59054. environmentTexture: BaseTexture;
  59055. /**
  59056. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59057. */
  59058. invertNormalMapX: boolean;
  59059. /**
  59060. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59061. */
  59062. invertNormalMapY: boolean;
  59063. /**
  59064. * Normal map used in the model.
  59065. */
  59066. normalTexture: BaseTexture;
  59067. /**
  59068. * Emissivie color used to self-illuminate the model.
  59069. */
  59070. emissiveColor: Color3;
  59071. /**
  59072. * Emissivie texture used to self-illuminate the model.
  59073. */
  59074. emissiveTexture: BaseTexture;
  59075. /**
  59076. * Occlusion Channel Strenght.
  59077. */
  59078. occlusionStrength: number;
  59079. /**
  59080. * Occlusion Texture of the material (adding extra occlusion effects).
  59081. */
  59082. occlusionTexture: BaseTexture;
  59083. /**
  59084. * Defines the alpha limits in alpha test mode.
  59085. */
  59086. alphaCutOff: number;
  59087. /**
  59088. * Gets the current double sided mode.
  59089. */
  59090. get doubleSided(): boolean;
  59091. /**
  59092. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59093. */
  59094. set doubleSided(value: boolean);
  59095. /**
  59096. * Stores the pre-calculated light information of a mesh in a texture.
  59097. */
  59098. lightmapTexture: BaseTexture;
  59099. /**
  59100. * If true, the light map contains occlusion information instead of lighting info.
  59101. */
  59102. useLightmapAsShadowmap: boolean;
  59103. /**
  59104. * Instantiates a new PBRMaterial instance.
  59105. *
  59106. * @param name The material name
  59107. * @param scene The scene the material will be use in.
  59108. */
  59109. constructor(name: string, scene: Scene);
  59110. getClassName(): string;
  59111. }
  59112. }
  59113. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59114. import { Scene } from "babylonjs/scene";
  59115. import { Color3 } from "babylonjs/Maths/math.color";
  59116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59117. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59118. /**
  59119. * The PBR material of BJS following the metal roughness convention.
  59120. *
  59121. * This fits to the PBR convention in the GLTF definition:
  59122. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59123. */
  59124. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59125. /**
  59126. * The base color has two different interpretations depending on the value of metalness.
  59127. * When the material is a metal, the base color is the specific measured reflectance value
  59128. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59129. * of the material.
  59130. */
  59131. baseColor: Color3;
  59132. /**
  59133. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59134. * well as opacity information in the alpha channel.
  59135. */
  59136. baseTexture: BaseTexture;
  59137. /**
  59138. * Specifies the metallic scalar value of the material.
  59139. * Can also be used to scale the metalness values of the metallic texture.
  59140. */
  59141. metallic: number;
  59142. /**
  59143. * Specifies the roughness scalar value of the material.
  59144. * Can also be used to scale the roughness values of the metallic texture.
  59145. */
  59146. roughness: number;
  59147. /**
  59148. * Texture containing both the metallic value in the B channel and the
  59149. * roughness value in the G channel to keep better precision.
  59150. */
  59151. metallicRoughnessTexture: BaseTexture;
  59152. /**
  59153. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59154. *
  59155. * @param name The material name
  59156. * @param scene The scene the material will be use in.
  59157. */
  59158. constructor(name: string, scene: Scene);
  59159. /**
  59160. * Return the currrent class name of the material.
  59161. */
  59162. getClassName(): string;
  59163. /**
  59164. * Makes a duplicate of the current material.
  59165. * @param name - name to use for the new material.
  59166. */
  59167. clone(name: string): PBRMetallicRoughnessMaterial;
  59168. /**
  59169. * Serialize the material to a parsable JSON object.
  59170. */
  59171. serialize(): any;
  59172. /**
  59173. * Parses a JSON object correponding to the serialize function.
  59174. */
  59175. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59176. }
  59177. }
  59178. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59179. import { Scene } from "babylonjs/scene";
  59180. import { Color3 } from "babylonjs/Maths/math.color";
  59181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59182. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59183. /**
  59184. * The PBR material of BJS following the specular glossiness convention.
  59185. *
  59186. * This fits to the PBR convention in the GLTF definition:
  59187. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59188. */
  59189. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59190. /**
  59191. * Specifies the diffuse color of the material.
  59192. */
  59193. diffuseColor: Color3;
  59194. /**
  59195. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59196. * channel.
  59197. */
  59198. diffuseTexture: BaseTexture;
  59199. /**
  59200. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59201. */
  59202. specularColor: Color3;
  59203. /**
  59204. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59205. */
  59206. glossiness: number;
  59207. /**
  59208. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59209. */
  59210. specularGlossinessTexture: BaseTexture;
  59211. /**
  59212. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59213. *
  59214. * @param name The material name
  59215. * @param scene The scene the material will be use in.
  59216. */
  59217. constructor(name: string, scene: Scene);
  59218. /**
  59219. * Return the currrent class name of the material.
  59220. */
  59221. getClassName(): string;
  59222. /**
  59223. * Makes a duplicate of the current material.
  59224. * @param name - name to use for the new material.
  59225. */
  59226. clone(name: string): PBRSpecularGlossinessMaterial;
  59227. /**
  59228. * Serialize the material to a parsable JSON object.
  59229. */
  59230. serialize(): any;
  59231. /**
  59232. * Parses a JSON object correponding to the serialize function.
  59233. */
  59234. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59235. }
  59236. }
  59237. declare module "babylonjs/Materials/PBR/index" {
  59238. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59239. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59240. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59241. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59242. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59243. }
  59244. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59245. import { Nullable } from "babylonjs/types";
  59246. import { Scene } from "babylonjs/scene";
  59247. import { Matrix } from "babylonjs/Maths/math.vector";
  59248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59249. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59250. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59251. /**
  59252. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59253. * It can help converting any input color in a desired output one. This can then be used to create effects
  59254. * from sepia, black and white to sixties or futuristic rendering...
  59255. *
  59256. * The only supported format is currently 3dl.
  59257. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59258. */
  59259. export class ColorGradingTexture extends BaseTexture {
  59260. /**
  59261. * The texture URL.
  59262. */
  59263. url: string;
  59264. /**
  59265. * Empty line regex stored for GC.
  59266. */
  59267. private static _noneEmptyLineRegex;
  59268. private _textureMatrix;
  59269. private _onLoad;
  59270. /**
  59271. * Instantiates a ColorGradingTexture from the following parameters.
  59272. *
  59273. * @param url The location of the color gradind data (currently only supporting 3dl)
  59274. * @param sceneOrEngine The scene or engine the texture will be used in
  59275. * @param onLoad defines a callback triggered when the texture has been loaded
  59276. */
  59277. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59278. /**
  59279. * Fires the onload event from the constructor if requested.
  59280. */
  59281. private _triggerOnLoad;
  59282. /**
  59283. * Returns the texture matrix used in most of the material.
  59284. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59285. */
  59286. getTextureMatrix(): Matrix;
  59287. /**
  59288. * Occurs when the file being loaded is a .3dl LUT file.
  59289. */
  59290. private load3dlTexture;
  59291. /**
  59292. * Starts the loading process of the texture.
  59293. */
  59294. private loadTexture;
  59295. /**
  59296. * Clones the color gradind texture.
  59297. */
  59298. clone(): ColorGradingTexture;
  59299. /**
  59300. * Called during delayed load for textures.
  59301. */
  59302. delayLoad(): void;
  59303. /**
  59304. * Parses a color grading texture serialized by Babylon.
  59305. * @param parsedTexture The texture information being parsedTexture
  59306. * @param scene The scene to load the texture in
  59307. * @param rootUrl The root url of the data assets to load
  59308. * @return A color gradind texture
  59309. */
  59310. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59311. /**
  59312. * Serializes the LUT texture to json format.
  59313. */
  59314. serialize(): any;
  59315. }
  59316. }
  59317. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59319. import { Scene } from "babylonjs/scene";
  59320. import { Nullable } from "babylonjs/types";
  59321. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59322. /**
  59323. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59324. */
  59325. export class EquiRectangularCubeTexture extends BaseTexture {
  59326. /** The six faces of the cube. */
  59327. private static _FacesMapping;
  59328. private _noMipmap;
  59329. private _onLoad;
  59330. private _onError;
  59331. /** The size of the cubemap. */
  59332. private _size;
  59333. /** The buffer of the image. */
  59334. private _buffer;
  59335. /** The width of the input image. */
  59336. private _width;
  59337. /** The height of the input image. */
  59338. private _height;
  59339. /** The URL to the image. */
  59340. url: string;
  59341. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59342. coordinatesMode: number;
  59343. /**
  59344. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59345. * @param url The location of the image
  59346. * @param scene The scene the texture will be used in
  59347. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59348. * @param noMipmap Forces to not generate the mipmap if true
  59349. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59350. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59351. * @param onLoad — defines a callback called when texture is loaded
  59352. * @param onError — defines a callback called if there is an error
  59353. */
  59354. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59355. /**
  59356. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59357. */
  59358. private loadImage;
  59359. /**
  59360. * Convert the image buffer into a cubemap and create a CubeTexture.
  59361. */
  59362. private loadTexture;
  59363. /**
  59364. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59365. * @param buffer The ArrayBuffer that should be converted.
  59366. * @returns The buffer as Float32Array.
  59367. */
  59368. private getFloat32ArrayFromArrayBuffer;
  59369. /**
  59370. * Get the current class name of the texture useful for serialization or dynamic coding.
  59371. * @returns "EquiRectangularCubeTexture"
  59372. */
  59373. getClassName(): string;
  59374. /**
  59375. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59376. * @returns A clone of the current EquiRectangularCubeTexture.
  59377. */
  59378. clone(): EquiRectangularCubeTexture;
  59379. }
  59380. }
  59381. declare module "babylonjs/Misc/tga" {
  59382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59383. /**
  59384. * Based on jsTGALoader - Javascript loader for TGA file
  59385. * By Vincent Thibault
  59386. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59387. */
  59388. export class TGATools {
  59389. private static _TYPE_INDEXED;
  59390. private static _TYPE_RGB;
  59391. private static _TYPE_GREY;
  59392. private static _TYPE_RLE_INDEXED;
  59393. private static _TYPE_RLE_RGB;
  59394. private static _TYPE_RLE_GREY;
  59395. private static _ORIGIN_MASK;
  59396. private static _ORIGIN_SHIFT;
  59397. private static _ORIGIN_BL;
  59398. private static _ORIGIN_BR;
  59399. private static _ORIGIN_UL;
  59400. private static _ORIGIN_UR;
  59401. /**
  59402. * Gets the header of a TGA file
  59403. * @param data defines the TGA data
  59404. * @returns the header
  59405. */
  59406. static GetTGAHeader(data: Uint8Array): any;
  59407. /**
  59408. * Uploads TGA content to a Babylon Texture
  59409. * @hidden
  59410. */
  59411. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59412. /** @hidden */
  59413. 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;
  59414. /** @hidden */
  59415. 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;
  59416. /** @hidden */
  59417. 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;
  59418. /** @hidden */
  59419. 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;
  59420. /** @hidden */
  59421. 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;
  59422. /** @hidden */
  59423. 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;
  59424. }
  59425. }
  59426. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59427. import { Nullable } from "babylonjs/types";
  59428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59429. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59430. /**
  59431. * Implementation of the TGA Texture Loader.
  59432. * @hidden
  59433. */
  59434. export class _TGATextureLoader implements IInternalTextureLoader {
  59435. /**
  59436. * Defines wether the loader supports cascade loading the different faces.
  59437. */
  59438. readonly supportCascades: boolean;
  59439. /**
  59440. * This returns if the loader support the current file information.
  59441. * @param extension defines the file extension of the file being loaded
  59442. * @returns true if the loader can load the specified file
  59443. */
  59444. canLoad(extension: string): boolean;
  59445. /**
  59446. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59447. * @param data contains the texture data
  59448. * @param texture defines the BabylonJS internal texture
  59449. * @param createPolynomials will be true if polynomials have been requested
  59450. * @param onLoad defines the callback to trigger once the texture is ready
  59451. * @param onError defines the callback to trigger in case of error
  59452. */
  59453. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59454. /**
  59455. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59456. * @param data contains the texture data
  59457. * @param texture defines the BabylonJS internal texture
  59458. * @param callback defines the method to call once ready to upload
  59459. */
  59460. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59461. }
  59462. }
  59463. declare module "babylonjs/Misc/basis" {
  59464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59465. /**
  59466. * Info about the .basis files
  59467. */
  59468. class BasisFileInfo {
  59469. /**
  59470. * If the file has alpha
  59471. */
  59472. hasAlpha: boolean;
  59473. /**
  59474. * Info about each image of the basis file
  59475. */
  59476. images: Array<{
  59477. levels: Array<{
  59478. width: number;
  59479. height: number;
  59480. transcodedPixels: ArrayBufferView;
  59481. }>;
  59482. }>;
  59483. }
  59484. /**
  59485. * Result of transcoding a basis file
  59486. */
  59487. class TranscodeResult {
  59488. /**
  59489. * Info about the .basis file
  59490. */
  59491. fileInfo: BasisFileInfo;
  59492. /**
  59493. * Format to use when loading the file
  59494. */
  59495. format: number;
  59496. }
  59497. /**
  59498. * Configuration options for the Basis transcoder
  59499. */
  59500. export class BasisTranscodeConfiguration {
  59501. /**
  59502. * Supported compression formats used to determine the supported output format of the transcoder
  59503. */
  59504. supportedCompressionFormats?: {
  59505. /**
  59506. * etc1 compression format
  59507. */
  59508. etc1?: boolean;
  59509. /**
  59510. * s3tc compression format
  59511. */
  59512. s3tc?: boolean;
  59513. /**
  59514. * pvrtc compression format
  59515. */
  59516. pvrtc?: boolean;
  59517. /**
  59518. * etc2 compression format
  59519. */
  59520. etc2?: boolean;
  59521. };
  59522. /**
  59523. * If mipmap levels should be loaded for transcoded images (Default: true)
  59524. */
  59525. loadMipmapLevels?: boolean;
  59526. /**
  59527. * Index of a single image to load (Default: all images)
  59528. */
  59529. loadSingleImage?: number;
  59530. }
  59531. /**
  59532. * Used to load .Basis files
  59533. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59534. */
  59535. export class BasisTools {
  59536. private static _IgnoreSupportedFormats;
  59537. /**
  59538. * URL to use when loading the basis transcoder
  59539. */
  59540. static JSModuleURL: string;
  59541. /**
  59542. * URL to use when loading the wasm module for the transcoder
  59543. */
  59544. static WasmModuleURL: string;
  59545. /**
  59546. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59547. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59548. * @returns internal format corresponding to the Basis format
  59549. */
  59550. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59551. private static _WorkerPromise;
  59552. private static _Worker;
  59553. private static _actionId;
  59554. private static _CreateWorkerAsync;
  59555. /**
  59556. * Transcodes a loaded image file to compressed pixel data
  59557. * @param data image data to transcode
  59558. * @param config configuration options for the transcoding
  59559. * @returns a promise resulting in the transcoded image
  59560. */
  59561. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59562. /**
  59563. * Loads a texture from the transcode result
  59564. * @param texture texture load to
  59565. * @param transcodeResult the result of transcoding the basis file to load from
  59566. */
  59567. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59568. }
  59569. }
  59570. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59571. import { Nullable } from "babylonjs/types";
  59572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59573. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59574. /**
  59575. * Loader for .basis file format
  59576. */
  59577. export class _BasisTextureLoader implements IInternalTextureLoader {
  59578. /**
  59579. * Defines whether the loader supports cascade loading the different faces.
  59580. */
  59581. readonly supportCascades: boolean;
  59582. /**
  59583. * This returns if the loader support the current file information.
  59584. * @param extension defines the file extension of the file being loaded
  59585. * @returns true if the loader can load the specified file
  59586. */
  59587. canLoad(extension: string): boolean;
  59588. /**
  59589. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59590. * @param data contains the texture data
  59591. * @param texture defines the BabylonJS internal texture
  59592. * @param createPolynomials will be true if polynomials have been requested
  59593. * @param onLoad defines the callback to trigger once the texture is ready
  59594. * @param onError defines the callback to trigger in case of error
  59595. */
  59596. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59597. /**
  59598. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59599. * @param data contains the texture data
  59600. * @param texture defines the BabylonJS internal texture
  59601. * @param callback defines the method to call once ready to upload
  59602. */
  59603. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59604. }
  59605. }
  59606. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59607. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59608. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59609. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59610. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59611. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59612. }
  59613. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59614. import { Scene } from "babylonjs/scene";
  59615. import { Texture } from "babylonjs/Materials/Textures/texture";
  59616. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59617. /**
  59618. * 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.
  59619. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59620. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59621. */
  59622. export class CustomProceduralTexture extends ProceduralTexture {
  59623. private _animate;
  59624. private _time;
  59625. private _config;
  59626. private _texturePath;
  59627. /**
  59628. * Instantiates a new Custom Procedural Texture.
  59629. * 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.
  59630. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59631. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59632. * @param name Define the name of the texture
  59633. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59634. * @param size Define the size of the texture to create
  59635. * @param scene Define the scene the texture belongs to
  59636. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59637. * @param generateMipMaps Define if the texture should creates mip maps or not
  59638. */
  59639. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59640. private _loadJson;
  59641. /**
  59642. * Is the texture ready to be used ? (rendered at least once)
  59643. * @returns true if ready, otherwise, false.
  59644. */
  59645. isReady(): boolean;
  59646. /**
  59647. * Render the texture to its associated render target.
  59648. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59649. */
  59650. render(useCameraPostProcess?: boolean): void;
  59651. /**
  59652. * Update the list of dependant textures samplers in the shader.
  59653. */
  59654. updateTextures(): void;
  59655. /**
  59656. * Update the uniform values of the procedural texture in the shader.
  59657. */
  59658. updateShaderUniforms(): void;
  59659. /**
  59660. * Define if the texture animates or not.
  59661. */
  59662. get animate(): boolean;
  59663. set animate(value: boolean);
  59664. }
  59665. }
  59666. declare module "babylonjs/Shaders/noise.fragment" {
  59667. /** @hidden */
  59668. export var noisePixelShader: {
  59669. name: string;
  59670. shader: string;
  59671. };
  59672. }
  59673. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59674. import { Nullable } from "babylonjs/types";
  59675. import { Scene } from "babylonjs/scene";
  59676. import { Texture } from "babylonjs/Materials/Textures/texture";
  59677. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59678. import "babylonjs/Shaders/noise.fragment";
  59679. /**
  59680. * Class used to generate noise procedural textures
  59681. */
  59682. export class NoiseProceduralTexture extends ProceduralTexture {
  59683. private _time;
  59684. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59685. brightness: number;
  59686. /** Defines the number of octaves to process */
  59687. octaves: number;
  59688. /** Defines the level of persistence (0.8 by default) */
  59689. persistence: number;
  59690. /** Gets or sets animation speed factor (default is 1) */
  59691. animationSpeedFactor: number;
  59692. /**
  59693. * Creates a new NoiseProceduralTexture
  59694. * @param name defines the name fo the texture
  59695. * @param size defines the size of the texture (default is 256)
  59696. * @param scene defines the hosting scene
  59697. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59698. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59699. */
  59700. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59701. private _updateShaderUniforms;
  59702. protected _getDefines(): string;
  59703. /** Generate the current state of the procedural texture */
  59704. render(useCameraPostProcess?: boolean): void;
  59705. /**
  59706. * Serializes this noise procedural texture
  59707. * @returns a serialized noise procedural texture object
  59708. */
  59709. serialize(): any;
  59710. /**
  59711. * Clone the texture.
  59712. * @returns the cloned texture
  59713. */
  59714. clone(): NoiseProceduralTexture;
  59715. /**
  59716. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59717. * @param parsedTexture defines parsed texture data
  59718. * @param scene defines the current scene
  59719. * @param rootUrl defines the root URL containing noise procedural texture information
  59720. * @returns a parsed NoiseProceduralTexture
  59721. */
  59722. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59723. }
  59724. }
  59725. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59726. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59727. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59728. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59729. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59730. }
  59731. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59732. import { Nullable } from "babylonjs/types";
  59733. import { Scene } from "babylonjs/scene";
  59734. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59736. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59738. /**
  59739. * Raw cube texture where the raw buffers are passed in
  59740. */
  59741. export class RawCubeTexture extends CubeTexture {
  59742. /**
  59743. * Creates a cube texture where the raw buffers are passed in.
  59744. * @param scene defines the scene the texture is attached to
  59745. * @param data defines the array of data to use to create each face
  59746. * @param size defines the size of the textures
  59747. * @param format defines the format of the data
  59748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59749. * @param generateMipMaps defines if the engine should generate the mip levels
  59750. * @param invertY defines if data must be stored with Y axis inverted
  59751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59752. * @param compression defines the compression used (null by default)
  59753. */
  59754. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59755. /**
  59756. * Updates the raw cube texture.
  59757. * @param data defines the data to store
  59758. * @param format defines the data format
  59759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59760. * @param invertY defines if data must be stored with Y axis inverted
  59761. * @param compression defines the compression used (null by default)
  59762. * @param level defines which level of the texture to update
  59763. */
  59764. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59765. /**
  59766. * Updates a raw cube texture with RGBD encoded data.
  59767. * @param data defines the array of data [mipmap][face] to use to create each face
  59768. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59769. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59770. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59771. * @returns a promsie that resolves when the operation is complete
  59772. */
  59773. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59774. /**
  59775. * Clones the raw cube texture.
  59776. * @return a new cube texture
  59777. */
  59778. clone(): CubeTexture;
  59779. /** @hidden */
  59780. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59781. }
  59782. }
  59783. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59784. import { Scene } from "babylonjs/scene";
  59785. import { Texture } from "babylonjs/Materials/Textures/texture";
  59786. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59787. /**
  59788. * Class used to store 3D textures containing user data
  59789. */
  59790. export class RawTexture3D extends Texture {
  59791. /** Gets or sets the texture format to use */
  59792. format: number;
  59793. /**
  59794. * Create a new RawTexture3D
  59795. * @param data defines the data of the texture
  59796. * @param width defines the width of the texture
  59797. * @param height defines the height of the texture
  59798. * @param depth defines the depth of the texture
  59799. * @param format defines the texture format to use
  59800. * @param scene defines the hosting scene
  59801. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59802. * @param invertY defines if texture must be stored with Y axis inverted
  59803. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59805. */
  59806. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59807. /** Gets or sets the texture format to use */
  59808. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59809. /**
  59810. * Update the texture with new data
  59811. * @param data defines the data to store in the texture
  59812. */
  59813. update(data: ArrayBufferView): void;
  59814. }
  59815. }
  59816. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59817. import { Scene } from "babylonjs/scene";
  59818. import { Texture } from "babylonjs/Materials/Textures/texture";
  59819. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59820. /**
  59821. * Class used to store 2D array textures containing user data
  59822. */
  59823. export class RawTexture2DArray extends Texture {
  59824. /** Gets or sets the texture format to use */
  59825. format: number;
  59826. /**
  59827. * Create a new RawTexture2DArray
  59828. * @param data defines the data of the texture
  59829. * @param width defines the width of the texture
  59830. * @param height defines the height of the texture
  59831. * @param depth defines the number of layers of the texture
  59832. * @param format defines the texture format to use
  59833. * @param scene defines the hosting scene
  59834. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59835. * @param invertY defines if texture must be stored with Y axis inverted
  59836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59838. */
  59839. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59840. /** Gets or sets the texture format to use */
  59841. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59842. /**
  59843. * Update the texture with new data
  59844. * @param data defines the data to store in the texture
  59845. */
  59846. update(data: ArrayBufferView): void;
  59847. }
  59848. }
  59849. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59850. import { Scene } from "babylonjs/scene";
  59851. import { Plane } from "babylonjs/Maths/math.plane";
  59852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59853. /**
  59854. * Creates a refraction texture used by refraction channel of the standard material.
  59855. * It is like a mirror but to see through a material.
  59856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59857. */
  59858. export class RefractionTexture extends RenderTargetTexture {
  59859. /**
  59860. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59861. * 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.
  59862. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59863. */
  59864. refractionPlane: Plane;
  59865. /**
  59866. * Define how deep under the surface we should see.
  59867. */
  59868. depth: number;
  59869. /**
  59870. * Creates a refraction texture used by refraction channel of the standard material.
  59871. * It is like a mirror but to see through a material.
  59872. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59873. * @param name Define the texture name
  59874. * @param size Define the size of the underlying texture
  59875. * @param scene Define the scene the refraction belongs to
  59876. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59877. */
  59878. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59879. /**
  59880. * Clone the refraction texture.
  59881. * @returns the cloned texture
  59882. */
  59883. clone(): RefractionTexture;
  59884. /**
  59885. * Serialize the texture to a JSON representation you could use in Parse later on
  59886. * @returns the serialized JSON representation
  59887. */
  59888. serialize(): any;
  59889. }
  59890. }
  59891. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59892. import { Nullable } from "babylonjs/types";
  59893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59894. import { Matrix } from "babylonjs/Maths/math.vector";
  59895. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59896. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59897. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59898. import { Scene } from "babylonjs/scene";
  59899. /**
  59900. * Defines the options related to the creation of an HtmlElementTexture
  59901. */
  59902. export interface IHtmlElementTextureOptions {
  59903. /**
  59904. * Defines wether mip maps should be created or not.
  59905. */
  59906. generateMipMaps?: boolean;
  59907. /**
  59908. * Defines the sampling mode of the texture.
  59909. */
  59910. samplingMode?: number;
  59911. /**
  59912. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59913. */
  59914. engine: Nullable<ThinEngine>;
  59915. /**
  59916. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59917. */
  59918. scene: Nullable<Scene>;
  59919. }
  59920. /**
  59921. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59922. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59923. * is automatically managed.
  59924. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59925. * in your application.
  59926. *
  59927. * As the update is not automatic, you need to call them manually.
  59928. */
  59929. export class HtmlElementTexture extends BaseTexture {
  59930. /**
  59931. * The texture URL.
  59932. */
  59933. element: HTMLVideoElement | HTMLCanvasElement;
  59934. private static readonly DefaultOptions;
  59935. private _textureMatrix;
  59936. private _isVideo;
  59937. private _generateMipMaps;
  59938. private _samplingMode;
  59939. /**
  59940. * Instantiates a HtmlElementTexture from the following parameters.
  59941. *
  59942. * @param name Defines the name of the texture
  59943. * @param element Defines the video or canvas the texture is filled with
  59944. * @param options Defines the other none mandatory texture creation options
  59945. */
  59946. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59947. private _createInternalTexture;
  59948. /**
  59949. * Returns the texture matrix used in most of the material.
  59950. */
  59951. getTextureMatrix(): Matrix;
  59952. /**
  59953. * Updates the content of the texture.
  59954. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59955. */
  59956. update(invertY?: Nullable<boolean>): void;
  59957. }
  59958. }
  59959. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59960. import { Vector2 } from "babylonjs/Maths/math.vector";
  59961. /**
  59962. * Defines the basic options interface of a TexturePacker Frame
  59963. */
  59964. export interface ITexturePackerFrame {
  59965. /**
  59966. * The frame ID
  59967. */
  59968. id: number;
  59969. /**
  59970. * The frames Scale
  59971. */
  59972. scale: Vector2;
  59973. /**
  59974. * The Frames offset
  59975. */
  59976. offset: Vector2;
  59977. }
  59978. /**
  59979. * This is a support class for frame Data on texture packer sets.
  59980. */
  59981. export class TexturePackerFrame implements ITexturePackerFrame {
  59982. /**
  59983. * The frame ID
  59984. */
  59985. id: number;
  59986. /**
  59987. * The frames Scale
  59988. */
  59989. scale: Vector2;
  59990. /**
  59991. * The Frames offset
  59992. */
  59993. offset: Vector2;
  59994. /**
  59995. * Initializes a texture package frame.
  59996. * @param id The numerical frame identifier
  59997. * @param scale Scalar Vector2 for UV frame
  59998. * @param offset Vector2 for the frame position in UV units.
  59999. * @returns TexturePackerFrame
  60000. */
  60001. constructor(id: number, scale: Vector2, offset: Vector2);
  60002. }
  60003. }
  60004. declare module "babylonjs/Materials/Textures/Packer/packer" {
  60005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60006. import { Scene } from "babylonjs/scene";
  60007. import { Nullable } from "babylonjs/types";
  60008. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  60009. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  60010. /**
  60011. * Defines the basic options interface of a TexturePacker
  60012. */
  60013. export interface ITexturePackerOptions {
  60014. /**
  60015. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60016. */
  60017. map?: string[];
  60018. /**
  60019. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60020. */
  60021. uvsIn?: string;
  60022. /**
  60023. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60024. */
  60025. uvsOut?: string;
  60026. /**
  60027. * number representing the layout style. Defaults to LAYOUT_STRIP
  60028. */
  60029. layout?: number;
  60030. /**
  60031. * number of columns if using custom column count layout(2). This defaults to 4.
  60032. */
  60033. colnum?: number;
  60034. /**
  60035. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60036. */
  60037. updateInputMeshes?: boolean;
  60038. /**
  60039. * boolean flag to dispose all the source textures. Defaults to true.
  60040. */
  60041. disposeSources?: boolean;
  60042. /**
  60043. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60044. */
  60045. fillBlanks?: boolean;
  60046. /**
  60047. * string value representing the context fill style color. Defaults to 'black'.
  60048. */
  60049. customFillColor?: string;
  60050. /**
  60051. * Width and Height Value of each Frame in the TexturePacker Sets
  60052. */
  60053. frameSize?: number;
  60054. /**
  60055. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60056. */
  60057. paddingRatio?: number;
  60058. /**
  60059. * Number that declares the fill method for the padding gutter.
  60060. */
  60061. paddingMode?: number;
  60062. /**
  60063. * If in SUBUV_COLOR padding mode what color to use.
  60064. */
  60065. paddingColor?: Color3 | Color4;
  60066. }
  60067. /**
  60068. * Defines the basic interface of a TexturePacker JSON File
  60069. */
  60070. export interface ITexturePackerJSON {
  60071. /**
  60072. * The frame ID
  60073. */
  60074. name: string;
  60075. /**
  60076. * The base64 channel data
  60077. */
  60078. sets: any;
  60079. /**
  60080. * The options of the Packer
  60081. */
  60082. options: ITexturePackerOptions;
  60083. /**
  60084. * The frame data of the Packer
  60085. */
  60086. frames: Array<number>;
  60087. }
  60088. /**
  60089. * This is a support class that generates a series of packed texture sets.
  60090. * @see https://doc.babylonjs.com/babylon101/materials
  60091. */
  60092. export class TexturePacker {
  60093. /** Packer Layout Constant 0 */
  60094. static readonly LAYOUT_STRIP: number;
  60095. /** Packer Layout Constant 1 */
  60096. static readonly LAYOUT_POWER2: number;
  60097. /** Packer Layout Constant 2 */
  60098. static readonly LAYOUT_COLNUM: number;
  60099. /** Packer Layout Constant 0 */
  60100. static readonly SUBUV_WRAP: number;
  60101. /** Packer Layout Constant 1 */
  60102. static readonly SUBUV_EXTEND: number;
  60103. /** Packer Layout Constant 2 */
  60104. static readonly SUBUV_COLOR: number;
  60105. /** The Name of the Texture Package */
  60106. name: string;
  60107. /** The scene scope of the TexturePacker */
  60108. scene: Scene;
  60109. /** The Meshes to target */
  60110. meshes: AbstractMesh[];
  60111. /** Arguments passed with the Constructor */
  60112. options: ITexturePackerOptions;
  60113. /** The promise that is started upon initialization */
  60114. promise: Nullable<Promise<TexturePacker | string>>;
  60115. /** The Container object for the channel sets that are generated */
  60116. sets: object;
  60117. /** The Container array for the frames that are generated */
  60118. frames: TexturePackerFrame[];
  60119. /** The expected number of textures the system is parsing. */
  60120. private _expecting;
  60121. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60122. private _paddingValue;
  60123. /**
  60124. * Initializes a texture package series from an array of meshes or a single mesh.
  60125. * @param name The name of the package
  60126. * @param meshes The target meshes to compose the package from
  60127. * @param options The arguments that texture packer should follow while building.
  60128. * @param scene The scene which the textures are scoped to.
  60129. * @returns TexturePacker
  60130. */
  60131. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60132. /**
  60133. * Starts the package process
  60134. * @param resolve The promises resolution function
  60135. * @returns TexturePacker
  60136. */
  60137. private _createFrames;
  60138. /**
  60139. * Calculates the Size of the Channel Sets
  60140. * @returns Vector2
  60141. */
  60142. private _calculateSize;
  60143. /**
  60144. * Calculates the UV data for the frames.
  60145. * @param baseSize the base frameSize
  60146. * @param padding the base frame padding
  60147. * @param dtSize size of the Dynamic Texture for that channel
  60148. * @param dtUnits is 1/dtSize
  60149. * @param update flag to update the input meshes
  60150. */
  60151. private _calculateMeshUVFrames;
  60152. /**
  60153. * Calculates the frames Offset.
  60154. * @param index of the frame
  60155. * @returns Vector2
  60156. */
  60157. private _getFrameOffset;
  60158. /**
  60159. * Updates a Mesh to the frame data
  60160. * @param mesh that is the target
  60161. * @param frameID or the frame index
  60162. */
  60163. private _updateMeshUV;
  60164. /**
  60165. * Updates a Meshes materials to use the texture packer channels
  60166. * @param m is the mesh to target
  60167. * @param force all channels on the packer to be set.
  60168. */
  60169. private _updateTextureReferences;
  60170. /**
  60171. * Public method to set a Mesh to a frame
  60172. * @param m that is the target
  60173. * @param frameID or the frame index
  60174. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60175. */
  60176. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60177. /**
  60178. * Starts the async promise to compile the texture packer.
  60179. * @returns Promise<void>
  60180. */
  60181. processAsync(): Promise<void>;
  60182. /**
  60183. * Disposes all textures associated with this packer
  60184. */
  60185. dispose(): void;
  60186. /**
  60187. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60188. * @param imageType is the image type to use.
  60189. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60190. */
  60191. download(imageType?: string, quality?: number): void;
  60192. /**
  60193. * Public method to load a texturePacker JSON file.
  60194. * @param data of the JSON file in string format.
  60195. */
  60196. updateFromJSON(data: string): void;
  60197. }
  60198. }
  60199. declare module "babylonjs/Materials/Textures/Packer/index" {
  60200. export * from "babylonjs/Materials/Textures/Packer/packer";
  60201. export * from "babylonjs/Materials/Textures/Packer/frame";
  60202. }
  60203. declare module "babylonjs/Materials/Textures/index" {
  60204. export * from "babylonjs/Materials/Textures/baseTexture";
  60205. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60206. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60207. export * from "babylonjs/Materials/Textures/cubeTexture";
  60208. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60209. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60210. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60211. export * from "babylonjs/Materials/Textures/internalTexture";
  60212. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60213. export * from "babylonjs/Materials/Textures/Loaders/index";
  60214. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60215. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60216. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60217. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60218. export * from "babylonjs/Materials/Textures/rawTexture";
  60219. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60220. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60221. export * from "babylonjs/Materials/Textures/refractionTexture";
  60222. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60223. export * from "babylonjs/Materials/Textures/texture";
  60224. export * from "babylonjs/Materials/Textures/videoTexture";
  60225. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60226. export * from "babylonjs/Materials/Textures/Packer/index";
  60227. }
  60228. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60229. /**
  60230. * Enum used to define the target of a block
  60231. */
  60232. export enum NodeMaterialBlockTargets {
  60233. /** Vertex shader */
  60234. Vertex = 1,
  60235. /** Fragment shader */
  60236. Fragment = 2,
  60237. /** Neutral */
  60238. Neutral = 4,
  60239. /** Vertex and Fragment */
  60240. VertexAndFragment = 3
  60241. }
  60242. }
  60243. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60244. /**
  60245. * Defines the kind of connection point for node based material
  60246. */
  60247. export enum NodeMaterialBlockConnectionPointTypes {
  60248. /** Float */
  60249. Float = 1,
  60250. /** Int */
  60251. Int = 2,
  60252. /** Vector2 */
  60253. Vector2 = 4,
  60254. /** Vector3 */
  60255. Vector3 = 8,
  60256. /** Vector4 */
  60257. Vector4 = 16,
  60258. /** Color3 */
  60259. Color3 = 32,
  60260. /** Color4 */
  60261. Color4 = 64,
  60262. /** Matrix */
  60263. Matrix = 128,
  60264. /** Custom object */
  60265. Object = 256,
  60266. /** Detect type based on connection */
  60267. AutoDetect = 1024,
  60268. /** Output type that will be defined by input type */
  60269. BasedOnInput = 2048
  60270. }
  60271. }
  60272. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60273. /**
  60274. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60275. */
  60276. export enum NodeMaterialBlockConnectionPointMode {
  60277. /** Value is an uniform */
  60278. Uniform = 0,
  60279. /** Value is a mesh attribute */
  60280. Attribute = 1,
  60281. /** Value is a varying between vertex and fragment shaders */
  60282. Varying = 2,
  60283. /** Mode is undefined */
  60284. Undefined = 3
  60285. }
  60286. }
  60287. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60288. /**
  60289. * Enum used to define system values e.g. values automatically provided by the system
  60290. */
  60291. export enum NodeMaterialSystemValues {
  60292. /** World */
  60293. World = 1,
  60294. /** View */
  60295. View = 2,
  60296. /** Projection */
  60297. Projection = 3,
  60298. /** ViewProjection */
  60299. ViewProjection = 4,
  60300. /** WorldView */
  60301. WorldView = 5,
  60302. /** WorldViewProjection */
  60303. WorldViewProjection = 6,
  60304. /** CameraPosition */
  60305. CameraPosition = 7,
  60306. /** Fog Color */
  60307. FogColor = 8,
  60308. /** Delta time */
  60309. DeltaTime = 9
  60310. }
  60311. }
  60312. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  60313. /**
  60314. * Enum used to define the material modes
  60315. */
  60316. export enum NodeMaterialModes {
  60317. /** Regular material */
  60318. Material = 0,
  60319. /** For post process */
  60320. PostProcess = 1
  60321. }
  60322. }
  60323. declare module "babylonjs/Materials/Node/Enums/index" {
  60324. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60325. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60326. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60327. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60328. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  60329. }
  60330. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60332. /**
  60333. * Root class for all node material optimizers
  60334. */
  60335. export class NodeMaterialOptimizer {
  60336. /**
  60337. * Function used to optimize a NodeMaterial graph
  60338. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60339. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60340. */
  60341. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60342. }
  60343. }
  60344. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60348. import { Scene } from "babylonjs/scene";
  60349. /**
  60350. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60351. */
  60352. export class TransformBlock extends NodeMaterialBlock {
  60353. /**
  60354. * Defines the value to use to complement W value to transform it to a Vector4
  60355. */
  60356. complementW: number;
  60357. /**
  60358. * Defines the value to use to complement z value to transform it to a Vector4
  60359. */
  60360. complementZ: number;
  60361. /**
  60362. * Creates a new TransformBlock
  60363. * @param name defines the block name
  60364. */
  60365. constructor(name: string);
  60366. /**
  60367. * Gets the current class name
  60368. * @returns the class name
  60369. */
  60370. getClassName(): string;
  60371. /**
  60372. * Gets the vector input
  60373. */
  60374. get vector(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the output component
  60377. */
  60378. get output(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the xyz output component
  60381. */
  60382. get xyz(): NodeMaterialConnectionPoint;
  60383. /**
  60384. * Gets the matrix transform input
  60385. */
  60386. get transform(): NodeMaterialConnectionPoint;
  60387. protected _buildBlock(state: NodeMaterialBuildState): this;
  60388. serialize(): any;
  60389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60390. protected _dumpPropertiesCode(): string;
  60391. }
  60392. }
  60393. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60397. /**
  60398. * Block used to output the vertex position
  60399. */
  60400. export class VertexOutputBlock extends NodeMaterialBlock {
  60401. /**
  60402. * Creates a new VertexOutputBlock
  60403. * @param name defines the block name
  60404. */
  60405. constructor(name: string);
  60406. /**
  60407. * Gets the current class name
  60408. * @returns the class name
  60409. */
  60410. getClassName(): string;
  60411. /**
  60412. * Gets the vector input component
  60413. */
  60414. get vector(): NodeMaterialConnectionPoint;
  60415. protected _buildBlock(state: NodeMaterialBuildState): this;
  60416. }
  60417. }
  60418. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60422. /**
  60423. * Block used to output the final color
  60424. */
  60425. export class FragmentOutputBlock extends NodeMaterialBlock {
  60426. /**
  60427. * Create a new FragmentOutputBlock
  60428. * @param name defines the block name
  60429. */
  60430. constructor(name: string);
  60431. /**
  60432. * Gets the current class name
  60433. * @returns the class name
  60434. */
  60435. getClassName(): string;
  60436. /**
  60437. * Gets the rgba input component
  60438. */
  60439. get rgba(): NodeMaterialConnectionPoint;
  60440. /**
  60441. * Gets the rgb input component
  60442. */
  60443. get rgb(): NodeMaterialConnectionPoint;
  60444. /**
  60445. * Gets the a input component
  60446. */
  60447. get a(): NodeMaterialConnectionPoint;
  60448. protected _buildBlock(state: NodeMaterialBuildState): this;
  60449. }
  60450. }
  60451. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60457. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60458. import { Effect } from "babylonjs/Materials/effect";
  60459. import { Mesh } from "babylonjs/Meshes/mesh";
  60460. import { Nullable } from "babylonjs/types";
  60461. import { Scene } from "babylonjs/scene";
  60462. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60463. /**
  60464. * Base block used to read a reflection texture from a sampler
  60465. */
  60466. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60467. /** @hidden */
  60468. _define3DName: string;
  60469. /** @hidden */
  60470. _defineCubicName: string;
  60471. /** @hidden */
  60472. _defineExplicitName: string;
  60473. /** @hidden */
  60474. _defineProjectionName: string;
  60475. /** @hidden */
  60476. _defineLocalCubicName: string;
  60477. /** @hidden */
  60478. _defineSphericalName: string;
  60479. /** @hidden */
  60480. _definePlanarName: string;
  60481. /** @hidden */
  60482. _defineEquirectangularName: string;
  60483. /** @hidden */
  60484. _defineMirroredEquirectangularFixedName: string;
  60485. /** @hidden */
  60486. _defineEquirectangularFixedName: string;
  60487. /** @hidden */
  60488. _defineSkyboxName: string;
  60489. /** @hidden */
  60490. _defineOppositeZ: string;
  60491. /** @hidden */
  60492. _cubeSamplerName: string;
  60493. /** @hidden */
  60494. _2DSamplerName: string;
  60495. protected _positionUVWName: string;
  60496. protected _directionWName: string;
  60497. protected _reflectionVectorName: string;
  60498. /** @hidden */
  60499. _reflectionCoordsName: string;
  60500. /** @hidden */
  60501. _reflectionMatrixName: string;
  60502. protected _reflectionColorName: string;
  60503. /**
  60504. * Gets or sets the texture associated with the node
  60505. */
  60506. texture: Nullable<BaseTexture>;
  60507. /**
  60508. * Create a new ReflectionTextureBaseBlock
  60509. * @param name defines the block name
  60510. */
  60511. constructor(name: string);
  60512. /**
  60513. * Gets the current class name
  60514. * @returns the class name
  60515. */
  60516. getClassName(): string;
  60517. /**
  60518. * Gets the world position input component
  60519. */
  60520. abstract get position(): NodeMaterialConnectionPoint;
  60521. /**
  60522. * Gets the world position input component
  60523. */
  60524. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60525. /**
  60526. * Gets the world normal input component
  60527. */
  60528. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60529. /**
  60530. * Gets the world input component
  60531. */
  60532. abstract get world(): NodeMaterialConnectionPoint;
  60533. /**
  60534. * Gets the camera (or eye) position component
  60535. */
  60536. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60537. /**
  60538. * Gets the view input component
  60539. */
  60540. abstract get view(): NodeMaterialConnectionPoint;
  60541. protected _getTexture(): Nullable<BaseTexture>;
  60542. autoConfigure(material: NodeMaterial): void;
  60543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60544. isReady(): boolean;
  60545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60546. /**
  60547. * Gets the code to inject in the vertex shader
  60548. * @param state current state of the node material building
  60549. * @returns the shader code
  60550. */
  60551. handleVertexSide(state: NodeMaterialBuildState): string;
  60552. /**
  60553. * Handles the inits for the fragment code path
  60554. * @param state node material build state
  60555. */
  60556. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60557. /**
  60558. * Generates the reflection coords code for the fragment code path
  60559. * @param worldNormalVarName name of the world normal variable
  60560. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60561. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60562. * @returns the shader code
  60563. */
  60564. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60565. /**
  60566. * Generates the reflection color code for the fragment code path
  60567. * @param lodVarName name of the lod variable
  60568. * @param swizzleLookupTexture swizzle to use for the final color variable
  60569. * @returns the shader code
  60570. */
  60571. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60572. /**
  60573. * Generates the code corresponding to the connected output points
  60574. * @param state node material build state
  60575. * @param varName name of the variable to output
  60576. * @returns the shader code
  60577. */
  60578. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60579. protected _buildBlock(state: NodeMaterialBuildState): this;
  60580. protected _dumpPropertiesCode(): string;
  60581. serialize(): any;
  60582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60583. }
  60584. }
  60585. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60587. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60588. import { Nullable } from "babylonjs/types";
  60589. /**
  60590. * Defines a connection point to be used for points with a custom object type
  60591. */
  60592. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60593. private _blockType;
  60594. private _blockName;
  60595. private _nameForCheking?;
  60596. /**
  60597. * Creates a new connection point
  60598. * @param name defines the connection point name
  60599. * @param ownerBlock defines the block hosting this connection point
  60600. * @param direction defines the direction of the connection point
  60601. */
  60602. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60603. /**
  60604. * Gets a number indicating if the current point can be connected to another point
  60605. * @param connectionPoint defines the other connection point
  60606. * @returns a number defining the compatibility state
  60607. */
  60608. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60609. /**
  60610. * Creates a block suitable to be used as an input for this input point.
  60611. * If null is returned, a block based on the point type will be created.
  60612. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  60613. */
  60614. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60615. }
  60616. }
  60617. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60618. /**
  60619. * Enum defining the type of properties that can be edited in the property pages in the NME
  60620. */
  60621. export enum PropertyTypeForEdition {
  60622. /** property is a boolean */
  60623. Boolean = 0,
  60624. /** property is a float */
  60625. Float = 1,
  60626. /** property is a Vector2 */
  60627. Vector2 = 2,
  60628. /** property is a list of values */
  60629. List = 3
  60630. }
  60631. /**
  60632. * Interface that defines an option in a variable of type list
  60633. */
  60634. export interface IEditablePropertyListOption {
  60635. /** label of the option */
  60636. "label": string;
  60637. /** value of the option */
  60638. "value": number;
  60639. }
  60640. /**
  60641. * Interface that defines the options available for an editable property
  60642. */
  60643. export interface IEditablePropertyOption {
  60644. /** min value */
  60645. "min"?: number;
  60646. /** max value */
  60647. "max"?: number;
  60648. /** notifiers: indicates which actions to take when the property is changed */
  60649. "notifiers"?: {
  60650. /** the material should be rebuilt */
  60651. "rebuild"?: boolean;
  60652. /** the preview should be updated */
  60653. "update"?: boolean;
  60654. };
  60655. /** list of the options for a variable of type list */
  60656. "options"?: IEditablePropertyListOption[];
  60657. }
  60658. /**
  60659. * Interface that describes an editable property
  60660. */
  60661. export interface IPropertyDescriptionForEdition {
  60662. /** name of the property */
  60663. "propertyName": string;
  60664. /** display name of the property */
  60665. "displayName": string;
  60666. /** type of the property */
  60667. "type": PropertyTypeForEdition;
  60668. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60669. "groupName": string;
  60670. /** options for the property */
  60671. "options": IEditablePropertyOption;
  60672. }
  60673. /**
  60674. * Decorator that flags a property in a node material block as being editable
  60675. */
  60676. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60677. }
  60678. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60683. import { Nullable } from "babylonjs/types";
  60684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60685. import { Mesh } from "babylonjs/Meshes/mesh";
  60686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60687. import { Effect } from "babylonjs/Materials/effect";
  60688. import { Scene } from "babylonjs/scene";
  60689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60690. /**
  60691. * Block used to implement the refraction part of the sub surface module of the PBR material
  60692. */
  60693. export class RefractionBlock extends NodeMaterialBlock {
  60694. /** @hidden */
  60695. _define3DName: string;
  60696. /** @hidden */
  60697. _refractionMatrixName: string;
  60698. /** @hidden */
  60699. _defineLODRefractionAlpha: string;
  60700. /** @hidden */
  60701. _defineLinearSpecularRefraction: string;
  60702. /** @hidden */
  60703. _defineOppositeZ: string;
  60704. /** @hidden */
  60705. _cubeSamplerName: string;
  60706. /** @hidden */
  60707. _2DSamplerName: string;
  60708. /** @hidden */
  60709. _vRefractionMicrosurfaceInfosName: string;
  60710. /** @hidden */
  60711. _vRefractionInfosName: string;
  60712. private _scene;
  60713. /**
  60714. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60715. * Materials half opaque for instance using refraction could benefit from this control.
  60716. */
  60717. linkRefractionWithTransparency: boolean;
  60718. /**
  60719. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60720. */
  60721. invertRefractionY: boolean;
  60722. /**
  60723. * Gets or sets the texture associated with the node
  60724. */
  60725. texture: Nullable<BaseTexture>;
  60726. /**
  60727. * Create a new RefractionBlock
  60728. * @param name defines the block name
  60729. */
  60730. constructor(name: string);
  60731. /**
  60732. * Gets the current class name
  60733. * @returns the class name
  60734. */
  60735. getClassName(): string;
  60736. /**
  60737. * Gets the intensity input component
  60738. */
  60739. get intensity(): NodeMaterialConnectionPoint;
  60740. /**
  60741. * Gets the index of refraction input component
  60742. */
  60743. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60744. /**
  60745. * Gets the tint at distance input component
  60746. */
  60747. get tintAtDistance(): NodeMaterialConnectionPoint;
  60748. /**
  60749. * Gets the view input component
  60750. */
  60751. get view(): NodeMaterialConnectionPoint;
  60752. /**
  60753. * Gets the refraction object output component
  60754. */
  60755. get refraction(): NodeMaterialConnectionPoint;
  60756. /**
  60757. * Returns true if the block has a texture
  60758. */
  60759. get hasTexture(): boolean;
  60760. protected _getTexture(): Nullable<BaseTexture>;
  60761. autoConfigure(material: NodeMaterial): void;
  60762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60763. isReady(): boolean;
  60764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60765. /**
  60766. * Gets the main code of the block (fragment side)
  60767. * @param state current state of the node material building
  60768. * @returns the shader code
  60769. */
  60770. getCode(state: NodeMaterialBuildState): string;
  60771. protected _buildBlock(state: NodeMaterialBuildState): this;
  60772. protected _dumpPropertiesCode(): string;
  60773. serialize(): any;
  60774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60775. }
  60776. }
  60777. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  60778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60780. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60783. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60785. import { Nullable } from "babylonjs/types";
  60786. import { Scene } from "babylonjs/scene";
  60787. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60788. /**
  60789. * Base block used as input for post process
  60790. */
  60791. export class CurrentScreenBlock extends NodeMaterialBlock {
  60792. private _samplerName;
  60793. private _linearDefineName;
  60794. private _gammaDefineName;
  60795. private _mainUVName;
  60796. private _tempTextureRead;
  60797. /**
  60798. * Gets or sets the texture associated with the node
  60799. */
  60800. texture: Nullable<BaseTexture>;
  60801. /**
  60802. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60803. */
  60804. convertToGammaSpace: boolean;
  60805. /**
  60806. * Gets or sets a boolean indicating if content needs to be converted to linear space
  60807. */
  60808. convertToLinearSpace: boolean;
  60809. /**
  60810. * Create a new CurrentScreenBlock
  60811. * @param name defines the block name
  60812. */
  60813. constructor(name: string);
  60814. /**
  60815. * Gets the current class name
  60816. * @returns the class name
  60817. */
  60818. getClassName(): string;
  60819. /**
  60820. * Gets the uv input component
  60821. */
  60822. get uv(): NodeMaterialConnectionPoint;
  60823. /**
  60824. * Gets the rgba output component
  60825. */
  60826. get rgba(): NodeMaterialConnectionPoint;
  60827. /**
  60828. * Gets the rgb output component
  60829. */
  60830. get rgb(): NodeMaterialConnectionPoint;
  60831. /**
  60832. * Gets the r output component
  60833. */
  60834. get r(): NodeMaterialConnectionPoint;
  60835. /**
  60836. * Gets the g output component
  60837. */
  60838. get g(): NodeMaterialConnectionPoint;
  60839. /**
  60840. * Gets the b output component
  60841. */
  60842. get b(): NodeMaterialConnectionPoint;
  60843. /**
  60844. * Gets the a output component
  60845. */
  60846. get a(): NodeMaterialConnectionPoint;
  60847. /**
  60848. * Initialize the block and prepare the context for build
  60849. * @param state defines the state that will be used for the build
  60850. */
  60851. initialize(state: NodeMaterialBuildState): void;
  60852. get target(): NodeMaterialBlockTargets;
  60853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60854. isReady(): boolean;
  60855. private _injectVertexCode;
  60856. private _writeTextureRead;
  60857. private _writeOutput;
  60858. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60859. serialize(): any;
  60860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60861. }
  60862. }
  60863. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60867. /**
  60868. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60869. */
  60870. export class VectorMergerBlock extends NodeMaterialBlock {
  60871. /**
  60872. * Create a new VectorMergerBlock
  60873. * @param name defines the block name
  60874. */
  60875. constructor(name: string);
  60876. /**
  60877. * Gets the current class name
  60878. * @returns the class name
  60879. */
  60880. getClassName(): string;
  60881. /**
  60882. * Gets the xyz component (input)
  60883. */
  60884. get xyzIn(): NodeMaterialConnectionPoint;
  60885. /**
  60886. * Gets the xy component (input)
  60887. */
  60888. get xyIn(): NodeMaterialConnectionPoint;
  60889. /**
  60890. * Gets the x component (input)
  60891. */
  60892. get x(): NodeMaterialConnectionPoint;
  60893. /**
  60894. * Gets the y component (input)
  60895. */
  60896. get y(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the z component (input)
  60899. */
  60900. get z(): NodeMaterialConnectionPoint;
  60901. /**
  60902. * Gets the w component (input)
  60903. */
  60904. get w(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the xyzw component (output)
  60907. */
  60908. get xyzw(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the xyz component (output)
  60911. */
  60912. get xyzOut(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the xy component (output)
  60915. */
  60916. get xyOut(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the xy component (output)
  60919. * @deprecated Please use xyOut instead.
  60920. */
  60921. get xy(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the xyz component (output)
  60924. * @deprecated Please use xyzOut instead.
  60925. */
  60926. get xyz(): NodeMaterialConnectionPoint;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this;
  60928. }
  60929. }
  60930. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60934. import { Vector2 } from "babylonjs/Maths/math.vector";
  60935. import { Scene } from "babylonjs/scene";
  60936. /**
  60937. * Block used to remap a float from a range to a new one
  60938. */
  60939. export class RemapBlock extends NodeMaterialBlock {
  60940. /**
  60941. * Gets or sets the source range
  60942. */
  60943. sourceRange: Vector2;
  60944. /**
  60945. * Gets or sets the target range
  60946. */
  60947. targetRange: Vector2;
  60948. /**
  60949. * Creates a new RemapBlock
  60950. * @param name defines the block name
  60951. */
  60952. constructor(name: string);
  60953. /**
  60954. * Gets the current class name
  60955. * @returns the class name
  60956. */
  60957. getClassName(): string;
  60958. /**
  60959. * Gets the input component
  60960. */
  60961. get input(): NodeMaterialConnectionPoint;
  60962. /**
  60963. * Gets the source min input component
  60964. */
  60965. get sourceMin(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the source max input component
  60968. */
  60969. get sourceMax(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the target min input component
  60972. */
  60973. get targetMin(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the target max input component
  60976. */
  60977. get targetMax(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the output component
  60980. */
  60981. get output(): NodeMaterialConnectionPoint;
  60982. protected _buildBlock(state: NodeMaterialBuildState): this;
  60983. protected _dumpPropertiesCode(): string;
  60984. serialize(): any;
  60985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60986. }
  60987. }
  60988. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  60989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60992. /**
  60993. * Block used to multiply 2 values
  60994. */
  60995. export class MultiplyBlock extends NodeMaterialBlock {
  60996. /**
  60997. * Creates a new MultiplyBlock
  60998. * @param name defines the block name
  60999. */
  61000. constructor(name: string);
  61001. /**
  61002. * Gets the current class name
  61003. * @returns the class name
  61004. */
  61005. getClassName(): string;
  61006. /**
  61007. * Gets the left operand input component
  61008. */
  61009. get left(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the right operand input component
  61012. */
  61013. get right(): NodeMaterialConnectionPoint;
  61014. /**
  61015. * Gets the output component
  61016. */
  61017. get output(): NodeMaterialConnectionPoint;
  61018. protected _buildBlock(state: NodeMaterialBuildState): this;
  61019. }
  61020. }
  61021. declare module "babylonjs/Materials/Node/nodeMaterial" {
  61022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61023. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  61024. import { Scene } from "babylonjs/scene";
  61025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61026. import { Matrix } from "babylonjs/Maths/math.vector";
  61027. import { Mesh } from "babylonjs/Meshes/mesh";
  61028. import { Engine } from "babylonjs/Engines/engine";
  61029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61030. import { Observable } from "babylonjs/Misc/observable";
  61031. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  61033. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61034. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  61035. import { Nullable } from "babylonjs/types";
  61036. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61037. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61038. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61039. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61040. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61041. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61042. import { Camera } from "babylonjs/Cameras/camera";
  61043. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  61044. /**
  61045. * Interface used to configure the node material editor
  61046. */
  61047. export interface INodeMaterialEditorOptions {
  61048. /** Define the URl to load node editor script */
  61049. editorURL?: string;
  61050. }
  61051. /** @hidden */
  61052. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  61053. NORMAL: boolean;
  61054. TANGENT: boolean;
  61055. UV1: boolean;
  61056. /** BONES */
  61057. NUM_BONE_INFLUENCERS: number;
  61058. BonesPerMesh: number;
  61059. BONETEXTURE: boolean;
  61060. /** MORPH TARGETS */
  61061. MORPHTARGETS: boolean;
  61062. MORPHTARGETS_NORMAL: boolean;
  61063. MORPHTARGETS_TANGENT: boolean;
  61064. MORPHTARGETS_UV: boolean;
  61065. NUM_MORPH_INFLUENCERS: number;
  61066. /** IMAGE PROCESSING */
  61067. IMAGEPROCESSING: boolean;
  61068. VIGNETTE: boolean;
  61069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  61070. VIGNETTEBLENDMODEOPAQUE: boolean;
  61071. TONEMAPPING: boolean;
  61072. TONEMAPPING_ACES: boolean;
  61073. CONTRAST: boolean;
  61074. EXPOSURE: boolean;
  61075. COLORCURVES: boolean;
  61076. COLORGRADING: boolean;
  61077. COLORGRADING3D: boolean;
  61078. SAMPLER3DGREENDEPTH: boolean;
  61079. SAMPLER3DBGRMAP: boolean;
  61080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  61081. /** MISC. */
  61082. BUMPDIRECTUV: number;
  61083. constructor();
  61084. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  61085. }
  61086. /**
  61087. * Class used to configure NodeMaterial
  61088. */
  61089. export interface INodeMaterialOptions {
  61090. /**
  61091. * Defines if blocks should emit comments
  61092. */
  61093. emitComments: boolean;
  61094. }
  61095. /**
  61096. * Class used to create a node based material built by assembling shader blocks
  61097. */
  61098. export class NodeMaterial extends PushMaterial {
  61099. private static _BuildIdGenerator;
  61100. private _options;
  61101. private _vertexCompilationState;
  61102. private _fragmentCompilationState;
  61103. private _sharedData;
  61104. private _buildId;
  61105. private _buildWasSuccessful;
  61106. private _cachedWorldViewMatrix;
  61107. private _cachedWorldViewProjectionMatrix;
  61108. private _optimizers;
  61109. private _animationFrame;
  61110. /** Define the Url to load node editor script */
  61111. static EditorURL: string;
  61112. /** Define the Url to load snippets */
  61113. static SnippetUrl: string;
  61114. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  61115. static IgnoreTexturesAtLoadTime: boolean;
  61116. private BJSNODEMATERIALEDITOR;
  61117. /** Get the inspector from bundle or global */
  61118. private _getGlobalNodeMaterialEditor;
  61119. /**
  61120. * Snippet ID if the material was created from the snippet server
  61121. */
  61122. snippetId: string;
  61123. /**
  61124. * Gets or sets data used by visual editor
  61125. * @see https://nme.babylonjs.com
  61126. */
  61127. editorData: any;
  61128. /**
  61129. * 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)
  61130. */
  61131. ignoreAlpha: boolean;
  61132. /**
  61133. * Defines the maximum number of lights that can be used in the material
  61134. */
  61135. maxSimultaneousLights: number;
  61136. /**
  61137. * Observable raised when the material is built
  61138. */
  61139. onBuildObservable: Observable<NodeMaterial>;
  61140. /**
  61141. * Gets or sets the root nodes of the material vertex shader
  61142. */
  61143. _vertexOutputNodes: NodeMaterialBlock[];
  61144. /**
  61145. * Gets or sets the root nodes of the material fragment (pixel) shader
  61146. */
  61147. _fragmentOutputNodes: NodeMaterialBlock[];
  61148. /** Gets or sets options to control the node material overall behavior */
  61149. get options(): INodeMaterialOptions;
  61150. set options(options: INodeMaterialOptions);
  61151. /**
  61152. * Default configuration related to image processing available in the standard Material.
  61153. */
  61154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61155. /**
  61156. * Gets the image processing configuration used either in this material.
  61157. */
  61158. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  61159. /**
  61160. * Sets the Default image processing configuration used either in the this material.
  61161. *
  61162. * If sets to null, the scene one is in use.
  61163. */
  61164. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  61165. /**
  61166. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  61167. */
  61168. attachedBlocks: NodeMaterialBlock[];
  61169. /**
  61170. * Specifies the mode of the node material
  61171. * @hidden
  61172. */
  61173. _mode: NodeMaterialModes;
  61174. /**
  61175. * Gets the mode property
  61176. */
  61177. get mode(): NodeMaterialModes;
  61178. /**
  61179. * Create a new node based material
  61180. * @param name defines the material name
  61181. * @param scene defines the hosting scene
  61182. * @param options defines creation option
  61183. */
  61184. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  61185. /**
  61186. * Gets the current class name of the material e.g. "NodeMaterial"
  61187. * @returns the class name
  61188. */
  61189. getClassName(): string;
  61190. /**
  61191. * Keep track of the image processing observer to allow dispose and replace.
  61192. */
  61193. private _imageProcessingObserver;
  61194. /**
  61195. * Attaches a new image processing configuration to the Standard Material.
  61196. * @param configuration
  61197. */
  61198. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61199. /**
  61200. * Get a block by its name
  61201. * @param name defines the name of the block to retrieve
  61202. * @returns the required block or null if not found
  61203. */
  61204. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  61205. /**
  61206. * Get a block by its name
  61207. * @param predicate defines the predicate used to find the good candidate
  61208. * @returns the required block or null if not found
  61209. */
  61210. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  61211. /**
  61212. * Get an input block by its name
  61213. * @param predicate defines the predicate used to find the good candidate
  61214. * @returns the required input block or null if not found
  61215. */
  61216. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  61217. /**
  61218. * Gets the list of input blocks attached to this material
  61219. * @returns an array of InputBlocks
  61220. */
  61221. getInputBlocks(): InputBlock[];
  61222. /**
  61223. * Adds a new optimizer to the list of optimizers
  61224. * @param optimizer defines the optimizers to add
  61225. * @returns the current material
  61226. */
  61227. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61228. /**
  61229. * Remove an optimizer from the list of optimizers
  61230. * @param optimizer defines the optimizers to remove
  61231. * @returns the current material
  61232. */
  61233. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  61234. /**
  61235. * Add a new block to the list of output nodes
  61236. * @param node defines the node to add
  61237. * @returns the current material
  61238. */
  61239. addOutputNode(node: NodeMaterialBlock): this;
  61240. /**
  61241. * Remove a block from the list of root nodes
  61242. * @param node defines the node to remove
  61243. * @returns the current material
  61244. */
  61245. removeOutputNode(node: NodeMaterialBlock): this;
  61246. private _addVertexOutputNode;
  61247. private _removeVertexOutputNode;
  61248. private _addFragmentOutputNode;
  61249. private _removeFragmentOutputNode;
  61250. /**
  61251. * Specifies if the material will require alpha blending
  61252. * @returns a boolean specifying if alpha blending is needed
  61253. */
  61254. needAlphaBlending(): boolean;
  61255. /**
  61256. * Specifies if this material should be rendered in alpha test mode
  61257. * @returns a boolean specifying if an alpha test is needed.
  61258. */
  61259. needAlphaTesting(): boolean;
  61260. private _initializeBlock;
  61261. private _resetDualBlocks;
  61262. /**
  61263. * Remove a block from the current node material
  61264. * @param block defines the block to remove
  61265. */
  61266. removeBlock(block: NodeMaterialBlock): void;
  61267. /**
  61268. * Build the material and generates the inner effect
  61269. * @param verbose defines if the build should log activity
  61270. */
  61271. build(verbose?: boolean): void;
  61272. /**
  61273. * Runs an otpimization phase to try to improve the shader code
  61274. */
  61275. optimize(): void;
  61276. private _prepareDefinesForAttributes;
  61277. /**
  61278. * Create a post process from the material
  61279. * @param camera The camera to apply the render pass to.
  61280. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  61281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61282. * @param engine The engine which the post process will be applied. (default: current engine)
  61283. * @param reusable If the post process can be reused on the same frame. (default: false)
  61284. * @param textureType Type of textures used when performing the post process. (default: 0)
  61285. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  61286. * @returns the post process created
  61287. */
  61288. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  61289. private _processDefines;
  61290. /**
  61291. * Get if the submesh is ready to be used and all its information available.
  61292. * Child classes can use it to update shaders
  61293. * @param mesh defines the mesh to check
  61294. * @param subMesh defines which submesh to check
  61295. * @param useInstances specifies that instances should be used
  61296. * @returns a boolean indicating that the submesh is ready or not
  61297. */
  61298. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61299. /**
  61300. * Get a string representing the shaders built by the current node graph
  61301. */
  61302. get compiledShaders(): string;
  61303. /**
  61304. * Binds the world matrix to the material
  61305. * @param world defines the world transformation matrix
  61306. */
  61307. bindOnlyWorldMatrix(world: Matrix): void;
  61308. /**
  61309. * Binds the submesh to this material by preparing the effect and shader to draw
  61310. * @param world defines the world transformation matrix
  61311. * @param mesh defines the mesh containing the submesh
  61312. * @param subMesh defines the submesh to bind the material to
  61313. */
  61314. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61315. /**
  61316. * Gets the active textures from the material
  61317. * @returns an array of textures
  61318. */
  61319. getActiveTextures(): BaseTexture[];
  61320. /**
  61321. * Gets the list of texture blocks
  61322. * @returns an array of texture blocks
  61323. */
  61324. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  61325. /**
  61326. * Specifies if the material uses a texture
  61327. * @param texture defines the texture to check against the material
  61328. * @returns a boolean specifying if the material uses the texture
  61329. */
  61330. hasTexture(texture: BaseTexture): boolean;
  61331. /**
  61332. * Disposes the material
  61333. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61334. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61335. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61336. */
  61337. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61338. /** Creates the node editor window. */
  61339. private _createNodeEditor;
  61340. /**
  61341. * Launch the node material editor
  61342. * @param config Define the configuration of the editor
  61343. * @return a promise fulfilled when the node editor is visible
  61344. */
  61345. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61346. /**
  61347. * Clear the current material
  61348. */
  61349. clear(): void;
  61350. /**
  61351. * Clear the current material and set it to a default state
  61352. */
  61353. setToDefault(): void;
  61354. /**
  61355. * Clear the current material and set it to a default state for post process
  61356. */
  61357. setToDefaultPostProcess(): void;
  61358. /**
  61359. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61360. * @param url defines the url to load from
  61361. * @returns a promise that will fullfil when the material is fully loaded
  61362. */
  61363. loadAsync(url: string): Promise<void>;
  61364. private _gatherBlocks;
  61365. /**
  61366. * Generate a string containing the code declaration required to create an equivalent of this material
  61367. * @returns a string
  61368. */
  61369. generateCode(): string;
  61370. /**
  61371. * Serializes this material in a JSON representation
  61372. * @returns the serialized material object
  61373. */
  61374. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61375. private _restoreConnections;
  61376. /**
  61377. * Clear the current graph and load a new one from a serialization object
  61378. * @param source defines the JSON representation of the material
  61379. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61380. */
  61381. loadFromSerialization(source: any, rootUrl?: string): void;
  61382. /**
  61383. * Makes a duplicate of the current material.
  61384. * @param name - name to use for the new material.
  61385. */
  61386. clone(name: string): NodeMaterial;
  61387. /**
  61388. * Creates a node material from parsed material data
  61389. * @param source defines the JSON representation of the material
  61390. * @param scene defines the hosting scene
  61391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61392. * @returns a new node material
  61393. */
  61394. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61395. /**
  61396. * Creates a node material from a snippet saved in a remote file
  61397. * @param name defines the name of the material to create
  61398. * @param url defines the url to load from
  61399. * @param scene defines the hosting scene
  61400. * @returns a promise that will resolve to the new node material
  61401. */
  61402. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61403. /**
  61404. * Creates a node material from a snippet saved by the node material editor
  61405. * @param snippetId defines the snippet to load
  61406. * @param scene defines the hosting scene
  61407. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61408. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61409. * @returns a promise that will resolve to the new node material
  61410. */
  61411. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61412. /**
  61413. * Creates a new node material set to default basic configuration
  61414. * @param name defines the name of the material
  61415. * @param scene defines the hosting scene
  61416. * @returns a new NodeMaterial
  61417. */
  61418. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61419. }
  61420. }
  61421. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61424. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61427. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61428. import { Effect } from "babylonjs/Materials/effect";
  61429. import { Mesh } from "babylonjs/Meshes/mesh";
  61430. import { Nullable } from "babylonjs/types";
  61431. import { Texture } from "babylonjs/Materials/Textures/texture";
  61432. import { Scene } from "babylonjs/scene";
  61433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61434. /**
  61435. * Block used to read a texture from a sampler
  61436. */
  61437. export class TextureBlock extends NodeMaterialBlock {
  61438. private _defineName;
  61439. private _linearDefineName;
  61440. private _gammaDefineName;
  61441. private _tempTextureRead;
  61442. private _samplerName;
  61443. private _transformedUVName;
  61444. private _textureTransformName;
  61445. private _textureInfoName;
  61446. private _mainUVName;
  61447. private _mainUVDefineName;
  61448. /**
  61449. * Gets or sets the texture associated with the node
  61450. */
  61451. texture: Nullable<Texture>;
  61452. /**
  61453. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61454. */
  61455. convertToGammaSpace: boolean;
  61456. /**
  61457. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61458. */
  61459. convertToLinearSpace: boolean;
  61460. /**
  61461. * Create a new TextureBlock
  61462. * @param name defines the block name
  61463. */
  61464. constructor(name: string);
  61465. /**
  61466. * Gets the current class name
  61467. * @returns the class name
  61468. */
  61469. getClassName(): string;
  61470. /**
  61471. * Gets the uv input component
  61472. */
  61473. get uv(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the rgba output component
  61476. */
  61477. get rgba(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the rgb output component
  61480. */
  61481. get rgb(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the r output component
  61484. */
  61485. get r(): NodeMaterialConnectionPoint;
  61486. /**
  61487. * Gets the g output component
  61488. */
  61489. get g(): NodeMaterialConnectionPoint;
  61490. /**
  61491. * Gets the b output component
  61492. */
  61493. get b(): NodeMaterialConnectionPoint;
  61494. /**
  61495. * Gets the a output component
  61496. */
  61497. get a(): NodeMaterialConnectionPoint;
  61498. get target(): NodeMaterialBlockTargets;
  61499. autoConfigure(material: NodeMaterial): void;
  61500. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61502. isReady(): boolean;
  61503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61504. private get _isMixed();
  61505. private _injectVertexCode;
  61506. private _writeTextureRead;
  61507. private _writeOutput;
  61508. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61509. protected _dumpPropertiesCode(): string;
  61510. serialize(): any;
  61511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61512. }
  61513. }
  61514. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61517. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61518. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61519. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61520. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61521. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  61522. import { Scene } from "babylonjs/scene";
  61523. /**
  61524. * Class used to store shared data between 2 NodeMaterialBuildState
  61525. */
  61526. export class NodeMaterialBuildStateSharedData {
  61527. /**
  61528. * Gets the list of emitted varyings
  61529. */
  61530. temps: string[];
  61531. /**
  61532. * Gets the list of emitted varyings
  61533. */
  61534. varyings: string[];
  61535. /**
  61536. * Gets the varying declaration string
  61537. */
  61538. varyingDeclaration: string;
  61539. /**
  61540. * Input blocks
  61541. */
  61542. inputBlocks: InputBlock[];
  61543. /**
  61544. * Input blocks
  61545. */
  61546. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  61547. /**
  61548. * Bindable blocks (Blocks that need to set data to the effect)
  61549. */
  61550. bindableBlocks: NodeMaterialBlock[];
  61551. /**
  61552. * List of blocks that can provide a compilation fallback
  61553. */
  61554. blocksWithFallbacks: NodeMaterialBlock[];
  61555. /**
  61556. * List of blocks that can provide a define update
  61557. */
  61558. blocksWithDefines: NodeMaterialBlock[];
  61559. /**
  61560. * List of blocks that can provide a repeatable content
  61561. */
  61562. repeatableContentBlocks: NodeMaterialBlock[];
  61563. /**
  61564. * List of blocks that can provide a dynamic list of uniforms
  61565. */
  61566. dynamicUniformBlocks: NodeMaterialBlock[];
  61567. /**
  61568. * List of blocks that can block the isReady function for the material
  61569. */
  61570. blockingBlocks: NodeMaterialBlock[];
  61571. /**
  61572. * Gets the list of animated inputs
  61573. */
  61574. animatedInputs: InputBlock[];
  61575. /**
  61576. * Build Id used to avoid multiple recompilations
  61577. */
  61578. buildId: number;
  61579. /** List of emitted variables */
  61580. variableNames: {
  61581. [key: string]: number;
  61582. };
  61583. /** List of emitted defines */
  61584. defineNames: {
  61585. [key: string]: number;
  61586. };
  61587. /** Should emit comments? */
  61588. emitComments: boolean;
  61589. /** Emit build activity */
  61590. verbose: boolean;
  61591. /** Gets or sets the hosting scene */
  61592. scene: Scene;
  61593. /**
  61594. * Gets the compilation hints emitted at compilation time
  61595. */
  61596. hints: {
  61597. needWorldViewMatrix: boolean;
  61598. needWorldViewProjectionMatrix: boolean;
  61599. needAlphaBlending: boolean;
  61600. needAlphaTesting: boolean;
  61601. };
  61602. /**
  61603. * List of compilation checks
  61604. */
  61605. checks: {
  61606. emitVertex: boolean;
  61607. emitFragment: boolean;
  61608. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61609. };
  61610. /** Creates a new shared data */
  61611. constructor();
  61612. /**
  61613. * Emits console errors and exceptions if there is a failing check
  61614. */
  61615. emitErrors(): void;
  61616. }
  61617. }
  61618. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61619. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61620. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61621. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61622. /**
  61623. * Class used to store node based material build state
  61624. */
  61625. export class NodeMaterialBuildState {
  61626. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61627. supportUniformBuffers: boolean;
  61628. /**
  61629. * Gets the list of emitted attributes
  61630. */
  61631. attributes: string[];
  61632. /**
  61633. * Gets the list of emitted uniforms
  61634. */
  61635. uniforms: string[];
  61636. /**
  61637. * Gets the list of emitted constants
  61638. */
  61639. constants: string[];
  61640. /**
  61641. * Gets the list of emitted samplers
  61642. */
  61643. samplers: string[];
  61644. /**
  61645. * Gets the list of emitted functions
  61646. */
  61647. functions: {
  61648. [key: string]: string;
  61649. };
  61650. /**
  61651. * Gets the list of emitted extensions
  61652. */
  61653. extensions: {
  61654. [key: string]: string;
  61655. };
  61656. /**
  61657. * Gets the target of the compilation state
  61658. */
  61659. target: NodeMaterialBlockTargets;
  61660. /**
  61661. * Gets the list of emitted counters
  61662. */
  61663. counters: {
  61664. [key: string]: number;
  61665. };
  61666. /**
  61667. * Shared data between multiple NodeMaterialBuildState instances
  61668. */
  61669. sharedData: NodeMaterialBuildStateSharedData;
  61670. /** @hidden */
  61671. _vertexState: NodeMaterialBuildState;
  61672. /** @hidden */
  61673. _attributeDeclaration: string;
  61674. /** @hidden */
  61675. _uniformDeclaration: string;
  61676. /** @hidden */
  61677. _constantDeclaration: string;
  61678. /** @hidden */
  61679. _samplerDeclaration: string;
  61680. /** @hidden */
  61681. _varyingTransfer: string;
  61682. /** @hidden */
  61683. _injectAtEnd: string;
  61684. private _repeatableContentAnchorIndex;
  61685. /** @hidden */
  61686. _builtCompilationString: string;
  61687. /**
  61688. * Gets the emitted compilation strings
  61689. */
  61690. compilationString: string;
  61691. /**
  61692. * Finalize the compilation strings
  61693. * @param state defines the current compilation state
  61694. */
  61695. finalize(state: NodeMaterialBuildState): void;
  61696. /** @hidden */
  61697. get _repeatableContentAnchor(): string;
  61698. /** @hidden */
  61699. _getFreeVariableName(prefix: string): string;
  61700. /** @hidden */
  61701. _getFreeDefineName(prefix: string): string;
  61702. /** @hidden */
  61703. _excludeVariableName(name: string): void;
  61704. /** @hidden */
  61705. _emit2DSampler(name: string): void;
  61706. /** @hidden */
  61707. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61708. /** @hidden */
  61709. _emitExtension(name: string, extension: string, define?: string): void;
  61710. /** @hidden */
  61711. _emitFunction(name: string, code: string, comments: string): void;
  61712. /** @hidden */
  61713. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61714. replaceStrings?: {
  61715. search: RegExp;
  61716. replace: string;
  61717. }[];
  61718. repeatKey?: string;
  61719. }): string;
  61720. /** @hidden */
  61721. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61722. repeatKey?: string;
  61723. removeAttributes?: boolean;
  61724. removeUniforms?: boolean;
  61725. removeVaryings?: boolean;
  61726. removeIfDef?: boolean;
  61727. replaceStrings?: {
  61728. search: RegExp;
  61729. replace: string;
  61730. }[];
  61731. }, storeKey?: string): void;
  61732. /** @hidden */
  61733. _registerTempVariable(name: string): boolean;
  61734. /** @hidden */
  61735. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61736. /** @hidden */
  61737. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61738. /** @hidden */
  61739. _emitFloat(value: number): string;
  61740. }
  61741. }
  61742. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61743. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61745. import { Nullable } from "babylonjs/types";
  61746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61747. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61748. import { Effect } from "babylonjs/Materials/effect";
  61749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61750. import { Mesh } from "babylonjs/Meshes/mesh";
  61751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61752. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61753. import { Scene } from "babylonjs/scene";
  61754. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61755. /**
  61756. * Defines a block that can be used inside a node based material
  61757. */
  61758. export class NodeMaterialBlock {
  61759. private _buildId;
  61760. private _buildTarget;
  61761. private _target;
  61762. private _isFinalMerger;
  61763. private _isInput;
  61764. protected _isUnique: boolean;
  61765. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61766. inputsAreExclusive: boolean;
  61767. /** @hidden */
  61768. _codeVariableName: string;
  61769. /** @hidden */
  61770. _inputs: NodeMaterialConnectionPoint[];
  61771. /** @hidden */
  61772. _outputs: NodeMaterialConnectionPoint[];
  61773. /** @hidden */
  61774. _preparationId: number;
  61775. /**
  61776. * Gets or sets the name of the block
  61777. */
  61778. name: string;
  61779. /**
  61780. * Gets or sets the unique id of the node
  61781. */
  61782. uniqueId: number;
  61783. /**
  61784. * Gets or sets the comments associated with this block
  61785. */
  61786. comments: string;
  61787. /**
  61788. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61789. */
  61790. get isUnique(): boolean;
  61791. /**
  61792. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61793. */
  61794. get isFinalMerger(): boolean;
  61795. /**
  61796. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61797. */
  61798. get isInput(): boolean;
  61799. /**
  61800. * Gets or sets the build Id
  61801. */
  61802. get buildId(): number;
  61803. set buildId(value: number);
  61804. /**
  61805. * Gets or sets the target of the block
  61806. */
  61807. get target(): NodeMaterialBlockTargets;
  61808. set target(value: NodeMaterialBlockTargets);
  61809. /**
  61810. * Gets the list of input points
  61811. */
  61812. get inputs(): NodeMaterialConnectionPoint[];
  61813. /** Gets the list of output points */
  61814. get outputs(): NodeMaterialConnectionPoint[];
  61815. /**
  61816. * Find an input by its name
  61817. * @param name defines the name of the input to look for
  61818. * @returns the input or null if not found
  61819. */
  61820. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61821. /**
  61822. * Find an output by its name
  61823. * @param name defines the name of the outputto look for
  61824. * @returns the output or null if not found
  61825. */
  61826. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61827. /**
  61828. * Creates a new NodeMaterialBlock
  61829. * @param name defines the block name
  61830. * @param target defines the target of that block (Vertex by default)
  61831. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61832. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61833. */
  61834. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61835. /**
  61836. * Initialize the block and prepare the context for build
  61837. * @param state defines the state that will be used for the build
  61838. */
  61839. initialize(state: NodeMaterialBuildState): void;
  61840. /**
  61841. * Bind data to effect. Will only be called for blocks with isBindable === true
  61842. * @param effect defines the effect to bind data to
  61843. * @param nodeMaterial defines the hosting NodeMaterial
  61844. * @param mesh defines the mesh that will be rendered
  61845. * @param subMesh defines the submesh that will be rendered
  61846. */
  61847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61848. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61849. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61850. protected _writeFloat(value: number): string;
  61851. /**
  61852. * Gets the current class name e.g. "NodeMaterialBlock"
  61853. * @returns the class name
  61854. */
  61855. getClassName(): string;
  61856. /**
  61857. * Register a new input. Must be called inside a block constructor
  61858. * @param name defines the connection point name
  61859. * @param type defines the connection point type
  61860. * @param isOptional defines a boolean indicating that this input can be omitted
  61861. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61862. * @param point an already created connection point. If not provided, create a new one
  61863. * @returns the current block
  61864. */
  61865. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61866. /**
  61867. * Register a new output. Must be called inside a block constructor
  61868. * @param name defines the connection point name
  61869. * @param type defines the connection point type
  61870. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61871. * @param point an already created connection point. If not provided, create a new one
  61872. * @returns the current block
  61873. */
  61874. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61875. /**
  61876. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61877. * @param forOutput defines an optional connection point to check compatibility with
  61878. * @returns the first available input or null
  61879. */
  61880. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61881. /**
  61882. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61883. * @param forBlock defines an optional block to check compatibility with
  61884. * @returns the first available input or null
  61885. */
  61886. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61887. /**
  61888. * Gets the sibling of the given output
  61889. * @param current defines the current output
  61890. * @returns the next output in the list or null
  61891. */
  61892. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61893. /**
  61894. * Connect current block with another block
  61895. * @param other defines the block to connect with
  61896. * @param options define the various options to help pick the right connections
  61897. * @returns the current block
  61898. */
  61899. connectTo(other: NodeMaterialBlock, options?: {
  61900. input?: string;
  61901. output?: string;
  61902. outputSwizzle?: string;
  61903. }): this | undefined;
  61904. protected _buildBlock(state: NodeMaterialBuildState): void;
  61905. /**
  61906. * Add uniforms, samplers and uniform buffers at compilation time
  61907. * @param state defines the state to update
  61908. * @param nodeMaterial defines the node material requesting the update
  61909. * @param defines defines the material defines to update
  61910. * @param uniformBuffers defines the list of uniform buffer names
  61911. */
  61912. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61913. /**
  61914. * Add potential fallbacks if shader compilation fails
  61915. * @param mesh defines the mesh to be rendered
  61916. * @param fallbacks defines the current prioritized list of fallbacks
  61917. */
  61918. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61919. /**
  61920. * Initialize defines for shader compilation
  61921. * @param mesh defines the mesh to be rendered
  61922. * @param nodeMaterial defines the node material requesting the update
  61923. * @param defines defines the material defines to update
  61924. * @param useInstances specifies that instances should be used
  61925. */
  61926. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61927. /**
  61928. * Update defines for shader compilation
  61929. * @param mesh defines the mesh to be rendered
  61930. * @param nodeMaterial defines the node material requesting the update
  61931. * @param defines defines the material defines to update
  61932. * @param useInstances specifies that instances should be used
  61933. */
  61934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61935. /**
  61936. * Lets the block try to connect some inputs automatically
  61937. * @param material defines the hosting NodeMaterial
  61938. */
  61939. autoConfigure(material: NodeMaterial): void;
  61940. /**
  61941. * Function called when a block is declared as repeatable content generator
  61942. * @param vertexShaderState defines the current compilation state for the vertex shader
  61943. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61944. * @param mesh defines the mesh to be rendered
  61945. * @param defines defines the material defines to update
  61946. */
  61947. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61948. /**
  61949. * Checks if the block is ready
  61950. * @param mesh defines the mesh to be rendered
  61951. * @param nodeMaterial defines the node material requesting the update
  61952. * @param defines defines the material defines to update
  61953. * @param useInstances specifies that instances should be used
  61954. * @returns true if the block is ready
  61955. */
  61956. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61957. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61958. private _processBuild;
  61959. /**
  61960. * Compile the current node and generate the shader code
  61961. * @param state defines the current compilation state (uniforms, samplers, current string)
  61962. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61963. * @returns true if already built
  61964. */
  61965. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61966. protected _inputRename(name: string): string;
  61967. protected _outputRename(name: string): string;
  61968. protected _dumpPropertiesCode(): string;
  61969. /** @hidden */
  61970. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61971. /** @hidden */
  61972. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61973. /**
  61974. * Clone the current block to a new identical block
  61975. * @param scene defines the hosting scene
  61976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61977. * @returns a copy of the current block
  61978. */
  61979. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61980. /**
  61981. * Serializes this block in a JSON representation
  61982. * @returns the serialized block object
  61983. */
  61984. serialize(): any;
  61985. /** @hidden */
  61986. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61987. private _deserializePortDisplayNames;
  61988. /**
  61989. * Release resources
  61990. */
  61991. dispose(): void;
  61992. }
  61993. }
  61994. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61995. /**
  61996. * Enum defining the type of animations supported by InputBlock
  61997. */
  61998. export enum AnimatedInputBlockTypes {
  61999. /** No animation */
  62000. None = 0,
  62001. /** Time based animation. Will only work for floats */
  62002. Time = 1
  62003. }
  62004. }
  62005. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  62006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62007. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62008. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  62009. import { Nullable } from "babylonjs/types";
  62010. import { Effect } from "babylonjs/Materials/effect";
  62011. import { Matrix } from "babylonjs/Maths/math.vector";
  62012. import { Scene } from "babylonjs/scene";
  62013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62016. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62017. import { Observable } from "babylonjs/Misc/observable";
  62018. /**
  62019. * Block used to expose an input value
  62020. */
  62021. export class InputBlock extends NodeMaterialBlock {
  62022. private _mode;
  62023. private _associatedVariableName;
  62024. private _storedValue;
  62025. private _valueCallback;
  62026. private _type;
  62027. private _animationType;
  62028. /** Gets or set a value used to limit the range of float values */
  62029. min: number;
  62030. /** Gets or set a value used to limit the range of float values */
  62031. max: number;
  62032. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  62033. isBoolean: boolean;
  62034. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  62035. matrixMode: number;
  62036. /** @hidden */
  62037. _systemValue: Nullable<NodeMaterialSystemValues>;
  62038. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  62039. visibleInInspector: boolean;
  62040. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  62041. isConstant: boolean;
  62042. /** Gets or sets the group to use to display this block in the Inspector */
  62043. groupInInspector: string;
  62044. /** Gets an observable raised when the value is changed */
  62045. onValueChangedObservable: Observable<InputBlock>;
  62046. /**
  62047. * Gets or sets the connection point type (default is float)
  62048. */
  62049. get type(): NodeMaterialBlockConnectionPointTypes;
  62050. /**
  62051. * Creates a new InputBlock
  62052. * @param name defines the block name
  62053. * @param target defines the target of that block (Vertex by default)
  62054. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  62055. */
  62056. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  62057. /**
  62058. * Gets the output component
  62059. */
  62060. get output(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Set the source of this connection point to a vertex attribute
  62063. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  62064. * @returns the current connection point
  62065. */
  62066. setAsAttribute(attributeName?: string): InputBlock;
  62067. /**
  62068. * Set the source of this connection point to a system value
  62069. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  62070. * @returns the current connection point
  62071. */
  62072. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  62073. /**
  62074. * Gets or sets the value of that point.
  62075. * Please note that this value will be ignored if valueCallback is defined
  62076. */
  62077. get value(): any;
  62078. set value(value: any);
  62079. /**
  62080. * Gets or sets a callback used to get the value of that point.
  62081. * Please note that setting this value will force the connection point to ignore the value property
  62082. */
  62083. get valueCallback(): () => any;
  62084. set valueCallback(value: () => any);
  62085. /**
  62086. * Gets or sets the associated variable name in the shader
  62087. */
  62088. get associatedVariableName(): string;
  62089. set associatedVariableName(value: string);
  62090. /** Gets or sets the type of animation applied to the input */
  62091. get animationType(): AnimatedInputBlockTypes;
  62092. set animationType(value: AnimatedInputBlockTypes);
  62093. /**
  62094. * Gets a boolean indicating that this connection point not defined yet
  62095. */
  62096. get isUndefined(): boolean;
  62097. /**
  62098. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  62099. * In this case the connection point name must be the name of the uniform to use.
  62100. * Can only be set on inputs
  62101. */
  62102. get isUniform(): boolean;
  62103. set isUniform(value: boolean);
  62104. /**
  62105. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  62106. * In this case the connection point name must be the name of the attribute to use
  62107. * Can only be set on inputs
  62108. */
  62109. get isAttribute(): boolean;
  62110. set isAttribute(value: boolean);
  62111. /**
  62112. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  62113. * Can only be set on exit points
  62114. */
  62115. get isVarying(): boolean;
  62116. set isVarying(value: boolean);
  62117. /**
  62118. * Gets a boolean indicating that the current connection point is a system value
  62119. */
  62120. get isSystemValue(): boolean;
  62121. /**
  62122. * Gets or sets the current well known value or null if not defined as a system value
  62123. */
  62124. get systemValue(): Nullable<NodeMaterialSystemValues>;
  62125. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  62126. /**
  62127. * Gets the current class name
  62128. * @returns the class name
  62129. */
  62130. getClassName(): string;
  62131. /**
  62132. * Animate the input if animationType !== None
  62133. * @param scene defines the rendering scene
  62134. */
  62135. animate(scene: Scene): void;
  62136. private _emitDefine;
  62137. initialize(state: NodeMaterialBuildState): void;
  62138. /**
  62139. * Set the input block to its default value (based on its type)
  62140. */
  62141. setDefaultValue(): void;
  62142. private _emitConstant;
  62143. private _emit;
  62144. /** @hidden */
  62145. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  62146. /** @hidden */
  62147. _transmit(effect: Effect, scene: Scene): void;
  62148. protected _buildBlock(state: NodeMaterialBuildState): void;
  62149. protected _dumpPropertiesCode(): string;
  62150. dispose(): void;
  62151. serialize(): any;
  62152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62153. }
  62154. }
  62155. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  62156. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  62157. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  62158. import { Nullable } from "babylonjs/types";
  62159. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62160. import { Observable } from "babylonjs/Misc/observable";
  62161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62162. /**
  62163. * Enum used to define the compatibility state between two connection points
  62164. */
  62165. export enum NodeMaterialConnectionPointCompatibilityStates {
  62166. /** Points are compatibles */
  62167. Compatible = 0,
  62168. /** Points are incompatible because of their types */
  62169. TypeIncompatible = 1,
  62170. /** Points are incompatible because of their targets (vertex vs fragment) */
  62171. TargetIncompatible = 2
  62172. }
  62173. /**
  62174. * Defines the direction of a connection point
  62175. */
  62176. export enum NodeMaterialConnectionPointDirection {
  62177. /** Input */
  62178. Input = 0,
  62179. /** Output */
  62180. Output = 1
  62181. }
  62182. /**
  62183. * Defines a connection point for a block
  62184. */
  62185. export class NodeMaterialConnectionPoint {
  62186. /** @hidden */
  62187. _ownerBlock: NodeMaterialBlock;
  62188. /** @hidden */
  62189. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  62190. private _endpoints;
  62191. private _associatedVariableName;
  62192. private _direction;
  62193. /** @hidden */
  62194. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62195. /** @hidden */
  62196. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  62197. private _type;
  62198. /** @hidden */
  62199. _enforceAssociatedVariableName: boolean;
  62200. /** Gets the direction of the point */
  62201. get direction(): NodeMaterialConnectionPointDirection;
  62202. /** Indicates that this connection point needs dual validation before being connected to another point */
  62203. needDualDirectionValidation: boolean;
  62204. /**
  62205. * Gets or sets the additional types supported by this connection point
  62206. */
  62207. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62208. /**
  62209. * Gets or sets the additional types excluded by this connection point
  62210. */
  62211. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  62212. /**
  62213. * Observable triggered when this point is connected
  62214. */
  62215. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  62216. /**
  62217. * Gets or sets the associated variable name in the shader
  62218. */
  62219. get associatedVariableName(): string;
  62220. set associatedVariableName(value: string);
  62221. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  62222. get innerType(): NodeMaterialBlockConnectionPointTypes;
  62223. /**
  62224. * Gets or sets the connection point type (default is float)
  62225. */
  62226. get type(): NodeMaterialBlockConnectionPointTypes;
  62227. set type(value: NodeMaterialBlockConnectionPointTypes);
  62228. /**
  62229. * Gets or sets the connection point name
  62230. */
  62231. name: string;
  62232. /**
  62233. * Gets or sets the connection point name
  62234. */
  62235. displayName: string;
  62236. /**
  62237. * Gets or sets a boolean indicating that this connection point can be omitted
  62238. */
  62239. isOptional: boolean;
  62240. /**
  62241. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  62242. */
  62243. define: string;
  62244. /** @hidden */
  62245. _prioritizeVertex: boolean;
  62246. private _target;
  62247. /** Gets or sets the target of that connection point */
  62248. get target(): NodeMaterialBlockTargets;
  62249. set target(value: NodeMaterialBlockTargets);
  62250. /**
  62251. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  62252. */
  62253. get isConnected(): boolean;
  62254. /**
  62255. * Gets a boolean indicating that the current point is connected to an input block
  62256. */
  62257. get isConnectedToInputBlock(): boolean;
  62258. /**
  62259. * Gets a the connected input block (if any)
  62260. */
  62261. get connectInputBlock(): Nullable<InputBlock>;
  62262. /** Get the other side of the connection (if any) */
  62263. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  62264. /** Get the block that owns this connection point */
  62265. get ownerBlock(): NodeMaterialBlock;
  62266. /** Get the block connected on the other side of this connection (if any) */
  62267. get sourceBlock(): Nullable<NodeMaterialBlock>;
  62268. /** Get the block connected on the endpoints of this connection (if any) */
  62269. get connectedBlocks(): Array<NodeMaterialBlock>;
  62270. /** Gets the list of connected endpoints */
  62271. get endpoints(): NodeMaterialConnectionPoint[];
  62272. /** Gets a boolean indicating if that output point is connected to at least one input */
  62273. get hasEndpoints(): boolean;
  62274. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  62275. get isConnectedInVertexShader(): boolean;
  62276. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  62277. get isConnectedInFragmentShader(): boolean;
  62278. /**
  62279. * Creates a block suitable to be used as an input for this input point.
  62280. * If null is returned, a block based on the point type will be created.
  62281. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  62282. */
  62283. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  62284. /**
  62285. * Creates a new connection point
  62286. * @param name defines the connection point name
  62287. * @param ownerBlock defines the block hosting this connection point
  62288. * @param direction defines the direction of the connection point
  62289. */
  62290. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  62291. /**
  62292. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  62293. * @returns the class name
  62294. */
  62295. getClassName(): string;
  62296. /**
  62297. * Gets a boolean indicating if the current point can be connected to another point
  62298. * @param connectionPoint defines the other connection point
  62299. * @returns a boolean
  62300. */
  62301. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  62302. /**
  62303. * Gets a number indicating if the current point can be connected to another point
  62304. * @param connectionPoint defines the other connection point
  62305. * @returns a number defining the compatibility state
  62306. */
  62307. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  62308. /**
  62309. * Connect this point to another connection point
  62310. * @param connectionPoint defines the other connection point
  62311. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  62312. * @returns the current connection point
  62313. */
  62314. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Disconnect this point from one of his endpoint
  62317. * @param endpoint defines the other connection point
  62318. * @returns the current connection point
  62319. */
  62320. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Serializes this point in a JSON representation
  62323. * @param isInput defines if the connection point is an input (default is true)
  62324. * @returns the serialized point object
  62325. */
  62326. serialize(isInput?: boolean): any;
  62327. /**
  62328. * Release resources
  62329. */
  62330. dispose(): void;
  62331. }
  62332. }
  62333. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  62334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62337. import { Mesh } from "babylonjs/Meshes/mesh";
  62338. import { Effect } from "babylonjs/Materials/effect";
  62339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62342. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62343. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62344. /**
  62345. * Block used to add support for vertex skinning (bones)
  62346. */
  62347. export class BonesBlock extends NodeMaterialBlock {
  62348. /**
  62349. * Creates a new BonesBlock
  62350. * @param name defines the block name
  62351. */
  62352. constructor(name: string);
  62353. /**
  62354. * Initialize the block and prepare the context for build
  62355. * @param state defines the state that will be used for the build
  62356. */
  62357. initialize(state: NodeMaterialBuildState): void;
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the matrix indices input component
  62365. */
  62366. get matricesIndices(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the matrix weights input component
  62369. */
  62370. get matricesWeights(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Gets the extra matrix indices input component
  62373. */
  62374. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the extra matrix weights input component
  62377. */
  62378. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the world input component
  62381. */
  62382. get world(): NodeMaterialConnectionPoint;
  62383. /**
  62384. * Gets the output component
  62385. */
  62386. get output(): NodeMaterialConnectionPoint;
  62387. autoConfigure(material: NodeMaterial): void;
  62388. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62391. protected _buildBlock(state: NodeMaterialBuildState): this;
  62392. }
  62393. }
  62394. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62399. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62400. /**
  62401. * Block used to add support for instances
  62402. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62403. */
  62404. export class InstancesBlock extends NodeMaterialBlock {
  62405. /**
  62406. * Creates a new InstancesBlock
  62407. * @param name defines the block name
  62408. */
  62409. constructor(name: string);
  62410. /**
  62411. * Gets the current class name
  62412. * @returns the class name
  62413. */
  62414. getClassName(): string;
  62415. /**
  62416. * Gets the first world row input component
  62417. */
  62418. get world0(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the second world row input component
  62421. */
  62422. get world1(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the third world row input component
  62425. */
  62426. get world2(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the forth world row input component
  62429. */
  62430. get world3(): NodeMaterialConnectionPoint;
  62431. /**
  62432. * Gets the world input component
  62433. */
  62434. get world(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the output component
  62437. */
  62438. get output(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the isntanceID component
  62441. */
  62442. get instanceID(): NodeMaterialConnectionPoint;
  62443. autoConfigure(material: NodeMaterial): void;
  62444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62445. protected _buildBlock(state: NodeMaterialBuildState): this;
  62446. }
  62447. }
  62448. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62453. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62454. import { Effect } from "babylonjs/Materials/effect";
  62455. import { Mesh } from "babylonjs/Meshes/mesh";
  62456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62458. /**
  62459. * Block used to add morph targets support to vertex shader
  62460. */
  62461. export class MorphTargetsBlock extends NodeMaterialBlock {
  62462. private _repeatableContentAnchor;
  62463. /**
  62464. * Create a new MorphTargetsBlock
  62465. * @param name defines the block name
  62466. */
  62467. constructor(name: string);
  62468. /**
  62469. * Gets the current class name
  62470. * @returns the class name
  62471. */
  62472. getClassName(): string;
  62473. /**
  62474. * Gets the position input component
  62475. */
  62476. get position(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the normal input component
  62479. */
  62480. get normal(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the tangent input component
  62483. */
  62484. get tangent(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the tangent input component
  62487. */
  62488. get uv(): NodeMaterialConnectionPoint;
  62489. /**
  62490. * Gets the position output component
  62491. */
  62492. get positionOutput(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the normal output component
  62495. */
  62496. get normalOutput(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the tangent output component
  62499. */
  62500. get tangentOutput(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the tangent output component
  62503. */
  62504. get uvOutput(): NodeMaterialConnectionPoint;
  62505. initialize(state: NodeMaterialBuildState): void;
  62506. autoConfigure(material: NodeMaterial): void;
  62507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62509. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62510. protected _buildBlock(state: NodeMaterialBuildState): this;
  62511. }
  62512. }
  62513. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62517. import { Nullable } from "babylonjs/types";
  62518. import { Scene } from "babylonjs/scene";
  62519. import { Effect } from "babylonjs/Materials/effect";
  62520. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62521. import { Mesh } from "babylonjs/Meshes/mesh";
  62522. import { Light } from "babylonjs/Lights/light";
  62523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62524. /**
  62525. * Block used to get data information from a light
  62526. */
  62527. export class LightInformationBlock extends NodeMaterialBlock {
  62528. private _lightDataUniformName;
  62529. private _lightColorUniformName;
  62530. private _lightTypeDefineName;
  62531. /**
  62532. * Gets or sets the light associated with this block
  62533. */
  62534. light: Nullable<Light>;
  62535. /**
  62536. * Creates a new LightInformationBlock
  62537. * @param name defines the block name
  62538. */
  62539. constructor(name: string);
  62540. /**
  62541. * Gets the current class name
  62542. * @returns the class name
  62543. */
  62544. getClassName(): string;
  62545. /**
  62546. * Gets the world position input component
  62547. */
  62548. get worldPosition(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the direction output component
  62551. */
  62552. get direction(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the direction output component
  62555. */
  62556. get color(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the direction output component
  62559. */
  62560. get intensity(): NodeMaterialConnectionPoint;
  62561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62563. protected _buildBlock(state: NodeMaterialBuildState): this;
  62564. serialize(): any;
  62565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62566. }
  62567. }
  62568. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62569. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62570. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62571. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62572. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62573. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62574. }
  62575. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62581. import { Effect } from "babylonjs/Materials/effect";
  62582. import { Mesh } from "babylonjs/Meshes/mesh";
  62583. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62584. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62585. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62586. /**
  62587. * Block used to add image processing support to fragment shader
  62588. */
  62589. export class ImageProcessingBlock extends NodeMaterialBlock {
  62590. /**
  62591. * Create a new ImageProcessingBlock
  62592. * @param name defines the block name
  62593. */
  62594. constructor(name: string);
  62595. /**
  62596. * Gets the current class name
  62597. * @returns the class name
  62598. */
  62599. getClassName(): string;
  62600. /**
  62601. * Gets the color input component
  62602. */
  62603. get color(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the output component
  62606. */
  62607. get output(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Initialize the block and prepare the context for build
  62610. * @param state defines the state that will be used for the build
  62611. */
  62612. initialize(state: NodeMaterialBuildState): void;
  62613. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62615. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62616. protected _buildBlock(state: NodeMaterialBuildState): this;
  62617. }
  62618. }
  62619. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62623. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62625. import { Effect } from "babylonjs/Materials/effect";
  62626. import { Mesh } from "babylonjs/Meshes/mesh";
  62627. import { Scene } from "babylonjs/scene";
  62628. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62629. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62630. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62631. /**
  62632. * Block used to pertub normals based on a normal map
  62633. */
  62634. export class PerturbNormalBlock extends NodeMaterialBlock {
  62635. private _tangentSpaceParameterName;
  62636. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62637. invertX: boolean;
  62638. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62639. invertY: boolean;
  62640. /**
  62641. * Create a new PerturbNormalBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the world position input component
  62652. */
  62653. get worldPosition(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the world normal input component
  62656. */
  62657. get worldNormal(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the world tangent input component
  62660. */
  62661. get worldTangent(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the uv input component
  62664. */
  62665. get uv(): NodeMaterialConnectionPoint;
  62666. /**
  62667. * Gets the normal map color input component
  62668. */
  62669. get normalMapColor(): NodeMaterialConnectionPoint;
  62670. /**
  62671. * Gets the strength input component
  62672. */
  62673. get strength(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the output component
  62676. */
  62677. get output(): NodeMaterialConnectionPoint;
  62678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62680. autoConfigure(material: NodeMaterial): void;
  62681. protected _buildBlock(state: NodeMaterialBuildState): this;
  62682. protected _dumpPropertiesCode(): string;
  62683. serialize(): any;
  62684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62685. }
  62686. }
  62687. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62691. /**
  62692. * Block used to discard a pixel if a value is smaller than a cutoff
  62693. */
  62694. export class DiscardBlock extends NodeMaterialBlock {
  62695. /**
  62696. * Create a new DiscardBlock
  62697. * @param name defines the block name
  62698. */
  62699. constructor(name: string);
  62700. /**
  62701. * Gets the current class name
  62702. * @returns the class name
  62703. */
  62704. getClassName(): string;
  62705. /**
  62706. * Gets the color input component
  62707. */
  62708. get value(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the cutoff input component
  62711. */
  62712. get cutoff(): NodeMaterialConnectionPoint;
  62713. protected _buildBlock(state: NodeMaterialBuildState): this;
  62714. }
  62715. }
  62716. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62720. /**
  62721. * Block used to test if the fragment shader is front facing
  62722. */
  62723. export class FrontFacingBlock extends NodeMaterialBlock {
  62724. /**
  62725. * Creates a new FrontFacingBlock
  62726. * @param name defines the block name
  62727. */
  62728. constructor(name: string);
  62729. /**
  62730. * Gets the current class name
  62731. * @returns the class name
  62732. */
  62733. getClassName(): string;
  62734. /**
  62735. * Gets the output component
  62736. */
  62737. get output(): NodeMaterialConnectionPoint;
  62738. protected _buildBlock(state: NodeMaterialBuildState): this;
  62739. }
  62740. }
  62741. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62745. /**
  62746. * Block used to get the derivative value on x and y of a given input
  62747. */
  62748. export class DerivativeBlock extends NodeMaterialBlock {
  62749. /**
  62750. * Create a new DerivativeBlock
  62751. * @param name defines the block name
  62752. */
  62753. constructor(name: string);
  62754. /**
  62755. * Gets the current class name
  62756. * @returns the class name
  62757. */
  62758. getClassName(): string;
  62759. /**
  62760. * Gets the input component
  62761. */
  62762. get input(): NodeMaterialConnectionPoint;
  62763. /**
  62764. * Gets the derivative output on x
  62765. */
  62766. get dx(): NodeMaterialConnectionPoint;
  62767. /**
  62768. * Gets the derivative output on y
  62769. */
  62770. get dy(): NodeMaterialConnectionPoint;
  62771. protected _buildBlock(state: NodeMaterialBuildState): this;
  62772. }
  62773. }
  62774. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62775. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62776. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62777. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62778. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62779. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62780. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62781. }
  62782. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62785. import { Mesh } from "babylonjs/Meshes/mesh";
  62786. import { Effect } from "babylonjs/Materials/effect";
  62787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62789. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62790. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62791. /**
  62792. * Block used to add support for scene fog
  62793. */
  62794. export class FogBlock extends NodeMaterialBlock {
  62795. private _fogDistanceName;
  62796. private _fogParameters;
  62797. /**
  62798. * Create a new FogBlock
  62799. * @param name defines the block name
  62800. */
  62801. constructor(name: string);
  62802. /**
  62803. * Gets the current class name
  62804. * @returns the class name
  62805. */
  62806. getClassName(): string;
  62807. /**
  62808. * Gets the world position input component
  62809. */
  62810. get worldPosition(): NodeMaterialConnectionPoint;
  62811. /**
  62812. * Gets the view input component
  62813. */
  62814. get view(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the color input component
  62817. */
  62818. get input(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the fog color input component
  62821. */
  62822. get fogColor(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the output component
  62825. */
  62826. get output(): NodeMaterialConnectionPoint;
  62827. autoConfigure(material: NodeMaterial): void;
  62828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62830. protected _buildBlock(state: NodeMaterialBuildState): this;
  62831. }
  62832. }
  62833. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62839. import { Effect } from "babylonjs/Materials/effect";
  62840. import { Mesh } from "babylonjs/Meshes/mesh";
  62841. import { Light } from "babylonjs/Lights/light";
  62842. import { Nullable } from "babylonjs/types";
  62843. import { Scene } from "babylonjs/scene";
  62844. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62845. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62846. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62848. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62849. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62850. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62851. /**
  62852. * Block used to add light in the fragment shader
  62853. */
  62854. export class LightBlock extends NodeMaterialBlock {
  62855. private _lightId;
  62856. /**
  62857. * Gets or sets the light associated with this block
  62858. */
  62859. light: Nullable<Light>;
  62860. /**
  62861. * Create a new LightBlock
  62862. * @param name defines the block name
  62863. */
  62864. constructor(name: string);
  62865. /**
  62866. * Gets the current class name
  62867. * @returns the class name
  62868. */
  62869. getClassName(): string;
  62870. /**
  62871. * Gets the world position input component
  62872. */
  62873. get worldPosition(): NodeMaterialConnectionPoint;
  62874. /**
  62875. * Gets the world normal input component
  62876. */
  62877. get worldNormal(): NodeMaterialConnectionPoint;
  62878. /**
  62879. * Gets the camera (or eye) position component
  62880. */
  62881. get cameraPosition(): NodeMaterialConnectionPoint;
  62882. /**
  62883. * Gets the glossiness component
  62884. */
  62885. get glossiness(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the glossinness power component
  62888. */
  62889. get glossPower(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the diffuse color component
  62892. */
  62893. get diffuseColor(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the specular color component
  62896. */
  62897. get specularColor(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the diffuse output component
  62900. */
  62901. get diffuseOutput(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the specular output component
  62904. */
  62905. get specularOutput(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the shadow output component
  62908. */
  62909. get shadow(): NodeMaterialConnectionPoint;
  62910. autoConfigure(material: NodeMaterial): void;
  62911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62912. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62914. private _injectVertexCode;
  62915. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62916. serialize(): any;
  62917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62918. }
  62919. }
  62920. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62923. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62924. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62925. /**
  62926. * Block used to read a reflection texture from a sampler
  62927. */
  62928. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62929. /**
  62930. * Create a new ReflectionTextureBlock
  62931. * @param name defines the block name
  62932. */
  62933. constructor(name: string);
  62934. /**
  62935. * Gets the current class name
  62936. * @returns the class name
  62937. */
  62938. getClassName(): string;
  62939. /**
  62940. * Gets the world position input component
  62941. */
  62942. get position(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the world position input component
  62945. */
  62946. get worldPosition(): NodeMaterialConnectionPoint;
  62947. /**
  62948. * Gets the world normal input component
  62949. */
  62950. get worldNormal(): NodeMaterialConnectionPoint;
  62951. /**
  62952. * Gets the world input component
  62953. */
  62954. get world(): NodeMaterialConnectionPoint;
  62955. /**
  62956. * Gets the camera (or eye) position component
  62957. */
  62958. get cameraPosition(): NodeMaterialConnectionPoint;
  62959. /**
  62960. * Gets the view input component
  62961. */
  62962. get view(): NodeMaterialConnectionPoint;
  62963. /**
  62964. * Gets the rgb output component
  62965. */
  62966. get rgb(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the r output component
  62969. */
  62970. get r(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the g output component
  62973. */
  62974. get g(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the b output component
  62977. */
  62978. get b(): NodeMaterialConnectionPoint;
  62979. autoConfigure(material: NodeMaterial): void;
  62980. protected _buildBlock(state: NodeMaterialBuildState): this;
  62981. }
  62982. }
  62983. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62984. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62985. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62986. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62987. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62988. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  62989. }
  62990. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62991. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62992. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62993. }
  62994. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62998. /**
  62999. * Block used to add 2 vectors
  63000. */
  63001. export class AddBlock extends NodeMaterialBlock {
  63002. /**
  63003. * Creates a new AddBlock
  63004. * @param name defines the block name
  63005. */
  63006. constructor(name: string);
  63007. /**
  63008. * Gets the current class name
  63009. * @returns the class name
  63010. */
  63011. getClassName(): string;
  63012. /**
  63013. * Gets the left operand input component
  63014. */
  63015. get left(): NodeMaterialConnectionPoint;
  63016. /**
  63017. * Gets the right operand input component
  63018. */
  63019. get right(): NodeMaterialConnectionPoint;
  63020. /**
  63021. * Gets the output component
  63022. */
  63023. get output(): NodeMaterialConnectionPoint;
  63024. protected _buildBlock(state: NodeMaterialBuildState): this;
  63025. }
  63026. }
  63027. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  63028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63031. /**
  63032. * Block used to scale a vector by a float
  63033. */
  63034. export class ScaleBlock extends NodeMaterialBlock {
  63035. /**
  63036. * Creates a new ScaleBlock
  63037. * @param name defines the block name
  63038. */
  63039. constructor(name: string);
  63040. /**
  63041. * Gets the current class name
  63042. * @returns the class name
  63043. */
  63044. getClassName(): string;
  63045. /**
  63046. * Gets the input component
  63047. */
  63048. get input(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the factor input component
  63051. */
  63052. get factor(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the output component
  63055. */
  63056. get output(): NodeMaterialConnectionPoint;
  63057. protected _buildBlock(state: NodeMaterialBuildState): this;
  63058. }
  63059. }
  63060. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  63061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63064. import { Scene } from "babylonjs/scene";
  63065. /**
  63066. * Block used to clamp a float
  63067. */
  63068. export class ClampBlock extends NodeMaterialBlock {
  63069. /** Gets or sets the minimum range */
  63070. minimum: number;
  63071. /** Gets or sets the maximum range */
  63072. maximum: number;
  63073. /**
  63074. * Creates a new ClampBlock
  63075. * @param name defines the block name
  63076. */
  63077. constructor(name: string);
  63078. /**
  63079. * Gets the current class name
  63080. * @returns the class name
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * Gets the value input component
  63085. */
  63086. get value(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the output component
  63089. */
  63090. get output(): NodeMaterialConnectionPoint;
  63091. protected _buildBlock(state: NodeMaterialBuildState): this;
  63092. protected _dumpPropertiesCode(): string;
  63093. serialize(): any;
  63094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63095. }
  63096. }
  63097. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  63098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63101. /**
  63102. * Block used to apply a cross product between 2 vectors
  63103. */
  63104. export class CrossBlock extends NodeMaterialBlock {
  63105. /**
  63106. * Creates a new CrossBlock
  63107. * @param name defines the block name
  63108. */
  63109. constructor(name: string);
  63110. /**
  63111. * Gets the current class name
  63112. * @returns the class name
  63113. */
  63114. getClassName(): string;
  63115. /**
  63116. * Gets the left operand input component
  63117. */
  63118. get left(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the right operand input component
  63121. */
  63122. get right(): NodeMaterialConnectionPoint;
  63123. /**
  63124. * Gets the output component
  63125. */
  63126. get output(): NodeMaterialConnectionPoint;
  63127. protected _buildBlock(state: NodeMaterialBuildState): this;
  63128. }
  63129. }
  63130. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  63131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63134. /**
  63135. * Block used to apply a dot product between 2 vectors
  63136. */
  63137. export class DotBlock extends NodeMaterialBlock {
  63138. /**
  63139. * Creates a new DotBlock
  63140. * @param name defines the block name
  63141. */
  63142. constructor(name: string);
  63143. /**
  63144. * Gets the current class name
  63145. * @returns the class name
  63146. */
  63147. getClassName(): string;
  63148. /**
  63149. * Gets the left operand input component
  63150. */
  63151. get left(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the right operand input component
  63154. */
  63155. get right(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the output component
  63158. */
  63159. get output(): NodeMaterialConnectionPoint;
  63160. protected _buildBlock(state: NodeMaterialBuildState): this;
  63161. }
  63162. }
  63163. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  63164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63167. /**
  63168. * Block used to normalize a vector
  63169. */
  63170. export class NormalizeBlock extends NodeMaterialBlock {
  63171. /**
  63172. * Creates a new NormalizeBlock
  63173. * @param name defines the block name
  63174. */
  63175. constructor(name: string);
  63176. /**
  63177. * Gets the current class name
  63178. * @returns the class name
  63179. */
  63180. getClassName(): string;
  63181. /**
  63182. * Gets the input component
  63183. */
  63184. get input(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the output component
  63187. */
  63188. get output(): NodeMaterialConnectionPoint;
  63189. protected _buildBlock(state: NodeMaterialBuildState): this;
  63190. }
  63191. }
  63192. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  63193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63196. import { Scene } from "babylonjs/scene";
  63197. /**
  63198. * Operations supported by the Trigonometry block
  63199. */
  63200. export enum TrigonometryBlockOperations {
  63201. /** Cos */
  63202. Cos = 0,
  63203. /** Sin */
  63204. Sin = 1,
  63205. /** Abs */
  63206. Abs = 2,
  63207. /** Exp */
  63208. Exp = 3,
  63209. /** Exp2 */
  63210. Exp2 = 4,
  63211. /** Round */
  63212. Round = 5,
  63213. /** Floor */
  63214. Floor = 6,
  63215. /** Ceiling */
  63216. Ceiling = 7,
  63217. /** Square root */
  63218. Sqrt = 8,
  63219. /** Log */
  63220. Log = 9,
  63221. /** Tangent */
  63222. Tan = 10,
  63223. /** Arc tangent */
  63224. ArcTan = 11,
  63225. /** Arc cosinus */
  63226. ArcCos = 12,
  63227. /** Arc sinus */
  63228. ArcSin = 13,
  63229. /** Fraction */
  63230. Fract = 14,
  63231. /** Sign */
  63232. Sign = 15,
  63233. /** To radians (from degrees) */
  63234. Radians = 16,
  63235. /** To degrees (from radians) */
  63236. Degrees = 17
  63237. }
  63238. /**
  63239. * Block used to apply trigonometry operation to floats
  63240. */
  63241. export class TrigonometryBlock extends NodeMaterialBlock {
  63242. /**
  63243. * Gets or sets the operation applied by the block
  63244. */
  63245. operation: TrigonometryBlockOperations;
  63246. /**
  63247. * Creates a new TrigonometryBlock
  63248. * @param name defines the block name
  63249. */
  63250. constructor(name: string);
  63251. /**
  63252. * Gets the current class name
  63253. * @returns the class name
  63254. */
  63255. getClassName(): string;
  63256. /**
  63257. * Gets the input component
  63258. */
  63259. get input(): NodeMaterialConnectionPoint;
  63260. /**
  63261. * Gets the output component
  63262. */
  63263. get output(): NodeMaterialConnectionPoint;
  63264. protected _buildBlock(state: NodeMaterialBuildState): this;
  63265. serialize(): any;
  63266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63267. protected _dumpPropertiesCode(): string;
  63268. }
  63269. }
  63270. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63274. /**
  63275. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63276. */
  63277. export class ColorMergerBlock extends NodeMaterialBlock {
  63278. /**
  63279. * Create a new ColorMergerBlock
  63280. * @param name defines the block name
  63281. */
  63282. constructor(name: string);
  63283. /**
  63284. * Gets the current class name
  63285. * @returns the class name
  63286. */
  63287. getClassName(): string;
  63288. /**
  63289. * Gets the rgb component (input)
  63290. */
  63291. get rgbIn(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the r component (input)
  63294. */
  63295. get r(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the g component (input)
  63298. */
  63299. get g(): NodeMaterialConnectionPoint;
  63300. /**
  63301. * Gets the b component (input)
  63302. */
  63303. get b(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Gets the a component (input)
  63306. */
  63307. get a(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the rgba component (output)
  63310. */
  63311. get rgba(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the rgb component (output)
  63314. */
  63315. get rgbOut(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the rgb component (output)
  63318. * @deprecated Please use rgbOut instead.
  63319. */
  63320. get rgb(): NodeMaterialConnectionPoint;
  63321. protected _buildBlock(state: NodeMaterialBuildState): this;
  63322. }
  63323. }
  63324. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63328. /**
  63329. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63330. */
  63331. export class ColorSplitterBlock extends NodeMaterialBlock {
  63332. /**
  63333. * Create a new ColorSplitterBlock
  63334. * @param name defines the block name
  63335. */
  63336. constructor(name: string);
  63337. /**
  63338. * Gets the current class name
  63339. * @returns the class name
  63340. */
  63341. getClassName(): string;
  63342. /**
  63343. * Gets the rgba component (input)
  63344. */
  63345. get rgba(): NodeMaterialConnectionPoint;
  63346. /**
  63347. * Gets the rgb component (input)
  63348. */
  63349. get rgbIn(): NodeMaterialConnectionPoint;
  63350. /**
  63351. * Gets the rgb component (output)
  63352. */
  63353. get rgbOut(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the r component (output)
  63356. */
  63357. get r(): NodeMaterialConnectionPoint;
  63358. /**
  63359. * Gets the g component (output)
  63360. */
  63361. get g(): NodeMaterialConnectionPoint;
  63362. /**
  63363. * Gets the b component (output)
  63364. */
  63365. get b(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the a component (output)
  63368. */
  63369. get a(): NodeMaterialConnectionPoint;
  63370. protected _inputRename(name: string): string;
  63371. protected _outputRename(name: string): string;
  63372. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63373. }
  63374. }
  63375. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63379. /**
  63380. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63381. */
  63382. export class VectorSplitterBlock extends NodeMaterialBlock {
  63383. /**
  63384. * Create a new VectorSplitterBlock
  63385. * @param name defines the block name
  63386. */
  63387. constructor(name: string);
  63388. /**
  63389. * Gets the current class name
  63390. * @returns the class name
  63391. */
  63392. getClassName(): string;
  63393. /**
  63394. * Gets the xyzw component (input)
  63395. */
  63396. get xyzw(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the xyz component (input)
  63399. */
  63400. get xyzIn(): NodeMaterialConnectionPoint;
  63401. /**
  63402. * Gets the xy component (input)
  63403. */
  63404. get xyIn(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the xyz component (output)
  63407. */
  63408. get xyzOut(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the xy component (output)
  63411. */
  63412. get xyOut(): NodeMaterialConnectionPoint;
  63413. /**
  63414. * Gets the x component (output)
  63415. */
  63416. get x(): NodeMaterialConnectionPoint;
  63417. /**
  63418. * Gets the y component (output)
  63419. */
  63420. get y(): NodeMaterialConnectionPoint;
  63421. /**
  63422. * Gets the z component (output)
  63423. */
  63424. get z(): NodeMaterialConnectionPoint;
  63425. /**
  63426. * Gets the w component (output)
  63427. */
  63428. get w(): NodeMaterialConnectionPoint;
  63429. protected _inputRename(name: string): string;
  63430. protected _outputRename(name: string): string;
  63431. protected _buildBlock(state: NodeMaterialBuildState): this;
  63432. }
  63433. }
  63434. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63438. /**
  63439. * Block used to lerp between 2 values
  63440. */
  63441. export class LerpBlock extends NodeMaterialBlock {
  63442. /**
  63443. * Creates a new LerpBlock
  63444. * @param name defines the block name
  63445. */
  63446. constructor(name: string);
  63447. /**
  63448. * Gets the current class name
  63449. * @returns the class name
  63450. */
  63451. getClassName(): string;
  63452. /**
  63453. * Gets the left operand input component
  63454. */
  63455. get left(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the right operand input component
  63458. */
  63459. get right(): NodeMaterialConnectionPoint;
  63460. /**
  63461. * Gets the gradient operand input component
  63462. */
  63463. get gradient(): NodeMaterialConnectionPoint;
  63464. /**
  63465. * Gets the output component
  63466. */
  63467. get output(): NodeMaterialConnectionPoint;
  63468. protected _buildBlock(state: NodeMaterialBuildState): this;
  63469. }
  63470. }
  63471. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63475. /**
  63476. * Block used to divide 2 vectors
  63477. */
  63478. export class DivideBlock extends NodeMaterialBlock {
  63479. /**
  63480. * Creates a new DivideBlock
  63481. * @param name defines the block name
  63482. */
  63483. constructor(name: string);
  63484. /**
  63485. * Gets the current class name
  63486. * @returns the class name
  63487. */
  63488. getClassName(): string;
  63489. /**
  63490. * Gets the left operand input component
  63491. */
  63492. get left(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the right operand input component
  63495. */
  63496. get right(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the output component
  63499. */
  63500. get output(): NodeMaterialConnectionPoint;
  63501. protected _buildBlock(state: NodeMaterialBuildState): this;
  63502. }
  63503. }
  63504. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63508. /**
  63509. * Block used to subtract 2 vectors
  63510. */
  63511. export class SubtractBlock extends NodeMaterialBlock {
  63512. /**
  63513. * Creates a new SubtractBlock
  63514. * @param name defines the block name
  63515. */
  63516. constructor(name: string);
  63517. /**
  63518. * Gets the current class name
  63519. * @returns the class name
  63520. */
  63521. getClassName(): string;
  63522. /**
  63523. * Gets the left operand input component
  63524. */
  63525. get left(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the right operand input component
  63528. */
  63529. get right(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the output component
  63532. */
  63533. get output(): NodeMaterialConnectionPoint;
  63534. protected _buildBlock(state: NodeMaterialBuildState): this;
  63535. }
  63536. }
  63537. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63541. /**
  63542. * Block used to step a value
  63543. */
  63544. export class StepBlock extends NodeMaterialBlock {
  63545. /**
  63546. * Creates a new StepBlock
  63547. * @param name defines the block name
  63548. */
  63549. constructor(name: string);
  63550. /**
  63551. * Gets the current class name
  63552. * @returns the class name
  63553. */
  63554. getClassName(): string;
  63555. /**
  63556. * Gets the value operand input component
  63557. */
  63558. get value(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the edge operand input component
  63561. */
  63562. get edge(): NodeMaterialConnectionPoint;
  63563. /**
  63564. * Gets the output component
  63565. */
  63566. get output(): NodeMaterialConnectionPoint;
  63567. protected _buildBlock(state: NodeMaterialBuildState): this;
  63568. }
  63569. }
  63570. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63574. /**
  63575. * Block used to get the opposite (1 - x) of a value
  63576. */
  63577. export class OneMinusBlock extends NodeMaterialBlock {
  63578. /**
  63579. * Creates a new OneMinusBlock
  63580. * @param name defines the block name
  63581. */
  63582. constructor(name: string);
  63583. /**
  63584. * Gets the current class name
  63585. * @returns the class name
  63586. */
  63587. getClassName(): string;
  63588. /**
  63589. * Gets the input component
  63590. */
  63591. get input(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the output component
  63594. */
  63595. get output(): NodeMaterialConnectionPoint;
  63596. protected _buildBlock(state: NodeMaterialBuildState): this;
  63597. }
  63598. }
  63599. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63603. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63604. /**
  63605. * Block used to get the view direction
  63606. */
  63607. export class ViewDirectionBlock extends NodeMaterialBlock {
  63608. /**
  63609. * Creates a new ViewDirectionBlock
  63610. * @param name defines the block name
  63611. */
  63612. constructor(name: string);
  63613. /**
  63614. * Gets the current class name
  63615. * @returns the class name
  63616. */
  63617. getClassName(): string;
  63618. /**
  63619. * Gets the world position component
  63620. */
  63621. get worldPosition(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the camera position component
  63624. */
  63625. get cameraPosition(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the output component
  63628. */
  63629. get output(): NodeMaterialConnectionPoint;
  63630. autoConfigure(material: NodeMaterial): void;
  63631. protected _buildBlock(state: NodeMaterialBuildState): this;
  63632. }
  63633. }
  63634. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63638. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63639. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63640. /**
  63641. * Block used to compute fresnel value
  63642. */
  63643. export class FresnelBlock extends NodeMaterialBlock {
  63644. /**
  63645. * Create a new FresnelBlock
  63646. * @param name defines the block name
  63647. */
  63648. constructor(name: string);
  63649. /**
  63650. * Gets the current class name
  63651. * @returns the class name
  63652. */
  63653. getClassName(): string;
  63654. /**
  63655. * Gets the world normal input component
  63656. */
  63657. get worldNormal(): NodeMaterialConnectionPoint;
  63658. /**
  63659. * Gets the view direction input component
  63660. */
  63661. get viewDirection(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the bias input component
  63664. */
  63665. get bias(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the camera (or eye) position component
  63668. */
  63669. get power(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the fresnel output component
  63672. */
  63673. get fresnel(): NodeMaterialConnectionPoint;
  63674. autoConfigure(material: NodeMaterial): void;
  63675. protected _buildBlock(state: NodeMaterialBuildState): this;
  63676. }
  63677. }
  63678. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63682. /**
  63683. * Block used to get the max of 2 values
  63684. */
  63685. export class MaxBlock extends NodeMaterialBlock {
  63686. /**
  63687. * Creates a new MaxBlock
  63688. * @param name defines the block name
  63689. */
  63690. constructor(name: string);
  63691. /**
  63692. * Gets the current class name
  63693. * @returns the class name
  63694. */
  63695. getClassName(): string;
  63696. /**
  63697. * Gets the left operand input component
  63698. */
  63699. get left(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the right operand input component
  63702. */
  63703. get right(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the output component
  63706. */
  63707. get output(): NodeMaterialConnectionPoint;
  63708. protected _buildBlock(state: NodeMaterialBuildState): this;
  63709. }
  63710. }
  63711. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63715. /**
  63716. * Block used to get the min of 2 values
  63717. */
  63718. export class MinBlock extends NodeMaterialBlock {
  63719. /**
  63720. * Creates a new MinBlock
  63721. * @param name defines the block name
  63722. */
  63723. constructor(name: string);
  63724. /**
  63725. * Gets the current class name
  63726. * @returns the class name
  63727. */
  63728. getClassName(): string;
  63729. /**
  63730. * Gets the left operand input component
  63731. */
  63732. get left(): NodeMaterialConnectionPoint;
  63733. /**
  63734. * Gets the right operand input component
  63735. */
  63736. get right(): NodeMaterialConnectionPoint;
  63737. /**
  63738. * Gets the output component
  63739. */
  63740. get output(): NodeMaterialConnectionPoint;
  63741. protected _buildBlock(state: NodeMaterialBuildState): this;
  63742. }
  63743. }
  63744. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63748. /**
  63749. * Block used to get the distance between 2 values
  63750. */
  63751. export class DistanceBlock extends NodeMaterialBlock {
  63752. /**
  63753. * Creates a new DistanceBlock
  63754. * @param name defines the block name
  63755. */
  63756. constructor(name: string);
  63757. /**
  63758. * Gets the current class name
  63759. * @returns the class name
  63760. */
  63761. getClassName(): string;
  63762. /**
  63763. * Gets the left operand input component
  63764. */
  63765. get left(): NodeMaterialConnectionPoint;
  63766. /**
  63767. * Gets the right operand input component
  63768. */
  63769. get right(): NodeMaterialConnectionPoint;
  63770. /**
  63771. * Gets the output component
  63772. */
  63773. get output(): NodeMaterialConnectionPoint;
  63774. protected _buildBlock(state: NodeMaterialBuildState): this;
  63775. }
  63776. }
  63777. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63780. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63781. /**
  63782. * Block used to get the length of a vector
  63783. */
  63784. export class LengthBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Creates a new LengthBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the value input component
  63797. */
  63798. get value(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the output component
  63801. */
  63802. get output(): NodeMaterialConnectionPoint;
  63803. protected _buildBlock(state: NodeMaterialBuildState): this;
  63804. }
  63805. }
  63806. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63810. /**
  63811. * Block used to get negative version of a value (i.e. x * -1)
  63812. */
  63813. export class NegateBlock extends NodeMaterialBlock {
  63814. /**
  63815. * Creates a new NegateBlock
  63816. * @param name defines the block name
  63817. */
  63818. constructor(name: string);
  63819. /**
  63820. * Gets the current class name
  63821. * @returns the class name
  63822. */
  63823. getClassName(): string;
  63824. /**
  63825. * Gets the value input component
  63826. */
  63827. get value(): NodeMaterialConnectionPoint;
  63828. /**
  63829. * Gets the output component
  63830. */
  63831. get output(): NodeMaterialConnectionPoint;
  63832. protected _buildBlock(state: NodeMaterialBuildState): this;
  63833. }
  63834. }
  63835. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63839. /**
  63840. * Block used to get the value of the first parameter raised to the power of the second
  63841. */
  63842. export class PowBlock extends NodeMaterialBlock {
  63843. /**
  63844. * Creates a new PowBlock
  63845. * @param name defines the block name
  63846. */
  63847. constructor(name: string);
  63848. /**
  63849. * Gets the current class name
  63850. * @returns the class name
  63851. */
  63852. getClassName(): string;
  63853. /**
  63854. * Gets the value operand input component
  63855. */
  63856. get value(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the power operand input component
  63859. */
  63860. get power(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the output component
  63863. */
  63864. get output(): NodeMaterialConnectionPoint;
  63865. protected _buildBlock(state: NodeMaterialBuildState): this;
  63866. }
  63867. }
  63868. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63872. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63873. /**
  63874. * Block used to get a random number
  63875. */
  63876. export class RandomNumberBlock extends NodeMaterialBlock {
  63877. /**
  63878. * Creates a new RandomNumberBlock
  63879. * @param name defines the block name
  63880. */
  63881. constructor(name: string);
  63882. /**
  63883. * Gets the current class name
  63884. * @returns the class name
  63885. */
  63886. getClassName(): string;
  63887. /**
  63888. * Gets the seed input component
  63889. */
  63890. get seed(): NodeMaterialConnectionPoint;
  63891. /**
  63892. * Gets the output component
  63893. */
  63894. get output(): NodeMaterialConnectionPoint;
  63895. protected _buildBlock(state: NodeMaterialBuildState): this;
  63896. }
  63897. }
  63898. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63902. /**
  63903. * Block used to compute arc tangent of 2 values
  63904. */
  63905. export class ArcTan2Block extends NodeMaterialBlock {
  63906. /**
  63907. * Creates a new ArcTan2Block
  63908. * @param name defines the block name
  63909. */
  63910. constructor(name: string);
  63911. /**
  63912. * Gets the current class name
  63913. * @returns the class name
  63914. */
  63915. getClassName(): string;
  63916. /**
  63917. * Gets the x operand input component
  63918. */
  63919. get x(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the y operand input component
  63922. */
  63923. get y(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the output component
  63926. */
  63927. get output(): NodeMaterialConnectionPoint;
  63928. protected _buildBlock(state: NodeMaterialBuildState): this;
  63929. }
  63930. }
  63931. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63935. /**
  63936. * Block used to smooth step a value
  63937. */
  63938. export class SmoothStepBlock extends NodeMaterialBlock {
  63939. /**
  63940. * Creates a new SmoothStepBlock
  63941. * @param name defines the block name
  63942. */
  63943. constructor(name: string);
  63944. /**
  63945. * Gets the current class name
  63946. * @returns the class name
  63947. */
  63948. getClassName(): string;
  63949. /**
  63950. * Gets the value operand input component
  63951. */
  63952. get value(): NodeMaterialConnectionPoint;
  63953. /**
  63954. * Gets the first edge operand input component
  63955. */
  63956. get edge0(): NodeMaterialConnectionPoint;
  63957. /**
  63958. * Gets the second edge operand input component
  63959. */
  63960. get edge1(): NodeMaterialConnectionPoint;
  63961. /**
  63962. * Gets the output component
  63963. */
  63964. get output(): NodeMaterialConnectionPoint;
  63965. protected _buildBlock(state: NodeMaterialBuildState): this;
  63966. }
  63967. }
  63968. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63972. /**
  63973. * Block used to get the reciprocal (1 / x) of a value
  63974. */
  63975. export class ReciprocalBlock extends NodeMaterialBlock {
  63976. /**
  63977. * Creates a new ReciprocalBlock
  63978. * @param name defines the block name
  63979. */
  63980. constructor(name: string);
  63981. /**
  63982. * Gets the current class name
  63983. * @returns the class name
  63984. */
  63985. getClassName(): string;
  63986. /**
  63987. * Gets the input component
  63988. */
  63989. get input(): NodeMaterialConnectionPoint;
  63990. /**
  63991. * Gets the output component
  63992. */
  63993. get output(): NodeMaterialConnectionPoint;
  63994. protected _buildBlock(state: NodeMaterialBuildState): this;
  63995. }
  63996. }
  63997. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64001. /**
  64002. * Block used to replace a color by another one
  64003. */
  64004. export class ReplaceColorBlock extends NodeMaterialBlock {
  64005. /**
  64006. * Creates a new ReplaceColorBlock
  64007. * @param name defines the block name
  64008. */
  64009. constructor(name: string);
  64010. /**
  64011. * Gets the current class name
  64012. * @returns the class name
  64013. */
  64014. getClassName(): string;
  64015. /**
  64016. * Gets the value input component
  64017. */
  64018. get value(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the reference input component
  64021. */
  64022. get reference(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the distance input component
  64025. */
  64026. get distance(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the replacement input component
  64029. */
  64030. get replacement(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the output component
  64033. */
  64034. get output(): NodeMaterialConnectionPoint;
  64035. protected _buildBlock(state: NodeMaterialBuildState): this;
  64036. }
  64037. }
  64038. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  64039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64042. /**
  64043. * Block used to posterize a value
  64044. * @see https://en.wikipedia.org/wiki/Posterization
  64045. */
  64046. export class PosterizeBlock extends NodeMaterialBlock {
  64047. /**
  64048. * Creates a new PosterizeBlock
  64049. * @param name defines the block name
  64050. */
  64051. constructor(name: string);
  64052. /**
  64053. * Gets the current class name
  64054. * @returns the class name
  64055. */
  64056. getClassName(): string;
  64057. /**
  64058. * Gets the value input component
  64059. */
  64060. get value(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the steps input component
  64063. */
  64064. get steps(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the output component
  64067. */
  64068. get output(): NodeMaterialConnectionPoint;
  64069. protected _buildBlock(state: NodeMaterialBuildState): this;
  64070. }
  64071. }
  64072. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  64073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64076. import { Scene } from "babylonjs/scene";
  64077. /**
  64078. * Operations supported by the Wave block
  64079. */
  64080. export enum WaveBlockKind {
  64081. /** SawTooth */
  64082. SawTooth = 0,
  64083. /** Square */
  64084. Square = 1,
  64085. /** Triangle */
  64086. Triangle = 2
  64087. }
  64088. /**
  64089. * Block used to apply wave operation to floats
  64090. */
  64091. export class WaveBlock extends NodeMaterialBlock {
  64092. /**
  64093. * Gets or sets the kibnd of wave to be applied by the block
  64094. */
  64095. kind: WaveBlockKind;
  64096. /**
  64097. * Creates a new WaveBlock
  64098. * @param name defines the block name
  64099. */
  64100. constructor(name: string);
  64101. /**
  64102. * Gets the current class name
  64103. * @returns the class name
  64104. */
  64105. getClassName(): string;
  64106. /**
  64107. * Gets the input component
  64108. */
  64109. get input(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the output component
  64112. */
  64113. get output(): NodeMaterialConnectionPoint;
  64114. protected _buildBlock(state: NodeMaterialBuildState): this;
  64115. serialize(): any;
  64116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64117. }
  64118. }
  64119. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  64120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64123. import { Color3 } from "babylonjs/Maths/math.color";
  64124. import { Scene } from "babylonjs/scene";
  64125. /**
  64126. * Class used to store a color step for the GradientBlock
  64127. */
  64128. export class GradientBlockColorStep {
  64129. /**
  64130. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64131. */
  64132. step: number;
  64133. /**
  64134. * Gets or sets the color associated with this step
  64135. */
  64136. color: Color3;
  64137. /**
  64138. * Creates a new GradientBlockColorStep
  64139. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64140. * @param color defines the color associated with this step
  64141. */
  64142. constructor(
  64143. /**
  64144. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  64145. */
  64146. step: number,
  64147. /**
  64148. * Gets or sets the color associated with this step
  64149. */
  64150. color: Color3);
  64151. }
  64152. /**
  64153. * Block used to return a color from a gradient based on an input value between 0 and 1
  64154. */
  64155. export class GradientBlock extends NodeMaterialBlock {
  64156. /**
  64157. * Gets or sets the list of color steps
  64158. */
  64159. colorSteps: GradientBlockColorStep[];
  64160. /**
  64161. * Creates a new GradientBlock
  64162. * @param name defines the block name
  64163. */
  64164. constructor(name: string);
  64165. /**
  64166. * Gets the current class name
  64167. * @returns the class name
  64168. */
  64169. getClassName(): string;
  64170. /**
  64171. * Gets the gradient input component
  64172. */
  64173. get gradient(): NodeMaterialConnectionPoint;
  64174. /**
  64175. * Gets the output component
  64176. */
  64177. get output(): NodeMaterialConnectionPoint;
  64178. private _writeColorConstant;
  64179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64180. serialize(): any;
  64181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64182. protected _dumpPropertiesCode(): string;
  64183. }
  64184. }
  64185. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64189. /**
  64190. * Block used to normalize lerp between 2 values
  64191. */
  64192. export class NLerpBlock extends NodeMaterialBlock {
  64193. /**
  64194. * Creates a new NLerpBlock
  64195. * @param name defines the block name
  64196. */
  64197. constructor(name: string);
  64198. /**
  64199. * Gets the current class name
  64200. * @returns the class name
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Gets the left operand input component
  64205. */
  64206. get left(): NodeMaterialConnectionPoint;
  64207. /**
  64208. * Gets the right operand input component
  64209. */
  64210. get right(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the gradient operand input component
  64213. */
  64214. get gradient(): NodeMaterialConnectionPoint;
  64215. /**
  64216. * Gets the output component
  64217. */
  64218. get output(): NodeMaterialConnectionPoint;
  64219. protected _buildBlock(state: NodeMaterialBuildState): this;
  64220. }
  64221. }
  64222. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64226. import { Scene } from "babylonjs/scene";
  64227. /**
  64228. * block used to Generate a Worley Noise 3D Noise Pattern
  64229. */
  64230. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64231. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64232. manhattanDistance: boolean;
  64233. /**
  64234. * Creates a new WorleyNoise3DBlock
  64235. * @param name defines the block name
  64236. */
  64237. constructor(name: string);
  64238. /**
  64239. * Gets the current class name
  64240. * @returns the class name
  64241. */
  64242. getClassName(): string;
  64243. /**
  64244. * Gets the seed input component
  64245. */
  64246. get seed(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the jitter input component
  64249. */
  64250. get jitter(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the output component
  64253. */
  64254. get output(): NodeMaterialConnectionPoint;
  64255. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64256. /**
  64257. * Exposes the properties to the UI?
  64258. */
  64259. protected _dumpPropertiesCode(): string;
  64260. /**
  64261. * Exposes the properties to the Seralize?
  64262. */
  64263. serialize(): any;
  64264. /**
  64265. * Exposes the properties to the deseralize?
  64266. */
  64267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64268. }
  64269. }
  64270. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64274. /**
  64275. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64276. */
  64277. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64278. /**
  64279. * Creates a new SimplexPerlin3DBlock
  64280. * @param name defines the block name
  64281. */
  64282. constructor(name: string);
  64283. /**
  64284. * Gets the current class name
  64285. * @returns the class name
  64286. */
  64287. getClassName(): string;
  64288. /**
  64289. * Gets the seed operand input component
  64290. */
  64291. get seed(): NodeMaterialConnectionPoint;
  64292. /**
  64293. * Gets the output component
  64294. */
  64295. get output(): NodeMaterialConnectionPoint;
  64296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64297. }
  64298. }
  64299. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64301. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64303. /**
  64304. * Block used to blend normals
  64305. */
  64306. export class NormalBlendBlock extends NodeMaterialBlock {
  64307. /**
  64308. * Creates a new NormalBlendBlock
  64309. * @param name defines the block name
  64310. */
  64311. constructor(name: string);
  64312. /**
  64313. * Gets the current class name
  64314. * @returns the class name
  64315. */
  64316. getClassName(): string;
  64317. /**
  64318. * Gets the first input component
  64319. */
  64320. get normalMap0(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the second input component
  64323. */
  64324. get normalMap1(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the output component
  64327. */
  64328. get output(): NodeMaterialConnectionPoint;
  64329. protected _buildBlock(state: NodeMaterialBuildState): this;
  64330. }
  64331. }
  64332. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64336. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64337. /**
  64338. * Block used to rotate a 2d vector by a given angle
  64339. */
  64340. export class Rotate2dBlock extends NodeMaterialBlock {
  64341. /**
  64342. * Creates a new Rotate2dBlock
  64343. * @param name defines the block name
  64344. */
  64345. constructor(name: string);
  64346. /**
  64347. * Gets the current class name
  64348. * @returns the class name
  64349. */
  64350. getClassName(): string;
  64351. /**
  64352. * Gets the input vector
  64353. */
  64354. get input(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the input angle
  64357. */
  64358. get angle(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the output component
  64361. */
  64362. get output(): NodeMaterialConnectionPoint;
  64363. autoConfigure(material: NodeMaterial): void;
  64364. protected _buildBlock(state: NodeMaterialBuildState): this;
  64365. }
  64366. }
  64367. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64371. /**
  64372. * Block used to get the reflected vector from a direction and a normal
  64373. */
  64374. export class ReflectBlock extends NodeMaterialBlock {
  64375. /**
  64376. * Creates a new ReflectBlock
  64377. * @param name defines the block name
  64378. */
  64379. constructor(name: string);
  64380. /**
  64381. * Gets the current class name
  64382. * @returns the class name
  64383. */
  64384. getClassName(): string;
  64385. /**
  64386. * Gets the incident component
  64387. */
  64388. get incident(): NodeMaterialConnectionPoint;
  64389. /**
  64390. * Gets the normal component
  64391. */
  64392. get normal(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the output component
  64395. */
  64396. get output(): NodeMaterialConnectionPoint;
  64397. protected _buildBlock(state: NodeMaterialBuildState): this;
  64398. }
  64399. }
  64400. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64404. /**
  64405. * Block used to get the refracted vector from a direction and a normal
  64406. */
  64407. export class RefractBlock extends NodeMaterialBlock {
  64408. /**
  64409. * Creates a new RefractBlock
  64410. * @param name defines the block name
  64411. */
  64412. constructor(name: string);
  64413. /**
  64414. * Gets the current class name
  64415. * @returns the class name
  64416. */
  64417. getClassName(): string;
  64418. /**
  64419. * Gets the incident component
  64420. */
  64421. get incident(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the normal component
  64424. */
  64425. get normal(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the index of refraction component
  64428. */
  64429. get ior(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the output component
  64432. */
  64433. get output(): NodeMaterialConnectionPoint;
  64434. protected _buildBlock(state: NodeMaterialBuildState): this;
  64435. }
  64436. }
  64437. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64441. /**
  64442. * Block used to desaturate a color
  64443. */
  64444. export class DesaturateBlock extends NodeMaterialBlock {
  64445. /**
  64446. * Creates a new DesaturateBlock
  64447. * @param name defines the block name
  64448. */
  64449. constructor(name: string);
  64450. /**
  64451. * Gets the current class name
  64452. * @returns the class name
  64453. */
  64454. getClassName(): string;
  64455. /**
  64456. * Gets the color operand input component
  64457. */
  64458. get color(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the level operand input component
  64461. */
  64462. get level(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the output component
  64465. */
  64466. get output(): NodeMaterialConnectionPoint;
  64467. protected _buildBlock(state: NodeMaterialBuildState): this;
  64468. }
  64469. }
  64470. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64474. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64475. import { Nullable } from "babylonjs/types";
  64476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64477. import { Scene } from "babylonjs/scene";
  64478. /**
  64479. * Block used to implement the ambient occlusion module of the PBR material
  64480. */
  64481. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64482. /**
  64483. * Create a new AmbientOcclusionBlock
  64484. * @param name defines the block name
  64485. */
  64486. constructor(name: string);
  64487. /**
  64488. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64489. */
  64490. useAmbientInGrayScale: boolean;
  64491. /**
  64492. * Initialize the block and prepare the context for build
  64493. * @param state defines the state that will be used for the build
  64494. */
  64495. initialize(state: NodeMaterialBuildState): void;
  64496. /**
  64497. * Gets the current class name
  64498. * @returns the class name
  64499. */
  64500. getClassName(): string;
  64501. /**
  64502. * Gets the texture input component
  64503. */
  64504. get texture(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the texture intensity component
  64507. */
  64508. get intensity(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the direct light intensity input component
  64511. */
  64512. get directLightIntensity(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the ambient occlusion object output component
  64515. */
  64516. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the main code of the block (fragment side)
  64519. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64520. * @returns the shader code
  64521. */
  64522. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64524. protected _buildBlock(state: NodeMaterialBuildState): this;
  64525. protected _dumpPropertiesCode(): string;
  64526. serialize(): any;
  64527. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64528. }
  64529. }
  64530. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64533. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64534. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64536. import { Nullable } from "babylonjs/types";
  64537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64538. import { Mesh } from "babylonjs/Meshes/mesh";
  64539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64540. import { Effect } from "babylonjs/Materials/effect";
  64541. import { Scene } from "babylonjs/scene";
  64542. /**
  64543. * Block used to implement the reflection module of the PBR material
  64544. */
  64545. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64546. /** @hidden */
  64547. _defineLODReflectionAlpha: string;
  64548. /** @hidden */
  64549. _defineLinearSpecularReflection: string;
  64550. private _vEnvironmentIrradianceName;
  64551. /** @hidden */
  64552. _vReflectionMicrosurfaceInfosName: string;
  64553. /** @hidden */
  64554. _vReflectionInfosName: string;
  64555. private _scene;
  64556. /**
  64557. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64558. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64559. * It's less burden on the user side in the editor part.
  64560. */
  64561. /** @hidden */
  64562. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64563. /** @hidden */
  64564. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64565. /** @hidden */
  64566. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64567. /**
  64568. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64569. * diffuse part of the IBL.
  64570. */
  64571. useSphericalHarmonics: boolean;
  64572. /**
  64573. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64574. */
  64575. forceIrradianceInFragment: boolean;
  64576. /**
  64577. * Create a new ReflectionBlock
  64578. * @param name defines the block name
  64579. */
  64580. constructor(name: string);
  64581. /**
  64582. * Gets the current class name
  64583. * @returns the class name
  64584. */
  64585. getClassName(): string;
  64586. /**
  64587. * Gets the position input component
  64588. */
  64589. get position(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the world position input component
  64592. */
  64593. get worldPosition(): NodeMaterialConnectionPoint;
  64594. /**
  64595. * Gets the world normal input component
  64596. */
  64597. get worldNormal(): NodeMaterialConnectionPoint;
  64598. /**
  64599. * Gets the world input component
  64600. */
  64601. get world(): NodeMaterialConnectionPoint;
  64602. /**
  64603. * Gets the camera (or eye) position component
  64604. */
  64605. get cameraPosition(): NodeMaterialConnectionPoint;
  64606. /**
  64607. * Gets the view input component
  64608. */
  64609. get view(): NodeMaterialConnectionPoint;
  64610. /**
  64611. * Gets the color input component
  64612. */
  64613. get color(): NodeMaterialConnectionPoint;
  64614. /**
  64615. * Gets the reflection object output component
  64616. */
  64617. get reflection(): NodeMaterialConnectionPoint;
  64618. /**
  64619. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64620. */
  64621. get hasTexture(): boolean;
  64622. /**
  64623. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64624. */
  64625. get reflectionColor(): string;
  64626. protected _getTexture(): Nullable<BaseTexture>;
  64627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64629. /**
  64630. * Gets the code to inject in the vertex shader
  64631. * @param state current state of the node material building
  64632. * @returns the shader code
  64633. */
  64634. handleVertexSide(state: NodeMaterialBuildState): string;
  64635. /**
  64636. * Gets the main code of the block (fragment side)
  64637. * @param state current state of the node material building
  64638. * @param normalVarName name of the existing variable corresponding to the normal
  64639. * @returns the shader code
  64640. */
  64641. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64642. protected _buildBlock(state: NodeMaterialBuildState): this;
  64643. protected _dumpPropertiesCode(): string;
  64644. serialize(): any;
  64645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64646. }
  64647. }
  64648. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64652. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64654. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64655. import { Scene } from "babylonjs/scene";
  64656. import { Nullable } from "babylonjs/types";
  64657. /**
  64658. * Block used to implement the sheen module of the PBR material
  64659. */
  64660. export class SheenBlock extends NodeMaterialBlock {
  64661. /**
  64662. * Create a new SheenBlock
  64663. * @param name defines the block name
  64664. */
  64665. constructor(name: string);
  64666. /**
  64667. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64668. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64669. * making it easier to setup and tweak the effect
  64670. */
  64671. albedoScaling: boolean;
  64672. /**
  64673. * Defines if the sheen is linked to the sheen color.
  64674. */
  64675. linkSheenWithAlbedo: boolean;
  64676. /**
  64677. * Initialize the block and prepare the context for build
  64678. * @param state defines the state that will be used for the build
  64679. */
  64680. initialize(state: NodeMaterialBuildState): void;
  64681. /**
  64682. * Gets the current class name
  64683. * @returns the class name
  64684. */
  64685. getClassName(): string;
  64686. /**
  64687. * Gets the intensity input component
  64688. */
  64689. get intensity(): NodeMaterialConnectionPoint;
  64690. /**
  64691. * Gets the color input component
  64692. */
  64693. get color(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the roughness input component
  64696. */
  64697. get roughness(): NodeMaterialConnectionPoint;
  64698. /**
  64699. * Gets the texture input component
  64700. */
  64701. get texture(): NodeMaterialConnectionPoint;
  64702. /**
  64703. * Gets the sheen object output component
  64704. */
  64705. get sheen(): NodeMaterialConnectionPoint;
  64706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64707. /**
  64708. * Gets the main code of the block (fragment side)
  64709. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64710. * @returns the shader code
  64711. */
  64712. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64713. protected _buildBlock(state: NodeMaterialBuildState): this;
  64714. protected _dumpPropertiesCode(): string;
  64715. serialize(): any;
  64716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64717. }
  64718. }
  64719. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64720. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64725. import { Scene } from "babylonjs/scene";
  64726. /**
  64727. * Block used to implement the reflectivity module of the PBR material
  64728. */
  64729. export class ReflectivityBlock extends NodeMaterialBlock {
  64730. /**
  64731. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64732. */
  64733. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64734. /**
  64735. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64736. */
  64737. useMetallnessFromMetallicTextureBlue: boolean;
  64738. /**
  64739. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64740. */
  64741. useRoughnessFromMetallicTextureAlpha: boolean;
  64742. /**
  64743. * Specifies if the metallic texture contains the roughness information in its green channel.
  64744. */
  64745. useRoughnessFromMetallicTextureGreen: boolean;
  64746. /**
  64747. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64748. */
  64749. useMetallicF0FactorFromMetallicTexture: boolean;
  64750. /**
  64751. * Create a new ReflectivityBlock
  64752. * @param name defines the block name
  64753. */
  64754. constructor(name: string);
  64755. /**
  64756. * Initialize the block and prepare the context for build
  64757. * @param state defines the state that will be used for the build
  64758. */
  64759. initialize(state: NodeMaterialBuildState): void;
  64760. /**
  64761. * Gets the current class name
  64762. * @returns the class name
  64763. */
  64764. getClassName(): string;
  64765. /**
  64766. * Gets the metallic input component
  64767. */
  64768. get metallic(): NodeMaterialConnectionPoint;
  64769. /**
  64770. * Gets the roughness input component
  64771. */
  64772. get roughness(): NodeMaterialConnectionPoint;
  64773. /**
  64774. * Gets the texture input component
  64775. */
  64776. get texture(): NodeMaterialConnectionPoint;
  64777. /**
  64778. * Gets the reflectivity object output component
  64779. */
  64780. get reflectivity(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the main code of the block (fragment side)
  64783. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64784. * @returns the shader code
  64785. */
  64786. getCode(aoIntensityVarName: string): string;
  64787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64788. protected _buildBlock(state: NodeMaterialBuildState): this;
  64789. protected _dumpPropertiesCode(): string;
  64790. serialize(): any;
  64791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64792. }
  64793. }
  64794. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64795. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64800. /**
  64801. * Block used to implement the anisotropy module of the PBR material
  64802. */
  64803. export class AnisotropyBlock extends NodeMaterialBlock {
  64804. /**
  64805. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64806. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64807. * It's less burden on the user side in the editor part.
  64808. */
  64809. /** @hidden */
  64810. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64811. /** @hidden */
  64812. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64813. /**
  64814. * Create a new AnisotropyBlock
  64815. * @param name defines the block name
  64816. */
  64817. constructor(name: string);
  64818. /**
  64819. * Initialize the block and prepare the context for build
  64820. * @param state defines the state that will be used for the build
  64821. */
  64822. initialize(state: NodeMaterialBuildState): void;
  64823. /**
  64824. * Gets the current class name
  64825. * @returns the class name
  64826. */
  64827. getClassName(): string;
  64828. /**
  64829. * Gets the intensity input component
  64830. */
  64831. get intensity(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the direction input component
  64834. */
  64835. get direction(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the texture input component
  64838. */
  64839. get texture(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the uv input component
  64842. */
  64843. get uv(): NodeMaterialConnectionPoint;
  64844. /**
  64845. * Gets the worldTangent input component
  64846. */
  64847. get worldTangent(): NodeMaterialConnectionPoint;
  64848. /**
  64849. * Gets the anisotropy object output component
  64850. */
  64851. get anisotropy(): NodeMaterialConnectionPoint;
  64852. private _generateTBNSpace;
  64853. /**
  64854. * Gets the main code of the block (fragment side)
  64855. * @param state current state of the node material building
  64856. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64857. * @returns the shader code
  64858. */
  64859. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64861. protected _buildBlock(state: NodeMaterialBuildState): this;
  64862. }
  64863. }
  64864. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64868. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64870. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64871. import { Nullable } from "babylonjs/types";
  64872. import { Mesh } from "babylonjs/Meshes/mesh";
  64873. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64874. import { Effect } from "babylonjs/Materials/effect";
  64875. /**
  64876. * Block used to implement the clear coat module of the PBR material
  64877. */
  64878. export class ClearCoatBlock extends NodeMaterialBlock {
  64879. private _scene;
  64880. /**
  64881. * Create a new ClearCoatBlock
  64882. * @param name defines the block name
  64883. */
  64884. constructor(name: string);
  64885. /**
  64886. * Initialize the block and prepare the context for build
  64887. * @param state defines the state that will be used for the build
  64888. */
  64889. initialize(state: NodeMaterialBuildState): void;
  64890. /**
  64891. * Gets the current class name
  64892. * @returns the class name
  64893. */
  64894. getClassName(): string;
  64895. /**
  64896. * Gets the intensity input component
  64897. */
  64898. get intensity(): NodeMaterialConnectionPoint;
  64899. /**
  64900. * Gets the roughness input component
  64901. */
  64902. get roughness(): NodeMaterialConnectionPoint;
  64903. /**
  64904. * Gets the ior input component
  64905. */
  64906. get ior(): NodeMaterialConnectionPoint;
  64907. /**
  64908. * Gets the texture input component
  64909. */
  64910. get texture(): NodeMaterialConnectionPoint;
  64911. /**
  64912. * Gets the bump texture input component
  64913. */
  64914. get bumpTexture(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Gets the uv input component
  64917. */
  64918. get uv(): NodeMaterialConnectionPoint;
  64919. /**
  64920. * Gets the tint color input component
  64921. */
  64922. get tintColor(): NodeMaterialConnectionPoint;
  64923. /**
  64924. * Gets the tint "at distance" input component
  64925. */
  64926. get tintAtDistance(): NodeMaterialConnectionPoint;
  64927. /**
  64928. * Gets the tint thickness input component
  64929. */
  64930. get tintThickness(): NodeMaterialConnectionPoint;
  64931. /**
  64932. * Gets the tint texture input component
  64933. */
  64934. get tintTexture(): NodeMaterialConnectionPoint;
  64935. /**
  64936. * Gets the world tangent input component
  64937. */
  64938. get worldTangent(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the clear coat object output component
  64941. */
  64942. get clearcoat(): NodeMaterialConnectionPoint;
  64943. autoConfigure(material: NodeMaterial): void;
  64944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64946. private _generateTBNSpace;
  64947. /**
  64948. * Gets the main code of the block (fragment side)
  64949. * @param state current state of the node material building
  64950. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64951. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64952. * @param worldPosVarName name of the variable holding the world position
  64953. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64954. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64955. * @param worldNormalVarName name of the variable holding the world normal
  64956. * @returns the shader code
  64957. */
  64958. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64959. protected _buildBlock(state: NodeMaterialBuildState): this;
  64960. }
  64961. }
  64962. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  64963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64966. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64968. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64969. import { Nullable } from "babylonjs/types";
  64970. /**
  64971. * Block used to implement the sub surface module of the PBR material
  64972. */
  64973. export class SubSurfaceBlock extends NodeMaterialBlock {
  64974. /**
  64975. * Create a new SubSurfaceBlock
  64976. * @param name defines the block name
  64977. */
  64978. constructor(name: string);
  64979. /**
  64980. * Stores the intensity of the different subsurface effects in the thickness texture.
  64981. * * the green channel is the translucency intensity.
  64982. * * the blue channel is the scattering intensity.
  64983. * * the alpha channel is the refraction intensity.
  64984. */
  64985. useMaskFromThicknessTexture: boolean;
  64986. /**
  64987. * Initialize the block and prepare the context for build
  64988. * @param state defines the state that will be used for the build
  64989. */
  64990. initialize(state: NodeMaterialBuildState): void;
  64991. /**
  64992. * Gets the current class name
  64993. * @returns the class name
  64994. */
  64995. getClassName(): string;
  64996. /**
  64997. * Gets the min thickness input component
  64998. */
  64999. get minThickness(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the max thickness input component
  65002. */
  65003. get maxThickness(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the thickness texture component
  65006. */
  65007. get thicknessTexture(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the tint color input component
  65010. */
  65011. get tintColor(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the translucency intensity input component
  65014. */
  65015. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the translucency diffusion distance input component
  65018. */
  65019. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the refraction object parameters
  65022. */
  65023. get refraction(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the sub surface object output component
  65026. */
  65027. get subsurface(): NodeMaterialConnectionPoint;
  65028. autoConfigure(material: NodeMaterial): void;
  65029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65030. /**
  65031. * Gets the main code of the block (fragment side)
  65032. * @param state current state of the node material building
  65033. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65034. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65035. * @param worldPosVarName name of the variable holding the world position
  65036. * @returns the shader code
  65037. */
  65038. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65039. protected _buildBlock(state: NodeMaterialBuildState): this;
  65040. }
  65041. }
  65042. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  65043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65046. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65047. import { Light } from "babylonjs/Lights/light";
  65048. import { Nullable } from "babylonjs/types";
  65049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65050. import { Effect } from "babylonjs/Materials/effect";
  65051. import { Mesh } from "babylonjs/Meshes/mesh";
  65052. import { Scene } from "babylonjs/scene";
  65053. /**
  65054. * Block used to implement the PBR metallic/roughness model
  65055. */
  65056. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65057. /**
  65058. * Gets or sets the light associated with this block
  65059. */
  65060. light: Nullable<Light>;
  65061. private _lightId;
  65062. private _scene;
  65063. private _environmentBRDFTexture;
  65064. private _environmentBrdfSamplerName;
  65065. private _vNormalWName;
  65066. private _invertNormalName;
  65067. /**
  65068. * Create a new ReflectionBlock
  65069. * @param name defines the block name
  65070. */
  65071. constructor(name: string);
  65072. /**
  65073. * Intensity of the direct lights e.g. the four lights available in your scene.
  65074. * This impacts both the direct diffuse and specular highlights.
  65075. */
  65076. directIntensity: number;
  65077. /**
  65078. * Intensity of the environment e.g. how much the environment will light the object
  65079. * either through harmonics for rough material or through the refelction for shiny ones.
  65080. */
  65081. environmentIntensity: number;
  65082. /**
  65083. * This is a special control allowing the reduction of the specular highlights coming from the
  65084. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65085. */
  65086. specularIntensity: number;
  65087. /**
  65088. * Defines the falloff type used in this material.
  65089. * It by default is Physical.
  65090. */
  65091. lightFalloff: number;
  65092. /**
  65093. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65094. */
  65095. useAlphaFromAlbedoTexture: boolean;
  65096. /**
  65097. * Specifies that alpha test should be used
  65098. */
  65099. useAlphaTest: boolean;
  65100. /**
  65101. * Defines the alpha limits in alpha test mode.
  65102. */
  65103. alphaTestCutoff: number;
  65104. /**
  65105. * Specifies that alpha blending should be used
  65106. */
  65107. useAlphaBlending: boolean;
  65108. /**
  65109. * Defines if the alpha value should be determined via the rgb values.
  65110. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65111. */
  65112. opacityRGB: boolean;
  65113. /**
  65114. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65115. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65116. */
  65117. useRadianceOverAlpha: boolean;
  65118. /**
  65119. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65120. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65121. */
  65122. useSpecularOverAlpha: boolean;
  65123. /**
  65124. * Enables specular anti aliasing in the PBR shader.
  65125. * It will both interacts on the Geometry for analytical and IBL lighting.
  65126. * It also prefilter the roughness map based on the bump values.
  65127. */
  65128. enableSpecularAntiAliasing: boolean;
  65129. /**
  65130. * Defines if the material uses energy conservation.
  65131. */
  65132. useEnergyConservation: boolean;
  65133. /**
  65134. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65135. * too much the area relying on ambient texture to define their ambient occlusion.
  65136. */
  65137. useRadianceOcclusion: boolean;
  65138. /**
  65139. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65140. * makes the reflect vector face the model (under horizon).
  65141. */
  65142. useHorizonOcclusion: boolean;
  65143. /**
  65144. * If set to true, no lighting calculations will be applied.
  65145. */
  65146. unlit: boolean;
  65147. /**
  65148. * Force normal to face away from face.
  65149. */
  65150. forceNormalForward: boolean;
  65151. /**
  65152. * Defines the material debug mode.
  65153. * It helps seeing only some components of the material while troubleshooting.
  65154. */
  65155. debugMode: number;
  65156. /**
  65157. * Specify from where on screen the debug mode should start.
  65158. * The value goes from -1 (full screen) to 1 (not visible)
  65159. * It helps with side by side comparison against the final render
  65160. * This defaults to 0
  65161. */
  65162. debugLimit: number;
  65163. /**
  65164. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65165. * You can use the factor to better multiply the final value.
  65166. */
  65167. debugFactor: number;
  65168. /**
  65169. * Initialize the block and prepare the context for build
  65170. * @param state defines the state that will be used for the build
  65171. */
  65172. initialize(state: NodeMaterialBuildState): void;
  65173. /**
  65174. * Gets the current class name
  65175. * @returns the class name
  65176. */
  65177. getClassName(): string;
  65178. /**
  65179. * Gets the world position input component
  65180. */
  65181. get worldPosition(): NodeMaterialConnectionPoint;
  65182. /**
  65183. * Gets the world normal input component
  65184. */
  65185. get worldNormal(): NodeMaterialConnectionPoint;
  65186. /**
  65187. * Gets the perturbed normal input component
  65188. */
  65189. get perturbedNormal(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the camera position input component
  65192. */
  65193. get cameraPosition(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the base color input component
  65196. */
  65197. get baseColor(): NodeMaterialConnectionPoint;
  65198. /**
  65199. * Gets the base texture input component
  65200. */
  65201. get baseTexture(): NodeMaterialConnectionPoint;
  65202. /**
  65203. * Gets the opacity texture input component
  65204. */
  65205. get opacityTexture(): NodeMaterialConnectionPoint;
  65206. /**
  65207. * Gets the ambient color input component
  65208. */
  65209. get ambientColor(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the reflectivity object parameters
  65212. */
  65213. get reflectivity(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the ambient occlusion object parameters
  65216. */
  65217. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the reflection object parameters
  65220. */
  65221. get reflection(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the sheen object parameters
  65224. */
  65225. get sheen(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the clear coat object parameters
  65228. */
  65229. get clearcoat(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the sub surface object parameters
  65232. */
  65233. get subsurface(): NodeMaterialConnectionPoint;
  65234. /**
  65235. * Gets the anisotropy object parameters
  65236. */
  65237. get anisotropy(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the ambient output component
  65240. */
  65241. get ambient(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the diffuse output component
  65244. */
  65245. get diffuse(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the specular output component
  65248. */
  65249. get specular(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the sheen output component
  65252. */
  65253. get sheenDir(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the clear coat output component
  65256. */
  65257. get clearcoatDir(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the indirect diffuse output component
  65260. */
  65261. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65262. /**
  65263. * Gets the indirect specular output component
  65264. */
  65265. get specularIndirect(): NodeMaterialConnectionPoint;
  65266. /**
  65267. * Gets the indirect sheen output component
  65268. */
  65269. get sheenIndirect(): NodeMaterialConnectionPoint;
  65270. /**
  65271. * Gets the indirect clear coat output component
  65272. */
  65273. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the refraction output component
  65276. */
  65277. get refraction(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the global lighting output component
  65280. */
  65281. get lighting(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the shadow output component
  65284. */
  65285. get shadow(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the alpha output component
  65288. */
  65289. get alpha(): NodeMaterialConnectionPoint;
  65290. autoConfigure(material: NodeMaterial): void;
  65291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65292. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65294. private _injectVertexCode;
  65295. /**
  65296. * Gets the code corresponding to the albedo/opacity module
  65297. * @returns the shader code
  65298. */
  65299. getAlbedoOpacityCode(): string;
  65300. protected _buildBlock(state: NodeMaterialBuildState): this;
  65301. protected _dumpPropertiesCode(): string;
  65302. serialize(): any;
  65303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65304. }
  65305. }
  65306. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65307. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65308. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65309. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65310. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65311. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65312. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65313. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65314. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65315. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65316. }
  65317. declare module "babylonjs/Materials/Node/Blocks/index" {
  65318. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65319. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65320. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65321. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65322. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65323. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65324. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65325. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65326. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65327. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65328. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65329. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65330. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65331. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65332. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65333. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65334. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65335. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65336. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65337. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65338. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65339. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65340. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65341. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65342. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65343. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65344. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65345. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65346. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65347. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65348. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65349. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65350. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65351. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65352. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65353. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65354. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65355. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65356. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65357. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65358. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65359. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65360. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65361. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65362. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65363. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65364. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65365. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65366. }
  65367. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65368. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65369. }
  65370. declare module "babylonjs/Materials/Node/index" {
  65371. export * from "babylonjs/Materials/Node/Enums/index";
  65372. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65373. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65374. export * from "babylonjs/Materials/Node/nodeMaterial";
  65375. export * from "babylonjs/Materials/Node/Blocks/index";
  65376. export * from "babylonjs/Materials/Node/Optimizers/index";
  65377. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65378. }
  65379. declare module "babylonjs/Materials/effectRenderer" {
  65380. import { Nullable } from "babylonjs/types";
  65381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65382. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65383. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65384. import { Viewport } from "babylonjs/Maths/math.viewport";
  65385. import { Observable } from "babylonjs/Misc/observable";
  65386. import { Effect } from "babylonjs/Materials/effect";
  65387. import "babylonjs/Shaders/postprocess.vertex";
  65388. /**
  65389. * Effect Render Options
  65390. */
  65391. export interface IEffectRendererOptions {
  65392. /**
  65393. * Defines the vertices positions.
  65394. */
  65395. positions?: number[];
  65396. /**
  65397. * Defines the indices.
  65398. */
  65399. indices?: number[];
  65400. }
  65401. /**
  65402. * Helper class to render one or more effects.
  65403. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65404. */
  65405. export class EffectRenderer {
  65406. private engine;
  65407. private static _DefaultOptions;
  65408. private _vertexBuffers;
  65409. private _indexBuffer;
  65410. private _fullscreenViewport;
  65411. /**
  65412. * Creates an effect renderer
  65413. * @param engine the engine to use for rendering
  65414. * @param options defines the options of the effect renderer
  65415. */
  65416. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65417. /**
  65418. * Sets the current viewport in normalized coordinates 0-1
  65419. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65420. */
  65421. setViewport(viewport?: Viewport): void;
  65422. /**
  65423. * Binds the embedded attributes buffer to the effect.
  65424. * @param effect Defines the effect to bind the attributes for
  65425. */
  65426. bindBuffers(effect: Effect): void;
  65427. /**
  65428. * Sets the current effect wrapper to use during draw.
  65429. * The effect needs to be ready before calling this api.
  65430. * This also sets the default full screen position attribute.
  65431. * @param effectWrapper Defines the effect to draw with
  65432. */
  65433. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65434. /**
  65435. * Draws a full screen quad.
  65436. */
  65437. draw(): void;
  65438. private isRenderTargetTexture;
  65439. /**
  65440. * renders one or more effects to a specified texture
  65441. * @param effectWrapper the effect to renderer
  65442. * @param outputTexture texture to draw to, if null it will render to the screen.
  65443. */
  65444. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65445. /**
  65446. * Disposes of the effect renderer
  65447. */
  65448. dispose(): void;
  65449. }
  65450. /**
  65451. * Options to create an EffectWrapper
  65452. */
  65453. interface EffectWrapperCreationOptions {
  65454. /**
  65455. * Engine to use to create the effect
  65456. */
  65457. engine: ThinEngine;
  65458. /**
  65459. * Fragment shader for the effect
  65460. */
  65461. fragmentShader: string;
  65462. /**
  65463. * Vertex shader for the effect
  65464. */
  65465. vertexShader?: string;
  65466. /**
  65467. * Attributes to use in the shader
  65468. */
  65469. attributeNames?: Array<string>;
  65470. /**
  65471. * Uniforms to use in the shader
  65472. */
  65473. uniformNames?: Array<string>;
  65474. /**
  65475. * Texture sampler names to use in the shader
  65476. */
  65477. samplerNames?: Array<string>;
  65478. /**
  65479. * The friendly name of the effect displayed in Spector.
  65480. */
  65481. name?: string;
  65482. }
  65483. /**
  65484. * Wraps an effect to be used for rendering
  65485. */
  65486. export class EffectWrapper {
  65487. /**
  65488. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65489. */
  65490. onApplyObservable: Observable<{}>;
  65491. /**
  65492. * The underlying effect
  65493. */
  65494. effect: Effect;
  65495. /**
  65496. * Creates an effect to be renderer
  65497. * @param creationOptions options to create the effect
  65498. */
  65499. constructor(creationOptions: EffectWrapperCreationOptions);
  65500. /**
  65501. * Disposes of the effect wrapper
  65502. */
  65503. dispose(): void;
  65504. }
  65505. }
  65506. declare module "babylonjs/Materials/index" {
  65507. export * from "babylonjs/Materials/Background/index";
  65508. export * from "babylonjs/Materials/colorCurves";
  65509. export * from "babylonjs/Materials/iEffectFallbacks";
  65510. export * from "babylonjs/Materials/effectFallbacks";
  65511. export * from "babylonjs/Materials/effect";
  65512. export * from "babylonjs/Materials/fresnelParameters";
  65513. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65514. export * from "babylonjs/Materials/material";
  65515. export * from "babylonjs/Materials/materialDefines";
  65516. export * from "babylonjs/Materials/materialHelper";
  65517. export * from "babylonjs/Materials/multiMaterial";
  65518. export * from "babylonjs/Materials/PBR/index";
  65519. export * from "babylonjs/Materials/pushMaterial";
  65520. export * from "babylonjs/Materials/shaderMaterial";
  65521. export * from "babylonjs/Materials/standardMaterial";
  65522. export * from "babylonjs/Materials/Textures/index";
  65523. export * from "babylonjs/Materials/uniformBuffer";
  65524. export * from "babylonjs/Materials/materialFlags";
  65525. export * from "babylonjs/Materials/Node/index";
  65526. export * from "babylonjs/Materials/effectRenderer";
  65527. export * from "babylonjs/Materials/shadowDepthWrapper";
  65528. }
  65529. declare module "babylonjs/Maths/index" {
  65530. export * from "babylonjs/Maths/math.scalar";
  65531. export * from "babylonjs/Maths/math";
  65532. export * from "babylonjs/Maths/sphericalPolynomial";
  65533. }
  65534. declare module "babylonjs/Misc/workerPool" {
  65535. import { IDisposable } from "babylonjs/scene";
  65536. /**
  65537. * Helper class to push actions to a pool of workers.
  65538. */
  65539. export class WorkerPool implements IDisposable {
  65540. private _workerInfos;
  65541. private _pendingActions;
  65542. /**
  65543. * Constructor
  65544. * @param workers Array of workers to use for actions
  65545. */
  65546. constructor(workers: Array<Worker>);
  65547. /**
  65548. * Terminates all workers and clears any pending actions.
  65549. */
  65550. dispose(): void;
  65551. /**
  65552. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65553. * pended until a worker has completed its action.
  65554. * @param action The action to perform. Call onComplete when the action is complete.
  65555. */
  65556. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65557. private _execute;
  65558. }
  65559. }
  65560. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65561. import { IDisposable } from "babylonjs/scene";
  65562. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65563. /**
  65564. * Configuration for Draco compression
  65565. */
  65566. export interface IDracoCompressionConfiguration {
  65567. /**
  65568. * Configuration for the decoder.
  65569. */
  65570. decoder: {
  65571. /**
  65572. * The url to the WebAssembly module.
  65573. */
  65574. wasmUrl?: string;
  65575. /**
  65576. * The url to the WebAssembly binary.
  65577. */
  65578. wasmBinaryUrl?: string;
  65579. /**
  65580. * The url to the fallback JavaScript module.
  65581. */
  65582. fallbackUrl?: string;
  65583. };
  65584. }
  65585. /**
  65586. * Draco compression (https://google.github.io/draco/)
  65587. *
  65588. * This class wraps the Draco module.
  65589. *
  65590. * **Encoder**
  65591. *
  65592. * The encoder is not currently implemented.
  65593. *
  65594. * **Decoder**
  65595. *
  65596. * 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.
  65597. *
  65598. * To update the configuration, use the following code:
  65599. * ```javascript
  65600. * DracoCompression.Configuration = {
  65601. * decoder: {
  65602. * wasmUrl: "<url to the WebAssembly library>",
  65603. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65604. * fallbackUrl: "<url to the fallback JavaScript library>",
  65605. * }
  65606. * };
  65607. * ```
  65608. *
  65609. * 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.
  65610. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65611. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65612. *
  65613. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65614. * ```javascript
  65615. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65616. * ```
  65617. *
  65618. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65619. */
  65620. export class DracoCompression implements IDisposable {
  65621. private _workerPoolPromise?;
  65622. private _decoderModulePromise?;
  65623. /**
  65624. * The configuration. Defaults to the following urls:
  65625. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65626. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65627. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65628. */
  65629. static Configuration: IDracoCompressionConfiguration;
  65630. /**
  65631. * Returns true if the decoder configuration is available.
  65632. */
  65633. static get DecoderAvailable(): boolean;
  65634. /**
  65635. * Default number of workers to create when creating the draco compression object.
  65636. */
  65637. static DefaultNumWorkers: number;
  65638. private static GetDefaultNumWorkers;
  65639. private static _Default;
  65640. /**
  65641. * Default instance for the draco compression object.
  65642. */
  65643. static get Default(): DracoCompression;
  65644. /**
  65645. * Constructor
  65646. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65647. */
  65648. constructor(numWorkers?: number);
  65649. /**
  65650. * Stop all async operations and release resources.
  65651. */
  65652. dispose(): void;
  65653. /**
  65654. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65655. * @returns a promise that resolves when ready
  65656. */
  65657. whenReadyAsync(): Promise<void>;
  65658. /**
  65659. * Decode Draco compressed mesh data to vertex data.
  65660. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65661. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65662. * @returns A promise that resolves with the decoded vertex data
  65663. */
  65664. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65665. [kind: string]: number;
  65666. }): Promise<VertexData>;
  65667. }
  65668. }
  65669. declare module "babylonjs/Meshes/Compression/index" {
  65670. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65671. }
  65672. declare module "babylonjs/Meshes/csg" {
  65673. import { Nullable } from "babylonjs/types";
  65674. import { Scene } from "babylonjs/scene";
  65675. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65676. import { Mesh } from "babylonjs/Meshes/mesh";
  65677. import { Material } from "babylonjs/Materials/material";
  65678. /**
  65679. * Class for building Constructive Solid Geometry
  65680. */
  65681. export class CSG {
  65682. private polygons;
  65683. /**
  65684. * The world matrix
  65685. */
  65686. matrix: Matrix;
  65687. /**
  65688. * Stores the position
  65689. */
  65690. position: Vector3;
  65691. /**
  65692. * Stores the rotation
  65693. */
  65694. rotation: Vector3;
  65695. /**
  65696. * Stores the rotation quaternion
  65697. */
  65698. rotationQuaternion: Nullable<Quaternion>;
  65699. /**
  65700. * Stores the scaling vector
  65701. */
  65702. scaling: Vector3;
  65703. /**
  65704. * Convert the Mesh to CSG
  65705. * @param mesh The Mesh to convert to CSG
  65706. * @returns A new CSG from the Mesh
  65707. */
  65708. static FromMesh(mesh: Mesh): CSG;
  65709. /**
  65710. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65711. * @param polygons Polygons used to construct a CSG solid
  65712. */
  65713. private static FromPolygons;
  65714. /**
  65715. * Clones, or makes a deep copy, of the CSG
  65716. * @returns A new CSG
  65717. */
  65718. clone(): CSG;
  65719. /**
  65720. * Unions this CSG with another CSG
  65721. * @param csg The CSG to union against this CSG
  65722. * @returns The unioned CSG
  65723. */
  65724. union(csg: CSG): CSG;
  65725. /**
  65726. * Unions this CSG with another CSG in place
  65727. * @param csg The CSG to union against this CSG
  65728. */
  65729. unionInPlace(csg: CSG): void;
  65730. /**
  65731. * Subtracts this CSG with another CSG
  65732. * @param csg The CSG to subtract against this CSG
  65733. * @returns A new CSG
  65734. */
  65735. subtract(csg: CSG): CSG;
  65736. /**
  65737. * Subtracts this CSG with another CSG in place
  65738. * @param csg The CSG to subtact against this CSG
  65739. */
  65740. subtractInPlace(csg: CSG): void;
  65741. /**
  65742. * Intersect this CSG with another CSG
  65743. * @param csg The CSG to intersect against this CSG
  65744. * @returns A new CSG
  65745. */
  65746. intersect(csg: CSG): CSG;
  65747. /**
  65748. * Intersects this CSG with another CSG in place
  65749. * @param csg The CSG to intersect against this CSG
  65750. */
  65751. intersectInPlace(csg: CSG): void;
  65752. /**
  65753. * Return a new CSG solid with solid and empty space switched. This solid is
  65754. * not modified.
  65755. * @returns A new CSG solid with solid and empty space switched
  65756. */
  65757. inverse(): CSG;
  65758. /**
  65759. * Inverses the CSG in place
  65760. */
  65761. inverseInPlace(): void;
  65762. /**
  65763. * This is used to keep meshes transformations so they can be restored
  65764. * when we build back a Babylon Mesh
  65765. * NB : All CSG operations are performed in world coordinates
  65766. * @param csg The CSG to copy the transform attributes from
  65767. * @returns This CSG
  65768. */
  65769. copyTransformAttributes(csg: CSG): CSG;
  65770. /**
  65771. * Build Raw mesh from CSG
  65772. * Coordinates here are in world space
  65773. * @param name The name of the mesh geometry
  65774. * @param scene The Scene
  65775. * @param keepSubMeshes Specifies if the submeshes should be kept
  65776. * @returns A new Mesh
  65777. */
  65778. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65779. /**
  65780. * Build Mesh from CSG taking material and transforms into account
  65781. * @param name The name of the Mesh
  65782. * @param material The material of the Mesh
  65783. * @param scene The Scene
  65784. * @param keepSubMeshes Specifies if submeshes should be kept
  65785. * @returns The new Mesh
  65786. */
  65787. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65788. }
  65789. }
  65790. declare module "babylonjs/Meshes/trailMesh" {
  65791. import { Mesh } from "babylonjs/Meshes/mesh";
  65792. import { Scene } from "babylonjs/scene";
  65793. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65794. /**
  65795. * Class used to create a trail following a mesh
  65796. */
  65797. export class TrailMesh extends Mesh {
  65798. private _generator;
  65799. private _autoStart;
  65800. private _running;
  65801. private _diameter;
  65802. private _length;
  65803. private _sectionPolygonPointsCount;
  65804. private _sectionVectors;
  65805. private _sectionNormalVectors;
  65806. private _beforeRenderObserver;
  65807. /**
  65808. * @constructor
  65809. * @param name The value used by scene.getMeshByName() to do a lookup.
  65810. * @param generator The mesh or transform node to generate a trail.
  65811. * @param scene The scene to add this mesh to.
  65812. * @param diameter Diameter of trailing mesh. Default is 1.
  65813. * @param length Length of trailing mesh. Default is 60.
  65814. * @param autoStart Automatically start trailing mesh. Default true.
  65815. */
  65816. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65817. /**
  65818. * "TrailMesh"
  65819. * @returns "TrailMesh"
  65820. */
  65821. getClassName(): string;
  65822. private _createMesh;
  65823. /**
  65824. * Start trailing mesh.
  65825. */
  65826. start(): void;
  65827. /**
  65828. * Stop trailing mesh.
  65829. */
  65830. stop(): void;
  65831. /**
  65832. * Update trailing mesh geometry.
  65833. */
  65834. update(): void;
  65835. /**
  65836. * Returns a new TrailMesh object.
  65837. * @param name is a string, the name given to the new mesh
  65838. * @param newGenerator use new generator object for cloned trail mesh
  65839. * @returns a new mesh
  65840. */
  65841. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65842. /**
  65843. * Serializes this trail mesh
  65844. * @param serializationObject object to write serialization to
  65845. */
  65846. serialize(serializationObject: any): void;
  65847. /**
  65848. * Parses a serialized trail mesh
  65849. * @param parsedMesh the serialized mesh
  65850. * @param scene the scene to create the trail mesh in
  65851. * @returns the created trail mesh
  65852. */
  65853. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65854. }
  65855. }
  65856. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65857. import { Nullable } from "babylonjs/types";
  65858. import { Scene } from "babylonjs/scene";
  65859. import { Vector4 } from "babylonjs/Maths/math.vector";
  65860. import { Color4 } from "babylonjs/Maths/math.color";
  65861. import { Mesh } from "babylonjs/Meshes/mesh";
  65862. /**
  65863. * Class containing static functions to help procedurally build meshes
  65864. */
  65865. export class TiledBoxBuilder {
  65866. /**
  65867. * Creates a box mesh
  65868. * 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)
  65869. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65873. * @param name defines the name of the mesh
  65874. * @param options defines the options used to create the mesh
  65875. * @param scene defines the hosting scene
  65876. * @returns the box mesh
  65877. */
  65878. static CreateTiledBox(name: string, options: {
  65879. pattern?: number;
  65880. width?: number;
  65881. height?: number;
  65882. depth?: number;
  65883. tileSize?: number;
  65884. tileWidth?: number;
  65885. tileHeight?: number;
  65886. alignHorizontal?: number;
  65887. alignVertical?: number;
  65888. faceUV?: Vector4[];
  65889. faceColors?: Color4[];
  65890. sideOrientation?: number;
  65891. updatable?: boolean;
  65892. }, scene?: Nullable<Scene>): Mesh;
  65893. }
  65894. }
  65895. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65896. import { Vector4 } from "babylonjs/Maths/math.vector";
  65897. import { Mesh } from "babylonjs/Meshes/mesh";
  65898. /**
  65899. * Class containing static functions to help procedurally build meshes
  65900. */
  65901. export class TorusKnotBuilder {
  65902. /**
  65903. * Creates a torus knot mesh
  65904. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65905. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65906. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65907. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65911. * @param name defines the name of the mesh
  65912. * @param options defines the options used to create the mesh
  65913. * @param scene defines the hosting scene
  65914. * @returns the torus knot mesh
  65915. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65916. */
  65917. static CreateTorusKnot(name: string, options: {
  65918. radius?: number;
  65919. tube?: number;
  65920. radialSegments?: number;
  65921. tubularSegments?: number;
  65922. p?: number;
  65923. q?: number;
  65924. updatable?: boolean;
  65925. sideOrientation?: number;
  65926. frontUVs?: Vector4;
  65927. backUVs?: Vector4;
  65928. }, scene: any): Mesh;
  65929. }
  65930. }
  65931. declare module "babylonjs/Meshes/polygonMesh" {
  65932. import { Scene } from "babylonjs/scene";
  65933. import { Vector2 } from "babylonjs/Maths/math.vector";
  65934. import { Mesh } from "babylonjs/Meshes/mesh";
  65935. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65936. import { Path2 } from "babylonjs/Maths/math.path";
  65937. /**
  65938. * Polygon
  65939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65940. */
  65941. export class Polygon {
  65942. /**
  65943. * Creates a rectangle
  65944. * @param xmin bottom X coord
  65945. * @param ymin bottom Y coord
  65946. * @param xmax top X coord
  65947. * @param ymax top Y coord
  65948. * @returns points that make the resulting rectation
  65949. */
  65950. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65951. /**
  65952. * Creates a circle
  65953. * @param radius radius of circle
  65954. * @param cx scale in x
  65955. * @param cy scale in y
  65956. * @param numberOfSides number of sides that make up the circle
  65957. * @returns points that make the resulting circle
  65958. */
  65959. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65960. /**
  65961. * Creates a polygon from input string
  65962. * @param input Input polygon data
  65963. * @returns the parsed points
  65964. */
  65965. static Parse(input: string): Vector2[];
  65966. /**
  65967. * Starts building a polygon from x and y coordinates
  65968. * @param x x coordinate
  65969. * @param y y coordinate
  65970. * @returns the started path2
  65971. */
  65972. static StartingAt(x: number, y: number): Path2;
  65973. }
  65974. /**
  65975. * Builds a polygon
  65976. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65977. */
  65978. export class PolygonMeshBuilder {
  65979. private _points;
  65980. private _outlinepoints;
  65981. private _holes;
  65982. private _name;
  65983. private _scene;
  65984. private _epoints;
  65985. private _eholes;
  65986. private _addToepoint;
  65987. /**
  65988. * Babylon reference to the earcut plugin.
  65989. */
  65990. bjsEarcut: any;
  65991. /**
  65992. * Creates a PolygonMeshBuilder
  65993. * @param name name of the builder
  65994. * @param contours Path of the polygon
  65995. * @param scene scene to add to when creating the mesh
  65996. * @param earcutInjection can be used to inject your own earcut reference
  65997. */
  65998. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65999. /**
  66000. * Adds a whole within the polygon
  66001. * @param hole Array of points defining the hole
  66002. * @returns this
  66003. */
  66004. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66005. /**
  66006. * Creates the polygon
  66007. * @param updatable If the mesh should be updatable
  66008. * @param depth The depth of the mesh created
  66009. * @returns the created mesh
  66010. */
  66011. build(updatable?: boolean, depth?: number): Mesh;
  66012. /**
  66013. * Creates the polygon
  66014. * @param depth The depth of the mesh created
  66015. * @returns the created VertexData
  66016. */
  66017. buildVertexData(depth?: number): VertexData;
  66018. /**
  66019. * Adds a side to the polygon
  66020. * @param positions points that make the polygon
  66021. * @param normals normals of the polygon
  66022. * @param uvs uvs of the polygon
  66023. * @param indices indices of the polygon
  66024. * @param bounds bounds of the polygon
  66025. * @param points points of the polygon
  66026. * @param depth depth of the polygon
  66027. * @param flip flip of the polygon
  66028. */
  66029. private addSide;
  66030. }
  66031. }
  66032. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66033. import { Scene } from "babylonjs/scene";
  66034. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66035. import { Color4 } from "babylonjs/Maths/math.color";
  66036. import { Mesh } from "babylonjs/Meshes/mesh";
  66037. import { Nullable } from "babylonjs/types";
  66038. /**
  66039. * Class containing static functions to help procedurally build meshes
  66040. */
  66041. export class PolygonBuilder {
  66042. /**
  66043. * Creates a polygon mesh
  66044. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66045. * * 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
  66046. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66049. * * Remember you can only change the shape positions, not their number when updating a polygon
  66050. * @param name defines the name of the mesh
  66051. * @param options defines the options used to create the mesh
  66052. * @param scene defines the hosting scene
  66053. * @param earcutInjection can be used to inject your own earcut reference
  66054. * @returns the polygon mesh
  66055. */
  66056. static CreatePolygon(name: string, options: {
  66057. shape: Vector3[];
  66058. holes?: Vector3[][];
  66059. depth?: number;
  66060. faceUV?: Vector4[];
  66061. faceColors?: Color4[];
  66062. updatable?: boolean;
  66063. sideOrientation?: number;
  66064. frontUVs?: Vector4;
  66065. backUVs?: Vector4;
  66066. wrap?: boolean;
  66067. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66068. /**
  66069. * Creates an extruded polygon mesh, with depth in the Y direction.
  66070. * * 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)
  66071. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66072. * @param name defines the name of the mesh
  66073. * @param options defines the options used to create the mesh
  66074. * @param scene defines the hosting scene
  66075. * @param earcutInjection can be used to inject your own earcut reference
  66076. * @returns the polygon mesh
  66077. */
  66078. static ExtrudePolygon(name: string, options: {
  66079. shape: Vector3[];
  66080. holes?: Vector3[][];
  66081. depth?: number;
  66082. faceUV?: Vector4[];
  66083. faceColors?: Color4[];
  66084. updatable?: boolean;
  66085. sideOrientation?: number;
  66086. frontUVs?: Vector4;
  66087. backUVs?: Vector4;
  66088. wrap?: boolean;
  66089. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66090. }
  66091. }
  66092. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  66093. import { Scene } from "babylonjs/scene";
  66094. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66095. import { Mesh } from "babylonjs/Meshes/mesh";
  66096. import { Nullable } from "babylonjs/types";
  66097. /**
  66098. * Class containing static functions to help procedurally build meshes
  66099. */
  66100. export class LatheBuilder {
  66101. /**
  66102. * Creates lathe mesh.
  66103. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66104. * * 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
  66105. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66106. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66107. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66108. * * 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
  66109. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66110. * * 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
  66111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66113. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66115. * @param name defines the name of the mesh
  66116. * @param options defines the options used to create the mesh
  66117. * @param scene defines the hosting scene
  66118. * @returns the lathe mesh
  66119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66120. */
  66121. static CreateLathe(name: string, options: {
  66122. shape: Vector3[];
  66123. radius?: number;
  66124. tessellation?: number;
  66125. clip?: number;
  66126. arc?: number;
  66127. closed?: boolean;
  66128. updatable?: boolean;
  66129. sideOrientation?: number;
  66130. frontUVs?: Vector4;
  66131. backUVs?: Vector4;
  66132. cap?: number;
  66133. invertUV?: boolean;
  66134. }, scene?: Nullable<Scene>): Mesh;
  66135. }
  66136. }
  66137. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  66138. import { Nullable } from "babylonjs/types";
  66139. import { Scene } from "babylonjs/scene";
  66140. import { Vector4 } from "babylonjs/Maths/math.vector";
  66141. import { Mesh } from "babylonjs/Meshes/mesh";
  66142. /**
  66143. * Class containing static functions to help procedurally build meshes
  66144. */
  66145. export class TiledPlaneBuilder {
  66146. /**
  66147. * Creates a tiled plane mesh
  66148. * * The parameter `pattern` will, depending on value, do nothing or
  66149. * * * flip (reflect about central vertical) alternate tiles across and up
  66150. * * * flip every tile on alternate rows
  66151. * * * rotate (180 degs) alternate tiles across and up
  66152. * * * rotate every tile on alternate rows
  66153. * * * flip and rotate alternate tiles across and up
  66154. * * * flip and rotate every tile on alternate rows
  66155. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66156. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66159. * * 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)
  66160. * * 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)
  66161. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66162. * @param name defines the name of the mesh
  66163. * @param options defines the options used to create the mesh
  66164. * @param scene defines the hosting scene
  66165. * @returns the box mesh
  66166. */
  66167. static CreateTiledPlane(name: string, options: {
  66168. pattern?: number;
  66169. tileSize?: number;
  66170. tileWidth?: number;
  66171. tileHeight?: number;
  66172. size?: number;
  66173. width?: number;
  66174. height?: number;
  66175. alignHorizontal?: number;
  66176. alignVertical?: number;
  66177. sideOrientation?: number;
  66178. frontUVs?: Vector4;
  66179. backUVs?: Vector4;
  66180. updatable?: boolean;
  66181. }, scene?: Nullable<Scene>): Mesh;
  66182. }
  66183. }
  66184. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66185. import { Nullable } from "babylonjs/types";
  66186. import { Scene } from "babylonjs/scene";
  66187. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66188. import { Mesh } from "babylonjs/Meshes/mesh";
  66189. /**
  66190. * Class containing static functions to help procedurally build meshes
  66191. */
  66192. export class TubeBuilder {
  66193. /**
  66194. * Creates a tube mesh.
  66195. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66196. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66197. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66198. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66199. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66200. * * 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)
  66201. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66202. * * 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
  66203. * * 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
  66204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66206. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66208. * @param name defines the name of the mesh
  66209. * @param options defines the options used to create the mesh
  66210. * @param scene defines the hosting scene
  66211. * @returns the tube mesh
  66212. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66213. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66214. */
  66215. static CreateTube(name: string, options: {
  66216. path: Vector3[];
  66217. radius?: number;
  66218. tessellation?: number;
  66219. radiusFunction?: {
  66220. (i: number, distance: number): number;
  66221. };
  66222. cap?: number;
  66223. arc?: number;
  66224. updatable?: boolean;
  66225. sideOrientation?: number;
  66226. frontUVs?: Vector4;
  66227. backUVs?: Vector4;
  66228. instance?: Mesh;
  66229. invertUV?: boolean;
  66230. }, scene?: Nullable<Scene>): Mesh;
  66231. }
  66232. }
  66233. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66234. import { Scene } from "babylonjs/scene";
  66235. import { Vector4 } from "babylonjs/Maths/math.vector";
  66236. import { Mesh } from "babylonjs/Meshes/mesh";
  66237. import { Nullable } from "babylonjs/types";
  66238. /**
  66239. * Class containing static functions to help procedurally build meshes
  66240. */
  66241. export class IcoSphereBuilder {
  66242. /**
  66243. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66244. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66245. * * 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`)
  66246. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66247. * * 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
  66248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66251. * @param name defines the name of the mesh
  66252. * @param options defines the options used to create the mesh
  66253. * @param scene defines the hosting scene
  66254. * @returns the icosahedron mesh
  66255. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66256. */
  66257. static CreateIcoSphere(name: string, options: {
  66258. radius?: number;
  66259. radiusX?: number;
  66260. radiusY?: number;
  66261. radiusZ?: number;
  66262. flat?: boolean;
  66263. subdivisions?: number;
  66264. sideOrientation?: number;
  66265. frontUVs?: Vector4;
  66266. backUVs?: Vector4;
  66267. updatable?: boolean;
  66268. }, scene?: Nullable<Scene>): Mesh;
  66269. }
  66270. }
  66271. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66272. import { Vector3 } from "babylonjs/Maths/math.vector";
  66273. import { Mesh } from "babylonjs/Meshes/mesh";
  66274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66275. /**
  66276. * Class containing static functions to help procedurally build meshes
  66277. */
  66278. export class DecalBuilder {
  66279. /**
  66280. * Creates a decal mesh.
  66281. * 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
  66282. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66283. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66284. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66285. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66286. * @param name defines the name of the mesh
  66287. * @param sourceMesh defines the mesh where the decal must be applied
  66288. * @param options defines the options used to create the mesh
  66289. * @param scene defines the hosting scene
  66290. * @returns the decal mesh
  66291. * @see https://doc.babylonjs.com/how_to/decals
  66292. */
  66293. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66294. position?: Vector3;
  66295. normal?: Vector3;
  66296. size?: Vector3;
  66297. angle?: number;
  66298. }): Mesh;
  66299. }
  66300. }
  66301. declare module "babylonjs/Meshes/meshBuilder" {
  66302. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66303. import { Nullable } from "babylonjs/types";
  66304. import { Scene } from "babylonjs/scene";
  66305. import { Mesh } from "babylonjs/Meshes/mesh";
  66306. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66307. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66309. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66310. import { Plane } from "babylonjs/Maths/math.plane";
  66311. /**
  66312. * Class containing static functions to help procedurally build meshes
  66313. */
  66314. export class MeshBuilder {
  66315. /**
  66316. * Creates a box mesh
  66317. * * The parameter `size` sets the size (float) of each box side (default 1)
  66318. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66319. * * 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)
  66320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66324. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66325. * @param name defines the name of the mesh
  66326. * @param options defines the options used to create the mesh
  66327. * @param scene defines the hosting scene
  66328. * @returns the box mesh
  66329. */
  66330. static CreateBox(name: string, options: {
  66331. size?: number;
  66332. width?: number;
  66333. height?: number;
  66334. depth?: number;
  66335. faceUV?: Vector4[];
  66336. faceColors?: Color4[];
  66337. sideOrientation?: number;
  66338. frontUVs?: Vector4;
  66339. backUVs?: Vector4;
  66340. wrap?: boolean;
  66341. topBaseAt?: number;
  66342. bottomBaseAt?: number;
  66343. updatable?: boolean;
  66344. }, scene?: Nullable<Scene>): Mesh;
  66345. /**
  66346. * Creates a tiled box mesh
  66347. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66349. * @param name defines the name of the mesh
  66350. * @param options defines the options used to create the mesh
  66351. * @param scene defines the hosting scene
  66352. * @returns the tiled box mesh
  66353. */
  66354. static CreateTiledBox(name: string, options: {
  66355. pattern?: number;
  66356. size?: number;
  66357. width?: number;
  66358. height?: number;
  66359. depth: number;
  66360. tileSize?: number;
  66361. tileWidth?: number;
  66362. tileHeight?: number;
  66363. faceUV?: Vector4[];
  66364. faceColors?: Color4[];
  66365. alignHorizontal?: number;
  66366. alignVertical?: number;
  66367. sideOrientation?: number;
  66368. updatable?: boolean;
  66369. }, scene?: Nullable<Scene>): Mesh;
  66370. /**
  66371. * Creates a sphere mesh
  66372. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66373. * * 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`)
  66374. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66375. * * 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
  66376. * * 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)
  66377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66380. * @param name defines the name of the mesh
  66381. * @param options defines the options used to create the mesh
  66382. * @param scene defines the hosting scene
  66383. * @returns the sphere mesh
  66384. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66385. */
  66386. static CreateSphere(name: string, options: {
  66387. segments?: number;
  66388. diameter?: number;
  66389. diameterX?: number;
  66390. diameterY?: number;
  66391. diameterZ?: number;
  66392. arc?: number;
  66393. slice?: number;
  66394. sideOrientation?: number;
  66395. frontUVs?: Vector4;
  66396. backUVs?: Vector4;
  66397. updatable?: boolean;
  66398. }, scene?: Nullable<Scene>): Mesh;
  66399. /**
  66400. * Creates a plane polygonal mesh. By default, this is a disc
  66401. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66402. * * 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
  66403. * * 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
  66404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66407. * @param name defines the name of the mesh
  66408. * @param options defines the options used to create the mesh
  66409. * @param scene defines the hosting scene
  66410. * @returns the plane polygonal mesh
  66411. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66412. */
  66413. static CreateDisc(name: string, options: {
  66414. radius?: number;
  66415. tessellation?: number;
  66416. arc?: number;
  66417. updatable?: boolean;
  66418. sideOrientation?: number;
  66419. frontUVs?: Vector4;
  66420. backUVs?: Vector4;
  66421. }, scene?: Nullable<Scene>): Mesh;
  66422. /**
  66423. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66424. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66425. * * 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`)
  66426. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66427. * * 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
  66428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66431. * @param name defines the name of the mesh
  66432. * @param options defines the options used to create the mesh
  66433. * @param scene defines the hosting scene
  66434. * @returns the icosahedron mesh
  66435. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66436. */
  66437. static CreateIcoSphere(name: string, options: {
  66438. radius?: number;
  66439. radiusX?: number;
  66440. radiusY?: number;
  66441. radiusZ?: number;
  66442. flat?: boolean;
  66443. subdivisions?: number;
  66444. sideOrientation?: number;
  66445. frontUVs?: Vector4;
  66446. backUVs?: Vector4;
  66447. updatable?: boolean;
  66448. }, scene?: Nullable<Scene>): Mesh;
  66449. /**
  66450. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66451. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66452. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66453. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66454. * * 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
  66455. * * 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
  66456. * * 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
  66457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66460. * * 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
  66461. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66462. * * 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
  66463. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66465. * @param name defines the name of the mesh
  66466. * @param options defines the options used to create the mesh
  66467. * @param scene defines the hosting scene
  66468. * @returns the ribbon mesh
  66469. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66471. */
  66472. static CreateRibbon(name: string, options: {
  66473. pathArray: Vector3[][];
  66474. closeArray?: boolean;
  66475. closePath?: boolean;
  66476. offset?: number;
  66477. updatable?: boolean;
  66478. sideOrientation?: number;
  66479. frontUVs?: Vector4;
  66480. backUVs?: Vector4;
  66481. instance?: Mesh;
  66482. invertUV?: boolean;
  66483. uvs?: Vector2[];
  66484. colors?: Color4[];
  66485. }, scene?: Nullable<Scene>): Mesh;
  66486. /**
  66487. * Creates a cylinder or a cone mesh
  66488. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66489. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66490. * * 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.
  66491. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66492. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66493. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66494. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66495. * * 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).
  66496. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66497. * * 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).
  66498. * * 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
  66499. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66500. * * 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
  66501. * * 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.
  66502. * * If `enclose` is false, a ring surface is one element.
  66503. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66504. * * 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
  66505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66508. * @param name defines the name of the mesh
  66509. * @param options defines the options used to create the mesh
  66510. * @param scene defines the hosting scene
  66511. * @returns the cylinder mesh
  66512. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66513. */
  66514. static CreateCylinder(name: string, options: {
  66515. height?: number;
  66516. diameterTop?: number;
  66517. diameterBottom?: number;
  66518. diameter?: number;
  66519. tessellation?: number;
  66520. subdivisions?: number;
  66521. arc?: number;
  66522. faceColors?: Color4[];
  66523. faceUV?: Vector4[];
  66524. updatable?: boolean;
  66525. hasRings?: boolean;
  66526. enclose?: boolean;
  66527. cap?: number;
  66528. sideOrientation?: number;
  66529. frontUVs?: Vector4;
  66530. backUVs?: Vector4;
  66531. }, scene?: Nullable<Scene>): Mesh;
  66532. /**
  66533. * Creates a torus mesh
  66534. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66535. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66536. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66540. * @param name defines the name of the mesh
  66541. * @param options defines the options used to create the mesh
  66542. * @param scene defines the hosting scene
  66543. * @returns the torus mesh
  66544. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66545. */
  66546. static CreateTorus(name: string, options: {
  66547. diameter?: number;
  66548. thickness?: number;
  66549. tessellation?: number;
  66550. updatable?: boolean;
  66551. sideOrientation?: number;
  66552. frontUVs?: Vector4;
  66553. backUVs?: Vector4;
  66554. }, scene?: Nullable<Scene>): Mesh;
  66555. /**
  66556. * Creates a torus knot mesh
  66557. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66558. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66559. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66560. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66564. * @param name defines the name of the mesh
  66565. * @param options defines the options used to create the mesh
  66566. * @param scene defines the hosting scene
  66567. * @returns the torus knot mesh
  66568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66569. */
  66570. static CreateTorusKnot(name: string, options: {
  66571. radius?: number;
  66572. tube?: number;
  66573. radialSegments?: number;
  66574. tubularSegments?: number;
  66575. p?: number;
  66576. q?: number;
  66577. updatable?: boolean;
  66578. sideOrientation?: number;
  66579. frontUVs?: Vector4;
  66580. backUVs?: Vector4;
  66581. }, scene?: Nullable<Scene>): Mesh;
  66582. /**
  66583. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66584. * * 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
  66585. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66586. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66587. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66588. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66589. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66590. * * 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
  66591. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66594. * @param name defines the name of the new line system
  66595. * @param options defines the options used to create the line system
  66596. * @param scene defines the hosting scene
  66597. * @returns a new line system mesh
  66598. */
  66599. static CreateLineSystem(name: string, options: {
  66600. lines: Vector3[][];
  66601. updatable?: boolean;
  66602. instance?: Nullable<LinesMesh>;
  66603. colors?: Nullable<Color4[][]>;
  66604. useVertexAlpha?: boolean;
  66605. }, scene: Nullable<Scene>): LinesMesh;
  66606. /**
  66607. * Creates a line mesh
  66608. * 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
  66609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66610. * * The parameter `points` is an array successive Vector3
  66611. * * 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
  66612. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66614. * * When updating an instance, remember that only point positions can change, not the number of points
  66615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66617. * @param name defines the name of the new line system
  66618. * @param options defines the options used to create the line system
  66619. * @param scene defines the hosting scene
  66620. * @returns a new line mesh
  66621. */
  66622. static CreateLines(name: string, options: {
  66623. points: Vector3[];
  66624. updatable?: boolean;
  66625. instance?: Nullable<LinesMesh>;
  66626. colors?: Color4[];
  66627. useVertexAlpha?: boolean;
  66628. }, scene?: Nullable<Scene>): LinesMesh;
  66629. /**
  66630. * Creates a dashed line mesh
  66631. * * 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
  66632. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66633. * * The parameter `points` is an array successive Vector3
  66634. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66635. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66636. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66637. * * 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
  66638. * * When updating an instance, remember that only point positions can change, not the number of points
  66639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66640. * @param name defines the name of the mesh
  66641. * @param options defines the options used to create the mesh
  66642. * @param scene defines the hosting scene
  66643. * @returns the dashed line mesh
  66644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66645. */
  66646. static CreateDashedLines(name: string, options: {
  66647. points: Vector3[];
  66648. dashSize?: number;
  66649. gapSize?: number;
  66650. dashNb?: number;
  66651. updatable?: boolean;
  66652. instance?: LinesMesh;
  66653. }, scene?: Nullable<Scene>): LinesMesh;
  66654. /**
  66655. * 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.
  66656. * * 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.
  66657. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66658. * * 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.
  66659. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66660. * * 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
  66661. * * 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
  66662. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66667. * @param name defines the name of the mesh
  66668. * @param options defines the options used to create the mesh
  66669. * @param scene defines the hosting scene
  66670. * @returns the extruded shape mesh
  66671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66673. */
  66674. static ExtrudeShape(name: string, options: {
  66675. shape: Vector3[];
  66676. path: Vector3[];
  66677. scale?: number;
  66678. rotation?: number;
  66679. cap?: number;
  66680. updatable?: boolean;
  66681. sideOrientation?: number;
  66682. frontUVs?: Vector4;
  66683. backUVs?: Vector4;
  66684. instance?: Mesh;
  66685. invertUV?: boolean;
  66686. }, scene?: Nullable<Scene>): Mesh;
  66687. /**
  66688. * Creates an custom extruded shape mesh.
  66689. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66690. * * 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.
  66691. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66692. * * 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
  66693. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66694. * * 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
  66695. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66696. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66697. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66698. * * 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
  66699. * * 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
  66700. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66705. * @param name defines the name of the mesh
  66706. * @param options defines the options used to create the mesh
  66707. * @param scene defines the hosting scene
  66708. * @returns the custom extruded shape mesh
  66709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66710. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66712. */
  66713. static ExtrudeShapeCustom(name: string, options: {
  66714. shape: Vector3[];
  66715. path: Vector3[];
  66716. scaleFunction?: any;
  66717. rotationFunction?: any;
  66718. ribbonCloseArray?: boolean;
  66719. ribbonClosePath?: boolean;
  66720. cap?: number;
  66721. updatable?: boolean;
  66722. sideOrientation?: number;
  66723. frontUVs?: Vector4;
  66724. backUVs?: Vector4;
  66725. instance?: Mesh;
  66726. invertUV?: boolean;
  66727. }, scene?: Nullable<Scene>): Mesh;
  66728. /**
  66729. * Creates lathe mesh.
  66730. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66731. * * 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
  66732. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66733. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66734. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66735. * * 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
  66736. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66737. * * 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
  66738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66742. * @param name defines the name of the mesh
  66743. * @param options defines the options used to create the mesh
  66744. * @param scene defines the hosting scene
  66745. * @returns the lathe mesh
  66746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66747. */
  66748. static CreateLathe(name: string, options: {
  66749. shape: Vector3[];
  66750. radius?: number;
  66751. tessellation?: number;
  66752. clip?: number;
  66753. arc?: number;
  66754. closed?: boolean;
  66755. updatable?: boolean;
  66756. sideOrientation?: number;
  66757. frontUVs?: Vector4;
  66758. backUVs?: Vector4;
  66759. cap?: number;
  66760. invertUV?: boolean;
  66761. }, scene?: Nullable<Scene>): Mesh;
  66762. /**
  66763. * Creates a tiled plane mesh
  66764. * * You can set a limited pattern arrangement with the tiles
  66765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66768. * @param name defines the name of the mesh
  66769. * @param options defines the options used to create the mesh
  66770. * @param scene defines the hosting scene
  66771. * @returns the plane mesh
  66772. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66773. */
  66774. static CreateTiledPlane(name: string, options: {
  66775. pattern?: number;
  66776. tileSize?: number;
  66777. tileWidth?: number;
  66778. tileHeight?: number;
  66779. size?: number;
  66780. width?: number;
  66781. height?: number;
  66782. alignHorizontal?: number;
  66783. alignVertical?: number;
  66784. sideOrientation?: number;
  66785. frontUVs?: Vector4;
  66786. backUVs?: Vector4;
  66787. updatable?: boolean;
  66788. }, scene?: Nullable<Scene>): Mesh;
  66789. /**
  66790. * Creates a plane mesh
  66791. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66792. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66793. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66797. * @param name defines the name of the mesh
  66798. * @param options defines the options used to create the mesh
  66799. * @param scene defines the hosting scene
  66800. * @returns the plane mesh
  66801. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66802. */
  66803. static CreatePlane(name: string, options: {
  66804. size?: number;
  66805. width?: number;
  66806. height?: number;
  66807. sideOrientation?: number;
  66808. frontUVs?: Vector4;
  66809. backUVs?: Vector4;
  66810. updatable?: boolean;
  66811. sourcePlane?: Plane;
  66812. }, scene?: Nullable<Scene>): Mesh;
  66813. /**
  66814. * Creates a ground mesh
  66815. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66816. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66818. * @param name defines the name of the mesh
  66819. * @param options defines the options used to create the mesh
  66820. * @param scene defines the hosting scene
  66821. * @returns the ground mesh
  66822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66823. */
  66824. static CreateGround(name: string, options: {
  66825. width?: number;
  66826. height?: number;
  66827. subdivisions?: number;
  66828. subdivisionsX?: number;
  66829. subdivisionsY?: number;
  66830. updatable?: boolean;
  66831. }, scene?: Nullable<Scene>): Mesh;
  66832. /**
  66833. * Creates a tiled ground mesh
  66834. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66835. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66836. * * 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
  66837. * * 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
  66838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66839. * @param name defines the name of the mesh
  66840. * @param options defines the options used to create the mesh
  66841. * @param scene defines the hosting scene
  66842. * @returns the tiled ground mesh
  66843. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66844. */
  66845. static CreateTiledGround(name: string, options: {
  66846. xmin: number;
  66847. zmin: number;
  66848. xmax: number;
  66849. zmax: number;
  66850. subdivisions?: {
  66851. w: number;
  66852. h: number;
  66853. };
  66854. precision?: {
  66855. w: number;
  66856. h: number;
  66857. };
  66858. updatable?: boolean;
  66859. }, scene?: Nullable<Scene>): Mesh;
  66860. /**
  66861. * Creates a ground mesh from a height map
  66862. * * The parameter `url` sets the URL of the height map image resource.
  66863. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66864. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66865. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66866. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66867. * * 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.
  66868. * * 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).
  66869. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66871. * @param name defines the name of the mesh
  66872. * @param url defines the url to the height map
  66873. * @param options defines the options used to create the mesh
  66874. * @param scene defines the hosting scene
  66875. * @returns the ground mesh
  66876. * @see https://doc.babylonjs.com/babylon101/height_map
  66877. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66878. */
  66879. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66880. width?: number;
  66881. height?: number;
  66882. subdivisions?: number;
  66883. minHeight?: number;
  66884. maxHeight?: number;
  66885. colorFilter?: Color3;
  66886. alphaFilter?: number;
  66887. updatable?: boolean;
  66888. onReady?: (mesh: GroundMesh) => void;
  66889. }, scene?: Nullable<Scene>): GroundMesh;
  66890. /**
  66891. * Creates a polygon mesh
  66892. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66893. * * 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
  66894. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66897. * * Remember you can only change the shape positions, not their number when updating a polygon
  66898. * @param name defines the name of the mesh
  66899. * @param options defines the options used to create the mesh
  66900. * @param scene defines the hosting scene
  66901. * @param earcutInjection can be used to inject your own earcut reference
  66902. * @returns the polygon mesh
  66903. */
  66904. static CreatePolygon(name: string, options: {
  66905. shape: Vector3[];
  66906. holes?: Vector3[][];
  66907. depth?: number;
  66908. faceUV?: Vector4[];
  66909. faceColors?: Color4[];
  66910. updatable?: boolean;
  66911. sideOrientation?: number;
  66912. frontUVs?: Vector4;
  66913. backUVs?: Vector4;
  66914. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66915. /**
  66916. * Creates an extruded polygon mesh, with depth in the Y direction.
  66917. * * 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)
  66918. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66919. * @param name defines the name of the mesh
  66920. * @param options defines the options used to create the mesh
  66921. * @param scene defines the hosting scene
  66922. * @param earcutInjection can be used to inject your own earcut reference
  66923. * @returns the polygon mesh
  66924. */
  66925. static ExtrudePolygon(name: string, options: {
  66926. shape: Vector3[];
  66927. holes?: Vector3[][];
  66928. depth?: number;
  66929. faceUV?: Vector4[];
  66930. faceColors?: Color4[];
  66931. updatable?: boolean;
  66932. sideOrientation?: number;
  66933. frontUVs?: Vector4;
  66934. backUVs?: Vector4;
  66935. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66936. /**
  66937. * Creates a tube mesh.
  66938. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66939. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66940. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66941. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66942. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66943. * * 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)
  66944. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66945. * * 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
  66946. * * 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
  66947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66951. * @param name defines the name of the mesh
  66952. * @param options defines the options used to create the mesh
  66953. * @param scene defines the hosting scene
  66954. * @returns the tube mesh
  66955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66956. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66957. */
  66958. static CreateTube(name: string, options: {
  66959. path: Vector3[];
  66960. radius?: number;
  66961. tessellation?: number;
  66962. radiusFunction?: {
  66963. (i: number, distance: number): number;
  66964. };
  66965. cap?: number;
  66966. arc?: number;
  66967. updatable?: boolean;
  66968. sideOrientation?: number;
  66969. frontUVs?: Vector4;
  66970. backUVs?: Vector4;
  66971. instance?: Mesh;
  66972. invertUV?: boolean;
  66973. }, scene?: Nullable<Scene>): Mesh;
  66974. /**
  66975. * Creates a polyhedron mesh
  66976. * * 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
  66977. * * The parameter `size` (positive float, default 1) sets the polygon size
  66978. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66979. * * 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`
  66980. * * 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
  66981. * * 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)`)
  66982. * * 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
  66983. * * 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
  66984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66987. * @param name defines the name of the mesh
  66988. * @param options defines the options used to create the mesh
  66989. * @param scene defines the hosting scene
  66990. * @returns the polyhedron mesh
  66991. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66992. */
  66993. static CreatePolyhedron(name: string, options: {
  66994. type?: number;
  66995. size?: number;
  66996. sizeX?: number;
  66997. sizeY?: number;
  66998. sizeZ?: number;
  66999. custom?: any;
  67000. faceUV?: Vector4[];
  67001. faceColors?: Color4[];
  67002. flat?: boolean;
  67003. updatable?: boolean;
  67004. sideOrientation?: number;
  67005. frontUVs?: Vector4;
  67006. backUVs?: Vector4;
  67007. }, scene?: Nullable<Scene>): Mesh;
  67008. /**
  67009. * Creates a decal mesh.
  67010. * 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
  67011. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67012. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67013. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67014. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67015. * @param name defines the name of the mesh
  67016. * @param sourceMesh defines the mesh where the decal must be applied
  67017. * @param options defines the options used to create the mesh
  67018. * @param scene defines the hosting scene
  67019. * @returns the decal mesh
  67020. * @see https://doc.babylonjs.com/how_to/decals
  67021. */
  67022. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67023. position?: Vector3;
  67024. normal?: Vector3;
  67025. size?: Vector3;
  67026. angle?: number;
  67027. }): Mesh;
  67028. }
  67029. }
  67030. declare module "babylonjs/Meshes/meshSimplification" {
  67031. import { Mesh } from "babylonjs/Meshes/mesh";
  67032. /**
  67033. * A simplifier interface for future simplification implementations
  67034. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67035. */
  67036. export interface ISimplifier {
  67037. /**
  67038. * Simplification of a given mesh according to the given settings.
  67039. * Since this requires computation, it is assumed that the function runs async.
  67040. * @param settings The settings of the simplification, including quality and distance
  67041. * @param successCallback A callback that will be called after the mesh was simplified.
  67042. * @param errorCallback in case of an error, this callback will be called. optional.
  67043. */
  67044. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67045. }
  67046. /**
  67047. * Expected simplification settings.
  67048. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67049. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67050. */
  67051. export interface ISimplificationSettings {
  67052. /**
  67053. * Gets or sets the expected quality
  67054. */
  67055. quality: number;
  67056. /**
  67057. * Gets or sets the distance when this optimized version should be used
  67058. */
  67059. distance: number;
  67060. /**
  67061. * Gets an already optimized mesh
  67062. */
  67063. optimizeMesh?: boolean;
  67064. }
  67065. /**
  67066. * Class used to specify simplification options
  67067. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67068. */
  67069. export class SimplificationSettings implements ISimplificationSettings {
  67070. /** expected quality */
  67071. quality: number;
  67072. /** distance when this optimized version should be used */
  67073. distance: number;
  67074. /** already optimized mesh */
  67075. optimizeMesh?: boolean | undefined;
  67076. /**
  67077. * Creates a SimplificationSettings
  67078. * @param quality expected quality
  67079. * @param distance distance when this optimized version should be used
  67080. * @param optimizeMesh already optimized mesh
  67081. */
  67082. constructor(
  67083. /** expected quality */
  67084. quality: number,
  67085. /** distance when this optimized version should be used */
  67086. distance: number,
  67087. /** already optimized mesh */
  67088. optimizeMesh?: boolean | undefined);
  67089. }
  67090. /**
  67091. * Interface used to define a simplification task
  67092. */
  67093. export interface ISimplificationTask {
  67094. /**
  67095. * Array of settings
  67096. */
  67097. settings: Array<ISimplificationSettings>;
  67098. /**
  67099. * Simplification type
  67100. */
  67101. simplificationType: SimplificationType;
  67102. /**
  67103. * Mesh to simplify
  67104. */
  67105. mesh: Mesh;
  67106. /**
  67107. * Callback called on success
  67108. */
  67109. successCallback?: () => void;
  67110. /**
  67111. * Defines if parallel processing can be used
  67112. */
  67113. parallelProcessing: boolean;
  67114. }
  67115. /**
  67116. * Queue used to order the simplification tasks
  67117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67118. */
  67119. export class SimplificationQueue {
  67120. private _simplificationArray;
  67121. /**
  67122. * Gets a boolean indicating that the process is still running
  67123. */
  67124. running: boolean;
  67125. /**
  67126. * Creates a new queue
  67127. */
  67128. constructor();
  67129. /**
  67130. * Adds a new simplification task
  67131. * @param task defines a task to add
  67132. */
  67133. addTask(task: ISimplificationTask): void;
  67134. /**
  67135. * Execute next task
  67136. */
  67137. executeNext(): void;
  67138. /**
  67139. * Execute a simplification task
  67140. * @param task defines the task to run
  67141. */
  67142. runSimplification(task: ISimplificationTask): void;
  67143. private getSimplifier;
  67144. }
  67145. /**
  67146. * The implemented types of simplification
  67147. * At the moment only Quadratic Error Decimation is implemented
  67148. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67149. */
  67150. export enum SimplificationType {
  67151. /** Quadratic error decimation */
  67152. QUADRATIC = 0
  67153. }
  67154. /**
  67155. * An implementation of the Quadratic Error simplification algorithm.
  67156. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67157. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67158. * @author RaananW
  67159. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67160. */
  67161. export class QuadraticErrorSimplification implements ISimplifier {
  67162. private _mesh;
  67163. private triangles;
  67164. private vertices;
  67165. private references;
  67166. private _reconstructedMesh;
  67167. /** Gets or sets the number pf sync interations */
  67168. syncIterations: number;
  67169. /** Gets or sets the aggressiveness of the simplifier */
  67170. aggressiveness: number;
  67171. /** Gets or sets the number of allowed iterations for decimation */
  67172. decimationIterations: number;
  67173. /** Gets or sets the espilon to use for bounding box computation */
  67174. boundingBoxEpsilon: number;
  67175. /**
  67176. * Creates a new QuadraticErrorSimplification
  67177. * @param _mesh defines the target mesh
  67178. */
  67179. constructor(_mesh: Mesh);
  67180. /**
  67181. * Simplification of a given mesh according to the given settings.
  67182. * Since this requires computation, it is assumed that the function runs async.
  67183. * @param settings The settings of the simplification, including quality and distance
  67184. * @param successCallback A callback that will be called after the mesh was simplified.
  67185. */
  67186. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67187. private runDecimation;
  67188. private initWithMesh;
  67189. private init;
  67190. private reconstructMesh;
  67191. private initDecimatedMesh;
  67192. private isFlipped;
  67193. private updateTriangles;
  67194. private identifyBorder;
  67195. private updateMesh;
  67196. private vertexError;
  67197. private calculateError;
  67198. }
  67199. }
  67200. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67201. import { Scene } from "babylonjs/scene";
  67202. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67203. import { ISceneComponent } from "babylonjs/sceneComponent";
  67204. module "babylonjs/scene" {
  67205. interface Scene {
  67206. /** @hidden (Backing field) */
  67207. _simplificationQueue: SimplificationQueue;
  67208. /**
  67209. * Gets or sets the simplification queue attached to the scene
  67210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67211. */
  67212. simplificationQueue: SimplificationQueue;
  67213. }
  67214. }
  67215. module "babylonjs/Meshes/mesh" {
  67216. interface Mesh {
  67217. /**
  67218. * Simplify the mesh according to the given array of settings.
  67219. * Function will return immediately and will simplify async
  67220. * @param settings a collection of simplification settings
  67221. * @param parallelProcessing should all levels calculate parallel or one after the other
  67222. * @param simplificationType the type of simplification to run
  67223. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67224. * @returns the current mesh
  67225. */
  67226. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67227. }
  67228. }
  67229. /**
  67230. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67231. * created in a scene
  67232. */
  67233. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67234. /**
  67235. * The component name helpfull to identify the component in the list of scene components.
  67236. */
  67237. readonly name: string;
  67238. /**
  67239. * The scene the component belongs to.
  67240. */
  67241. scene: Scene;
  67242. /**
  67243. * Creates a new instance of the component for the given scene
  67244. * @param scene Defines the scene to register the component in
  67245. */
  67246. constructor(scene: Scene);
  67247. /**
  67248. * Registers the component in a given scene
  67249. */
  67250. register(): void;
  67251. /**
  67252. * Rebuilds the elements related to this component in case of
  67253. * context lost for instance.
  67254. */
  67255. rebuild(): void;
  67256. /**
  67257. * Disposes the component and the associated ressources
  67258. */
  67259. dispose(): void;
  67260. private _beforeCameraUpdate;
  67261. }
  67262. }
  67263. declare module "babylonjs/Meshes/Builders/index" {
  67264. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67265. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67266. export * from "babylonjs/Meshes/Builders/discBuilder";
  67267. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67268. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67269. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67270. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67271. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67272. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67273. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67274. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67275. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67276. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67277. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67278. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67279. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67280. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67281. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67282. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67283. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67284. }
  67285. declare module "babylonjs/Meshes/index" {
  67286. export * from "babylonjs/Meshes/abstractMesh";
  67287. export * from "babylonjs/Meshes/buffer";
  67288. export * from "babylonjs/Meshes/Compression/index";
  67289. export * from "babylonjs/Meshes/csg";
  67290. export * from "babylonjs/Meshes/geometry";
  67291. export * from "babylonjs/Meshes/groundMesh";
  67292. export * from "babylonjs/Meshes/trailMesh";
  67293. export * from "babylonjs/Meshes/instancedMesh";
  67294. export * from "babylonjs/Meshes/linesMesh";
  67295. export * from "babylonjs/Meshes/mesh";
  67296. export * from "babylonjs/Meshes/mesh.vertexData";
  67297. export * from "babylonjs/Meshes/meshBuilder";
  67298. export * from "babylonjs/Meshes/meshSimplification";
  67299. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67300. export * from "babylonjs/Meshes/polygonMesh";
  67301. export * from "babylonjs/Meshes/subMesh";
  67302. export * from "babylonjs/Meshes/meshLODLevel";
  67303. export * from "babylonjs/Meshes/transformNode";
  67304. export * from "babylonjs/Meshes/Builders/index";
  67305. export * from "babylonjs/Meshes/dataBuffer";
  67306. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67307. }
  67308. declare module "babylonjs/Morph/index" {
  67309. export * from "babylonjs/Morph/morphTarget";
  67310. export * from "babylonjs/Morph/morphTargetManager";
  67311. }
  67312. declare module "babylonjs/Navigation/INavigationEngine" {
  67313. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67314. import { Vector3 } from "babylonjs/Maths/math";
  67315. import { Mesh } from "babylonjs/Meshes/mesh";
  67316. import { Scene } from "babylonjs/scene";
  67317. /**
  67318. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67319. */
  67320. export interface INavigationEnginePlugin {
  67321. /**
  67322. * plugin name
  67323. */
  67324. name: string;
  67325. /**
  67326. * Creates a navigation mesh
  67327. * @param meshes array of all the geometry used to compute the navigatio mesh
  67328. * @param parameters bunch of parameters used to filter geometry
  67329. */
  67330. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67331. /**
  67332. * Create a navigation mesh debug mesh
  67333. * @param scene is where the mesh will be added
  67334. * @returns debug display mesh
  67335. */
  67336. createDebugNavMesh(scene: Scene): Mesh;
  67337. /**
  67338. * Get a navigation mesh constrained position, closest to the parameter position
  67339. * @param position world position
  67340. * @returns the closest point to position constrained by the navigation mesh
  67341. */
  67342. getClosestPoint(position: Vector3): Vector3;
  67343. /**
  67344. * Get a navigation mesh constrained position, closest to the parameter position
  67345. * @param position world position
  67346. * @param result output the closest point to position constrained by the navigation mesh
  67347. */
  67348. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67349. /**
  67350. * Get a navigation mesh constrained position, within a particular radius
  67351. * @param position world position
  67352. * @param maxRadius the maximum distance to the constrained world position
  67353. * @returns the closest point to position constrained by the navigation mesh
  67354. */
  67355. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67356. /**
  67357. * Get a navigation mesh constrained position, within a particular radius
  67358. * @param position world position
  67359. * @param maxRadius the maximum distance to the constrained world position
  67360. * @param result output the closest point to position constrained by the navigation mesh
  67361. */
  67362. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67363. /**
  67364. * Compute the final position from a segment made of destination-position
  67365. * @param position world position
  67366. * @param destination world position
  67367. * @returns the resulting point along the navmesh
  67368. */
  67369. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67370. /**
  67371. * Compute the final position from a segment made of destination-position
  67372. * @param position world position
  67373. * @param destination world position
  67374. * @param result output the resulting point along the navmesh
  67375. */
  67376. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67377. /**
  67378. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67379. * @param start world position
  67380. * @param end world position
  67381. * @returns array containing world position composing the path
  67382. */
  67383. computePath(start: Vector3, end: Vector3): Vector3[];
  67384. /**
  67385. * If this plugin is supported
  67386. * @returns true if plugin is supported
  67387. */
  67388. isSupported(): boolean;
  67389. /**
  67390. * Create a new Crowd so you can add agents
  67391. * @param maxAgents the maximum agent count in the crowd
  67392. * @param maxAgentRadius the maximum radius an agent can have
  67393. * @param scene to attach the crowd to
  67394. * @returns the crowd you can add agents to
  67395. */
  67396. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67397. /**
  67398. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67399. * The queries will try to find a solution within those bounds
  67400. * default is (1,1,1)
  67401. * @param extent x,y,z value that define the extent around the queries point of reference
  67402. */
  67403. setDefaultQueryExtent(extent: Vector3): void;
  67404. /**
  67405. * Get the Bounding box extent specified by setDefaultQueryExtent
  67406. * @returns the box extent values
  67407. */
  67408. getDefaultQueryExtent(): Vector3;
  67409. /**
  67410. * build the navmesh from a previously saved state using getNavmeshData
  67411. * @param data the Uint8Array returned by getNavmeshData
  67412. */
  67413. buildFromNavmeshData(data: Uint8Array): void;
  67414. /**
  67415. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67416. * @returns data the Uint8Array that can be saved and reused
  67417. */
  67418. getNavmeshData(): Uint8Array;
  67419. /**
  67420. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67421. * @param result output the box extent values
  67422. */
  67423. getDefaultQueryExtentToRef(result: Vector3): void;
  67424. /**
  67425. * Release all resources
  67426. */
  67427. dispose(): void;
  67428. }
  67429. /**
  67430. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67431. */
  67432. export interface ICrowd {
  67433. /**
  67434. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67435. * You can attach anything to that node. The node position is updated in the scene update tick.
  67436. * @param pos world position that will be constrained by the navigation mesh
  67437. * @param parameters agent parameters
  67438. * @param transform hooked to the agent that will be update by the scene
  67439. * @returns agent index
  67440. */
  67441. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67442. /**
  67443. * Returns the agent position in world space
  67444. * @param index agent index returned by addAgent
  67445. * @returns world space position
  67446. */
  67447. getAgentPosition(index: number): Vector3;
  67448. /**
  67449. * Gets the agent position result in world space
  67450. * @param index agent index returned by addAgent
  67451. * @param result output world space position
  67452. */
  67453. getAgentPositionToRef(index: number, result: Vector3): void;
  67454. /**
  67455. * Gets the agent velocity in world space
  67456. * @param index agent index returned by addAgent
  67457. * @returns world space velocity
  67458. */
  67459. getAgentVelocity(index: number): Vector3;
  67460. /**
  67461. * Gets the agent velocity result in world space
  67462. * @param index agent index returned by addAgent
  67463. * @param result output world space velocity
  67464. */
  67465. getAgentVelocityToRef(index: number, result: Vector3): void;
  67466. /**
  67467. * remove a particular agent previously created
  67468. * @param index agent index returned by addAgent
  67469. */
  67470. removeAgent(index: number): void;
  67471. /**
  67472. * get the list of all agents attached to this crowd
  67473. * @returns list of agent indices
  67474. */
  67475. getAgents(): number[];
  67476. /**
  67477. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67478. * @param deltaTime in seconds
  67479. */
  67480. update(deltaTime: number): void;
  67481. /**
  67482. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67483. * @param index agent index returned by addAgent
  67484. * @param destination targeted world position
  67485. */
  67486. agentGoto(index: number, destination: Vector3): void;
  67487. /**
  67488. * Teleport the agent to a new position
  67489. * @param index agent index returned by addAgent
  67490. * @param destination targeted world position
  67491. */
  67492. agentTeleport(index: number, destination: Vector3): void;
  67493. /**
  67494. * Update agent parameters
  67495. * @param index agent index returned by addAgent
  67496. * @param parameters agent parameters
  67497. */
  67498. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67499. /**
  67500. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67501. * The queries will try to find a solution within those bounds
  67502. * default is (1,1,1)
  67503. * @param extent x,y,z value that define the extent around the queries point of reference
  67504. */
  67505. setDefaultQueryExtent(extent: Vector3): void;
  67506. /**
  67507. * Get the Bounding box extent specified by setDefaultQueryExtent
  67508. * @returns the box extent values
  67509. */
  67510. getDefaultQueryExtent(): Vector3;
  67511. /**
  67512. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67513. * @param result output the box extent values
  67514. */
  67515. getDefaultQueryExtentToRef(result: Vector3): void;
  67516. /**
  67517. * Release all resources
  67518. */
  67519. dispose(): void;
  67520. }
  67521. /**
  67522. * Configures an agent
  67523. */
  67524. export interface IAgentParameters {
  67525. /**
  67526. * Agent radius. [Limit: >= 0]
  67527. */
  67528. radius: number;
  67529. /**
  67530. * Agent height. [Limit: > 0]
  67531. */
  67532. height: number;
  67533. /**
  67534. * Maximum allowed acceleration. [Limit: >= 0]
  67535. */
  67536. maxAcceleration: number;
  67537. /**
  67538. * Maximum allowed speed. [Limit: >= 0]
  67539. */
  67540. maxSpeed: number;
  67541. /**
  67542. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67543. */
  67544. collisionQueryRange: number;
  67545. /**
  67546. * The path visibility optimization range. [Limit: > 0]
  67547. */
  67548. pathOptimizationRange: number;
  67549. /**
  67550. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67551. */
  67552. separationWeight: number;
  67553. }
  67554. /**
  67555. * Configures the navigation mesh creation
  67556. */
  67557. export interface INavMeshParameters {
  67558. /**
  67559. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67560. */
  67561. cs: number;
  67562. /**
  67563. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67564. */
  67565. ch: number;
  67566. /**
  67567. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67568. */
  67569. walkableSlopeAngle: number;
  67570. /**
  67571. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67572. * be considered walkable. [Limit: >= 3] [Units: vx]
  67573. */
  67574. walkableHeight: number;
  67575. /**
  67576. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67577. */
  67578. walkableClimb: number;
  67579. /**
  67580. * The distance to erode/shrink the walkable area of the heightfield away from
  67581. * obstructions. [Limit: >=0] [Units: vx]
  67582. */
  67583. walkableRadius: number;
  67584. /**
  67585. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67586. */
  67587. maxEdgeLen: number;
  67588. /**
  67589. * The maximum distance a simplfied contour's border edges should deviate
  67590. * the original raw contour. [Limit: >=0] [Units: vx]
  67591. */
  67592. maxSimplificationError: number;
  67593. /**
  67594. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67595. */
  67596. minRegionArea: number;
  67597. /**
  67598. * Any regions with a span count smaller than this value will, if possible,
  67599. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67600. */
  67601. mergeRegionArea: number;
  67602. /**
  67603. * The maximum number of vertices allowed for polygons generated during the
  67604. * contour to polygon conversion process. [Limit: >= 3]
  67605. */
  67606. maxVertsPerPoly: number;
  67607. /**
  67608. * Sets the sampling distance to use when generating the detail mesh.
  67609. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67610. */
  67611. detailSampleDist: number;
  67612. /**
  67613. * The maximum distance the detail mesh surface should deviate from heightfield
  67614. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67615. */
  67616. detailSampleMaxError: number;
  67617. }
  67618. }
  67619. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67620. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67621. import { Mesh } from "babylonjs/Meshes/mesh";
  67622. import { Scene } from "babylonjs/scene";
  67623. import { Vector3 } from "babylonjs/Maths/math";
  67624. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67625. /**
  67626. * RecastJS navigation plugin
  67627. */
  67628. export class RecastJSPlugin implements INavigationEnginePlugin {
  67629. /**
  67630. * Reference to the Recast library
  67631. */
  67632. bjsRECAST: any;
  67633. /**
  67634. * plugin name
  67635. */
  67636. name: string;
  67637. /**
  67638. * the first navmesh created. We might extend this to support multiple navmeshes
  67639. */
  67640. navMesh: any;
  67641. /**
  67642. * Initializes the recastJS plugin
  67643. * @param recastInjection can be used to inject your own recast reference
  67644. */
  67645. constructor(recastInjection?: any);
  67646. /**
  67647. * Creates a navigation mesh
  67648. * @param meshes array of all the geometry used to compute the navigatio mesh
  67649. * @param parameters bunch of parameters used to filter geometry
  67650. */
  67651. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67652. /**
  67653. * Create a navigation mesh debug mesh
  67654. * @param scene is where the mesh will be added
  67655. * @returns debug display mesh
  67656. */
  67657. createDebugNavMesh(scene: Scene): Mesh;
  67658. /**
  67659. * Get a navigation mesh constrained position, closest to the parameter position
  67660. * @param position world position
  67661. * @returns the closest point to position constrained by the navigation mesh
  67662. */
  67663. getClosestPoint(position: Vector3): Vector3;
  67664. /**
  67665. * Get a navigation mesh constrained position, closest to the parameter position
  67666. * @param position world position
  67667. * @param result output the closest point to position constrained by the navigation mesh
  67668. */
  67669. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67670. /**
  67671. * Get a navigation mesh constrained position, within a particular radius
  67672. * @param position world position
  67673. * @param maxRadius the maximum distance to the constrained world position
  67674. * @returns the closest point to position constrained by the navigation mesh
  67675. */
  67676. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67677. /**
  67678. * Get a navigation mesh constrained position, within a particular radius
  67679. * @param position world position
  67680. * @param maxRadius the maximum distance to the constrained world position
  67681. * @param result output the closest point to position constrained by the navigation mesh
  67682. */
  67683. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67684. /**
  67685. * Compute the final position from a segment made of destination-position
  67686. * @param position world position
  67687. * @param destination world position
  67688. * @returns the resulting point along the navmesh
  67689. */
  67690. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67691. /**
  67692. * Compute the final position from a segment made of destination-position
  67693. * @param position world position
  67694. * @param destination world position
  67695. * @param result output the resulting point along the navmesh
  67696. */
  67697. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67698. /**
  67699. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67700. * @param start world position
  67701. * @param end world position
  67702. * @returns array containing world position composing the path
  67703. */
  67704. computePath(start: Vector3, end: Vector3): Vector3[];
  67705. /**
  67706. * Create a new Crowd so you can add agents
  67707. * @param maxAgents the maximum agent count in the crowd
  67708. * @param maxAgentRadius the maximum radius an agent can have
  67709. * @param scene to attach the crowd to
  67710. * @returns the crowd you can add agents to
  67711. */
  67712. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67713. /**
  67714. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67715. * The queries will try to find a solution within those bounds
  67716. * default is (1,1,1)
  67717. * @param extent x,y,z value that define the extent around the queries point of reference
  67718. */
  67719. setDefaultQueryExtent(extent: Vector3): void;
  67720. /**
  67721. * Get the Bounding box extent specified by setDefaultQueryExtent
  67722. * @returns the box extent values
  67723. */
  67724. getDefaultQueryExtent(): Vector3;
  67725. /**
  67726. * build the navmesh from a previously saved state using getNavmeshData
  67727. * @param data the Uint8Array returned by getNavmeshData
  67728. */
  67729. buildFromNavmeshData(data: Uint8Array): void;
  67730. /**
  67731. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67732. * @returns data the Uint8Array that can be saved and reused
  67733. */
  67734. getNavmeshData(): Uint8Array;
  67735. /**
  67736. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67737. * @param result output the box extent values
  67738. */
  67739. getDefaultQueryExtentToRef(result: Vector3): void;
  67740. /**
  67741. * Disposes
  67742. */
  67743. dispose(): void;
  67744. /**
  67745. * If this plugin is supported
  67746. * @returns true if plugin is supported
  67747. */
  67748. isSupported(): boolean;
  67749. }
  67750. /**
  67751. * Recast detour crowd implementation
  67752. */
  67753. export class RecastJSCrowd implements ICrowd {
  67754. /**
  67755. * Recast/detour plugin
  67756. */
  67757. bjsRECASTPlugin: RecastJSPlugin;
  67758. /**
  67759. * Link to the detour crowd
  67760. */
  67761. recastCrowd: any;
  67762. /**
  67763. * One transform per agent
  67764. */
  67765. transforms: TransformNode[];
  67766. /**
  67767. * All agents created
  67768. */
  67769. agents: number[];
  67770. /**
  67771. * Link to the scene is kept to unregister the crowd from the scene
  67772. */
  67773. private _scene;
  67774. /**
  67775. * Observer for crowd updates
  67776. */
  67777. private _onBeforeAnimationsObserver;
  67778. /**
  67779. * Constructor
  67780. * @param plugin recastJS plugin
  67781. * @param maxAgents the maximum agent count in the crowd
  67782. * @param maxAgentRadius the maximum radius an agent can have
  67783. * @param scene to attach the crowd to
  67784. * @returns the crowd you can add agents to
  67785. */
  67786. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67787. /**
  67788. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67789. * You can attach anything to that node. The node position is updated in the scene update tick.
  67790. * @param pos world position that will be constrained by the navigation mesh
  67791. * @param parameters agent parameters
  67792. * @param transform hooked to the agent that will be update by the scene
  67793. * @returns agent index
  67794. */
  67795. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67796. /**
  67797. * Returns the agent position in world space
  67798. * @param index agent index returned by addAgent
  67799. * @returns world space position
  67800. */
  67801. getAgentPosition(index: number): Vector3;
  67802. /**
  67803. * Returns the agent position result in world space
  67804. * @param index agent index returned by addAgent
  67805. * @param result output world space position
  67806. */
  67807. getAgentPositionToRef(index: number, result: Vector3): void;
  67808. /**
  67809. * Returns the agent velocity in world space
  67810. * @param index agent index returned by addAgent
  67811. * @returns world space velocity
  67812. */
  67813. getAgentVelocity(index: number): Vector3;
  67814. /**
  67815. * Returns the agent velocity result in world space
  67816. * @param index agent index returned by addAgent
  67817. * @param result output world space velocity
  67818. */
  67819. getAgentVelocityToRef(index: number, result: Vector3): void;
  67820. /**
  67821. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67822. * @param index agent index returned by addAgent
  67823. * @param destination targeted world position
  67824. */
  67825. agentGoto(index: number, destination: Vector3): void;
  67826. /**
  67827. * Teleport the agent to a new position
  67828. * @param index agent index returned by addAgent
  67829. * @param destination targeted world position
  67830. */
  67831. agentTeleport(index: number, destination: Vector3): void;
  67832. /**
  67833. * Update agent parameters
  67834. * @param index agent index returned by addAgent
  67835. * @param parameters agent parameters
  67836. */
  67837. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67838. /**
  67839. * remove a particular agent previously created
  67840. * @param index agent index returned by addAgent
  67841. */
  67842. removeAgent(index: number): void;
  67843. /**
  67844. * get the list of all agents attached to this crowd
  67845. * @returns list of agent indices
  67846. */
  67847. getAgents(): number[];
  67848. /**
  67849. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67850. * @param deltaTime in seconds
  67851. */
  67852. update(deltaTime: number): void;
  67853. /**
  67854. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67855. * The queries will try to find a solution within those bounds
  67856. * default is (1,1,1)
  67857. * @param extent x,y,z value that define the extent around the queries point of reference
  67858. */
  67859. setDefaultQueryExtent(extent: Vector3): void;
  67860. /**
  67861. * Get the Bounding box extent specified by setDefaultQueryExtent
  67862. * @returns the box extent values
  67863. */
  67864. getDefaultQueryExtent(): Vector3;
  67865. /**
  67866. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67867. * @param result output the box extent values
  67868. */
  67869. getDefaultQueryExtentToRef(result: Vector3): void;
  67870. /**
  67871. * Release all resources
  67872. */
  67873. dispose(): void;
  67874. }
  67875. }
  67876. declare module "babylonjs/Navigation/Plugins/index" {
  67877. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67878. }
  67879. declare module "babylonjs/Navigation/index" {
  67880. export * from "babylonjs/Navigation/INavigationEngine";
  67881. export * from "babylonjs/Navigation/Plugins/index";
  67882. }
  67883. declare module "babylonjs/Offline/database" {
  67884. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67885. /**
  67886. * Class used to enable access to IndexedDB
  67887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67888. */
  67889. export class Database implements IOfflineProvider {
  67890. private _callbackManifestChecked;
  67891. private _currentSceneUrl;
  67892. private _db;
  67893. private _enableSceneOffline;
  67894. private _enableTexturesOffline;
  67895. private _manifestVersionFound;
  67896. private _mustUpdateRessources;
  67897. private _hasReachedQuota;
  67898. private _isSupported;
  67899. private _idbFactory;
  67900. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67901. private static IsUASupportingBlobStorage;
  67902. /**
  67903. * Gets a boolean indicating if Database storate is enabled (off by default)
  67904. */
  67905. static IDBStorageEnabled: boolean;
  67906. /**
  67907. * Gets a boolean indicating if scene must be saved in the database
  67908. */
  67909. get enableSceneOffline(): boolean;
  67910. /**
  67911. * Gets a boolean indicating if textures must be saved in the database
  67912. */
  67913. get enableTexturesOffline(): boolean;
  67914. /**
  67915. * Creates a new Database
  67916. * @param urlToScene defines the url to load the scene
  67917. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67918. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67919. */
  67920. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67921. private static _ParseURL;
  67922. private static _ReturnFullUrlLocation;
  67923. private _checkManifestFile;
  67924. /**
  67925. * Open the database and make it available
  67926. * @param successCallback defines the callback to call on success
  67927. * @param errorCallback defines the callback to call on error
  67928. */
  67929. open(successCallback: () => void, errorCallback: () => void): void;
  67930. /**
  67931. * Loads an image from the database
  67932. * @param url defines the url to load from
  67933. * @param image defines the target DOM image
  67934. */
  67935. loadImage(url: string, image: HTMLImageElement): void;
  67936. private _loadImageFromDBAsync;
  67937. private _saveImageIntoDBAsync;
  67938. private _checkVersionFromDB;
  67939. private _loadVersionFromDBAsync;
  67940. private _saveVersionIntoDBAsync;
  67941. /**
  67942. * Loads a file from database
  67943. * @param url defines the URL to load from
  67944. * @param sceneLoaded defines a callback to call on success
  67945. * @param progressCallBack defines a callback to call when progress changed
  67946. * @param errorCallback defines a callback to call on error
  67947. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67948. */
  67949. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67950. private _loadFileAsync;
  67951. private _saveFileAsync;
  67952. /**
  67953. * Validates if xhr data is correct
  67954. * @param xhr defines the request to validate
  67955. * @param dataType defines the expected data type
  67956. * @returns true if data is correct
  67957. */
  67958. private static _ValidateXHRData;
  67959. }
  67960. }
  67961. declare module "babylonjs/Offline/index" {
  67962. export * from "babylonjs/Offline/database";
  67963. export * from "babylonjs/Offline/IOfflineProvider";
  67964. }
  67965. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67966. /** @hidden */
  67967. export var gpuUpdateParticlesPixelShader: {
  67968. name: string;
  67969. shader: string;
  67970. };
  67971. }
  67972. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  67973. /** @hidden */
  67974. export var gpuUpdateParticlesVertexShader: {
  67975. name: string;
  67976. shader: string;
  67977. };
  67978. }
  67979. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  67980. /** @hidden */
  67981. export var clipPlaneFragmentDeclaration2: {
  67982. name: string;
  67983. shader: string;
  67984. };
  67985. }
  67986. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  67987. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  67988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67990. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67991. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  67992. /** @hidden */
  67993. export var gpuRenderParticlesPixelShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  67999. /** @hidden */
  68000. export var clipPlaneVertexDeclaration2: {
  68001. name: string;
  68002. shader: string;
  68003. };
  68004. }
  68005. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68006. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68008. /** @hidden */
  68009. export var gpuRenderParticlesVertexShader: {
  68010. name: string;
  68011. shader: string;
  68012. };
  68013. }
  68014. declare module "babylonjs/Particles/gpuParticleSystem" {
  68015. import { Nullable } from "babylonjs/types";
  68016. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68017. import { Observable } from "babylonjs/Misc/observable";
  68018. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68019. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68020. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68021. import { Scene, IDisposable } from "babylonjs/scene";
  68022. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68023. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68024. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68025. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68026. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68027. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68028. /**
  68029. * This represents a GPU particle system in Babylon
  68030. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68031. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68032. */
  68033. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68034. /**
  68035. * The layer mask we are rendering the particles through.
  68036. */
  68037. layerMask: number;
  68038. private _capacity;
  68039. private _activeCount;
  68040. private _currentActiveCount;
  68041. private _accumulatedCount;
  68042. private _renderEffect;
  68043. private _updateEffect;
  68044. private _buffer0;
  68045. private _buffer1;
  68046. private _spriteBuffer;
  68047. private _updateVAO;
  68048. private _renderVAO;
  68049. private _targetIndex;
  68050. private _sourceBuffer;
  68051. private _targetBuffer;
  68052. private _engine;
  68053. private _currentRenderId;
  68054. private _started;
  68055. private _stopped;
  68056. private _timeDelta;
  68057. private _randomTexture;
  68058. private _randomTexture2;
  68059. private _attributesStrideSize;
  68060. private _updateEffectOptions;
  68061. private _randomTextureSize;
  68062. private _actualFrame;
  68063. private readonly _rawTextureWidth;
  68064. /**
  68065. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68066. */
  68067. static get IsSupported(): boolean;
  68068. /**
  68069. * An event triggered when the system is disposed.
  68070. */
  68071. onDisposeObservable: Observable<GPUParticleSystem>;
  68072. /**
  68073. * Gets the maximum number of particles active at the same time.
  68074. * @returns The max number of active particles.
  68075. */
  68076. getCapacity(): number;
  68077. /**
  68078. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68079. * to override the particles.
  68080. */
  68081. forceDepthWrite: boolean;
  68082. /**
  68083. * Gets or set the number of active particles
  68084. */
  68085. get activeParticleCount(): number;
  68086. set activeParticleCount(value: number);
  68087. private _preWarmDone;
  68088. /**
  68089. * Specifies if the particles are updated in emitter local space or world space.
  68090. */
  68091. isLocal: boolean;
  68092. /**
  68093. * Is this system ready to be used/rendered
  68094. * @return true if the system is ready
  68095. */
  68096. isReady(): boolean;
  68097. /**
  68098. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68099. * @returns True if it has been started, otherwise false.
  68100. */
  68101. isStarted(): boolean;
  68102. /**
  68103. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68104. * @returns True if it has been stopped, otherwise false.
  68105. */
  68106. isStopped(): boolean;
  68107. /**
  68108. * Gets a boolean indicating that the system is stopping
  68109. * @returns true if the system is currently stopping
  68110. */
  68111. isStopping(): boolean;
  68112. /**
  68113. * Gets the number of particles active at the same time.
  68114. * @returns The number of active particles.
  68115. */
  68116. getActiveCount(): number;
  68117. /**
  68118. * Starts the particle system and begins to emit
  68119. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68120. */
  68121. start(delay?: number): void;
  68122. /**
  68123. * Stops the particle system.
  68124. */
  68125. stop(): void;
  68126. /**
  68127. * Remove all active particles
  68128. */
  68129. reset(): void;
  68130. /**
  68131. * Returns the string "GPUParticleSystem"
  68132. * @returns a string containing the class name
  68133. */
  68134. getClassName(): string;
  68135. private _colorGradientsTexture;
  68136. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68137. /**
  68138. * Adds a new color gradient
  68139. * @param gradient defines the gradient to use (between 0 and 1)
  68140. * @param color1 defines the color to affect to the specified gradient
  68141. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68142. * @returns the current particle system
  68143. */
  68144. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68145. private _refreshColorGradient;
  68146. /** Force the system to rebuild all gradients that need to be resync */
  68147. forceRefreshGradients(): void;
  68148. /**
  68149. * Remove a specific color gradient
  68150. * @param gradient defines the gradient to remove
  68151. * @returns the current particle system
  68152. */
  68153. removeColorGradient(gradient: number): GPUParticleSystem;
  68154. private _angularSpeedGradientsTexture;
  68155. private _sizeGradientsTexture;
  68156. private _velocityGradientsTexture;
  68157. private _limitVelocityGradientsTexture;
  68158. private _dragGradientsTexture;
  68159. private _addFactorGradient;
  68160. /**
  68161. * Adds a new size gradient
  68162. * @param gradient defines the gradient to use (between 0 and 1)
  68163. * @param factor defines the size factor to affect to the specified gradient
  68164. * @returns the current particle system
  68165. */
  68166. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68167. /**
  68168. * Remove a specific size gradient
  68169. * @param gradient defines the gradient to remove
  68170. * @returns the current particle system
  68171. */
  68172. removeSizeGradient(gradient: number): GPUParticleSystem;
  68173. private _refreshFactorGradient;
  68174. /**
  68175. * Adds a new angular speed gradient
  68176. * @param gradient defines the gradient to use (between 0 and 1)
  68177. * @param factor defines the angular speed to affect to the specified gradient
  68178. * @returns the current particle system
  68179. */
  68180. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68181. /**
  68182. * Remove a specific angular speed gradient
  68183. * @param gradient defines the gradient to remove
  68184. * @returns the current particle system
  68185. */
  68186. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68187. /**
  68188. * Adds a new velocity gradient
  68189. * @param gradient defines the gradient to use (between 0 and 1)
  68190. * @param factor defines the velocity to affect to the specified gradient
  68191. * @returns the current particle system
  68192. */
  68193. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68194. /**
  68195. * Remove a specific velocity gradient
  68196. * @param gradient defines the gradient to remove
  68197. * @returns the current particle system
  68198. */
  68199. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68200. /**
  68201. * Adds a new limit velocity gradient
  68202. * @param gradient defines the gradient to use (between 0 and 1)
  68203. * @param factor defines the limit velocity value to affect to the specified gradient
  68204. * @returns the current particle system
  68205. */
  68206. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68207. /**
  68208. * Remove a specific limit velocity gradient
  68209. * @param gradient defines the gradient to remove
  68210. * @returns the current particle system
  68211. */
  68212. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68213. /**
  68214. * Adds a new drag gradient
  68215. * @param gradient defines the gradient to use (between 0 and 1)
  68216. * @param factor defines the drag value to affect to the specified gradient
  68217. * @returns the current particle system
  68218. */
  68219. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68220. /**
  68221. * Remove a specific drag gradient
  68222. * @param gradient defines the gradient to remove
  68223. * @returns the current particle system
  68224. */
  68225. removeDragGradient(gradient: number): GPUParticleSystem;
  68226. /**
  68227. * Not supported by GPUParticleSystem
  68228. * @param gradient defines the gradient to use (between 0 and 1)
  68229. * @param factor defines the emit rate value to affect to the specified gradient
  68230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68231. * @returns the current particle system
  68232. */
  68233. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68234. /**
  68235. * Not supported by GPUParticleSystem
  68236. * @param gradient defines the gradient to remove
  68237. * @returns the current particle system
  68238. */
  68239. removeEmitRateGradient(gradient: number): IParticleSystem;
  68240. /**
  68241. * Not supported by GPUParticleSystem
  68242. * @param gradient defines the gradient to use (between 0 and 1)
  68243. * @param factor defines the start size value to affect to the specified gradient
  68244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68245. * @returns the current particle system
  68246. */
  68247. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68248. /**
  68249. * Not supported by GPUParticleSystem
  68250. * @param gradient defines the gradient to remove
  68251. * @returns the current particle system
  68252. */
  68253. removeStartSizeGradient(gradient: number): IParticleSystem;
  68254. /**
  68255. * Not supported by GPUParticleSystem
  68256. * @param gradient defines the gradient to use (between 0 and 1)
  68257. * @param min defines the color remap minimal range
  68258. * @param max defines the color remap maximal range
  68259. * @returns the current particle system
  68260. */
  68261. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68262. /**
  68263. * Not supported by GPUParticleSystem
  68264. * @param gradient defines the gradient to remove
  68265. * @returns the current particle system
  68266. */
  68267. removeColorRemapGradient(): IParticleSystem;
  68268. /**
  68269. * Not supported by GPUParticleSystem
  68270. * @param gradient defines the gradient to use (between 0 and 1)
  68271. * @param min defines the alpha remap minimal range
  68272. * @param max defines the alpha remap maximal range
  68273. * @returns the current particle system
  68274. */
  68275. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68276. /**
  68277. * Not supported by GPUParticleSystem
  68278. * @param gradient defines the gradient to remove
  68279. * @returns the current particle system
  68280. */
  68281. removeAlphaRemapGradient(): IParticleSystem;
  68282. /**
  68283. * Not supported by GPUParticleSystem
  68284. * @param gradient defines the gradient to use (between 0 and 1)
  68285. * @param color defines the color to affect to the specified gradient
  68286. * @returns the current particle system
  68287. */
  68288. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68289. /**
  68290. * Not supported by GPUParticleSystem
  68291. * @param gradient defines the gradient to remove
  68292. * @returns the current particle system
  68293. */
  68294. removeRampGradient(): IParticleSystem;
  68295. /**
  68296. * Not supported by GPUParticleSystem
  68297. * @returns the list of ramp gradients
  68298. */
  68299. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68300. /**
  68301. * Not supported by GPUParticleSystem
  68302. * Gets or sets a boolean indicating that ramp gradients must be used
  68303. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68304. */
  68305. get useRampGradients(): boolean;
  68306. set useRampGradients(value: boolean);
  68307. /**
  68308. * Not supported by GPUParticleSystem
  68309. * @param gradient defines the gradient to use (between 0 and 1)
  68310. * @param factor defines the life time factor to affect to the specified gradient
  68311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68312. * @returns the current particle system
  68313. */
  68314. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68315. /**
  68316. * Not supported by GPUParticleSystem
  68317. * @param gradient defines the gradient to remove
  68318. * @returns the current particle system
  68319. */
  68320. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68321. /**
  68322. * Instantiates a GPU particle system.
  68323. * 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.
  68324. * @param name The name of the particle system
  68325. * @param options The options used to create the system
  68326. * @param scene The scene the particle system belongs to
  68327. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68328. */
  68329. constructor(name: string, options: Partial<{
  68330. capacity: number;
  68331. randomTextureSize: number;
  68332. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68333. protected _reset(): void;
  68334. private _createUpdateVAO;
  68335. private _createRenderVAO;
  68336. private _initialize;
  68337. /** @hidden */
  68338. _recreateUpdateEffect(): void;
  68339. /** @hidden */
  68340. _recreateRenderEffect(): void;
  68341. /**
  68342. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68343. * @param preWarm defines if we are in the pre-warmimg phase
  68344. */
  68345. animate(preWarm?: boolean): void;
  68346. private _createFactorGradientTexture;
  68347. private _createSizeGradientTexture;
  68348. private _createAngularSpeedGradientTexture;
  68349. private _createVelocityGradientTexture;
  68350. private _createLimitVelocityGradientTexture;
  68351. private _createDragGradientTexture;
  68352. private _createColorGradientTexture;
  68353. /**
  68354. * Renders the particle system in its current state
  68355. * @param preWarm defines if the system should only update the particles but not render them
  68356. * @returns the current number of particles
  68357. */
  68358. render(preWarm?: boolean): number;
  68359. /**
  68360. * Rebuilds the particle system
  68361. */
  68362. rebuild(): void;
  68363. private _releaseBuffers;
  68364. private _releaseVAOs;
  68365. /**
  68366. * Disposes the particle system and free the associated resources
  68367. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68368. */
  68369. dispose(disposeTexture?: boolean): void;
  68370. /**
  68371. * Clones the particle system.
  68372. * @param name The name of the cloned object
  68373. * @param newEmitter The new emitter to use
  68374. * @returns the cloned particle system
  68375. */
  68376. clone(name: string, newEmitter: any): GPUParticleSystem;
  68377. /**
  68378. * Serializes the particle system to a JSON object
  68379. * @param serializeTexture defines if the texture must be serialized as well
  68380. * @returns the JSON object
  68381. */
  68382. serialize(serializeTexture?: boolean): any;
  68383. /**
  68384. * Parses a JSON object to create a GPU particle system.
  68385. * @param parsedParticleSystem The JSON object to parse
  68386. * @param scene The scene to create the particle system in
  68387. * @param rootUrl The root url to use to load external dependencies like texture
  68388. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68389. * @returns the parsed GPU particle system
  68390. */
  68391. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68392. }
  68393. }
  68394. declare module "babylonjs/Particles/particleSystemSet" {
  68395. import { Nullable } from "babylonjs/types";
  68396. import { Color3 } from "babylonjs/Maths/math.color";
  68397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68399. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68400. import { Scene, IDisposable } from "babylonjs/scene";
  68401. /**
  68402. * Represents a set of particle systems working together to create a specific effect
  68403. */
  68404. export class ParticleSystemSet implements IDisposable {
  68405. /**
  68406. * Gets or sets base Assets URL
  68407. */
  68408. static BaseAssetsUrl: string;
  68409. private _emitterCreationOptions;
  68410. private _emitterNode;
  68411. /**
  68412. * Gets the particle system list
  68413. */
  68414. systems: IParticleSystem[];
  68415. /**
  68416. * Gets the emitter node used with this set
  68417. */
  68418. get emitterNode(): Nullable<TransformNode>;
  68419. /**
  68420. * Creates a new emitter mesh as a sphere
  68421. * @param options defines the options used to create the sphere
  68422. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68423. * @param scene defines the hosting scene
  68424. */
  68425. setEmitterAsSphere(options: {
  68426. diameter: number;
  68427. segments: number;
  68428. color: Color3;
  68429. }, renderingGroupId: number, scene: Scene): void;
  68430. /**
  68431. * Starts all particle systems of the set
  68432. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68433. */
  68434. start(emitter?: AbstractMesh): void;
  68435. /**
  68436. * Release all associated resources
  68437. */
  68438. dispose(): void;
  68439. /**
  68440. * Serialize the set into a JSON compatible object
  68441. * @param serializeTexture defines if the texture must be serialized as well
  68442. * @returns a JSON compatible representation of the set
  68443. */
  68444. serialize(serializeTexture?: boolean): any;
  68445. /**
  68446. * Parse a new ParticleSystemSet from a serialized source
  68447. * @param data defines a JSON compatible representation of the set
  68448. * @param scene defines the hosting scene
  68449. * @param gpu defines if we want GPU particles or CPU particles
  68450. * @returns a new ParticleSystemSet
  68451. */
  68452. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68453. }
  68454. }
  68455. declare module "babylonjs/Particles/particleHelper" {
  68456. import { Nullable } from "babylonjs/types";
  68457. import { Scene } from "babylonjs/scene";
  68458. import { Vector3 } from "babylonjs/Maths/math.vector";
  68459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68460. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68461. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68462. /**
  68463. * This class is made for on one-liner static method to help creating particle system set.
  68464. */
  68465. export class ParticleHelper {
  68466. /**
  68467. * Gets or sets base Assets URL
  68468. */
  68469. static BaseAssetsUrl: string;
  68470. /** Define the Url to load snippets */
  68471. static SnippetUrl: string;
  68472. /**
  68473. * Create a default particle system that you can tweak
  68474. * @param emitter defines the emitter to use
  68475. * @param capacity defines the system capacity (default is 500 particles)
  68476. * @param scene defines the hosting scene
  68477. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68478. * @returns the new Particle system
  68479. */
  68480. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68481. /**
  68482. * This is the main static method (one-liner) of this helper to create different particle systems
  68483. * @param type This string represents the type to the particle system to create
  68484. * @param scene The scene where the particle system should live
  68485. * @param gpu If the system will use gpu
  68486. * @returns the ParticleSystemSet created
  68487. */
  68488. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68489. /**
  68490. * Static function used to export a particle system to a ParticleSystemSet variable.
  68491. * Please note that the emitter shape is not exported
  68492. * @param systems defines the particle systems to export
  68493. * @returns the created particle system set
  68494. */
  68495. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68496. /**
  68497. * Creates a particle system from a snippet saved in a remote file
  68498. * @param name defines the name of the particle system to create
  68499. * @param url defines the url to load from
  68500. * @param scene defines the hosting scene
  68501. * @param gpu If the system will use gpu
  68502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68503. * @returns a promise that will resolve to the new particle system
  68504. */
  68505. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68506. /**
  68507. * Creates a particle system from a snippet saved by the particle system editor
  68508. * @param snippetId defines the snippet to load
  68509. * @param scene defines the hosting scene
  68510. * @param gpu If the system will use gpu
  68511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68512. * @returns a promise that will resolve to the new particle system
  68513. */
  68514. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68515. }
  68516. }
  68517. declare module "babylonjs/Particles/particleSystemComponent" {
  68518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68519. import { Effect } from "babylonjs/Materials/effect";
  68520. import "babylonjs/Shaders/particles.vertex";
  68521. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68522. module "babylonjs/Engines/engine" {
  68523. interface Engine {
  68524. /**
  68525. * Create an effect to use with particle systems.
  68526. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68527. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68528. * @param uniformsNames defines a list of attribute names
  68529. * @param samplers defines an array of string used to represent textures
  68530. * @param defines defines the string containing the defines to use to compile the shaders
  68531. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68532. * @param onCompiled defines a function to call when the effect creation is successful
  68533. * @param onError defines a function to call when the effect creation has failed
  68534. * @returns the new Effect
  68535. */
  68536. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68537. }
  68538. }
  68539. module "babylonjs/Meshes/mesh" {
  68540. interface Mesh {
  68541. /**
  68542. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68543. * @returns an array of IParticleSystem
  68544. */
  68545. getEmittedParticleSystems(): IParticleSystem[];
  68546. /**
  68547. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68548. * @returns an array of IParticleSystem
  68549. */
  68550. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68551. }
  68552. }
  68553. /**
  68554. * @hidden
  68555. */
  68556. export var _IDoNeedToBeInTheBuild: number;
  68557. }
  68558. declare module "babylonjs/Particles/pointsCloudSystem" {
  68559. import { Color4 } from "babylonjs/Maths/math";
  68560. import { Mesh } from "babylonjs/Meshes/mesh";
  68561. import { Scene, IDisposable } from "babylonjs/scene";
  68562. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68563. /** Defines the 4 color options */
  68564. export enum PointColor {
  68565. /** color value */
  68566. Color = 2,
  68567. /** uv value */
  68568. UV = 1,
  68569. /** random value */
  68570. Random = 0,
  68571. /** stated value */
  68572. Stated = 3
  68573. }
  68574. /**
  68575. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68576. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  68577. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68578. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68579. *
  68580. * Full documentation here : TO BE ENTERED
  68581. */
  68582. export class PointsCloudSystem implements IDisposable {
  68583. /**
  68584. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68585. * Example : var p = SPS.particles[i];
  68586. */
  68587. particles: CloudPoint[];
  68588. /**
  68589. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68590. */
  68591. nbParticles: number;
  68592. /**
  68593. * This a counter for your own usage. It's not set by any SPS functions.
  68594. */
  68595. counter: number;
  68596. /**
  68597. * The PCS name. This name is also given to the underlying mesh.
  68598. */
  68599. name: string;
  68600. /**
  68601. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68602. */
  68603. mesh: Mesh;
  68604. /**
  68605. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68606. * Please read :
  68607. */
  68608. vars: any;
  68609. /**
  68610. * @hidden
  68611. */
  68612. _size: number;
  68613. private _scene;
  68614. private _promises;
  68615. private _positions;
  68616. private _indices;
  68617. private _normals;
  68618. private _colors;
  68619. private _uvs;
  68620. private _indices32;
  68621. private _positions32;
  68622. private _colors32;
  68623. private _uvs32;
  68624. private _updatable;
  68625. private _isVisibilityBoxLocked;
  68626. private _alwaysVisible;
  68627. private _groups;
  68628. private _groupCounter;
  68629. private _computeParticleColor;
  68630. private _computeParticleTexture;
  68631. private _computeParticleRotation;
  68632. private _computeBoundingBox;
  68633. private _isReady;
  68634. /**
  68635. * Creates a PCS (Points Cloud System) object
  68636. * @param name (String) is the PCS name, this will be the underlying mesh name
  68637. * @param pointSize (number) is the size for each point
  68638. * @param scene (Scene) is the scene in which the PCS is added
  68639. * @param options defines the options of the PCS e.g.
  68640. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68641. */
  68642. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68643. updatable?: boolean;
  68644. });
  68645. /**
  68646. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68647. * If no points were added to the PCS, the returned mesh is just a single point.
  68648. * @returns a promise for the created mesh
  68649. */
  68650. buildMeshAsync(): Promise<Mesh>;
  68651. /**
  68652. * @hidden
  68653. */
  68654. private _buildMesh;
  68655. private _addParticle;
  68656. private _randomUnitVector;
  68657. private _getColorIndicesForCoord;
  68658. private _setPointsColorOrUV;
  68659. private _colorFromTexture;
  68660. private _calculateDensity;
  68661. /**
  68662. * Adds points to the PCS in random positions within a unit sphere
  68663. * @param nb (positive integer) the number of particles to be created from this model
  68664. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68665. * @returns the number of groups in the system
  68666. */
  68667. addPoints(nb: number, pointFunction?: any): number;
  68668. /**
  68669. * Adds points to the PCS from the surface of the model shape
  68670. * @param mesh is any Mesh object that will be used as a surface model for the points
  68671. * @param nb (positive integer) the number of particles to be created from this model
  68672. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68673. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68674. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68675. * @returns the number of groups in the system
  68676. */
  68677. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68678. /**
  68679. * Adds points to the PCS inside the model shape
  68680. * @param mesh is any Mesh object that will be used as a surface model for the points
  68681. * @param nb (positive integer) the number of particles to be created from this model
  68682. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68683. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68684. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68685. * @returns the number of groups in the system
  68686. */
  68687. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68688. /**
  68689. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68690. * This method calls `updateParticle()` for each particle of the SPS.
  68691. * For an animated SPS, it is usually called within the render loop.
  68692. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68693. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68694. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68695. * @returns the PCS.
  68696. */
  68697. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68698. /**
  68699. * Disposes the PCS.
  68700. */
  68701. dispose(): void;
  68702. /**
  68703. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68704. * doc :
  68705. * @returns the PCS.
  68706. */
  68707. refreshVisibleSize(): PointsCloudSystem;
  68708. /**
  68709. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68710. * @param size the size (float) of the visibility box
  68711. * note : this doesn't lock the PCS mesh bounding box.
  68712. * doc :
  68713. */
  68714. setVisibilityBox(size: number): void;
  68715. /**
  68716. * Gets whether the PCS is always visible or not
  68717. * doc :
  68718. */
  68719. get isAlwaysVisible(): boolean;
  68720. /**
  68721. * Sets the PCS as always visible or not
  68722. * doc :
  68723. */
  68724. set isAlwaysVisible(val: boolean);
  68725. /**
  68726. * Tells to `setParticles()` to compute the particle rotations or not
  68727. * Default value : false. The PCS is faster when it's set to false
  68728. * Note : particle rotations are only applied to parent particles
  68729. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68730. */
  68731. set computeParticleRotation(val: boolean);
  68732. /**
  68733. * Tells to `setParticles()` to compute the particle colors or not.
  68734. * Default value : true. The PCS is faster when it's set to false.
  68735. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68736. */
  68737. set computeParticleColor(val: boolean);
  68738. set computeParticleTexture(val: boolean);
  68739. /**
  68740. * Gets if `setParticles()` computes the particle colors or not.
  68741. * Default value : false. The PCS is faster when it's set to false.
  68742. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68743. */
  68744. get computeParticleColor(): boolean;
  68745. /**
  68746. * Gets if `setParticles()` computes the particle textures or not.
  68747. * Default value : false. The PCS is faster when it's set to false.
  68748. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68749. */
  68750. get computeParticleTexture(): boolean;
  68751. /**
  68752. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68753. */
  68754. set computeBoundingBox(val: boolean);
  68755. /**
  68756. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68757. */
  68758. get computeBoundingBox(): boolean;
  68759. /**
  68760. * This function does nothing. It may be overwritten to set all the particle first values.
  68761. * The PCS doesn't call this function, you may have to call it by your own.
  68762. * doc :
  68763. */
  68764. initParticles(): void;
  68765. /**
  68766. * This function does nothing. It may be overwritten to recycle a particle
  68767. * The PCS doesn't call this function, you can to call it
  68768. * doc :
  68769. * @param particle The particle to recycle
  68770. * @returns the recycled particle
  68771. */
  68772. recycleParticle(particle: CloudPoint): CloudPoint;
  68773. /**
  68774. * Updates a particle : this function should be overwritten by the user.
  68775. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68776. * doc :
  68777. * @example : just set a particle position or velocity and recycle conditions
  68778. * @param particle The particle to update
  68779. * @returns the updated particle
  68780. */
  68781. updateParticle(particle: CloudPoint): CloudPoint;
  68782. /**
  68783. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68784. * This does nothing and may be overwritten by the user.
  68785. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68786. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68787. * @param update the boolean update value actually passed to setParticles()
  68788. */
  68789. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68790. /**
  68791. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68792. * This will be passed three parameters.
  68793. * This does nothing and may be overwritten by the user.
  68794. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68795. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68796. * @param update the boolean update value actually passed to setParticles()
  68797. */
  68798. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68799. }
  68800. }
  68801. declare module "babylonjs/Particles/cloudPoint" {
  68802. import { Nullable } from "babylonjs/types";
  68803. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68804. import { Mesh } from "babylonjs/Meshes/mesh";
  68805. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68806. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68807. /**
  68808. * Represents one particle of a points cloud system.
  68809. */
  68810. export class CloudPoint {
  68811. /**
  68812. * particle global index
  68813. */
  68814. idx: number;
  68815. /**
  68816. * The color of the particle
  68817. */
  68818. color: Nullable<Color4>;
  68819. /**
  68820. * The world space position of the particle.
  68821. */
  68822. position: Vector3;
  68823. /**
  68824. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68825. */
  68826. rotation: Vector3;
  68827. /**
  68828. * The world space rotation quaternion of the particle.
  68829. */
  68830. rotationQuaternion: Nullable<Quaternion>;
  68831. /**
  68832. * The uv of the particle.
  68833. */
  68834. uv: Nullable<Vector2>;
  68835. /**
  68836. * The current speed of the particle.
  68837. */
  68838. velocity: Vector3;
  68839. /**
  68840. * The pivot point in the particle local space.
  68841. */
  68842. pivot: Vector3;
  68843. /**
  68844. * Must the particle be translated from its pivot point in its local space ?
  68845. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68846. * Default : false
  68847. */
  68848. translateFromPivot: boolean;
  68849. /**
  68850. * Index of this particle in the global "positions" array (Internal use)
  68851. * @hidden
  68852. */
  68853. _pos: number;
  68854. /**
  68855. * @hidden Index of this particle in the global "indices" array (Internal use)
  68856. */
  68857. _ind: number;
  68858. /**
  68859. * Group this particle belongs to
  68860. */
  68861. _group: PointsGroup;
  68862. /**
  68863. * Group id of this particle
  68864. */
  68865. groupId: number;
  68866. /**
  68867. * Index of the particle in its group id (Internal use)
  68868. */
  68869. idxInGroup: number;
  68870. /**
  68871. * @hidden Particle BoundingInfo object (Internal use)
  68872. */
  68873. _boundingInfo: BoundingInfo;
  68874. /**
  68875. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68876. */
  68877. _pcs: PointsCloudSystem;
  68878. /**
  68879. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68880. */
  68881. _stillInvisible: boolean;
  68882. /**
  68883. * @hidden Last computed particle rotation matrix
  68884. */
  68885. _rotationMatrix: number[];
  68886. /**
  68887. * Parent particle Id, if any.
  68888. * Default null.
  68889. */
  68890. parentId: Nullable<number>;
  68891. /**
  68892. * @hidden Internal global position in the PCS.
  68893. */
  68894. _globalPosition: Vector3;
  68895. /**
  68896. * Creates a Point Cloud object.
  68897. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68898. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68899. * @param group (PointsGroup) is the group the particle belongs to
  68900. * @param groupId (integer) is the group identifier in the PCS.
  68901. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68902. * @param pcs defines the PCS it is associated to
  68903. */
  68904. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68905. /**
  68906. * get point size
  68907. */
  68908. get size(): Vector3;
  68909. /**
  68910. * Set point size
  68911. */
  68912. set size(scale: Vector3);
  68913. /**
  68914. * Legacy support, changed quaternion to rotationQuaternion
  68915. */
  68916. get quaternion(): Nullable<Quaternion>;
  68917. /**
  68918. * Legacy support, changed quaternion to rotationQuaternion
  68919. */
  68920. set quaternion(q: Nullable<Quaternion>);
  68921. /**
  68922. * Returns a boolean. True if the particle intersects a mesh, else false
  68923. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68924. * @param target is the object (point or mesh) what the intersection is computed against
  68925. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68926. * @returns true if it intersects
  68927. */
  68928. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68929. /**
  68930. * get the rotation matrix of the particle
  68931. * @hidden
  68932. */
  68933. getRotationMatrix(m: Matrix): void;
  68934. }
  68935. /**
  68936. * Represents a group of points in a points cloud system
  68937. * * PCS internal tool, don't use it manually.
  68938. */
  68939. export class PointsGroup {
  68940. /**
  68941. * The group id
  68942. * @hidden
  68943. */
  68944. groupID: number;
  68945. /**
  68946. * image data for group (internal use)
  68947. * @hidden
  68948. */
  68949. _groupImageData: Nullable<ArrayBufferView>;
  68950. /**
  68951. * Image Width (internal use)
  68952. * @hidden
  68953. */
  68954. _groupImgWidth: number;
  68955. /**
  68956. * Image Height (internal use)
  68957. * @hidden
  68958. */
  68959. _groupImgHeight: number;
  68960. /**
  68961. * Custom position function (internal use)
  68962. * @hidden
  68963. */
  68964. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68965. /**
  68966. * density per facet for surface points
  68967. * @hidden
  68968. */
  68969. _groupDensity: number[];
  68970. /**
  68971. * Only when points are colored by texture carries pointer to texture list array
  68972. * @hidden
  68973. */
  68974. _textureNb: number;
  68975. /**
  68976. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68977. * PCS internal tool, don't use it manually.
  68978. * @hidden
  68979. */
  68980. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68981. }
  68982. }
  68983. declare module "babylonjs/Particles/index" {
  68984. export * from "babylonjs/Particles/baseParticleSystem";
  68985. export * from "babylonjs/Particles/EmitterTypes/index";
  68986. export * from "babylonjs/Particles/gpuParticleSystem";
  68987. export * from "babylonjs/Particles/IParticleSystem";
  68988. export * from "babylonjs/Particles/particle";
  68989. export * from "babylonjs/Particles/particleHelper";
  68990. export * from "babylonjs/Particles/particleSystem";
  68991. export * from "babylonjs/Particles/particleSystemComponent";
  68992. export * from "babylonjs/Particles/particleSystemSet";
  68993. export * from "babylonjs/Particles/solidParticle";
  68994. export * from "babylonjs/Particles/solidParticleSystem";
  68995. export * from "babylonjs/Particles/cloudPoint";
  68996. export * from "babylonjs/Particles/pointsCloudSystem";
  68997. export * from "babylonjs/Particles/subEmitter";
  68998. }
  68999. declare module "babylonjs/Physics/physicsEngineComponent" {
  69000. import { Nullable } from "babylonjs/types";
  69001. import { Observable, Observer } from "babylonjs/Misc/observable";
  69002. import { Vector3 } from "babylonjs/Maths/math.vector";
  69003. import { Mesh } from "babylonjs/Meshes/mesh";
  69004. import { ISceneComponent } from "babylonjs/sceneComponent";
  69005. import { Scene } from "babylonjs/scene";
  69006. import { Node } from "babylonjs/node";
  69007. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  69008. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69009. module "babylonjs/scene" {
  69010. interface Scene {
  69011. /** @hidden (Backing field) */
  69012. _physicsEngine: Nullable<IPhysicsEngine>;
  69013. /** @hidden */
  69014. _physicsTimeAccumulator: number;
  69015. /**
  69016. * Gets the current physics engine
  69017. * @returns a IPhysicsEngine or null if none attached
  69018. */
  69019. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69020. /**
  69021. * Enables physics to the current scene
  69022. * @param gravity defines the scene's gravity for the physics engine
  69023. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69024. * @return a boolean indicating if the physics engine was initialized
  69025. */
  69026. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69027. /**
  69028. * Disables and disposes the physics engine associated with the scene
  69029. */
  69030. disablePhysicsEngine(): void;
  69031. /**
  69032. * Gets a boolean indicating if there is an active physics engine
  69033. * @returns a boolean indicating if there is an active physics engine
  69034. */
  69035. isPhysicsEnabled(): boolean;
  69036. /**
  69037. * Deletes a physics compound impostor
  69038. * @param compound defines the compound to delete
  69039. */
  69040. deleteCompoundImpostor(compound: any): void;
  69041. /**
  69042. * An event triggered when physic simulation is about to be run
  69043. */
  69044. onBeforePhysicsObservable: Observable<Scene>;
  69045. /**
  69046. * An event triggered when physic simulation has been done
  69047. */
  69048. onAfterPhysicsObservable: Observable<Scene>;
  69049. }
  69050. }
  69051. module "babylonjs/Meshes/abstractMesh" {
  69052. interface AbstractMesh {
  69053. /** @hidden */
  69054. _physicsImpostor: Nullable<PhysicsImpostor>;
  69055. /**
  69056. * Gets or sets impostor used for physic simulation
  69057. * @see http://doc.babylonjs.com/features/physics_engine
  69058. */
  69059. physicsImpostor: Nullable<PhysicsImpostor>;
  69060. /**
  69061. * Gets the current physics impostor
  69062. * @see http://doc.babylonjs.com/features/physics_engine
  69063. * @returns a physics impostor or null
  69064. */
  69065. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69066. /** Apply a physic impulse to the mesh
  69067. * @param force defines the force to apply
  69068. * @param contactPoint defines where to apply the force
  69069. * @returns the current mesh
  69070. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  69071. */
  69072. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69073. /**
  69074. * Creates a physic joint between two meshes
  69075. * @param otherMesh defines the other mesh to use
  69076. * @param pivot1 defines the pivot to use on this mesh
  69077. * @param pivot2 defines the pivot to use on the other mesh
  69078. * @param options defines additional options (can be plugin dependent)
  69079. * @returns the current mesh
  69080. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69081. */
  69082. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69083. /** @hidden */
  69084. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69085. }
  69086. }
  69087. /**
  69088. * Defines the physics engine scene component responsible to manage a physics engine
  69089. */
  69090. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69091. /**
  69092. * The component name helpful to identify the component in the list of scene components.
  69093. */
  69094. readonly name: string;
  69095. /**
  69096. * The scene the component belongs to.
  69097. */
  69098. scene: Scene;
  69099. /**
  69100. * Creates a new instance of the component for the given scene
  69101. * @param scene Defines the scene to register the component in
  69102. */
  69103. constructor(scene: Scene);
  69104. /**
  69105. * Registers the component in a given scene
  69106. */
  69107. register(): void;
  69108. /**
  69109. * Rebuilds the elements related to this component in case of
  69110. * context lost for instance.
  69111. */
  69112. rebuild(): void;
  69113. /**
  69114. * Disposes the component and the associated ressources
  69115. */
  69116. dispose(): void;
  69117. }
  69118. }
  69119. declare module "babylonjs/Physics/physicsHelper" {
  69120. import { Nullable } from "babylonjs/types";
  69121. import { Vector3 } from "babylonjs/Maths/math.vector";
  69122. import { Mesh } from "babylonjs/Meshes/mesh";
  69123. import { Scene } from "babylonjs/scene";
  69124. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69125. /**
  69126. * A helper for physics simulations
  69127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69128. */
  69129. export class PhysicsHelper {
  69130. private _scene;
  69131. private _physicsEngine;
  69132. /**
  69133. * Initializes the Physics helper
  69134. * @param scene Babylon.js scene
  69135. */
  69136. constructor(scene: Scene);
  69137. /**
  69138. * Applies a radial explosion impulse
  69139. * @param origin the origin of the explosion
  69140. * @param radiusOrEventOptions the radius or the options of radial explosion
  69141. * @param strength the explosion strength
  69142. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69143. * @returns A physics radial explosion event, or null
  69144. */
  69145. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69146. /**
  69147. * Applies a radial explosion force
  69148. * @param origin the origin of the explosion
  69149. * @param radiusOrEventOptions the radius or the options of radial explosion
  69150. * @param strength the explosion strength
  69151. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69152. * @returns A physics radial explosion event, or null
  69153. */
  69154. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69155. /**
  69156. * Creates a gravitational field
  69157. * @param origin the origin of the explosion
  69158. * @param radiusOrEventOptions the radius or the options of radial explosion
  69159. * @param strength the explosion strength
  69160. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69161. * @returns A physics gravitational field event, or null
  69162. */
  69163. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69164. /**
  69165. * Creates a physics updraft event
  69166. * @param origin the origin of the updraft
  69167. * @param radiusOrEventOptions the radius or the options of the updraft
  69168. * @param strength the strength of the updraft
  69169. * @param height the height of the updraft
  69170. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69171. * @returns A physics updraft event, or null
  69172. */
  69173. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69174. /**
  69175. * Creates a physics vortex event
  69176. * @param origin the of the vortex
  69177. * @param radiusOrEventOptions the radius or the options of the vortex
  69178. * @param strength the strength of the vortex
  69179. * @param height the height of the vortex
  69180. * @returns a Physics vortex event, or null
  69181. * A physics vortex event or null
  69182. */
  69183. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69184. }
  69185. /**
  69186. * Represents a physics radial explosion event
  69187. */
  69188. class PhysicsRadialExplosionEvent {
  69189. private _scene;
  69190. private _options;
  69191. private _sphere;
  69192. private _dataFetched;
  69193. /**
  69194. * Initializes a radial explosioin event
  69195. * @param _scene BabylonJS scene
  69196. * @param _options The options for the vortex event
  69197. */
  69198. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69199. /**
  69200. * Returns the data related to the radial explosion event (sphere).
  69201. * @returns The radial explosion event data
  69202. */
  69203. getData(): PhysicsRadialExplosionEventData;
  69204. /**
  69205. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69206. * @param impostor A physics imposter
  69207. * @param origin the origin of the explosion
  69208. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69209. */
  69210. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69211. /**
  69212. * Triggers affecterd impostors callbacks
  69213. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69214. */
  69215. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69216. /**
  69217. * Disposes the sphere.
  69218. * @param force Specifies if the sphere should be disposed by force
  69219. */
  69220. dispose(force?: boolean): void;
  69221. /*** Helpers ***/
  69222. private _prepareSphere;
  69223. private _intersectsWithSphere;
  69224. }
  69225. /**
  69226. * Represents a gravitational field event
  69227. */
  69228. class PhysicsGravitationalFieldEvent {
  69229. private _physicsHelper;
  69230. private _scene;
  69231. private _origin;
  69232. private _options;
  69233. private _tickCallback;
  69234. private _sphere;
  69235. private _dataFetched;
  69236. /**
  69237. * Initializes the physics gravitational field event
  69238. * @param _physicsHelper A physics helper
  69239. * @param _scene BabylonJS scene
  69240. * @param _origin The origin position of the gravitational field event
  69241. * @param _options The options for the vortex event
  69242. */
  69243. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69244. /**
  69245. * Returns the data related to the gravitational field event (sphere).
  69246. * @returns A gravitational field event
  69247. */
  69248. getData(): PhysicsGravitationalFieldEventData;
  69249. /**
  69250. * Enables the gravitational field.
  69251. */
  69252. enable(): void;
  69253. /**
  69254. * Disables the gravitational field.
  69255. */
  69256. disable(): void;
  69257. /**
  69258. * Disposes the sphere.
  69259. * @param force The force to dispose from the gravitational field event
  69260. */
  69261. dispose(force?: boolean): void;
  69262. private _tick;
  69263. }
  69264. /**
  69265. * Represents a physics updraft event
  69266. */
  69267. class PhysicsUpdraftEvent {
  69268. private _scene;
  69269. private _origin;
  69270. private _options;
  69271. private _physicsEngine;
  69272. private _originTop;
  69273. private _originDirection;
  69274. private _tickCallback;
  69275. private _cylinder;
  69276. private _cylinderPosition;
  69277. private _dataFetched;
  69278. /**
  69279. * Initializes the physics updraft event
  69280. * @param _scene BabylonJS scene
  69281. * @param _origin The origin position of the updraft
  69282. * @param _options The options for the updraft event
  69283. */
  69284. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69285. /**
  69286. * Returns the data related to the updraft event (cylinder).
  69287. * @returns A physics updraft event
  69288. */
  69289. getData(): PhysicsUpdraftEventData;
  69290. /**
  69291. * Enables the updraft.
  69292. */
  69293. enable(): void;
  69294. /**
  69295. * Disables the updraft.
  69296. */
  69297. disable(): void;
  69298. /**
  69299. * Disposes the cylinder.
  69300. * @param force Specifies if the updraft should be disposed by force
  69301. */
  69302. dispose(force?: boolean): void;
  69303. private getImpostorHitData;
  69304. private _tick;
  69305. /*** Helpers ***/
  69306. private _prepareCylinder;
  69307. private _intersectsWithCylinder;
  69308. }
  69309. /**
  69310. * Represents a physics vortex event
  69311. */
  69312. class PhysicsVortexEvent {
  69313. private _scene;
  69314. private _origin;
  69315. private _options;
  69316. private _physicsEngine;
  69317. private _originTop;
  69318. private _tickCallback;
  69319. private _cylinder;
  69320. private _cylinderPosition;
  69321. private _dataFetched;
  69322. /**
  69323. * Initializes the physics vortex event
  69324. * @param _scene The BabylonJS scene
  69325. * @param _origin The origin position of the vortex
  69326. * @param _options The options for the vortex event
  69327. */
  69328. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69329. /**
  69330. * Returns the data related to the vortex event (cylinder).
  69331. * @returns The physics vortex event data
  69332. */
  69333. getData(): PhysicsVortexEventData;
  69334. /**
  69335. * Enables the vortex.
  69336. */
  69337. enable(): void;
  69338. /**
  69339. * Disables the cortex.
  69340. */
  69341. disable(): void;
  69342. /**
  69343. * Disposes the sphere.
  69344. * @param force
  69345. */
  69346. dispose(force?: boolean): void;
  69347. private getImpostorHitData;
  69348. private _tick;
  69349. /*** Helpers ***/
  69350. private _prepareCylinder;
  69351. private _intersectsWithCylinder;
  69352. }
  69353. /**
  69354. * Options fot the radial explosion event
  69355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69356. */
  69357. export class PhysicsRadialExplosionEventOptions {
  69358. /**
  69359. * The radius of the sphere for the radial explosion.
  69360. */
  69361. radius: number;
  69362. /**
  69363. * The strenth of the explosion.
  69364. */
  69365. strength: number;
  69366. /**
  69367. * The strenght of the force in correspondence to the distance of the affected object
  69368. */
  69369. falloff: PhysicsRadialImpulseFalloff;
  69370. /**
  69371. * Sphere options for the radial explosion.
  69372. */
  69373. sphere: {
  69374. segments: number;
  69375. diameter: number;
  69376. };
  69377. /**
  69378. * Sphere options for the radial explosion.
  69379. */
  69380. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69381. }
  69382. /**
  69383. * Options fot the updraft event
  69384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69385. */
  69386. export class PhysicsUpdraftEventOptions {
  69387. /**
  69388. * The radius of the cylinder for the vortex
  69389. */
  69390. radius: number;
  69391. /**
  69392. * The strenth of the updraft.
  69393. */
  69394. strength: number;
  69395. /**
  69396. * The height of the cylinder for the updraft.
  69397. */
  69398. height: number;
  69399. /**
  69400. * The mode for the the updraft.
  69401. */
  69402. updraftMode: PhysicsUpdraftMode;
  69403. }
  69404. /**
  69405. * Options fot the vortex event
  69406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69407. */
  69408. export class PhysicsVortexEventOptions {
  69409. /**
  69410. * The radius of the cylinder for the vortex
  69411. */
  69412. radius: number;
  69413. /**
  69414. * The strenth of the vortex.
  69415. */
  69416. strength: number;
  69417. /**
  69418. * The height of the cylinder for the vortex.
  69419. */
  69420. height: number;
  69421. /**
  69422. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69423. */
  69424. centripetalForceThreshold: number;
  69425. /**
  69426. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69427. */
  69428. centripetalForceMultiplier: number;
  69429. /**
  69430. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69431. */
  69432. centrifugalForceMultiplier: number;
  69433. /**
  69434. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69435. */
  69436. updraftForceMultiplier: number;
  69437. }
  69438. /**
  69439. * The strenght of the force in correspondence to the distance of the affected object
  69440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69441. */
  69442. export enum PhysicsRadialImpulseFalloff {
  69443. /** Defines that impulse is constant in strength across it's whole radius */
  69444. Constant = 0,
  69445. /** Defines that impulse gets weaker if it's further from the origin */
  69446. Linear = 1
  69447. }
  69448. /**
  69449. * The strength of the force in correspondence to the distance of the affected object
  69450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69451. */
  69452. export enum PhysicsUpdraftMode {
  69453. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69454. Center = 0,
  69455. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69456. Perpendicular = 1
  69457. }
  69458. /**
  69459. * Interface for a physics hit data
  69460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69461. */
  69462. export interface PhysicsHitData {
  69463. /**
  69464. * The force applied at the contact point
  69465. */
  69466. force: Vector3;
  69467. /**
  69468. * The contact point
  69469. */
  69470. contactPoint: Vector3;
  69471. /**
  69472. * The distance from the origin to the contact point
  69473. */
  69474. distanceFromOrigin: number;
  69475. }
  69476. /**
  69477. * Interface for radial explosion event data
  69478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69479. */
  69480. export interface PhysicsRadialExplosionEventData {
  69481. /**
  69482. * A sphere used for the radial explosion event
  69483. */
  69484. sphere: Mesh;
  69485. }
  69486. /**
  69487. * Interface for gravitational field event data
  69488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69489. */
  69490. export interface PhysicsGravitationalFieldEventData {
  69491. /**
  69492. * A sphere mesh used for the gravitational field event
  69493. */
  69494. sphere: Mesh;
  69495. }
  69496. /**
  69497. * Interface for updraft event data
  69498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69499. */
  69500. export interface PhysicsUpdraftEventData {
  69501. /**
  69502. * A cylinder used for the updraft event
  69503. */
  69504. cylinder: Mesh;
  69505. }
  69506. /**
  69507. * Interface for vortex event data
  69508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69509. */
  69510. export interface PhysicsVortexEventData {
  69511. /**
  69512. * A cylinder used for the vortex event
  69513. */
  69514. cylinder: Mesh;
  69515. }
  69516. /**
  69517. * Interface for an affected physics impostor
  69518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69519. */
  69520. export interface PhysicsAffectedImpostorWithData {
  69521. /**
  69522. * The impostor affected by the effect
  69523. */
  69524. impostor: PhysicsImpostor;
  69525. /**
  69526. * The data about the hit/horce from the explosion
  69527. */
  69528. hitData: PhysicsHitData;
  69529. }
  69530. }
  69531. declare module "babylonjs/Physics/Plugins/index" {
  69532. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69533. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69534. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69535. }
  69536. declare module "babylonjs/Physics/index" {
  69537. export * from "babylonjs/Physics/IPhysicsEngine";
  69538. export * from "babylonjs/Physics/physicsEngine";
  69539. export * from "babylonjs/Physics/physicsEngineComponent";
  69540. export * from "babylonjs/Physics/physicsHelper";
  69541. export * from "babylonjs/Physics/physicsImpostor";
  69542. export * from "babylonjs/Physics/physicsJoint";
  69543. export * from "babylonjs/Physics/Plugins/index";
  69544. }
  69545. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69546. /** @hidden */
  69547. export var blackAndWhitePixelShader: {
  69548. name: string;
  69549. shader: string;
  69550. };
  69551. }
  69552. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69554. import { Camera } from "babylonjs/Cameras/camera";
  69555. import { Engine } from "babylonjs/Engines/engine";
  69556. import "babylonjs/Shaders/blackAndWhite.fragment";
  69557. /**
  69558. * Post process used to render in black and white
  69559. */
  69560. export class BlackAndWhitePostProcess extends PostProcess {
  69561. /**
  69562. * Linear about to convert he result to black and white (default: 1)
  69563. */
  69564. degree: number;
  69565. /**
  69566. * Creates a black and white post process
  69567. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69568. * @param name The name of the effect.
  69569. * @param options The required width/height ratio to downsize to before computing the render pass.
  69570. * @param camera The camera to apply the render pass to.
  69571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69572. * @param engine The engine which the post process will be applied. (default: current engine)
  69573. * @param reusable If the post process can be reused on the same frame. (default: false)
  69574. */
  69575. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69576. }
  69577. }
  69578. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69579. import { Nullable } from "babylonjs/types";
  69580. import { Camera } from "babylonjs/Cameras/camera";
  69581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69582. import { Engine } from "babylonjs/Engines/engine";
  69583. /**
  69584. * This represents a set of one or more post processes in Babylon.
  69585. * A post process can be used to apply a shader to a texture after it is rendered.
  69586. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69587. */
  69588. export class PostProcessRenderEffect {
  69589. private _postProcesses;
  69590. private _getPostProcesses;
  69591. private _singleInstance;
  69592. private _cameras;
  69593. private _indicesForCamera;
  69594. /**
  69595. * Name of the effect
  69596. * @hidden
  69597. */
  69598. _name: string;
  69599. /**
  69600. * Instantiates a post process render effect.
  69601. * A post process can be used to apply a shader to a texture after it is rendered.
  69602. * @param engine The engine the effect is tied to
  69603. * @param name The name of the effect
  69604. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69605. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69606. */
  69607. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69608. /**
  69609. * Checks if all the post processes in the effect are supported.
  69610. */
  69611. get isSupported(): boolean;
  69612. /**
  69613. * Updates the current state of the effect
  69614. * @hidden
  69615. */
  69616. _update(): void;
  69617. /**
  69618. * Attaches the effect on cameras
  69619. * @param cameras The camera to attach to.
  69620. * @hidden
  69621. */
  69622. _attachCameras(cameras: Camera): void;
  69623. /**
  69624. * Attaches the effect on cameras
  69625. * @param cameras The camera to attach to.
  69626. * @hidden
  69627. */
  69628. _attachCameras(cameras: Camera[]): void;
  69629. /**
  69630. * Detaches the effect on cameras
  69631. * @param cameras The camera to detatch from.
  69632. * @hidden
  69633. */
  69634. _detachCameras(cameras: Camera): void;
  69635. /**
  69636. * Detatches the effect on cameras
  69637. * @param cameras The camera to detatch from.
  69638. * @hidden
  69639. */
  69640. _detachCameras(cameras: Camera[]): void;
  69641. /**
  69642. * Enables the effect on given cameras
  69643. * @param cameras The camera to enable.
  69644. * @hidden
  69645. */
  69646. _enable(cameras: Camera): void;
  69647. /**
  69648. * Enables the effect on given cameras
  69649. * @param cameras The camera to enable.
  69650. * @hidden
  69651. */
  69652. _enable(cameras: Nullable<Camera[]>): void;
  69653. /**
  69654. * Disables the effect on the given cameras
  69655. * @param cameras The camera to disable.
  69656. * @hidden
  69657. */
  69658. _disable(cameras: Camera): void;
  69659. /**
  69660. * Disables the effect on the given cameras
  69661. * @param cameras The camera to disable.
  69662. * @hidden
  69663. */
  69664. _disable(cameras: Nullable<Camera[]>): void;
  69665. /**
  69666. * Gets a list of the post processes contained in the effect.
  69667. * @param camera The camera to get the post processes on.
  69668. * @returns The list of the post processes in the effect.
  69669. */
  69670. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69671. }
  69672. }
  69673. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69674. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69675. /** @hidden */
  69676. export var extractHighlightsPixelShader: {
  69677. name: string;
  69678. shader: string;
  69679. };
  69680. }
  69681. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69682. import { Nullable } from "babylonjs/types";
  69683. import { Camera } from "babylonjs/Cameras/camera";
  69684. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69685. import { Engine } from "babylonjs/Engines/engine";
  69686. import "babylonjs/Shaders/extractHighlights.fragment";
  69687. /**
  69688. * 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.
  69689. */
  69690. export class ExtractHighlightsPostProcess extends PostProcess {
  69691. /**
  69692. * The luminance threshold, pixels below this value will be set to black.
  69693. */
  69694. threshold: number;
  69695. /** @hidden */
  69696. _exposure: number;
  69697. /**
  69698. * Post process which has the input texture to be used when performing highlight extraction
  69699. * @hidden
  69700. */
  69701. _inputPostProcess: Nullable<PostProcess>;
  69702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69703. }
  69704. }
  69705. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69706. /** @hidden */
  69707. export var bloomMergePixelShader: {
  69708. name: string;
  69709. shader: string;
  69710. };
  69711. }
  69712. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69714. import { Nullable } from "babylonjs/types";
  69715. import { Engine } from "babylonjs/Engines/engine";
  69716. import { Camera } from "babylonjs/Cameras/camera";
  69717. import "babylonjs/Shaders/bloomMerge.fragment";
  69718. /**
  69719. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69720. */
  69721. export class BloomMergePostProcess extends PostProcess {
  69722. /** Weight of the bloom to be added to the original input. */
  69723. weight: number;
  69724. /**
  69725. * Creates a new instance of @see BloomMergePostProcess
  69726. * @param name The name of the effect.
  69727. * @param originalFromInput Post process which's input will be used for the merge.
  69728. * @param blurred Blurred highlights post process which's output will be used.
  69729. * @param weight Weight of the bloom to be added to the original input.
  69730. * @param options The required width/height ratio to downsize to before computing the render pass.
  69731. * @param camera The camera to apply the render pass to.
  69732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69733. * @param engine The engine which the post process will be applied. (default: current engine)
  69734. * @param reusable If the post process can be reused on the same frame. (default: false)
  69735. * @param textureType Type of textures used when performing the post process. (default: 0)
  69736. * @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)
  69737. */
  69738. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69739. /** Weight of the bloom to be added to the original input. */
  69740. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69741. }
  69742. }
  69743. declare module "babylonjs/PostProcesses/bloomEffect" {
  69744. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69745. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69746. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69747. import { Camera } from "babylonjs/Cameras/camera";
  69748. import { Scene } from "babylonjs/scene";
  69749. /**
  69750. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69751. */
  69752. export class BloomEffect extends PostProcessRenderEffect {
  69753. private bloomScale;
  69754. /**
  69755. * @hidden Internal
  69756. */
  69757. _effects: Array<PostProcess>;
  69758. /**
  69759. * @hidden Internal
  69760. */
  69761. _downscale: ExtractHighlightsPostProcess;
  69762. private _blurX;
  69763. private _blurY;
  69764. private _merge;
  69765. /**
  69766. * The luminance threshold to find bright areas of the image to bloom.
  69767. */
  69768. get threshold(): number;
  69769. set threshold(value: number);
  69770. /**
  69771. * The strength of the bloom.
  69772. */
  69773. get weight(): number;
  69774. set weight(value: number);
  69775. /**
  69776. * Specifies the size of the bloom blur kernel, relative to the final output size
  69777. */
  69778. get kernel(): number;
  69779. set kernel(value: number);
  69780. /**
  69781. * Creates a new instance of @see BloomEffect
  69782. * @param scene The scene the effect belongs to.
  69783. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69784. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69785. * @param bloomWeight The the strength of bloom.
  69786. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69787. * @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)
  69788. */
  69789. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69790. /**
  69791. * Disposes each of the internal effects for a given camera.
  69792. * @param camera The camera to dispose the effect on.
  69793. */
  69794. disposeEffects(camera: Camera): void;
  69795. /**
  69796. * @hidden Internal
  69797. */
  69798. _updateEffects(): void;
  69799. /**
  69800. * Internal
  69801. * @returns if all the contained post processes are ready.
  69802. * @hidden
  69803. */
  69804. _isReady(): boolean;
  69805. }
  69806. }
  69807. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69808. /** @hidden */
  69809. export var chromaticAberrationPixelShader: {
  69810. name: string;
  69811. shader: string;
  69812. };
  69813. }
  69814. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69815. import { Vector2 } from "babylonjs/Maths/math.vector";
  69816. import { Nullable } from "babylonjs/types";
  69817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69818. import { Camera } from "babylonjs/Cameras/camera";
  69819. import { Engine } from "babylonjs/Engines/engine";
  69820. import "babylonjs/Shaders/chromaticAberration.fragment";
  69821. /**
  69822. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69823. */
  69824. export class ChromaticAberrationPostProcess extends PostProcess {
  69825. /**
  69826. * The amount of seperation of rgb channels (default: 30)
  69827. */
  69828. aberrationAmount: number;
  69829. /**
  69830. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69831. */
  69832. radialIntensity: number;
  69833. /**
  69834. * 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))
  69835. */
  69836. direction: Vector2;
  69837. /**
  69838. * 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))
  69839. */
  69840. centerPosition: Vector2;
  69841. /**
  69842. * Creates a new instance ChromaticAberrationPostProcess
  69843. * @param name The name of the effect.
  69844. * @param screenWidth The width of the screen to apply the effect on.
  69845. * @param screenHeight The height of the screen to apply the effect on.
  69846. * @param options The required width/height ratio to downsize to before computing the render pass.
  69847. * @param camera The camera to apply the render pass to.
  69848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69849. * @param engine The engine which the post process will be applied. (default: current engine)
  69850. * @param reusable If the post process can be reused on the same frame. (default: false)
  69851. * @param textureType Type of textures used when performing the post process. (default: 0)
  69852. * @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)
  69853. */
  69854. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69855. }
  69856. }
  69857. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69858. /** @hidden */
  69859. export var circleOfConfusionPixelShader: {
  69860. name: string;
  69861. shader: string;
  69862. };
  69863. }
  69864. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69865. import { Nullable } from "babylonjs/types";
  69866. import { Engine } from "babylonjs/Engines/engine";
  69867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69869. import { Camera } from "babylonjs/Cameras/camera";
  69870. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69871. /**
  69872. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69873. */
  69874. export class CircleOfConfusionPostProcess extends PostProcess {
  69875. /**
  69876. * 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.
  69877. */
  69878. lensSize: number;
  69879. /**
  69880. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69881. */
  69882. fStop: number;
  69883. /**
  69884. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69885. */
  69886. focusDistance: number;
  69887. /**
  69888. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69889. */
  69890. focalLength: number;
  69891. private _depthTexture;
  69892. /**
  69893. * Creates a new instance CircleOfConfusionPostProcess
  69894. * @param name The name of the effect.
  69895. * @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.
  69896. * @param options The required width/height ratio to downsize to before computing the render pass.
  69897. * @param camera The camera to apply the render pass to.
  69898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69899. * @param engine The engine which the post process will be applied. (default: current engine)
  69900. * @param reusable If the post process can be reused on the same frame. (default: false)
  69901. * @param textureType Type of textures used when performing the post process. (default: 0)
  69902. * @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)
  69903. */
  69904. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69905. /**
  69906. * 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.
  69907. */
  69908. set depthTexture(value: RenderTargetTexture);
  69909. }
  69910. }
  69911. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69912. /** @hidden */
  69913. export var colorCorrectionPixelShader: {
  69914. name: string;
  69915. shader: string;
  69916. };
  69917. }
  69918. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69919. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69920. import { Engine } from "babylonjs/Engines/engine";
  69921. import { Camera } from "babylonjs/Cameras/camera";
  69922. import "babylonjs/Shaders/colorCorrection.fragment";
  69923. /**
  69924. *
  69925. * This post-process allows the modification of rendered colors by using
  69926. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69927. *
  69928. * The object needs to be provided an url to a texture containing the color
  69929. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69930. * Use an image editing software to tweak the LUT to match your needs.
  69931. *
  69932. * For an example of a color LUT, see here:
  69933. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69934. * For explanations on color grading, see here:
  69935. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69936. *
  69937. */
  69938. export class ColorCorrectionPostProcess extends PostProcess {
  69939. private _colorTableTexture;
  69940. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69941. }
  69942. }
  69943. declare module "babylonjs/Shaders/convolution.fragment" {
  69944. /** @hidden */
  69945. export var convolutionPixelShader: {
  69946. name: string;
  69947. shader: string;
  69948. };
  69949. }
  69950. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69951. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69952. import { Nullable } from "babylonjs/types";
  69953. import { Camera } from "babylonjs/Cameras/camera";
  69954. import { Engine } from "babylonjs/Engines/engine";
  69955. import "babylonjs/Shaders/convolution.fragment";
  69956. /**
  69957. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69958. * input texture to perform effects such as edge detection or sharpening
  69959. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69960. */
  69961. export class ConvolutionPostProcess extends PostProcess {
  69962. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69963. kernel: number[];
  69964. /**
  69965. * Creates a new instance ConvolutionPostProcess
  69966. * @param name The name of the effect.
  69967. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69968. * @param options The required width/height ratio to downsize to before computing the render pass.
  69969. * @param camera The camera to apply the render pass to.
  69970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69971. * @param engine The engine which the post process will be applied. (default: current engine)
  69972. * @param reusable If the post process can be reused on the same frame. (default: false)
  69973. * @param textureType Type of textures used when performing the post process. (default: 0)
  69974. */
  69975. constructor(name: string,
  69976. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69977. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69978. /**
  69979. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69980. */
  69981. static EdgeDetect0Kernel: number[];
  69982. /**
  69983. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69984. */
  69985. static EdgeDetect1Kernel: number[];
  69986. /**
  69987. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69988. */
  69989. static EdgeDetect2Kernel: number[];
  69990. /**
  69991. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69992. */
  69993. static SharpenKernel: number[];
  69994. /**
  69995. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69996. */
  69997. static EmbossKernel: number[];
  69998. /**
  69999. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70000. */
  70001. static GaussianKernel: number[];
  70002. }
  70003. }
  70004. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  70005. import { Nullable } from "babylonjs/types";
  70006. import { Vector2 } from "babylonjs/Maths/math.vector";
  70007. import { Camera } from "babylonjs/Cameras/camera";
  70008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70009. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70010. import { Engine } from "babylonjs/Engines/engine";
  70011. import { Scene } from "babylonjs/scene";
  70012. /**
  70013. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70014. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70015. * based on samples that have a large difference in distance than the center pixel.
  70016. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70017. */
  70018. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70019. direction: Vector2;
  70020. /**
  70021. * Creates a new instance CircleOfConfusionPostProcess
  70022. * @param name The name of the effect.
  70023. * @param scene The scene the effect belongs to.
  70024. * @param direction The direction the blur should be applied.
  70025. * @param kernel The size of the kernel used to blur.
  70026. * @param options The required width/height ratio to downsize to before computing the render pass.
  70027. * @param camera The camera to apply the render pass to.
  70028. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70029. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70031. * @param engine The engine which the post process will be applied. (default: current engine)
  70032. * @param reusable If the post process can be reused on the same frame. (default: false)
  70033. * @param textureType Type of textures used when performing the post process. (default: 0)
  70034. * @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)
  70035. */
  70036. 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);
  70037. }
  70038. }
  70039. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  70040. /** @hidden */
  70041. export var depthOfFieldMergePixelShader: {
  70042. name: string;
  70043. shader: string;
  70044. };
  70045. }
  70046. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  70047. import { Nullable } from "babylonjs/types";
  70048. import { Camera } from "babylonjs/Cameras/camera";
  70049. import { Effect } from "babylonjs/Materials/effect";
  70050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70051. import { Engine } from "babylonjs/Engines/engine";
  70052. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  70053. /**
  70054. * Options to be set when merging outputs from the default pipeline.
  70055. */
  70056. export class DepthOfFieldMergePostProcessOptions {
  70057. /**
  70058. * The original image to merge on top of
  70059. */
  70060. originalFromInput: PostProcess;
  70061. /**
  70062. * Parameters to perform the merge of the depth of field effect
  70063. */
  70064. depthOfField?: {
  70065. circleOfConfusion: PostProcess;
  70066. blurSteps: Array<PostProcess>;
  70067. };
  70068. /**
  70069. * Parameters to perform the merge of bloom effect
  70070. */
  70071. bloom?: {
  70072. blurred: PostProcess;
  70073. weight: number;
  70074. };
  70075. }
  70076. /**
  70077. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70078. */
  70079. export class DepthOfFieldMergePostProcess extends PostProcess {
  70080. private blurSteps;
  70081. /**
  70082. * Creates a new instance of DepthOfFieldMergePostProcess
  70083. * @param name The name of the effect.
  70084. * @param originalFromInput Post process which's input will be used for the merge.
  70085. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70086. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70087. * @param options The required width/height ratio to downsize to before computing the render pass.
  70088. * @param camera The camera to apply the render pass to.
  70089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70090. * @param engine The engine which the post process will be applied. (default: current engine)
  70091. * @param reusable If the post process can be reused on the same frame. (default: false)
  70092. * @param textureType Type of textures used when performing the post process. (default: 0)
  70093. * @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)
  70094. */
  70095. 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);
  70096. /**
  70097. * Updates the effect with the current post process compile time values and recompiles the shader.
  70098. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70099. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70100. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70101. * @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
  70102. * @param onCompiled Called when the shader has been compiled.
  70103. * @param onError Called if there is an error when compiling a shader.
  70104. */
  70105. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70106. }
  70107. }
  70108. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  70109. import { Nullable } from "babylonjs/types";
  70110. import { Camera } from "babylonjs/Cameras/camera";
  70111. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70113. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70114. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70115. import { Scene } from "babylonjs/scene";
  70116. /**
  70117. * Specifies the level of max blur that should be applied when using the depth of field effect
  70118. */
  70119. export enum DepthOfFieldEffectBlurLevel {
  70120. /**
  70121. * Subtle blur
  70122. */
  70123. Low = 0,
  70124. /**
  70125. * Medium blur
  70126. */
  70127. Medium = 1,
  70128. /**
  70129. * Large blur
  70130. */
  70131. High = 2
  70132. }
  70133. /**
  70134. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70135. */
  70136. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70137. private _circleOfConfusion;
  70138. /**
  70139. * @hidden Internal, blurs from high to low
  70140. */
  70141. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70142. private _depthOfFieldBlurY;
  70143. private _dofMerge;
  70144. /**
  70145. * @hidden Internal post processes in depth of field effect
  70146. */
  70147. _effects: Array<PostProcess>;
  70148. /**
  70149. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70150. */
  70151. set focalLength(value: number);
  70152. get focalLength(): number;
  70153. /**
  70154. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70155. */
  70156. set fStop(value: number);
  70157. get fStop(): number;
  70158. /**
  70159. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70160. */
  70161. set focusDistance(value: number);
  70162. get focusDistance(): number;
  70163. /**
  70164. * 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.
  70165. */
  70166. set lensSize(value: number);
  70167. get lensSize(): number;
  70168. /**
  70169. * Creates a new instance DepthOfFieldEffect
  70170. * @param scene The scene the effect belongs to.
  70171. * @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.
  70172. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70173. * @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)
  70174. */
  70175. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70176. /**
  70177. * Get the current class name of the current effet
  70178. * @returns "DepthOfFieldEffect"
  70179. */
  70180. getClassName(): string;
  70181. /**
  70182. * 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.
  70183. */
  70184. set depthTexture(value: RenderTargetTexture);
  70185. /**
  70186. * Disposes each of the internal effects for a given camera.
  70187. * @param camera The camera to dispose the effect on.
  70188. */
  70189. disposeEffects(camera: Camera): void;
  70190. /**
  70191. * @hidden Internal
  70192. */
  70193. _updateEffects(): void;
  70194. /**
  70195. * Internal
  70196. * @returns if all the contained post processes are ready.
  70197. * @hidden
  70198. */
  70199. _isReady(): boolean;
  70200. }
  70201. }
  70202. declare module "babylonjs/Shaders/displayPass.fragment" {
  70203. /** @hidden */
  70204. export var displayPassPixelShader: {
  70205. name: string;
  70206. shader: string;
  70207. };
  70208. }
  70209. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70210. import { Nullable } from "babylonjs/types";
  70211. import { Camera } from "babylonjs/Cameras/camera";
  70212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70213. import { Engine } from "babylonjs/Engines/engine";
  70214. import "babylonjs/Shaders/displayPass.fragment";
  70215. /**
  70216. * DisplayPassPostProcess which produces an output the same as it's input
  70217. */
  70218. export class DisplayPassPostProcess extends PostProcess {
  70219. /**
  70220. * Creates the DisplayPassPostProcess
  70221. * @param name The name of the effect.
  70222. * @param options The required width/height ratio to downsize to before computing the render pass.
  70223. * @param camera The camera to apply the render pass to.
  70224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70225. * @param engine The engine which the post process will be applied. (default: current engine)
  70226. * @param reusable If the post process can be reused on the same frame. (default: false)
  70227. */
  70228. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70229. }
  70230. }
  70231. declare module "babylonjs/Shaders/filter.fragment" {
  70232. /** @hidden */
  70233. export var filterPixelShader: {
  70234. name: string;
  70235. shader: string;
  70236. };
  70237. }
  70238. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70239. import { Nullable } from "babylonjs/types";
  70240. import { Matrix } from "babylonjs/Maths/math.vector";
  70241. import { Camera } from "babylonjs/Cameras/camera";
  70242. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70243. import { Engine } from "babylonjs/Engines/engine";
  70244. import "babylonjs/Shaders/filter.fragment";
  70245. /**
  70246. * Applies a kernel filter to the image
  70247. */
  70248. export class FilterPostProcess extends PostProcess {
  70249. /** The matrix to be applied to the image */
  70250. kernelMatrix: Matrix;
  70251. /**
  70252. *
  70253. * @param name The name of the effect.
  70254. * @param kernelMatrix The matrix to be applied to the image
  70255. * @param options The required width/height ratio to downsize to before computing the render pass.
  70256. * @param camera The camera to apply the render pass to.
  70257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70258. * @param engine The engine which the post process will be applied. (default: current engine)
  70259. * @param reusable If the post process can be reused on the same frame. (default: false)
  70260. */
  70261. constructor(name: string,
  70262. /** The matrix to be applied to the image */
  70263. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70264. }
  70265. }
  70266. declare module "babylonjs/Shaders/fxaa.fragment" {
  70267. /** @hidden */
  70268. export var fxaaPixelShader: {
  70269. name: string;
  70270. shader: string;
  70271. };
  70272. }
  70273. declare module "babylonjs/Shaders/fxaa.vertex" {
  70274. /** @hidden */
  70275. export var fxaaVertexShader: {
  70276. name: string;
  70277. shader: string;
  70278. };
  70279. }
  70280. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70281. import { Nullable } from "babylonjs/types";
  70282. import { Camera } from "babylonjs/Cameras/camera";
  70283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70284. import { Engine } from "babylonjs/Engines/engine";
  70285. import "babylonjs/Shaders/fxaa.fragment";
  70286. import "babylonjs/Shaders/fxaa.vertex";
  70287. /**
  70288. * Fxaa post process
  70289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70290. */
  70291. export class FxaaPostProcess extends PostProcess {
  70292. /** @hidden */
  70293. texelWidth: number;
  70294. /** @hidden */
  70295. texelHeight: number;
  70296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70297. private _getDefines;
  70298. }
  70299. }
  70300. declare module "babylonjs/Shaders/grain.fragment" {
  70301. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70302. /** @hidden */
  70303. export var grainPixelShader: {
  70304. name: string;
  70305. shader: string;
  70306. };
  70307. }
  70308. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70309. import { Nullable } from "babylonjs/types";
  70310. import { Camera } from "babylonjs/Cameras/camera";
  70311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70312. import { Engine } from "babylonjs/Engines/engine";
  70313. import "babylonjs/Shaders/grain.fragment";
  70314. /**
  70315. * The GrainPostProcess adds noise to the image at mid luminance levels
  70316. */
  70317. export class GrainPostProcess extends PostProcess {
  70318. /**
  70319. * The intensity of the grain added (default: 30)
  70320. */
  70321. intensity: number;
  70322. /**
  70323. * If the grain should be randomized on every frame
  70324. */
  70325. animated: boolean;
  70326. /**
  70327. * Creates a new instance of @see GrainPostProcess
  70328. * @param name The name of the effect.
  70329. * @param options The required width/height ratio to downsize to before computing the render pass.
  70330. * @param camera The camera to apply the render pass to.
  70331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70332. * @param engine The engine which the post process will be applied. (default: current engine)
  70333. * @param reusable If the post process can be reused on the same frame. (default: false)
  70334. * @param textureType Type of textures used when performing the post process. (default: 0)
  70335. * @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)
  70336. */
  70337. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70338. }
  70339. }
  70340. declare module "babylonjs/Shaders/highlights.fragment" {
  70341. /** @hidden */
  70342. export var highlightsPixelShader: {
  70343. name: string;
  70344. shader: string;
  70345. };
  70346. }
  70347. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70348. import { Nullable } from "babylonjs/types";
  70349. import { Camera } from "babylonjs/Cameras/camera";
  70350. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70351. import { Engine } from "babylonjs/Engines/engine";
  70352. import "babylonjs/Shaders/highlights.fragment";
  70353. /**
  70354. * Extracts highlights from the image
  70355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70356. */
  70357. export class HighlightsPostProcess extends PostProcess {
  70358. /**
  70359. * Extracts highlights from the image
  70360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70361. * @param name The name of the effect.
  70362. * @param options The required width/height ratio to downsize to before computing the render pass.
  70363. * @param camera The camera to apply the render pass to.
  70364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70365. * @param engine The engine which the post process will be applied. (default: current engine)
  70366. * @param reusable If the post process can be reused on the same frame. (default: false)
  70367. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70368. */
  70369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70370. }
  70371. }
  70372. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70373. /** @hidden */
  70374. export var mrtFragmentDeclaration: {
  70375. name: string;
  70376. shader: string;
  70377. };
  70378. }
  70379. declare module "babylonjs/Shaders/geometry.fragment" {
  70380. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70381. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70382. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70383. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70384. /** @hidden */
  70385. export var geometryPixelShader: {
  70386. name: string;
  70387. shader: string;
  70388. };
  70389. }
  70390. declare module "babylonjs/Shaders/geometry.vertex" {
  70391. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70394. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70395. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70396. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70397. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70398. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70399. /** @hidden */
  70400. export var geometryVertexShader: {
  70401. name: string;
  70402. shader: string;
  70403. };
  70404. }
  70405. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70406. import { Matrix } from "babylonjs/Maths/math.vector";
  70407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70408. import { Mesh } from "babylonjs/Meshes/mesh";
  70409. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70410. import { Effect } from "babylonjs/Materials/effect";
  70411. import { Scene } from "babylonjs/scene";
  70412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70413. import "babylonjs/Shaders/geometry.fragment";
  70414. import "babylonjs/Shaders/geometry.vertex";
  70415. /** @hidden */
  70416. interface ISavedTransformationMatrix {
  70417. world: Matrix;
  70418. viewProjection: Matrix;
  70419. }
  70420. /**
  70421. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70422. */
  70423. export class GeometryBufferRenderer {
  70424. /**
  70425. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70426. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70427. */
  70428. static readonly POSITION_TEXTURE_TYPE: number;
  70429. /**
  70430. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70431. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70432. */
  70433. static readonly VELOCITY_TEXTURE_TYPE: number;
  70434. /**
  70435. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70436. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70437. */
  70438. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70439. /**
  70440. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70441. * in order to compute objects velocities when enableVelocity is set to "true"
  70442. * @hidden
  70443. */
  70444. _previousTransformationMatrices: {
  70445. [index: number]: ISavedTransformationMatrix;
  70446. };
  70447. /**
  70448. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70449. * in order to compute objects velocities when enableVelocity is set to "true"
  70450. * @hidden
  70451. */
  70452. _previousBonesTransformationMatrices: {
  70453. [index: number]: Float32Array;
  70454. };
  70455. /**
  70456. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70457. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70458. */
  70459. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70460. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70461. renderTransparentMeshes: boolean;
  70462. private _scene;
  70463. private _multiRenderTarget;
  70464. private _ratio;
  70465. private _enablePosition;
  70466. private _enableVelocity;
  70467. private _enableReflectivity;
  70468. private _positionIndex;
  70469. private _velocityIndex;
  70470. private _reflectivityIndex;
  70471. protected _effect: Effect;
  70472. protected _cachedDefines: string;
  70473. /**
  70474. * Set the render list (meshes to be rendered) used in the G buffer.
  70475. */
  70476. set renderList(meshes: Mesh[]);
  70477. /**
  70478. * Gets wether or not G buffer are supported by the running hardware.
  70479. * This requires draw buffer supports
  70480. */
  70481. get isSupported(): boolean;
  70482. /**
  70483. * Returns the index of the given texture type in the G-Buffer textures array
  70484. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70485. * @returns the index of the given texture type in the G-Buffer textures array
  70486. */
  70487. getTextureIndex(textureType: number): number;
  70488. /**
  70489. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70490. */
  70491. get enablePosition(): boolean;
  70492. /**
  70493. * Sets whether or not objects positions are enabled for the G buffer.
  70494. */
  70495. set enablePosition(enable: boolean);
  70496. /**
  70497. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70498. */
  70499. get enableVelocity(): boolean;
  70500. /**
  70501. * Sets wether or not objects velocities are enabled for the G buffer.
  70502. */
  70503. set enableVelocity(enable: boolean);
  70504. /**
  70505. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70506. */
  70507. get enableReflectivity(): boolean;
  70508. /**
  70509. * Sets wether or not objects roughness are enabled for the G buffer.
  70510. */
  70511. set enableReflectivity(enable: boolean);
  70512. /**
  70513. * Gets the scene associated with the buffer.
  70514. */
  70515. get scene(): Scene;
  70516. /**
  70517. * Gets the ratio used by the buffer during its creation.
  70518. * How big is the buffer related to the main canvas.
  70519. */
  70520. get ratio(): number;
  70521. /** @hidden */
  70522. static _SceneComponentInitialization: (scene: Scene) => void;
  70523. /**
  70524. * Creates a new G Buffer for the scene
  70525. * @param scene The scene the buffer belongs to
  70526. * @param ratio How big is the buffer related to the main canvas.
  70527. */
  70528. constructor(scene: Scene, ratio?: number);
  70529. /**
  70530. * Checks wether everything is ready to render a submesh to the G buffer.
  70531. * @param subMesh the submesh to check readiness for
  70532. * @param useInstances is the mesh drawn using instance or not
  70533. * @returns true if ready otherwise false
  70534. */
  70535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70536. /**
  70537. * Gets the current underlying G Buffer.
  70538. * @returns the buffer
  70539. */
  70540. getGBuffer(): MultiRenderTarget;
  70541. /**
  70542. * Gets the number of samples used to render the buffer (anti aliasing).
  70543. */
  70544. get samples(): number;
  70545. /**
  70546. * Sets the number of samples used to render the buffer (anti aliasing).
  70547. */
  70548. set samples(value: number);
  70549. /**
  70550. * Disposes the renderer and frees up associated resources.
  70551. */
  70552. dispose(): void;
  70553. protected _createRenderTargets(): void;
  70554. private _copyBonesTransformationMatrices;
  70555. }
  70556. }
  70557. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70558. import { Nullable } from "babylonjs/types";
  70559. import { Scene } from "babylonjs/scene";
  70560. import { ISceneComponent } from "babylonjs/sceneComponent";
  70561. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70562. module "babylonjs/scene" {
  70563. interface Scene {
  70564. /** @hidden (Backing field) */
  70565. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70566. /**
  70567. * Gets or Sets the current geometry buffer associated to the scene.
  70568. */
  70569. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70570. /**
  70571. * Enables a GeometryBufferRender and associates it with the scene
  70572. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70573. * @returns the GeometryBufferRenderer
  70574. */
  70575. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70576. /**
  70577. * Disables the GeometryBufferRender associated with the scene
  70578. */
  70579. disableGeometryBufferRenderer(): void;
  70580. }
  70581. }
  70582. /**
  70583. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70584. * in several rendering techniques.
  70585. */
  70586. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70587. /**
  70588. * The component name helpful to identify the component in the list of scene components.
  70589. */
  70590. readonly name: string;
  70591. /**
  70592. * The scene the component belongs to.
  70593. */
  70594. scene: Scene;
  70595. /**
  70596. * Creates a new instance of the component for the given scene
  70597. * @param scene Defines the scene to register the component in
  70598. */
  70599. constructor(scene: Scene);
  70600. /**
  70601. * Registers the component in a given scene
  70602. */
  70603. register(): void;
  70604. /**
  70605. * Rebuilds the elements related to this component in case of
  70606. * context lost for instance.
  70607. */
  70608. rebuild(): void;
  70609. /**
  70610. * Disposes the component and the associated ressources
  70611. */
  70612. dispose(): void;
  70613. private _gatherRenderTargets;
  70614. }
  70615. }
  70616. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70617. /** @hidden */
  70618. export var motionBlurPixelShader: {
  70619. name: string;
  70620. shader: string;
  70621. };
  70622. }
  70623. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70624. import { Nullable } from "babylonjs/types";
  70625. import { Camera } from "babylonjs/Cameras/camera";
  70626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70627. import { Scene } from "babylonjs/scene";
  70628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70629. import "babylonjs/Animations/animatable";
  70630. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70631. import "babylonjs/Shaders/motionBlur.fragment";
  70632. import { Engine } from "babylonjs/Engines/engine";
  70633. /**
  70634. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70635. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70636. * As an example, all you have to do is to create the post-process:
  70637. * var mb = new BABYLON.MotionBlurPostProcess(
  70638. * 'mb', // The name of the effect.
  70639. * scene, // The scene containing the objects to blur according to their velocity.
  70640. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70641. * camera // The camera to apply the render pass to.
  70642. * );
  70643. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70644. */
  70645. export class MotionBlurPostProcess extends PostProcess {
  70646. /**
  70647. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70648. */
  70649. motionStrength: number;
  70650. /**
  70651. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70652. */
  70653. get motionBlurSamples(): number;
  70654. /**
  70655. * Sets the number of iterations to be used for motion blur quality
  70656. */
  70657. set motionBlurSamples(samples: number);
  70658. private _motionBlurSamples;
  70659. private _geometryBufferRenderer;
  70660. /**
  70661. * Creates a new instance MotionBlurPostProcess
  70662. * @param name The name of the effect.
  70663. * @param scene The scene containing the objects to blur according to their velocity.
  70664. * @param options The required width/height ratio to downsize to before computing the render pass.
  70665. * @param camera The camera to apply the render pass to.
  70666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70667. * @param engine The engine which the post process will be applied. (default: current engine)
  70668. * @param reusable If the post process can be reused on the same frame. (default: false)
  70669. * @param textureType Type of textures used when performing the post process. (default: 0)
  70670. * @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)
  70671. */
  70672. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70673. /**
  70674. * Excludes the given skinned mesh from computing bones velocities.
  70675. * 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.
  70676. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70677. */
  70678. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70679. /**
  70680. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70681. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70682. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70683. */
  70684. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70685. /**
  70686. * Disposes the post process.
  70687. * @param camera The camera to dispose the post process on.
  70688. */
  70689. dispose(camera?: Camera): void;
  70690. }
  70691. }
  70692. declare module "babylonjs/Shaders/refraction.fragment" {
  70693. /** @hidden */
  70694. export var refractionPixelShader: {
  70695. name: string;
  70696. shader: string;
  70697. };
  70698. }
  70699. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70700. import { Color3 } from "babylonjs/Maths/math.color";
  70701. import { Camera } from "babylonjs/Cameras/camera";
  70702. import { Texture } from "babylonjs/Materials/Textures/texture";
  70703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70704. import { Engine } from "babylonjs/Engines/engine";
  70705. import "babylonjs/Shaders/refraction.fragment";
  70706. /**
  70707. * Post process which applies a refractin texture
  70708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70709. */
  70710. export class RefractionPostProcess extends PostProcess {
  70711. /** the base color of the refraction (used to taint the rendering) */
  70712. color: Color3;
  70713. /** simulated refraction depth */
  70714. depth: number;
  70715. /** the coefficient of the base color (0 to remove base color tainting) */
  70716. colorLevel: number;
  70717. private _refTexture;
  70718. private _ownRefractionTexture;
  70719. /**
  70720. * Gets or sets the refraction texture
  70721. * Please note that you are responsible for disposing the texture if you set it manually
  70722. */
  70723. get refractionTexture(): Texture;
  70724. set refractionTexture(value: Texture);
  70725. /**
  70726. * Initializes the RefractionPostProcess
  70727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70728. * @param name The name of the effect.
  70729. * @param refractionTextureUrl Url of the refraction texture to use
  70730. * @param color the base color of the refraction (used to taint the rendering)
  70731. * @param depth simulated refraction depth
  70732. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70733. * @param camera The camera to apply the render pass to.
  70734. * @param options The required width/height ratio to downsize to before computing the render pass.
  70735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70736. * @param engine The engine which the post process will be applied. (default: current engine)
  70737. * @param reusable If the post process can be reused on the same frame. (default: false)
  70738. */
  70739. constructor(name: string, refractionTextureUrl: string,
  70740. /** the base color of the refraction (used to taint the rendering) */
  70741. color: Color3,
  70742. /** simulated refraction depth */
  70743. depth: number,
  70744. /** the coefficient of the base color (0 to remove base color tainting) */
  70745. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70746. /**
  70747. * Disposes of the post process
  70748. * @param camera Camera to dispose post process on
  70749. */
  70750. dispose(camera: Camera): void;
  70751. }
  70752. }
  70753. declare module "babylonjs/Shaders/sharpen.fragment" {
  70754. /** @hidden */
  70755. export var sharpenPixelShader: {
  70756. name: string;
  70757. shader: string;
  70758. };
  70759. }
  70760. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70761. import { Nullable } from "babylonjs/types";
  70762. import { Camera } from "babylonjs/Cameras/camera";
  70763. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70764. import "babylonjs/Shaders/sharpen.fragment";
  70765. import { Engine } from "babylonjs/Engines/engine";
  70766. /**
  70767. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70768. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70769. */
  70770. export class SharpenPostProcess extends PostProcess {
  70771. /**
  70772. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70773. */
  70774. colorAmount: number;
  70775. /**
  70776. * How much sharpness should be applied (default: 0.3)
  70777. */
  70778. edgeAmount: number;
  70779. /**
  70780. * Creates a new instance ConvolutionPostProcess
  70781. * @param name The name of the effect.
  70782. * @param options The required width/height ratio to downsize to before computing the render pass.
  70783. * @param camera The camera to apply the render pass to.
  70784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70785. * @param engine The engine which the post process will be applied. (default: current engine)
  70786. * @param reusable If the post process can be reused on the same frame. (default: false)
  70787. * @param textureType Type of textures used when performing the post process. (default: 0)
  70788. * @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)
  70789. */
  70790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70791. }
  70792. }
  70793. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70794. import { Nullable } from "babylonjs/types";
  70795. import { Camera } from "babylonjs/Cameras/camera";
  70796. import { Engine } from "babylonjs/Engines/engine";
  70797. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70798. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70799. /**
  70800. * PostProcessRenderPipeline
  70801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70802. */
  70803. export class PostProcessRenderPipeline {
  70804. private engine;
  70805. private _renderEffects;
  70806. private _renderEffectsForIsolatedPass;
  70807. /**
  70808. * List of inspectable custom properties (used by the Inspector)
  70809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70810. */
  70811. inspectableCustomProperties: IInspectable[];
  70812. /**
  70813. * @hidden
  70814. */
  70815. protected _cameras: Camera[];
  70816. /** @hidden */
  70817. _name: string;
  70818. /**
  70819. * Gets pipeline name
  70820. */
  70821. get name(): string;
  70822. /** Gets the list of attached cameras */
  70823. get cameras(): Camera[];
  70824. /**
  70825. * Initializes a PostProcessRenderPipeline
  70826. * @param engine engine to add the pipeline to
  70827. * @param name name of the pipeline
  70828. */
  70829. constructor(engine: Engine, name: string);
  70830. /**
  70831. * Gets the class name
  70832. * @returns "PostProcessRenderPipeline"
  70833. */
  70834. getClassName(): string;
  70835. /**
  70836. * If all the render effects in the pipeline are supported
  70837. */
  70838. get isSupported(): boolean;
  70839. /**
  70840. * Adds an effect to the pipeline
  70841. * @param renderEffect the effect to add
  70842. */
  70843. addEffect(renderEffect: PostProcessRenderEffect): void;
  70844. /** @hidden */
  70845. _rebuild(): void;
  70846. /** @hidden */
  70847. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70848. /** @hidden */
  70849. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70850. /** @hidden */
  70851. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70852. /** @hidden */
  70853. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70854. /** @hidden */
  70855. _attachCameras(cameras: Camera, unique: boolean): void;
  70856. /** @hidden */
  70857. _attachCameras(cameras: Camera[], unique: boolean): void;
  70858. /** @hidden */
  70859. _detachCameras(cameras: Camera): void;
  70860. /** @hidden */
  70861. _detachCameras(cameras: Nullable<Camera[]>): void;
  70862. /** @hidden */
  70863. _update(): void;
  70864. /** @hidden */
  70865. _reset(): void;
  70866. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70867. /**
  70868. * Disposes of the pipeline
  70869. */
  70870. dispose(): void;
  70871. }
  70872. }
  70873. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70874. import { Camera } from "babylonjs/Cameras/camera";
  70875. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70876. /**
  70877. * PostProcessRenderPipelineManager class
  70878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70879. */
  70880. export class PostProcessRenderPipelineManager {
  70881. private _renderPipelines;
  70882. /**
  70883. * Initializes a PostProcessRenderPipelineManager
  70884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70885. */
  70886. constructor();
  70887. /**
  70888. * Gets the list of supported render pipelines
  70889. */
  70890. get supportedPipelines(): PostProcessRenderPipeline[];
  70891. /**
  70892. * Adds a pipeline to the manager
  70893. * @param renderPipeline The pipeline to add
  70894. */
  70895. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70896. /**
  70897. * Attaches a camera to the pipeline
  70898. * @param renderPipelineName The name of the pipeline to attach to
  70899. * @param cameras the camera to attach
  70900. * @param unique if the camera can be attached multiple times to the pipeline
  70901. */
  70902. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70903. /**
  70904. * Detaches a camera from the pipeline
  70905. * @param renderPipelineName The name of the pipeline to detach from
  70906. * @param cameras the camera to detach
  70907. */
  70908. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70909. /**
  70910. * Enables an effect by name on a pipeline
  70911. * @param renderPipelineName the name of the pipeline to enable the effect in
  70912. * @param renderEffectName the name of the effect to enable
  70913. * @param cameras the cameras that the effect should be enabled on
  70914. */
  70915. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70916. /**
  70917. * Disables an effect by name on a pipeline
  70918. * @param renderPipelineName the name of the pipeline to disable the effect in
  70919. * @param renderEffectName the name of the effect to disable
  70920. * @param cameras the cameras that the effect should be disabled on
  70921. */
  70922. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70923. /**
  70924. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70925. */
  70926. update(): void;
  70927. /** @hidden */
  70928. _rebuild(): void;
  70929. /**
  70930. * Disposes of the manager and pipelines
  70931. */
  70932. dispose(): void;
  70933. }
  70934. }
  70935. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70936. import { ISceneComponent } from "babylonjs/sceneComponent";
  70937. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70938. import { Scene } from "babylonjs/scene";
  70939. module "babylonjs/scene" {
  70940. interface Scene {
  70941. /** @hidden (Backing field) */
  70942. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70943. /**
  70944. * Gets the postprocess render pipeline manager
  70945. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70946. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70947. */
  70948. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70949. }
  70950. }
  70951. /**
  70952. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70953. */
  70954. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70955. /**
  70956. * The component name helpfull to identify the component in the list of scene components.
  70957. */
  70958. readonly name: string;
  70959. /**
  70960. * The scene the component belongs to.
  70961. */
  70962. scene: Scene;
  70963. /**
  70964. * Creates a new instance of the component for the given scene
  70965. * @param scene Defines the scene to register the component in
  70966. */
  70967. constructor(scene: Scene);
  70968. /**
  70969. * Registers the component in a given scene
  70970. */
  70971. register(): void;
  70972. /**
  70973. * Rebuilds the elements related to this component in case of
  70974. * context lost for instance.
  70975. */
  70976. rebuild(): void;
  70977. /**
  70978. * Disposes the component and the associated ressources
  70979. */
  70980. dispose(): void;
  70981. private _gatherRenderTargets;
  70982. }
  70983. }
  70984. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  70985. import { Nullable } from "babylonjs/types";
  70986. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70987. import { Camera } from "babylonjs/Cameras/camera";
  70988. import { IDisposable } from "babylonjs/scene";
  70989. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  70990. import { Scene } from "babylonjs/scene";
  70991. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  70992. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70993. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70994. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  70995. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70996. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70997. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  70998. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70999. import { Animation } from "babylonjs/Animations/animation";
  71000. /**
  71001. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71002. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71003. */
  71004. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71005. private _scene;
  71006. private _camerasToBeAttached;
  71007. /**
  71008. * ID of the sharpen post process,
  71009. */
  71010. private readonly SharpenPostProcessId;
  71011. /**
  71012. * @ignore
  71013. * ID of the image processing post process;
  71014. */
  71015. readonly ImageProcessingPostProcessId: string;
  71016. /**
  71017. * @ignore
  71018. * ID of the Fast Approximate Anti-Aliasing post process;
  71019. */
  71020. readonly FxaaPostProcessId: string;
  71021. /**
  71022. * ID of the chromatic aberration post process,
  71023. */
  71024. private readonly ChromaticAberrationPostProcessId;
  71025. /**
  71026. * ID of the grain post process
  71027. */
  71028. private readonly GrainPostProcessId;
  71029. /**
  71030. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71031. */
  71032. sharpen: SharpenPostProcess;
  71033. private _sharpenEffect;
  71034. private bloom;
  71035. /**
  71036. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71037. */
  71038. depthOfField: DepthOfFieldEffect;
  71039. /**
  71040. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71041. */
  71042. fxaa: FxaaPostProcess;
  71043. /**
  71044. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71045. */
  71046. imageProcessing: ImageProcessingPostProcess;
  71047. /**
  71048. * Chromatic aberration post process which will shift rgb colors in the image
  71049. */
  71050. chromaticAberration: ChromaticAberrationPostProcess;
  71051. private _chromaticAberrationEffect;
  71052. /**
  71053. * Grain post process which add noise to the image
  71054. */
  71055. grain: GrainPostProcess;
  71056. private _grainEffect;
  71057. /**
  71058. * Glow post process which adds a glow to emissive areas of the image
  71059. */
  71060. private _glowLayer;
  71061. /**
  71062. * Animations which can be used to tweak settings over a period of time
  71063. */
  71064. animations: Animation[];
  71065. private _imageProcessingConfigurationObserver;
  71066. private _sharpenEnabled;
  71067. private _bloomEnabled;
  71068. private _depthOfFieldEnabled;
  71069. private _depthOfFieldBlurLevel;
  71070. private _fxaaEnabled;
  71071. private _imageProcessingEnabled;
  71072. private _defaultPipelineTextureType;
  71073. private _bloomScale;
  71074. private _chromaticAberrationEnabled;
  71075. private _grainEnabled;
  71076. private _buildAllowed;
  71077. /**
  71078. * Gets active scene
  71079. */
  71080. get scene(): Scene;
  71081. /**
  71082. * Enable or disable the sharpen process from the pipeline
  71083. */
  71084. set sharpenEnabled(enabled: boolean);
  71085. get sharpenEnabled(): boolean;
  71086. private _resizeObserver;
  71087. private _hardwareScaleLevel;
  71088. private _bloomKernel;
  71089. /**
  71090. * Specifies the size of the bloom blur kernel, relative to the final output size
  71091. */
  71092. get bloomKernel(): number;
  71093. set bloomKernel(value: number);
  71094. /**
  71095. * Specifies the weight of the bloom in the final rendering
  71096. */
  71097. private _bloomWeight;
  71098. /**
  71099. * Specifies the luma threshold for the area that will be blurred by the bloom
  71100. */
  71101. private _bloomThreshold;
  71102. private _hdr;
  71103. /**
  71104. * The strength of the bloom.
  71105. */
  71106. set bloomWeight(value: number);
  71107. get bloomWeight(): number;
  71108. /**
  71109. * The strength of the bloom.
  71110. */
  71111. set bloomThreshold(value: number);
  71112. get bloomThreshold(): number;
  71113. /**
  71114. * The scale of the bloom, lower value will provide better performance.
  71115. */
  71116. set bloomScale(value: number);
  71117. get bloomScale(): number;
  71118. /**
  71119. * Enable or disable the bloom from the pipeline
  71120. */
  71121. set bloomEnabled(enabled: boolean);
  71122. get bloomEnabled(): boolean;
  71123. private _rebuildBloom;
  71124. /**
  71125. * If the depth of field is enabled.
  71126. */
  71127. get depthOfFieldEnabled(): boolean;
  71128. set depthOfFieldEnabled(enabled: boolean);
  71129. /**
  71130. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71131. */
  71132. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71133. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71134. /**
  71135. * If the anti aliasing is enabled.
  71136. */
  71137. set fxaaEnabled(enabled: boolean);
  71138. get fxaaEnabled(): boolean;
  71139. private _samples;
  71140. /**
  71141. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71142. */
  71143. set samples(sampleCount: number);
  71144. get samples(): number;
  71145. /**
  71146. * If image processing is enabled.
  71147. */
  71148. set imageProcessingEnabled(enabled: boolean);
  71149. get imageProcessingEnabled(): boolean;
  71150. /**
  71151. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71152. */
  71153. set glowLayerEnabled(enabled: boolean);
  71154. get glowLayerEnabled(): boolean;
  71155. /**
  71156. * Gets the glow layer (or null if not defined)
  71157. */
  71158. get glowLayer(): Nullable<GlowLayer>;
  71159. /**
  71160. * Enable or disable the chromaticAberration process from the pipeline
  71161. */
  71162. set chromaticAberrationEnabled(enabled: boolean);
  71163. get chromaticAberrationEnabled(): boolean;
  71164. /**
  71165. * Enable or disable the grain process from the pipeline
  71166. */
  71167. set grainEnabled(enabled: boolean);
  71168. get grainEnabled(): boolean;
  71169. /**
  71170. * @constructor
  71171. * @param name - The rendering pipeline name (default: "")
  71172. * @param hdr - If high dynamic range textures should be used (default: true)
  71173. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71174. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71175. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71176. */
  71177. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71178. /**
  71179. * Get the class name
  71180. * @returns "DefaultRenderingPipeline"
  71181. */
  71182. getClassName(): string;
  71183. /**
  71184. * Force the compilation of the entire pipeline.
  71185. */
  71186. prepare(): void;
  71187. private _hasCleared;
  71188. private _prevPostProcess;
  71189. private _prevPrevPostProcess;
  71190. private _setAutoClearAndTextureSharing;
  71191. private _depthOfFieldSceneObserver;
  71192. private _buildPipeline;
  71193. private _disposePostProcesses;
  71194. /**
  71195. * Adds a camera to the pipeline
  71196. * @param camera the camera to be added
  71197. */
  71198. addCamera(camera: Camera): void;
  71199. /**
  71200. * Removes a camera from the pipeline
  71201. * @param camera the camera to remove
  71202. */
  71203. removeCamera(camera: Camera): void;
  71204. /**
  71205. * Dispose of the pipeline and stop all post processes
  71206. */
  71207. dispose(): void;
  71208. /**
  71209. * Serialize the rendering pipeline (Used when exporting)
  71210. * @returns the serialized object
  71211. */
  71212. serialize(): any;
  71213. /**
  71214. * Parse the serialized pipeline
  71215. * @param source Source pipeline.
  71216. * @param scene The scene to load the pipeline to.
  71217. * @param rootUrl The URL of the serialized pipeline.
  71218. * @returns An instantiated pipeline from the serialized object.
  71219. */
  71220. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71221. }
  71222. }
  71223. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71224. /** @hidden */
  71225. export var lensHighlightsPixelShader: {
  71226. name: string;
  71227. shader: string;
  71228. };
  71229. }
  71230. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71231. /** @hidden */
  71232. export var depthOfFieldPixelShader: {
  71233. name: string;
  71234. shader: string;
  71235. };
  71236. }
  71237. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71238. import { Camera } from "babylonjs/Cameras/camera";
  71239. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71240. import { Scene } from "babylonjs/scene";
  71241. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71242. import "babylonjs/Shaders/chromaticAberration.fragment";
  71243. import "babylonjs/Shaders/lensHighlights.fragment";
  71244. import "babylonjs/Shaders/depthOfField.fragment";
  71245. /**
  71246. * BABYLON.JS Chromatic Aberration GLSL Shader
  71247. * Author: Olivier Guyot
  71248. * Separates very slightly R, G and B colors on the edges of the screen
  71249. * Inspired by Francois Tarlier & Martins Upitis
  71250. */
  71251. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71252. /**
  71253. * @ignore
  71254. * The chromatic aberration PostProcess id in the pipeline
  71255. */
  71256. LensChromaticAberrationEffect: string;
  71257. /**
  71258. * @ignore
  71259. * The highlights enhancing PostProcess id in the pipeline
  71260. */
  71261. HighlightsEnhancingEffect: string;
  71262. /**
  71263. * @ignore
  71264. * The depth-of-field PostProcess id in the pipeline
  71265. */
  71266. LensDepthOfFieldEffect: string;
  71267. private _scene;
  71268. private _depthTexture;
  71269. private _grainTexture;
  71270. private _chromaticAberrationPostProcess;
  71271. private _highlightsPostProcess;
  71272. private _depthOfFieldPostProcess;
  71273. private _edgeBlur;
  71274. private _grainAmount;
  71275. private _chromaticAberration;
  71276. private _distortion;
  71277. private _highlightsGain;
  71278. private _highlightsThreshold;
  71279. private _dofDistance;
  71280. private _dofAperture;
  71281. private _dofDarken;
  71282. private _dofPentagon;
  71283. private _blurNoise;
  71284. /**
  71285. * @constructor
  71286. *
  71287. * Effect parameters are as follow:
  71288. * {
  71289. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71290. * edge_blur: number; // from 0 to x (1 for realism)
  71291. * distortion: number; // from 0 to x (1 for realism)
  71292. * grain_amount: number; // from 0 to 1
  71293. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71294. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71295. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71296. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71297. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71298. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71299. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71300. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71301. * }
  71302. * Note: if an effect parameter is unset, effect is disabled
  71303. *
  71304. * @param name The rendering pipeline name
  71305. * @param parameters - An object containing all parameters (see above)
  71306. * @param scene The scene linked to this pipeline
  71307. * @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)
  71308. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71309. */
  71310. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71311. /**
  71312. * Get the class name
  71313. * @returns "LensRenderingPipeline"
  71314. */
  71315. getClassName(): string;
  71316. /**
  71317. * Gets associated scene
  71318. */
  71319. get scene(): Scene;
  71320. /**
  71321. * Gets or sets the edge blur
  71322. */
  71323. get edgeBlur(): number;
  71324. set edgeBlur(value: number);
  71325. /**
  71326. * Gets or sets the grain amount
  71327. */
  71328. get grainAmount(): number;
  71329. set grainAmount(value: number);
  71330. /**
  71331. * Gets or sets the chromatic aberration amount
  71332. */
  71333. get chromaticAberration(): number;
  71334. set chromaticAberration(value: number);
  71335. /**
  71336. * Gets or sets the depth of field aperture
  71337. */
  71338. get dofAperture(): number;
  71339. set dofAperture(value: number);
  71340. /**
  71341. * Gets or sets the edge distortion
  71342. */
  71343. get edgeDistortion(): number;
  71344. set edgeDistortion(value: number);
  71345. /**
  71346. * Gets or sets the depth of field distortion
  71347. */
  71348. get dofDistortion(): number;
  71349. set dofDistortion(value: number);
  71350. /**
  71351. * Gets or sets the darken out of focus amount
  71352. */
  71353. get darkenOutOfFocus(): number;
  71354. set darkenOutOfFocus(value: number);
  71355. /**
  71356. * Gets or sets a boolean indicating if blur noise is enabled
  71357. */
  71358. get blurNoise(): boolean;
  71359. set blurNoise(value: boolean);
  71360. /**
  71361. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71362. */
  71363. get pentagonBokeh(): boolean;
  71364. set pentagonBokeh(value: boolean);
  71365. /**
  71366. * Gets or sets the highlight grain amount
  71367. */
  71368. get highlightsGain(): number;
  71369. set highlightsGain(value: number);
  71370. /**
  71371. * Gets or sets the highlight threshold
  71372. */
  71373. get highlightsThreshold(): number;
  71374. set highlightsThreshold(value: number);
  71375. /**
  71376. * Sets the amount of blur at the edges
  71377. * @param amount blur amount
  71378. */
  71379. setEdgeBlur(amount: number): void;
  71380. /**
  71381. * Sets edge blur to 0
  71382. */
  71383. disableEdgeBlur(): void;
  71384. /**
  71385. * Sets the amout of grain
  71386. * @param amount Amount of grain
  71387. */
  71388. setGrainAmount(amount: number): void;
  71389. /**
  71390. * Set grain amount to 0
  71391. */
  71392. disableGrain(): void;
  71393. /**
  71394. * Sets the chromatic aberration amount
  71395. * @param amount amount of chromatic aberration
  71396. */
  71397. setChromaticAberration(amount: number): void;
  71398. /**
  71399. * Sets chromatic aberration amount to 0
  71400. */
  71401. disableChromaticAberration(): void;
  71402. /**
  71403. * Sets the EdgeDistortion amount
  71404. * @param amount amount of EdgeDistortion
  71405. */
  71406. setEdgeDistortion(amount: number): void;
  71407. /**
  71408. * Sets edge distortion to 0
  71409. */
  71410. disableEdgeDistortion(): void;
  71411. /**
  71412. * Sets the FocusDistance amount
  71413. * @param amount amount of FocusDistance
  71414. */
  71415. setFocusDistance(amount: number): void;
  71416. /**
  71417. * Disables depth of field
  71418. */
  71419. disableDepthOfField(): void;
  71420. /**
  71421. * Sets the Aperture amount
  71422. * @param amount amount of Aperture
  71423. */
  71424. setAperture(amount: number): void;
  71425. /**
  71426. * Sets the DarkenOutOfFocus amount
  71427. * @param amount amount of DarkenOutOfFocus
  71428. */
  71429. setDarkenOutOfFocus(amount: number): void;
  71430. private _pentagonBokehIsEnabled;
  71431. /**
  71432. * Creates a pentagon bokeh effect
  71433. */
  71434. enablePentagonBokeh(): void;
  71435. /**
  71436. * Disables the pentagon bokeh effect
  71437. */
  71438. disablePentagonBokeh(): void;
  71439. /**
  71440. * Enables noise blur
  71441. */
  71442. enableNoiseBlur(): void;
  71443. /**
  71444. * Disables noise blur
  71445. */
  71446. disableNoiseBlur(): void;
  71447. /**
  71448. * Sets the HighlightsGain amount
  71449. * @param amount amount of HighlightsGain
  71450. */
  71451. setHighlightsGain(amount: number): void;
  71452. /**
  71453. * Sets the HighlightsThreshold amount
  71454. * @param amount amount of HighlightsThreshold
  71455. */
  71456. setHighlightsThreshold(amount: number): void;
  71457. /**
  71458. * Disables highlights
  71459. */
  71460. disableHighlights(): void;
  71461. /**
  71462. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71463. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71464. */
  71465. dispose(disableDepthRender?: boolean): void;
  71466. private _createChromaticAberrationPostProcess;
  71467. private _createHighlightsPostProcess;
  71468. private _createDepthOfFieldPostProcess;
  71469. private _createGrainTexture;
  71470. }
  71471. }
  71472. declare module "babylonjs/Shaders/ssao2.fragment" {
  71473. /** @hidden */
  71474. export var ssao2PixelShader: {
  71475. name: string;
  71476. shader: string;
  71477. };
  71478. }
  71479. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71480. /** @hidden */
  71481. export var ssaoCombinePixelShader: {
  71482. name: string;
  71483. shader: string;
  71484. };
  71485. }
  71486. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71487. import { Camera } from "babylonjs/Cameras/camera";
  71488. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71489. import { Scene } from "babylonjs/scene";
  71490. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71491. import "babylonjs/Shaders/ssao2.fragment";
  71492. import "babylonjs/Shaders/ssaoCombine.fragment";
  71493. /**
  71494. * Render pipeline to produce ssao effect
  71495. */
  71496. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71497. /**
  71498. * @ignore
  71499. * The PassPostProcess id in the pipeline that contains the original scene color
  71500. */
  71501. SSAOOriginalSceneColorEffect: string;
  71502. /**
  71503. * @ignore
  71504. * The SSAO PostProcess id in the pipeline
  71505. */
  71506. SSAORenderEffect: string;
  71507. /**
  71508. * @ignore
  71509. * The horizontal blur PostProcess id in the pipeline
  71510. */
  71511. SSAOBlurHRenderEffect: string;
  71512. /**
  71513. * @ignore
  71514. * The vertical blur PostProcess id in the pipeline
  71515. */
  71516. SSAOBlurVRenderEffect: string;
  71517. /**
  71518. * @ignore
  71519. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71520. */
  71521. SSAOCombineRenderEffect: string;
  71522. /**
  71523. * The output strength of the SSAO post-process. Default value is 1.0.
  71524. */
  71525. totalStrength: number;
  71526. /**
  71527. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71528. */
  71529. maxZ: number;
  71530. /**
  71531. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71532. */
  71533. minZAspect: number;
  71534. private _samples;
  71535. /**
  71536. * Number of samples used for the SSAO calculations. Default value is 8
  71537. */
  71538. set samples(n: number);
  71539. get samples(): number;
  71540. private _textureSamples;
  71541. /**
  71542. * Number of samples to use for antialiasing
  71543. */
  71544. set textureSamples(n: number);
  71545. get textureSamples(): number;
  71546. /**
  71547. * Ratio object used for SSAO ratio and blur ratio
  71548. */
  71549. private _ratio;
  71550. /**
  71551. * Dynamically generated sphere sampler.
  71552. */
  71553. private _sampleSphere;
  71554. /**
  71555. * Blur filter offsets
  71556. */
  71557. private _samplerOffsets;
  71558. private _expensiveBlur;
  71559. /**
  71560. * If bilateral blur should be used
  71561. */
  71562. set expensiveBlur(b: boolean);
  71563. get expensiveBlur(): boolean;
  71564. /**
  71565. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71566. */
  71567. radius: number;
  71568. /**
  71569. * The base color of the SSAO post-process
  71570. * The final result is "base + ssao" between [0, 1]
  71571. */
  71572. base: number;
  71573. /**
  71574. * Support test.
  71575. */
  71576. static get IsSupported(): boolean;
  71577. private _scene;
  71578. private _depthTexture;
  71579. private _normalTexture;
  71580. private _randomTexture;
  71581. private _originalColorPostProcess;
  71582. private _ssaoPostProcess;
  71583. private _blurHPostProcess;
  71584. private _blurVPostProcess;
  71585. private _ssaoCombinePostProcess;
  71586. /**
  71587. * Gets active scene
  71588. */
  71589. get scene(): Scene;
  71590. /**
  71591. * @constructor
  71592. * @param name The rendering pipeline name
  71593. * @param scene The scene linked to this pipeline
  71594. * @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 }
  71595. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71596. */
  71597. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71598. /**
  71599. * Get the class name
  71600. * @returns "SSAO2RenderingPipeline"
  71601. */
  71602. getClassName(): string;
  71603. /**
  71604. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71605. */
  71606. dispose(disableGeometryBufferRenderer?: boolean): void;
  71607. private _createBlurPostProcess;
  71608. /** @hidden */
  71609. _rebuild(): void;
  71610. private _bits;
  71611. private _radicalInverse_VdC;
  71612. private _hammersley;
  71613. private _hemisphereSample_uniform;
  71614. private _generateHemisphere;
  71615. private _createSSAOPostProcess;
  71616. private _createSSAOCombinePostProcess;
  71617. private _createRandomTexture;
  71618. /**
  71619. * Serialize the rendering pipeline (Used when exporting)
  71620. * @returns the serialized object
  71621. */
  71622. serialize(): any;
  71623. /**
  71624. * Parse the serialized pipeline
  71625. * @param source Source pipeline.
  71626. * @param scene The scene to load the pipeline to.
  71627. * @param rootUrl The URL of the serialized pipeline.
  71628. * @returns An instantiated pipeline from the serialized object.
  71629. */
  71630. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71631. }
  71632. }
  71633. declare module "babylonjs/Shaders/ssao.fragment" {
  71634. /** @hidden */
  71635. export var ssaoPixelShader: {
  71636. name: string;
  71637. shader: string;
  71638. };
  71639. }
  71640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71641. import { Camera } from "babylonjs/Cameras/camera";
  71642. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71643. import { Scene } from "babylonjs/scene";
  71644. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71645. import "babylonjs/Shaders/ssao.fragment";
  71646. import "babylonjs/Shaders/ssaoCombine.fragment";
  71647. /**
  71648. * Render pipeline to produce ssao effect
  71649. */
  71650. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71651. /**
  71652. * @ignore
  71653. * The PassPostProcess id in the pipeline that contains the original scene color
  71654. */
  71655. SSAOOriginalSceneColorEffect: string;
  71656. /**
  71657. * @ignore
  71658. * The SSAO PostProcess id in the pipeline
  71659. */
  71660. SSAORenderEffect: string;
  71661. /**
  71662. * @ignore
  71663. * The horizontal blur PostProcess id in the pipeline
  71664. */
  71665. SSAOBlurHRenderEffect: string;
  71666. /**
  71667. * @ignore
  71668. * The vertical blur PostProcess id in the pipeline
  71669. */
  71670. SSAOBlurVRenderEffect: string;
  71671. /**
  71672. * @ignore
  71673. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71674. */
  71675. SSAOCombineRenderEffect: string;
  71676. /**
  71677. * The output strength of the SSAO post-process. Default value is 1.0.
  71678. */
  71679. totalStrength: number;
  71680. /**
  71681. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71682. */
  71683. radius: number;
  71684. /**
  71685. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71686. * Must not be equal to fallOff and superior to fallOff.
  71687. * Default value is 0.0075
  71688. */
  71689. area: number;
  71690. /**
  71691. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71692. * Must not be equal to area and inferior to area.
  71693. * Default value is 0.000001
  71694. */
  71695. fallOff: number;
  71696. /**
  71697. * The base color of the SSAO post-process
  71698. * The final result is "base + ssao" between [0, 1]
  71699. */
  71700. base: number;
  71701. private _scene;
  71702. private _depthTexture;
  71703. private _randomTexture;
  71704. private _originalColorPostProcess;
  71705. private _ssaoPostProcess;
  71706. private _blurHPostProcess;
  71707. private _blurVPostProcess;
  71708. private _ssaoCombinePostProcess;
  71709. private _firstUpdate;
  71710. /**
  71711. * Gets active scene
  71712. */
  71713. get scene(): Scene;
  71714. /**
  71715. * @constructor
  71716. * @param name - The rendering pipeline name
  71717. * @param scene - The scene linked to this pipeline
  71718. * @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 }
  71719. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71720. */
  71721. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71722. /**
  71723. * Get the class name
  71724. * @returns "SSAORenderingPipeline"
  71725. */
  71726. getClassName(): string;
  71727. /**
  71728. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71729. */
  71730. dispose(disableDepthRender?: boolean): void;
  71731. private _createBlurPostProcess;
  71732. /** @hidden */
  71733. _rebuild(): void;
  71734. private _createSSAOPostProcess;
  71735. private _createSSAOCombinePostProcess;
  71736. private _createRandomTexture;
  71737. }
  71738. }
  71739. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71740. /** @hidden */
  71741. export var screenSpaceReflectionPixelShader: {
  71742. name: string;
  71743. shader: string;
  71744. };
  71745. }
  71746. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71747. import { Nullable } from "babylonjs/types";
  71748. import { Camera } from "babylonjs/Cameras/camera";
  71749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71750. import { Scene } from "babylonjs/scene";
  71751. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71752. import { Engine } from "babylonjs/Engines/engine";
  71753. /**
  71754. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71755. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71756. */
  71757. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71758. /**
  71759. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71760. */
  71761. threshold: number;
  71762. /**
  71763. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71764. */
  71765. strength: number;
  71766. /**
  71767. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71768. */
  71769. reflectionSpecularFalloffExponent: number;
  71770. /**
  71771. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  71772. */
  71773. step: number;
  71774. /**
  71775. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71776. */
  71777. roughnessFactor: number;
  71778. private _geometryBufferRenderer;
  71779. private _enableSmoothReflections;
  71780. private _reflectionSamples;
  71781. private _smoothSteps;
  71782. /**
  71783. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71784. * @param name The name of the effect.
  71785. * @param scene The scene containing the objects to calculate reflections.
  71786. * @param options The required width/height ratio to downsize to before computing the render pass.
  71787. * @param camera The camera to apply the render pass to.
  71788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71789. * @param engine The engine which the post process will be applied. (default: current engine)
  71790. * @param reusable If the post process can be reused on the same frame. (default: false)
  71791. * @param textureType Type of textures used when performing the post process. (default: 0)
  71792. * @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)
  71793. */
  71794. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71795. /**
  71796. * Gets wether or not smoothing reflections is enabled.
  71797. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71798. */
  71799. get enableSmoothReflections(): boolean;
  71800. /**
  71801. * Sets wether or not smoothing reflections is enabled.
  71802. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71803. */
  71804. set enableSmoothReflections(enabled: boolean);
  71805. /**
  71806. * Gets the number of samples taken while computing reflections. More samples count is high,
  71807. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71808. */
  71809. get reflectionSamples(): number;
  71810. /**
  71811. * Sets the number of samples taken while computing reflections. More samples count is high,
  71812. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71813. */
  71814. set reflectionSamples(samples: number);
  71815. /**
  71816. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71817. * more the post-process will require GPU power and can generate a drop in FPS.
  71818. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71819. */
  71820. get smoothSteps(): number;
  71821. set smoothSteps(steps: number);
  71822. private _updateEffectDefines;
  71823. }
  71824. }
  71825. declare module "babylonjs/Shaders/standard.fragment" {
  71826. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71827. /** @hidden */
  71828. export var standardPixelShader: {
  71829. name: string;
  71830. shader: string;
  71831. };
  71832. }
  71833. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71834. import { Nullable } from "babylonjs/types";
  71835. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71836. import { Camera } from "babylonjs/Cameras/camera";
  71837. import { Texture } from "babylonjs/Materials/Textures/texture";
  71838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71839. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71840. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71841. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71842. import { IDisposable } from "babylonjs/scene";
  71843. import { SpotLight } from "babylonjs/Lights/spotLight";
  71844. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71845. import { Scene } from "babylonjs/scene";
  71846. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71847. import { Animation } from "babylonjs/Animations/animation";
  71848. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71849. import "babylonjs/Shaders/standard.fragment";
  71850. /**
  71851. * Standard rendering pipeline
  71852. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71853. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71854. */
  71855. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71856. /**
  71857. * Public members
  71858. */
  71859. /**
  71860. * Post-process which contains the original scene color before the pipeline applies all the effects
  71861. */
  71862. originalPostProcess: Nullable<PostProcess>;
  71863. /**
  71864. * Post-process used to down scale an image x4
  71865. */
  71866. downSampleX4PostProcess: Nullable<PostProcess>;
  71867. /**
  71868. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71869. */
  71870. brightPassPostProcess: Nullable<PostProcess>;
  71871. /**
  71872. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71873. */
  71874. blurHPostProcesses: PostProcess[];
  71875. /**
  71876. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71877. */
  71878. blurVPostProcesses: PostProcess[];
  71879. /**
  71880. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71881. */
  71882. textureAdderPostProcess: Nullable<PostProcess>;
  71883. /**
  71884. * Post-process used to create volumetric lighting effect
  71885. */
  71886. volumetricLightPostProcess: Nullable<PostProcess>;
  71887. /**
  71888. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71889. */
  71890. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71891. /**
  71892. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71893. */
  71894. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71895. /**
  71896. * Post-process used to merge the volumetric light effect and the real scene color
  71897. */
  71898. volumetricLightMergePostProces: Nullable<PostProcess>;
  71899. /**
  71900. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71901. */
  71902. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71903. /**
  71904. * Base post-process used to calculate the average luminance of the final image for HDR
  71905. */
  71906. luminancePostProcess: Nullable<PostProcess>;
  71907. /**
  71908. * Post-processes used to create down sample post-processes in order to get
  71909. * the average luminance of the final image for HDR
  71910. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71911. */
  71912. luminanceDownSamplePostProcesses: PostProcess[];
  71913. /**
  71914. * Post-process used to create a HDR effect (light adaptation)
  71915. */
  71916. hdrPostProcess: Nullable<PostProcess>;
  71917. /**
  71918. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71919. */
  71920. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71921. /**
  71922. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71923. */
  71924. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71925. /**
  71926. * Post-process used to merge the final HDR post-process and the real scene color
  71927. */
  71928. hdrFinalPostProcess: Nullable<PostProcess>;
  71929. /**
  71930. * Post-process used to create a lens flare effect
  71931. */
  71932. lensFlarePostProcess: Nullable<PostProcess>;
  71933. /**
  71934. * Post-process that merges the result of the lens flare post-process and the real scene color
  71935. */
  71936. lensFlareComposePostProcess: Nullable<PostProcess>;
  71937. /**
  71938. * Post-process used to create a motion blur effect
  71939. */
  71940. motionBlurPostProcess: Nullable<PostProcess>;
  71941. /**
  71942. * Post-process used to create a depth of field effect
  71943. */
  71944. depthOfFieldPostProcess: Nullable<PostProcess>;
  71945. /**
  71946. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71947. */
  71948. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71949. /**
  71950. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71951. */
  71952. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71953. /**
  71954. * Represents the brightness threshold in order to configure the illuminated surfaces
  71955. */
  71956. brightThreshold: number;
  71957. /**
  71958. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71959. */
  71960. blurWidth: number;
  71961. /**
  71962. * Sets if the blur for highlighted surfaces must be only horizontal
  71963. */
  71964. horizontalBlur: boolean;
  71965. /**
  71966. * Gets the overall exposure used by the pipeline
  71967. */
  71968. get exposure(): number;
  71969. /**
  71970. * Sets the overall exposure used by the pipeline
  71971. */
  71972. set exposure(value: number);
  71973. /**
  71974. * Texture used typically to simulate "dirty" on camera lens
  71975. */
  71976. lensTexture: Nullable<Texture>;
  71977. /**
  71978. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71979. */
  71980. volumetricLightCoefficient: number;
  71981. /**
  71982. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71983. */
  71984. volumetricLightPower: number;
  71985. /**
  71986. * Used the set the blur intensity to smooth the volumetric lights
  71987. */
  71988. volumetricLightBlurScale: number;
  71989. /**
  71990. * Light (spot or directional) used to generate the volumetric lights rays
  71991. * The source light must have a shadow generate so the pipeline can get its
  71992. * depth map
  71993. */
  71994. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71995. /**
  71996. * For eye adaptation, represents the minimum luminance the eye can see
  71997. */
  71998. hdrMinimumLuminance: number;
  71999. /**
  72000. * For eye adaptation, represents the decrease luminance speed
  72001. */
  72002. hdrDecreaseRate: number;
  72003. /**
  72004. * For eye adaptation, represents the increase luminance speed
  72005. */
  72006. hdrIncreaseRate: number;
  72007. /**
  72008. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72009. */
  72010. get hdrAutoExposure(): boolean;
  72011. /**
  72012. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72013. */
  72014. set hdrAutoExposure(value: boolean);
  72015. /**
  72016. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72017. */
  72018. lensColorTexture: Nullable<Texture>;
  72019. /**
  72020. * The overall strengh for the lens flare effect
  72021. */
  72022. lensFlareStrength: number;
  72023. /**
  72024. * Dispersion coefficient for lens flare ghosts
  72025. */
  72026. lensFlareGhostDispersal: number;
  72027. /**
  72028. * Main lens flare halo width
  72029. */
  72030. lensFlareHaloWidth: number;
  72031. /**
  72032. * Based on the lens distortion effect, defines how much the lens flare result
  72033. * is distorted
  72034. */
  72035. lensFlareDistortionStrength: number;
  72036. /**
  72037. * Configures the blur intensity used for for lens flare (halo)
  72038. */
  72039. lensFlareBlurWidth: number;
  72040. /**
  72041. * Lens star texture must be used to simulate rays on the flares and is available
  72042. * in the documentation
  72043. */
  72044. lensStarTexture: Nullable<Texture>;
  72045. /**
  72046. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72047. * flare effect by taking account of the dirt texture
  72048. */
  72049. lensFlareDirtTexture: Nullable<Texture>;
  72050. /**
  72051. * Represents the focal length for the depth of field effect
  72052. */
  72053. depthOfFieldDistance: number;
  72054. /**
  72055. * Represents the blur intensity for the blurred part of the depth of field effect
  72056. */
  72057. depthOfFieldBlurWidth: number;
  72058. /**
  72059. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72060. */
  72061. get motionStrength(): number;
  72062. /**
  72063. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72064. */
  72065. set motionStrength(strength: number);
  72066. /**
  72067. * Gets wether or not the motion blur post-process is object based or screen based.
  72068. */
  72069. get objectBasedMotionBlur(): boolean;
  72070. /**
  72071. * Sets wether or not the motion blur post-process should be object based or screen based
  72072. */
  72073. set objectBasedMotionBlur(value: boolean);
  72074. /**
  72075. * List of animations for the pipeline (IAnimatable implementation)
  72076. */
  72077. animations: Animation[];
  72078. /**
  72079. * Private members
  72080. */
  72081. private _scene;
  72082. private _currentDepthOfFieldSource;
  72083. private _basePostProcess;
  72084. private _fixedExposure;
  72085. private _currentExposure;
  72086. private _hdrAutoExposure;
  72087. private _hdrCurrentLuminance;
  72088. private _motionStrength;
  72089. private _isObjectBasedMotionBlur;
  72090. private _floatTextureType;
  72091. private _camerasToBeAttached;
  72092. private _ratio;
  72093. private _bloomEnabled;
  72094. private _depthOfFieldEnabled;
  72095. private _vlsEnabled;
  72096. private _lensFlareEnabled;
  72097. private _hdrEnabled;
  72098. private _motionBlurEnabled;
  72099. private _fxaaEnabled;
  72100. private _screenSpaceReflectionsEnabled;
  72101. private _motionBlurSamples;
  72102. private _volumetricLightStepsCount;
  72103. private _samples;
  72104. /**
  72105. * @ignore
  72106. * Specifies if the bloom pipeline is enabled
  72107. */
  72108. get BloomEnabled(): boolean;
  72109. set BloomEnabled(enabled: boolean);
  72110. /**
  72111. * @ignore
  72112. * Specifies if the depth of field pipeline is enabed
  72113. */
  72114. get DepthOfFieldEnabled(): boolean;
  72115. set DepthOfFieldEnabled(enabled: boolean);
  72116. /**
  72117. * @ignore
  72118. * Specifies if the lens flare pipeline is enabed
  72119. */
  72120. get LensFlareEnabled(): boolean;
  72121. set LensFlareEnabled(enabled: boolean);
  72122. /**
  72123. * @ignore
  72124. * Specifies if the HDR pipeline is enabled
  72125. */
  72126. get HDREnabled(): boolean;
  72127. set HDREnabled(enabled: boolean);
  72128. /**
  72129. * @ignore
  72130. * Specifies if the volumetric lights scattering effect is enabled
  72131. */
  72132. get VLSEnabled(): boolean;
  72133. set VLSEnabled(enabled: boolean);
  72134. /**
  72135. * @ignore
  72136. * Specifies if the motion blur effect is enabled
  72137. */
  72138. get MotionBlurEnabled(): boolean;
  72139. set MotionBlurEnabled(enabled: boolean);
  72140. /**
  72141. * Specifies if anti-aliasing is enabled
  72142. */
  72143. get fxaaEnabled(): boolean;
  72144. set fxaaEnabled(enabled: boolean);
  72145. /**
  72146. * Specifies if screen space reflections are enabled.
  72147. */
  72148. get screenSpaceReflectionsEnabled(): boolean;
  72149. set screenSpaceReflectionsEnabled(enabled: boolean);
  72150. /**
  72151. * Specifies the number of steps used to calculate the volumetric lights
  72152. * Typically in interval [50, 200]
  72153. */
  72154. get volumetricLightStepsCount(): number;
  72155. set volumetricLightStepsCount(count: number);
  72156. /**
  72157. * Specifies the number of samples used for the motion blur effect
  72158. * Typically in interval [16, 64]
  72159. */
  72160. get motionBlurSamples(): number;
  72161. set motionBlurSamples(samples: number);
  72162. /**
  72163. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72164. */
  72165. get samples(): number;
  72166. set samples(sampleCount: number);
  72167. /**
  72168. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72169. * @constructor
  72170. * @param name The rendering pipeline name
  72171. * @param scene The scene linked to this pipeline
  72172. * @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)
  72173. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72174. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72175. */
  72176. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72177. private _buildPipeline;
  72178. private _createDownSampleX4PostProcess;
  72179. private _createBrightPassPostProcess;
  72180. private _createBlurPostProcesses;
  72181. private _createTextureAdderPostProcess;
  72182. private _createVolumetricLightPostProcess;
  72183. private _createLuminancePostProcesses;
  72184. private _createHdrPostProcess;
  72185. private _createLensFlarePostProcess;
  72186. private _createDepthOfFieldPostProcess;
  72187. private _createMotionBlurPostProcess;
  72188. private _getDepthTexture;
  72189. private _disposePostProcesses;
  72190. /**
  72191. * Dispose of the pipeline and stop all post processes
  72192. */
  72193. dispose(): void;
  72194. /**
  72195. * Serialize the rendering pipeline (Used when exporting)
  72196. * @returns the serialized object
  72197. */
  72198. serialize(): any;
  72199. /**
  72200. * Parse the serialized pipeline
  72201. * @param source Source pipeline.
  72202. * @param scene The scene to load the pipeline to.
  72203. * @param rootUrl The URL of the serialized pipeline.
  72204. * @returns An instantiated pipeline from the serialized object.
  72205. */
  72206. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72207. /**
  72208. * Luminance steps
  72209. */
  72210. static LuminanceSteps: number;
  72211. }
  72212. }
  72213. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72214. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72215. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72216. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72217. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72218. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72219. }
  72220. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72221. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72222. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72223. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72224. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72225. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72226. }
  72227. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72228. /** @hidden */
  72229. export var stereoscopicInterlacePixelShader: {
  72230. name: string;
  72231. shader: string;
  72232. };
  72233. }
  72234. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72235. import { Camera } from "babylonjs/Cameras/camera";
  72236. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72237. import { Engine } from "babylonjs/Engines/engine";
  72238. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72239. /**
  72240. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72241. */
  72242. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72243. private _stepSize;
  72244. private _passedProcess;
  72245. /**
  72246. * Initializes a StereoscopicInterlacePostProcessI
  72247. * @param name The name of the effect.
  72248. * @param rigCameras The rig cameras to be appled to the post process
  72249. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72250. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72252. * @param engine The engine which the post process will be applied. (default: current engine)
  72253. * @param reusable If the post process can be reused on the same frame. (default: false)
  72254. */
  72255. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72256. }
  72257. /**
  72258. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72259. */
  72260. export class StereoscopicInterlacePostProcess extends PostProcess {
  72261. private _stepSize;
  72262. private _passedProcess;
  72263. /**
  72264. * Initializes a StereoscopicInterlacePostProcess
  72265. * @param name The name of the effect.
  72266. * @param rigCameras The rig cameras to be appled to the post process
  72267. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72269. * @param engine The engine which the post process will be applied. (default: current engine)
  72270. * @param reusable If the post process can be reused on the same frame. (default: false)
  72271. */
  72272. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72273. }
  72274. }
  72275. declare module "babylonjs/Shaders/tonemap.fragment" {
  72276. /** @hidden */
  72277. export var tonemapPixelShader: {
  72278. name: string;
  72279. shader: string;
  72280. };
  72281. }
  72282. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72283. import { Camera } from "babylonjs/Cameras/camera";
  72284. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72285. import "babylonjs/Shaders/tonemap.fragment";
  72286. import { Engine } from "babylonjs/Engines/engine";
  72287. /** Defines operator used for tonemapping */
  72288. export enum TonemappingOperator {
  72289. /** Hable */
  72290. Hable = 0,
  72291. /** Reinhard */
  72292. Reinhard = 1,
  72293. /** HejiDawson */
  72294. HejiDawson = 2,
  72295. /** Photographic */
  72296. Photographic = 3
  72297. }
  72298. /**
  72299. * Defines a post process to apply tone mapping
  72300. */
  72301. export class TonemapPostProcess extends PostProcess {
  72302. private _operator;
  72303. /** Defines the required exposure adjustement */
  72304. exposureAdjustment: number;
  72305. /**
  72306. * Creates a new TonemapPostProcess
  72307. * @param name defines the name of the postprocess
  72308. * @param _operator defines the operator to use
  72309. * @param exposureAdjustment defines the required exposure adjustement
  72310. * @param camera defines the camera to use (can be null)
  72311. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72312. * @param engine defines the hosting engine (can be ignore if camera is set)
  72313. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72314. */
  72315. constructor(name: string, _operator: TonemappingOperator,
  72316. /** Defines the required exposure adjustement */
  72317. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72318. }
  72319. }
  72320. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72321. /** @hidden */
  72322. export var volumetricLightScatteringPixelShader: {
  72323. name: string;
  72324. shader: string;
  72325. };
  72326. }
  72327. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72328. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72331. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72332. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72333. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72334. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72335. /** @hidden */
  72336. export var volumetricLightScatteringPassVertexShader: {
  72337. name: string;
  72338. shader: string;
  72339. };
  72340. }
  72341. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72342. /** @hidden */
  72343. export var volumetricLightScatteringPassPixelShader: {
  72344. name: string;
  72345. shader: string;
  72346. };
  72347. }
  72348. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72349. import { Vector3 } from "babylonjs/Maths/math.vector";
  72350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72351. import { Mesh } from "babylonjs/Meshes/mesh";
  72352. import { Camera } from "babylonjs/Cameras/camera";
  72353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72354. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72355. import { Scene } from "babylonjs/scene";
  72356. import "babylonjs/Meshes/Builders/planeBuilder";
  72357. import "babylonjs/Shaders/depth.vertex";
  72358. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72359. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72360. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72361. import { Engine } from "babylonjs/Engines/engine";
  72362. /**
  72363. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72364. */
  72365. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72366. private _volumetricLightScatteringPass;
  72367. private _volumetricLightScatteringRTT;
  72368. private _viewPort;
  72369. private _screenCoordinates;
  72370. private _cachedDefines;
  72371. /**
  72372. * If not undefined, the mesh position is computed from the attached node position
  72373. */
  72374. attachedNode: {
  72375. position: Vector3;
  72376. };
  72377. /**
  72378. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72379. */
  72380. customMeshPosition: Vector3;
  72381. /**
  72382. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72383. */
  72384. useCustomMeshPosition: boolean;
  72385. /**
  72386. * If the post-process should inverse the light scattering direction
  72387. */
  72388. invert: boolean;
  72389. /**
  72390. * The internal mesh used by the post-process
  72391. */
  72392. mesh: Mesh;
  72393. /**
  72394. * @hidden
  72395. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72396. */
  72397. get useDiffuseColor(): boolean;
  72398. set useDiffuseColor(useDiffuseColor: boolean);
  72399. /**
  72400. * Array containing the excluded meshes not rendered in the internal pass
  72401. */
  72402. excludedMeshes: AbstractMesh[];
  72403. /**
  72404. * Controls the overall intensity of the post-process
  72405. */
  72406. exposure: number;
  72407. /**
  72408. * Dissipates each sample's contribution in range [0, 1]
  72409. */
  72410. decay: number;
  72411. /**
  72412. * Controls the overall intensity of each sample
  72413. */
  72414. weight: number;
  72415. /**
  72416. * Controls the density of each sample
  72417. */
  72418. density: number;
  72419. /**
  72420. * @constructor
  72421. * @param name The post-process name
  72422. * @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)
  72423. * @param camera The camera that the post-process will be attached to
  72424. * @param mesh The mesh used to create the light scattering
  72425. * @param samples The post-process quality, default 100
  72426. * @param samplingModeThe post-process filtering mode
  72427. * @param engine The babylon engine
  72428. * @param reusable If the post-process is reusable
  72429. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72430. */
  72431. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72432. /**
  72433. * Returns the string "VolumetricLightScatteringPostProcess"
  72434. * @returns "VolumetricLightScatteringPostProcess"
  72435. */
  72436. getClassName(): string;
  72437. private _isReady;
  72438. /**
  72439. * Sets the new light position for light scattering effect
  72440. * @param position The new custom light position
  72441. */
  72442. setCustomMeshPosition(position: Vector3): void;
  72443. /**
  72444. * Returns the light position for light scattering effect
  72445. * @return Vector3 The custom light position
  72446. */
  72447. getCustomMeshPosition(): Vector3;
  72448. /**
  72449. * Disposes the internal assets and detaches the post-process from the camera
  72450. */
  72451. dispose(camera: Camera): void;
  72452. /**
  72453. * Returns the render target texture used by the post-process
  72454. * @return the render target texture used by the post-process
  72455. */
  72456. getPass(): RenderTargetTexture;
  72457. private _meshExcluded;
  72458. private _createPass;
  72459. private _updateMeshScreenCoordinates;
  72460. /**
  72461. * Creates a default mesh for the Volumeric Light Scattering post-process
  72462. * @param name The mesh name
  72463. * @param scene The scene where to create the mesh
  72464. * @return the default mesh
  72465. */
  72466. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72467. }
  72468. }
  72469. declare module "babylonjs/PostProcesses/index" {
  72470. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72471. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72472. export * from "babylonjs/PostProcesses/bloomEffect";
  72473. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72474. export * from "babylonjs/PostProcesses/blurPostProcess";
  72475. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72476. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72477. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72478. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72479. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72480. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72481. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72482. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72483. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72484. export * from "babylonjs/PostProcesses/filterPostProcess";
  72485. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72486. export * from "babylonjs/PostProcesses/grainPostProcess";
  72487. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72488. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72489. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72490. export * from "babylonjs/PostProcesses/passPostProcess";
  72491. export * from "babylonjs/PostProcesses/postProcess";
  72492. export * from "babylonjs/PostProcesses/postProcessManager";
  72493. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72494. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72495. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72496. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72497. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72498. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72499. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72500. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72501. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72502. }
  72503. declare module "babylonjs/Probes/index" {
  72504. export * from "babylonjs/Probes/reflectionProbe";
  72505. }
  72506. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72507. import { Scene } from "babylonjs/scene";
  72508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72509. import { SmartArray } from "babylonjs/Misc/smartArray";
  72510. import { ISceneComponent } from "babylonjs/sceneComponent";
  72511. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72512. import "babylonjs/Meshes/Builders/boxBuilder";
  72513. import "babylonjs/Shaders/color.fragment";
  72514. import "babylonjs/Shaders/color.vertex";
  72515. import { Color3 } from "babylonjs/Maths/math.color";
  72516. module "babylonjs/scene" {
  72517. interface Scene {
  72518. /** @hidden (Backing field) */
  72519. _boundingBoxRenderer: BoundingBoxRenderer;
  72520. /** @hidden (Backing field) */
  72521. _forceShowBoundingBoxes: boolean;
  72522. /**
  72523. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72524. */
  72525. forceShowBoundingBoxes: boolean;
  72526. /**
  72527. * Gets the bounding box renderer associated with the scene
  72528. * @returns a BoundingBoxRenderer
  72529. */
  72530. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72531. }
  72532. }
  72533. module "babylonjs/Meshes/abstractMesh" {
  72534. interface AbstractMesh {
  72535. /** @hidden (Backing field) */
  72536. _showBoundingBox: boolean;
  72537. /**
  72538. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72539. */
  72540. showBoundingBox: boolean;
  72541. }
  72542. }
  72543. /**
  72544. * Component responsible of rendering the bounding box of the meshes in a scene.
  72545. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72546. */
  72547. export class BoundingBoxRenderer implements ISceneComponent {
  72548. /**
  72549. * The component name helpfull to identify the component in the list of scene components.
  72550. */
  72551. readonly name: string;
  72552. /**
  72553. * The scene the component belongs to.
  72554. */
  72555. scene: Scene;
  72556. /**
  72557. * Color of the bounding box lines placed in front of an object
  72558. */
  72559. frontColor: Color3;
  72560. /**
  72561. * Color of the bounding box lines placed behind an object
  72562. */
  72563. backColor: Color3;
  72564. /**
  72565. * Defines if the renderer should show the back lines or not
  72566. */
  72567. showBackLines: boolean;
  72568. /**
  72569. * @hidden
  72570. */
  72571. renderList: SmartArray<BoundingBox>;
  72572. private _colorShader;
  72573. private _vertexBuffers;
  72574. private _indexBuffer;
  72575. private _fillIndexBuffer;
  72576. private _fillIndexData;
  72577. /**
  72578. * Instantiates a new bounding box renderer in a scene.
  72579. * @param scene the scene the renderer renders in
  72580. */
  72581. constructor(scene: Scene);
  72582. /**
  72583. * Registers the component in a given scene
  72584. */
  72585. register(): void;
  72586. private _evaluateSubMesh;
  72587. private _activeMesh;
  72588. private _prepareRessources;
  72589. private _createIndexBuffer;
  72590. /**
  72591. * Rebuilds the elements related to this component in case of
  72592. * context lost for instance.
  72593. */
  72594. rebuild(): void;
  72595. /**
  72596. * @hidden
  72597. */
  72598. reset(): void;
  72599. /**
  72600. * Render the bounding boxes of a specific rendering group
  72601. * @param renderingGroupId defines the rendering group to render
  72602. */
  72603. render(renderingGroupId: number): void;
  72604. /**
  72605. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72606. * @param mesh Define the mesh to render the occlusion bounding box for
  72607. */
  72608. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72609. /**
  72610. * Dispose and release the resources attached to this renderer.
  72611. */
  72612. dispose(): void;
  72613. }
  72614. }
  72615. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72616. import { Nullable } from "babylonjs/types";
  72617. import { Scene } from "babylonjs/scene";
  72618. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72619. import { Camera } from "babylonjs/Cameras/camera";
  72620. import { ISceneComponent } from "babylonjs/sceneComponent";
  72621. module "babylonjs/scene" {
  72622. interface Scene {
  72623. /** @hidden (Backing field) */
  72624. _depthRenderer: {
  72625. [id: string]: DepthRenderer;
  72626. };
  72627. /**
  72628. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72629. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72630. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72631. * @returns the created depth renderer
  72632. */
  72633. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72634. /**
  72635. * Disables a depth renderer for a given camera
  72636. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72637. */
  72638. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72639. }
  72640. }
  72641. /**
  72642. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72643. * in several rendering techniques.
  72644. */
  72645. export class DepthRendererSceneComponent implements ISceneComponent {
  72646. /**
  72647. * The component name helpfull to identify the component in the list of scene components.
  72648. */
  72649. readonly name: string;
  72650. /**
  72651. * The scene the component belongs to.
  72652. */
  72653. scene: Scene;
  72654. /**
  72655. * Creates a new instance of the component for the given scene
  72656. * @param scene Defines the scene to register the component in
  72657. */
  72658. constructor(scene: Scene);
  72659. /**
  72660. * Registers the component in a given scene
  72661. */
  72662. register(): void;
  72663. /**
  72664. * Rebuilds the elements related to this component in case of
  72665. * context lost for instance.
  72666. */
  72667. rebuild(): void;
  72668. /**
  72669. * Disposes the component and the associated ressources
  72670. */
  72671. dispose(): void;
  72672. private _gatherRenderTargets;
  72673. private _gatherActiveCameraRenderTargets;
  72674. }
  72675. }
  72676. declare module "babylonjs/Shaders/outline.fragment" {
  72677. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72678. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72679. /** @hidden */
  72680. export var outlinePixelShader: {
  72681. name: string;
  72682. shader: string;
  72683. };
  72684. }
  72685. declare module "babylonjs/Shaders/outline.vertex" {
  72686. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72687. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72690. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72691. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72692. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72693. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72694. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72695. /** @hidden */
  72696. export var outlineVertexShader: {
  72697. name: string;
  72698. shader: string;
  72699. };
  72700. }
  72701. declare module "babylonjs/Rendering/outlineRenderer" {
  72702. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72703. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72704. import { Scene } from "babylonjs/scene";
  72705. import { ISceneComponent } from "babylonjs/sceneComponent";
  72706. import "babylonjs/Shaders/outline.fragment";
  72707. import "babylonjs/Shaders/outline.vertex";
  72708. module "babylonjs/scene" {
  72709. interface Scene {
  72710. /** @hidden */
  72711. _outlineRenderer: OutlineRenderer;
  72712. /**
  72713. * Gets the outline renderer associated with the scene
  72714. * @returns a OutlineRenderer
  72715. */
  72716. getOutlineRenderer(): OutlineRenderer;
  72717. }
  72718. }
  72719. module "babylonjs/Meshes/abstractMesh" {
  72720. interface AbstractMesh {
  72721. /** @hidden (Backing field) */
  72722. _renderOutline: boolean;
  72723. /**
  72724. * Gets or sets a boolean indicating if the outline must be rendered as well
  72725. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72726. */
  72727. renderOutline: boolean;
  72728. /** @hidden (Backing field) */
  72729. _renderOverlay: boolean;
  72730. /**
  72731. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72732. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72733. */
  72734. renderOverlay: boolean;
  72735. }
  72736. }
  72737. /**
  72738. * This class is responsible to draw bothe outline/overlay of meshes.
  72739. * It should not be used directly but through the available method on mesh.
  72740. */
  72741. export class OutlineRenderer implements ISceneComponent {
  72742. /**
  72743. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72744. */
  72745. private static _StencilReference;
  72746. /**
  72747. * The name of the component. Each component must have a unique name.
  72748. */
  72749. name: string;
  72750. /**
  72751. * The scene the component belongs to.
  72752. */
  72753. scene: Scene;
  72754. /**
  72755. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72756. */
  72757. zOffset: number;
  72758. private _engine;
  72759. private _effect;
  72760. private _cachedDefines;
  72761. private _savedDepthWrite;
  72762. /**
  72763. * Instantiates a new outline renderer. (There could be only one per scene).
  72764. * @param scene Defines the scene it belongs to
  72765. */
  72766. constructor(scene: Scene);
  72767. /**
  72768. * Register the component to one instance of a scene.
  72769. */
  72770. register(): void;
  72771. /**
  72772. * Rebuilds the elements related to this component in case of
  72773. * context lost for instance.
  72774. */
  72775. rebuild(): void;
  72776. /**
  72777. * Disposes the component and the associated ressources.
  72778. */
  72779. dispose(): void;
  72780. /**
  72781. * Renders the outline in the canvas.
  72782. * @param subMesh Defines the sumesh to render
  72783. * @param batch Defines the batch of meshes in case of instances
  72784. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72785. */
  72786. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72787. /**
  72788. * Returns whether or not the outline renderer is ready for a given submesh.
  72789. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72790. * @param subMesh Defines the submesh to check readyness for
  72791. * @param useInstances Defines wheter wee are trying to render instances or not
  72792. * @returns true if ready otherwise false
  72793. */
  72794. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72795. private _beforeRenderingMesh;
  72796. private _afterRenderingMesh;
  72797. }
  72798. }
  72799. declare module "babylonjs/Rendering/index" {
  72800. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72801. export * from "babylonjs/Rendering/depthRenderer";
  72802. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72803. export * from "babylonjs/Rendering/edgesRenderer";
  72804. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72805. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72806. export * from "babylonjs/Rendering/outlineRenderer";
  72807. export * from "babylonjs/Rendering/renderingGroup";
  72808. export * from "babylonjs/Rendering/renderingManager";
  72809. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72810. }
  72811. declare module "babylonjs/Sprites/ISprites" {
  72812. /**
  72813. * Defines the basic options interface of a Sprite Frame Source Size.
  72814. */
  72815. export interface ISpriteJSONSpriteSourceSize {
  72816. /**
  72817. * number of the original width of the Frame
  72818. */
  72819. w: number;
  72820. /**
  72821. * number of the original height of the Frame
  72822. */
  72823. h: number;
  72824. }
  72825. /**
  72826. * Defines the basic options interface of a Sprite Frame Data.
  72827. */
  72828. export interface ISpriteJSONSpriteFrameData {
  72829. /**
  72830. * number of the x offset of the Frame
  72831. */
  72832. x: number;
  72833. /**
  72834. * number of the y offset of the Frame
  72835. */
  72836. y: number;
  72837. /**
  72838. * number of the width of the Frame
  72839. */
  72840. w: number;
  72841. /**
  72842. * number of the height of the Frame
  72843. */
  72844. h: number;
  72845. }
  72846. /**
  72847. * Defines the basic options interface of a JSON Sprite.
  72848. */
  72849. export interface ISpriteJSONSprite {
  72850. /**
  72851. * string name of the Frame
  72852. */
  72853. filename: string;
  72854. /**
  72855. * ISpriteJSONSpriteFrame basic object of the frame data
  72856. */
  72857. frame: ISpriteJSONSpriteFrameData;
  72858. /**
  72859. * boolean to flag is the frame was rotated.
  72860. */
  72861. rotated: boolean;
  72862. /**
  72863. * boolean to flag is the frame was trimmed.
  72864. */
  72865. trimmed: boolean;
  72866. /**
  72867. * ISpriteJSONSpriteFrame basic object of the source data
  72868. */
  72869. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72870. /**
  72871. * ISpriteJSONSpriteFrame basic object of the source data
  72872. */
  72873. sourceSize: ISpriteJSONSpriteSourceSize;
  72874. }
  72875. /**
  72876. * Defines the basic options interface of a JSON atlas.
  72877. */
  72878. export interface ISpriteJSONAtlas {
  72879. /**
  72880. * Array of objects that contain the frame data.
  72881. */
  72882. frames: Array<ISpriteJSONSprite>;
  72883. /**
  72884. * object basic object containing the sprite meta data.
  72885. */
  72886. meta?: object;
  72887. }
  72888. }
  72889. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72890. /** @hidden */
  72891. export var spriteMapPixelShader: {
  72892. name: string;
  72893. shader: string;
  72894. };
  72895. }
  72896. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72897. /** @hidden */
  72898. export var spriteMapVertexShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module "babylonjs/Sprites/spriteMap" {
  72904. import { IDisposable, Scene } from "babylonjs/scene";
  72905. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72906. import { Texture } from "babylonjs/Materials/Textures/texture";
  72907. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72908. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72909. import "babylonjs/Meshes/Builders/planeBuilder";
  72910. import "babylonjs/Shaders/spriteMap.fragment";
  72911. import "babylonjs/Shaders/spriteMap.vertex";
  72912. /**
  72913. * Defines the basic options interface of a SpriteMap
  72914. */
  72915. export interface ISpriteMapOptions {
  72916. /**
  72917. * Vector2 of the number of cells in the grid.
  72918. */
  72919. stageSize?: Vector2;
  72920. /**
  72921. * Vector2 of the size of the output plane in World Units.
  72922. */
  72923. outputSize?: Vector2;
  72924. /**
  72925. * Vector3 of the position of the output plane in World Units.
  72926. */
  72927. outputPosition?: Vector3;
  72928. /**
  72929. * Vector3 of the rotation of the output plane.
  72930. */
  72931. outputRotation?: Vector3;
  72932. /**
  72933. * number of layers that the system will reserve in resources.
  72934. */
  72935. layerCount?: number;
  72936. /**
  72937. * number of max animation frames a single cell will reserve in resources.
  72938. */
  72939. maxAnimationFrames?: number;
  72940. /**
  72941. * number cell index of the base tile when the system compiles.
  72942. */
  72943. baseTile?: number;
  72944. /**
  72945. * boolean flip the sprite after its been repositioned by the framing data.
  72946. */
  72947. flipU?: boolean;
  72948. /**
  72949. * Vector3 scalar of the global RGB values of the SpriteMap.
  72950. */
  72951. colorMultiply?: Vector3;
  72952. }
  72953. /**
  72954. * Defines the IDisposable interface in order to be cleanable from resources.
  72955. */
  72956. export interface ISpriteMap extends IDisposable {
  72957. /**
  72958. * String name of the SpriteMap.
  72959. */
  72960. name: string;
  72961. /**
  72962. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72963. */
  72964. atlasJSON: ISpriteJSONAtlas;
  72965. /**
  72966. * Texture of the SpriteMap.
  72967. */
  72968. spriteSheet: Texture;
  72969. /**
  72970. * The parameters to initialize the SpriteMap with.
  72971. */
  72972. options: ISpriteMapOptions;
  72973. }
  72974. /**
  72975. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72976. */
  72977. export class SpriteMap implements ISpriteMap {
  72978. /** The Name of the spriteMap */
  72979. name: string;
  72980. /** The JSON file with the frame and meta data */
  72981. atlasJSON: ISpriteJSONAtlas;
  72982. /** The systems Sprite Sheet Texture */
  72983. spriteSheet: Texture;
  72984. /** Arguments passed with the Constructor */
  72985. options: ISpriteMapOptions;
  72986. /** Public Sprite Storage array, parsed from atlasJSON */
  72987. sprites: Array<ISpriteJSONSprite>;
  72988. /** Returns the Number of Sprites in the System */
  72989. get spriteCount(): number;
  72990. /** Returns the Position of Output Plane*/
  72991. get position(): Vector3;
  72992. /** Returns the Position of Output Plane*/
  72993. set position(v: Vector3);
  72994. /** Returns the Rotation of Output Plane*/
  72995. get rotation(): Vector3;
  72996. /** Returns the Rotation of Output Plane*/
  72997. set rotation(v: Vector3);
  72998. /** Sets the AnimationMap*/
  72999. get animationMap(): RawTexture;
  73000. /** Sets the AnimationMap*/
  73001. set animationMap(v: RawTexture);
  73002. /** Scene that the SpriteMap was created in */
  73003. private _scene;
  73004. /** Texture Buffer of Float32 that holds tile frame data*/
  73005. private _frameMap;
  73006. /** Texture Buffers of Float32 that holds tileMap data*/
  73007. private _tileMaps;
  73008. /** Texture Buffer of Float32 that holds Animation Data*/
  73009. private _animationMap;
  73010. /** Custom ShaderMaterial Central to the System*/
  73011. private _material;
  73012. /** Custom ShaderMaterial Central to the System*/
  73013. private _output;
  73014. /** Systems Time Ticker*/
  73015. private _time;
  73016. /**
  73017. * Creates a new SpriteMap
  73018. * @param name defines the SpriteMaps Name
  73019. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73020. * @param spriteSheet is the Texture that the Sprites are on.
  73021. * @param options a basic deployment configuration
  73022. * @param scene The Scene that the map is deployed on
  73023. */
  73024. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73025. /**
  73026. * Returns tileID location
  73027. * @returns Vector2 the cell position ID
  73028. */
  73029. getTileID(): Vector2;
  73030. /**
  73031. * Gets the UV location of the mouse over the SpriteMap.
  73032. * @returns Vector2 the UV position of the mouse interaction
  73033. */
  73034. getMousePosition(): Vector2;
  73035. /**
  73036. * Creates the "frame" texture Buffer
  73037. * -------------------------------------
  73038. * Structure of frames
  73039. * "filename": "Falling-Water-2.png",
  73040. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73041. * "rotated": true,
  73042. * "trimmed": true,
  73043. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73044. * "sourceSize": {"w":32,"h":32}
  73045. * @returns RawTexture of the frameMap
  73046. */
  73047. private _createFrameBuffer;
  73048. /**
  73049. * Creates the tileMap texture Buffer
  73050. * @param buffer normally and array of numbers, or a false to generate from scratch
  73051. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73052. * @returns RawTexture of the tileMap
  73053. */
  73054. private _createTileBuffer;
  73055. /**
  73056. * Modifies the data of the tileMaps
  73057. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73058. * @param pos is the iVector2 Coordinates of the Tile
  73059. * @param tile The SpriteIndex of the new Tile
  73060. */
  73061. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73062. /**
  73063. * Creates the animationMap texture Buffer
  73064. * @param buffer normally and array of numbers, or a false to generate from scratch
  73065. * @returns RawTexture of the animationMap
  73066. */
  73067. private _createTileAnimationBuffer;
  73068. /**
  73069. * Modifies the data of the animationMap
  73070. * @param cellID is the Index of the Sprite
  73071. * @param _frame is the target Animation frame
  73072. * @param toCell is the Target Index of the next frame of the animation
  73073. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73074. * @param speed is a global scalar of the time variable on the map.
  73075. */
  73076. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73077. /**
  73078. * Exports the .tilemaps file
  73079. */
  73080. saveTileMaps(): void;
  73081. /**
  73082. * Imports the .tilemaps file
  73083. * @param url of the .tilemaps file
  73084. */
  73085. loadTileMaps(url: string): void;
  73086. /**
  73087. * Release associated resources
  73088. */
  73089. dispose(): void;
  73090. }
  73091. }
  73092. declare module "babylonjs/Sprites/spritePackedManager" {
  73093. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  73094. import { Scene } from "babylonjs/scene";
  73095. /**
  73096. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73097. * @see http://doc.babylonjs.com/babylon101/sprites
  73098. */
  73099. export class SpritePackedManager extends SpriteManager {
  73100. /** defines the packed manager's name */
  73101. name: string;
  73102. /**
  73103. * Creates a new sprite manager from a packed sprite sheet
  73104. * @param name defines the manager's name
  73105. * @param imgUrl defines the sprite sheet url
  73106. * @param capacity defines the maximum allowed number of sprites
  73107. * @param scene defines the hosting scene
  73108. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73109. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73110. * @param samplingMode defines the smapling mode to use with spritesheet
  73111. * @param fromPacked set to true; do not alter
  73112. */
  73113. constructor(
  73114. /** defines the packed manager's name */
  73115. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73116. }
  73117. }
  73118. declare module "babylonjs/Sprites/index" {
  73119. export * from "babylonjs/Sprites/sprite";
  73120. export * from "babylonjs/Sprites/ISprites";
  73121. export * from "babylonjs/Sprites/spriteManager";
  73122. export * from "babylonjs/Sprites/spriteMap";
  73123. export * from "babylonjs/Sprites/spritePackedManager";
  73124. export * from "babylonjs/Sprites/spriteSceneComponent";
  73125. }
  73126. declare module "babylonjs/States/index" {
  73127. export * from "babylonjs/States/alphaCullingState";
  73128. export * from "babylonjs/States/depthCullingState";
  73129. export * from "babylonjs/States/stencilState";
  73130. }
  73131. declare module "babylonjs/Misc/assetsManager" {
  73132. import { Scene } from "babylonjs/scene";
  73133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73134. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73135. import { Skeleton } from "babylonjs/Bones/skeleton";
  73136. import { Observable } from "babylonjs/Misc/observable";
  73137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  73138. import { Texture } from "babylonjs/Materials/Textures/texture";
  73139. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  73140. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  73141. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  73142. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  73143. /**
  73144. * Defines the list of states available for a task inside a AssetsManager
  73145. */
  73146. export enum AssetTaskState {
  73147. /**
  73148. * Initialization
  73149. */
  73150. INIT = 0,
  73151. /**
  73152. * Running
  73153. */
  73154. RUNNING = 1,
  73155. /**
  73156. * Done
  73157. */
  73158. DONE = 2,
  73159. /**
  73160. * Error
  73161. */
  73162. ERROR = 3
  73163. }
  73164. /**
  73165. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73166. */
  73167. export abstract class AbstractAssetTask {
  73168. /**
  73169. * Task name
  73170. */ name: string;
  73171. /**
  73172. * Callback called when the task is successful
  73173. */
  73174. onSuccess: (task: any) => void;
  73175. /**
  73176. * Callback called when the task is not successful
  73177. */
  73178. onError: (task: any, message?: string, exception?: any) => void;
  73179. /**
  73180. * Creates a new AssetsManager
  73181. * @param name defines the name of the task
  73182. */
  73183. constructor(
  73184. /**
  73185. * Task name
  73186. */ name: string);
  73187. private _isCompleted;
  73188. private _taskState;
  73189. private _errorObject;
  73190. /**
  73191. * Get if the task is completed
  73192. */
  73193. get isCompleted(): boolean;
  73194. /**
  73195. * Gets the current state of the task
  73196. */
  73197. get taskState(): AssetTaskState;
  73198. /**
  73199. * Gets the current error object (if task is in error)
  73200. */
  73201. get errorObject(): {
  73202. message?: string;
  73203. exception?: any;
  73204. };
  73205. /**
  73206. * Internal only
  73207. * @hidden
  73208. */
  73209. _setErrorObject(message?: string, exception?: any): void;
  73210. /**
  73211. * Execute the current task
  73212. * @param scene defines the scene where you want your assets to be loaded
  73213. * @param onSuccess is a callback called when the task is successfully executed
  73214. * @param onError is a callback called if an error occurs
  73215. */
  73216. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73217. /**
  73218. * Execute the current task
  73219. * @param scene defines the scene where you want your assets to be loaded
  73220. * @param onSuccess is a callback called when the task is successfully executed
  73221. * @param onError is a callback called if an error occurs
  73222. */
  73223. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73224. /**
  73225. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73226. * This can be used with failed tasks that have the reason for failure fixed.
  73227. */
  73228. reset(): void;
  73229. private onErrorCallback;
  73230. private onDoneCallback;
  73231. }
  73232. /**
  73233. * Define the interface used by progress events raised during assets loading
  73234. */
  73235. export interface IAssetsProgressEvent {
  73236. /**
  73237. * Defines the number of remaining tasks to process
  73238. */
  73239. remainingCount: number;
  73240. /**
  73241. * Defines the total number of tasks
  73242. */
  73243. totalCount: number;
  73244. /**
  73245. * Defines the task that was just processed
  73246. */
  73247. task: AbstractAssetTask;
  73248. }
  73249. /**
  73250. * Class used to share progress information about assets loading
  73251. */
  73252. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73253. /**
  73254. * Defines the number of remaining tasks to process
  73255. */
  73256. remainingCount: number;
  73257. /**
  73258. * Defines the total number of tasks
  73259. */
  73260. totalCount: number;
  73261. /**
  73262. * Defines the task that was just processed
  73263. */
  73264. task: AbstractAssetTask;
  73265. /**
  73266. * Creates a AssetsProgressEvent
  73267. * @param remainingCount defines the number of remaining tasks to process
  73268. * @param totalCount defines the total number of tasks
  73269. * @param task defines the task that was just processed
  73270. */
  73271. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73272. }
  73273. /**
  73274. * Define a task used by AssetsManager to load meshes
  73275. */
  73276. export class MeshAssetTask extends AbstractAssetTask {
  73277. /**
  73278. * Defines the name of the task
  73279. */
  73280. name: string;
  73281. /**
  73282. * Defines the list of mesh's names you want to load
  73283. */
  73284. meshesNames: any;
  73285. /**
  73286. * Defines the root url to use as a base to load your meshes and associated resources
  73287. */
  73288. rootUrl: string;
  73289. /**
  73290. * Defines the filename or File of the scene to load from
  73291. */
  73292. sceneFilename: string | File;
  73293. /**
  73294. * Gets the list of loaded meshes
  73295. */
  73296. loadedMeshes: Array<AbstractMesh>;
  73297. /**
  73298. * Gets the list of loaded particle systems
  73299. */
  73300. loadedParticleSystems: Array<IParticleSystem>;
  73301. /**
  73302. * Gets the list of loaded skeletons
  73303. */
  73304. loadedSkeletons: Array<Skeleton>;
  73305. /**
  73306. * Gets the list of loaded animation groups
  73307. */
  73308. loadedAnimationGroups: Array<AnimationGroup>;
  73309. /**
  73310. * Callback called when the task is successful
  73311. */
  73312. onSuccess: (task: MeshAssetTask) => void;
  73313. /**
  73314. * Callback called when the task is successful
  73315. */
  73316. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73317. /**
  73318. * Creates a new MeshAssetTask
  73319. * @param name defines the name of the task
  73320. * @param meshesNames defines the list of mesh's names you want to load
  73321. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73322. * @param sceneFilename defines the filename or File of the scene to load from
  73323. */
  73324. constructor(
  73325. /**
  73326. * Defines the name of the task
  73327. */
  73328. name: string,
  73329. /**
  73330. * Defines the list of mesh's names you want to load
  73331. */
  73332. meshesNames: any,
  73333. /**
  73334. * Defines the root url to use as a base to load your meshes and associated resources
  73335. */
  73336. rootUrl: string,
  73337. /**
  73338. * Defines the filename or File of the scene to load from
  73339. */
  73340. sceneFilename: string | File);
  73341. /**
  73342. * Execute the current task
  73343. * @param scene defines the scene where you want your assets to be loaded
  73344. * @param onSuccess is a callback called when the task is successfully executed
  73345. * @param onError is a callback called if an error occurs
  73346. */
  73347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73348. }
  73349. /**
  73350. * Define a task used by AssetsManager to load text content
  73351. */
  73352. export class TextFileAssetTask extends AbstractAssetTask {
  73353. /**
  73354. * Defines the name of the task
  73355. */
  73356. name: string;
  73357. /**
  73358. * Defines the location of the file to load
  73359. */
  73360. url: string;
  73361. /**
  73362. * Gets the loaded text string
  73363. */
  73364. text: string;
  73365. /**
  73366. * Callback called when the task is successful
  73367. */
  73368. onSuccess: (task: TextFileAssetTask) => void;
  73369. /**
  73370. * Callback called when the task is successful
  73371. */
  73372. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73373. /**
  73374. * Creates a new TextFileAssetTask object
  73375. * @param name defines the name of the task
  73376. * @param url defines the location of the file to load
  73377. */
  73378. constructor(
  73379. /**
  73380. * Defines the name of the task
  73381. */
  73382. name: string,
  73383. /**
  73384. * Defines the location of the file to load
  73385. */
  73386. url: string);
  73387. /**
  73388. * Execute the current task
  73389. * @param scene defines the scene where you want your assets to be loaded
  73390. * @param onSuccess is a callback called when the task is successfully executed
  73391. * @param onError is a callback called if an error occurs
  73392. */
  73393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73394. }
  73395. /**
  73396. * Define a task used by AssetsManager to load binary data
  73397. */
  73398. export class BinaryFileAssetTask extends AbstractAssetTask {
  73399. /**
  73400. * Defines the name of the task
  73401. */
  73402. name: string;
  73403. /**
  73404. * Defines the location of the file to load
  73405. */
  73406. url: string;
  73407. /**
  73408. * Gets the lodaded data (as an array buffer)
  73409. */
  73410. data: ArrayBuffer;
  73411. /**
  73412. * Callback called when the task is successful
  73413. */
  73414. onSuccess: (task: BinaryFileAssetTask) => void;
  73415. /**
  73416. * Callback called when the task is successful
  73417. */
  73418. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73419. /**
  73420. * Creates a new BinaryFileAssetTask object
  73421. * @param name defines the name of the new task
  73422. * @param url defines the location of the file to load
  73423. */
  73424. constructor(
  73425. /**
  73426. * Defines the name of the task
  73427. */
  73428. name: string,
  73429. /**
  73430. * Defines the location of the file to load
  73431. */
  73432. url: string);
  73433. /**
  73434. * Execute the current task
  73435. * @param scene defines the scene where you want your assets to be loaded
  73436. * @param onSuccess is a callback called when the task is successfully executed
  73437. * @param onError is a callback called if an error occurs
  73438. */
  73439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73440. }
  73441. /**
  73442. * Define a task used by AssetsManager to load images
  73443. */
  73444. export class ImageAssetTask extends AbstractAssetTask {
  73445. /**
  73446. * Defines the name of the task
  73447. */
  73448. name: string;
  73449. /**
  73450. * Defines the location of the image to load
  73451. */
  73452. url: string;
  73453. /**
  73454. * Gets the loaded images
  73455. */
  73456. image: HTMLImageElement;
  73457. /**
  73458. * Callback called when the task is successful
  73459. */
  73460. onSuccess: (task: ImageAssetTask) => void;
  73461. /**
  73462. * Callback called when the task is successful
  73463. */
  73464. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73465. /**
  73466. * Creates a new ImageAssetTask
  73467. * @param name defines the name of the task
  73468. * @param url defines the location of the image to load
  73469. */
  73470. constructor(
  73471. /**
  73472. * Defines the name of the task
  73473. */
  73474. name: string,
  73475. /**
  73476. * Defines the location of the image to load
  73477. */
  73478. url: string);
  73479. /**
  73480. * Execute the current task
  73481. * @param scene defines the scene where you want your assets to be loaded
  73482. * @param onSuccess is a callback called when the task is successfully executed
  73483. * @param onError is a callback called if an error occurs
  73484. */
  73485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73486. }
  73487. /**
  73488. * Defines the interface used by texture loading tasks
  73489. */
  73490. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73491. /**
  73492. * Gets the loaded texture
  73493. */
  73494. texture: TEX;
  73495. }
  73496. /**
  73497. * Define a task used by AssetsManager to load 2D textures
  73498. */
  73499. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73500. /**
  73501. * Defines the name of the task
  73502. */
  73503. name: string;
  73504. /**
  73505. * Defines the location of the file to load
  73506. */
  73507. url: string;
  73508. /**
  73509. * Defines if mipmap should not be generated (default is false)
  73510. */
  73511. noMipmap?: boolean | undefined;
  73512. /**
  73513. * Defines if texture must be inverted on Y axis (default is true)
  73514. */
  73515. invertY: boolean;
  73516. /**
  73517. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73518. */
  73519. samplingMode: number;
  73520. /**
  73521. * Gets the loaded texture
  73522. */
  73523. texture: Texture;
  73524. /**
  73525. * Callback called when the task is successful
  73526. */
  73527. onSuccess: (task: TextureAssetTask) => void;
  73528. /**
  73529. * Callback called when the task is successful
  73530. */
  73531. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73532. /**
  73533. * Creates a new TextureAssetTask object
  73534. * @param name defines the name of the task
  73535. * @param url defines the location of the file to load
  73536. * @param noMipmap defines if mipmap should not be generated (default is false)
  73537. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73538. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73539. */
  73540. constructor(
  73541. /**
  73542. * Defines the name of the task
  73543. */
  73544. name: string,
  73545. /**
  73546. * Defines the location of the file to load
  73547. */
  73548. url: string,
  73549. /**
  73550. * Defines if mipmap should not be generated (default is false)
  73551. */
  73552. noMipmap?: boolean | undefined,
  73553. /**
  73554. * Defines if texture must be inverted on Y axis (default is true)
  73555. */
  73556. invertY?: boolean,
  73557. /**
  73558. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73559. */
  73560. samplingMode?: number);
  73561. /**
  73562. * Execute the current task
  73563. * @param scene defines the scene where you want your assets to be loaded
  73564. * @param onSuccess is a callback called when the task is successfully executed
  73565. * @param onError is a callback called if an error occurs
  73566. */
  73567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73568. }
  73569. /**
  73570. * Define a task used by AssetsManager to load cube textures
  73571. */
  73572. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73573. /**
  73574. * Defines the name of the task
  73575. */
  73576. name: string;
  73577. /**
  73578. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73579. */
  73580. url: string;
  73581. /**
  73582. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73583. */
  73584. extensions?: string[] | undefined;
  73585. /**
  73586. * Defines if mipmaps should not be generated (default is false)
  73587. */
  73588. noMipmap?: boolean | undefined;
  73589. /**
  73590. * Defines the explicit list of files (undefined by default)
  73591. */
  73592. files?: string[] | undefined;
  73593. /**
  73594. * Gets the loaded texture
  73595. */
  73596. texture: CubeTexture;
  73597. /**
  73598. * Callback called when the task is successful
  73599. */
  73600. onSuccess: (task: CubeTextureAssetTask) => void;
  73601. /**
  73602. * Callback called when the task is successful
  73603. */
  73604. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73605. /**
  73606. * Creates a new CubeTextureAssetTask
  73607. * @param name defines the name of the task
  73608. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73609. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73610. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73611. * @param files defines the explicit list of files (undefined by default)
  73612. */
  73613. constructor(
  73614. /**
  73615. * Defines the name of the task
  73616. */
  73617. name: string,
  73618. /**
  73619. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73620. */
  73621. url: string,
  73622. /**
  73623. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73624. */
  73625. extensions?: string[] | undefined,
  73626. /**
  73627. * Defines if mipmaps should not be generated (default is false)
  73628. */
  73629. noMipmap?: boolean | undefined,
  73630. /**
  73631. * Defines the explicit list of files (undefined by default)
  73632. */
  73633. files?: string[] | undefined);
  73634. /**
  73635. * Execute the current task
  73636. * @param scene defines the scene where you want your assets to be loaded
  73637. * @param onSuccess is a callback called when the task is successfully executed
  73638. * @param onError is a callback called if an error occurs
  73639. */
  73640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73641. }
  73642. /**
  73643. * Define a task used by AssetsManager to load HDR cube textures
  73644. */
  73645. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73646. /**
  73647. * Defines the name of the task
  73648. */
  73649. name: string;
  73650. /**
  73651. * Defines the location of the file to load
  73652. */
  73653. url: string;
  73654. /**
  73655. * Defines the desired size (the more it increases the longer the generation will be)
  73656. */
  73657. size: number;
  73658. /**
  73659. * Defines if mipmaps should not be generated (default is false)
  73660. */
  73661. noMipmap: boolean;
  73662. /**
  73663. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73664. */
  73665. generateHarmonics: boolean;
  73666. /**
  73667. * 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)
  73668. */
  73669. gammaSpace: boolean;
  73670. /**
  73671. * Internal Use Only
  73672. */
  73673. reserved: boolean;
  73674. /**
  73675. * Gets the loaded texture
  73676. */
  73677. texture: HDRCubeTexture;
  73678. /**
  73679. * Callback called when the task is successful
  73680. */
  73681. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73682. /**
  73683. * Callback called when the task is successful
  73684. */
  73685. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73686. /**
  73687. * Creates a new HDRCubeTextureAssetTask object
  73688. * @param name defines the name of the task
  73689. * @param url defines the location of the file to load
  73690. * @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.
  73691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73692. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73693. * @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)
  73694. * @param reserved Internal use only
  73695. */
  73696. constructor(
  73697. /**
  73698. * Defines the name of the task
  73699. */
  73700. name: string,
  73701. /**
  73702. * Defines the location of the file to load
  73703. */
  73704. url: string,
  73705. /**
  73706. * Defines the desired size (the more it increases the longer the generation will be)
  73707. */
  73708. size: number,
  73709. /**
  73710. * Defines if mipmaps should not be generated (default is false)
  73711. */
  73712. noMipmap?: boolean,
  73713. /**
  73714. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73715. */
  73716. generateHarmonics?: boolean,
  73717. /**
  73718. * 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)
  73719. */
  73720. gammaSpace?: boolean,
  73721. /**
  73722. * Internal Use Only
  73723. */
  73724. reserved?: boolean);
  73725. /**
  73726. * Execute the current task
  73727. * @param scene defines the scene where you want your assets to be loaded
  73728. * @param onSuccess is a callback called when the task is successfully executed
  73729. * @param onError is a callback called if an error occurs
  73730. */
  73731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73732. }
  73733. /**
  73734. * Define a task used by AssetsManager to load Equirectangular cube textures
  73735. */
  73736. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73737. /**
  73738. * Defines the name of the task
  73739. */
  73740. name: string;
  73741. /**
  73742. * Defines the location of the file to load
  73743. */
  73744. url: string;
  73745. /**
  73746. * Defines the desired size (the more it increases the longer the generation will be)
  73747. */
  73748. size: number;
  73749. /**
  73750. * Defines if mipmaps should not be generated (default is false)
  73751. */
  73752. noMipmap: boolean;
  73753. /**
  73754. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73755. * but the standard material would require them in Gamma space) (default is true)
  73756. */
  73757. gammaSpace: boolean;
  73758. /**
  73759. * Gets the loaded texture
  73760. */
  73761. texture: EquiRectangularCubeTexture;
  73762. /**
  73763. * Callback called when the task is successful
  73764. */
  73765. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73766. /**
  73767. * Callback called when the task is successful
  73768. */
  73769. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73770. /**
  73771. * Creates a new EquiRectangularCubeTextureAssetTask object
  73772. * @param name defines the name of the task
  73773. * @param url defines the location of the file to load
  73774. * @param size defines the desired size (the more it increases the longer the generation will be)
  73775. * If the size is omitted this implies you are using a preprocessed cubemap.
  73776. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73777. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73778. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73779. * (default is true)
  73780. */
  73781. constructor(
  73782. /**
  73783. * Defines the name of the task
  73784. */
  73785. name: string,
  73786. /**
  73787. * Defines the location of the file to load
  73788. */
  73789. url: string,
  73790. /**
  73791. * Defines the desired size (the more it increases the longer the generation will be)
  73792. */
  73793. size: number,
  73794. /**
  73795. * Defines if mipmaps should not be generated (default is false)
  73796. */
  73797. noMipmap?: boolean,
  73798. /**
  73799. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73800. * but the standard material would require them in Gamma space) (default is true)
  73801. */
  73802. gammaSpace?: boolean);
  73803. /**
  73804. * Execute the current task
  73805. * @param scene defines the scene where you want your assets to be loaded
  73806. * @param onSuccess is a callback called when the task is successfully executed
  73807. * @param onError is a callback called if an error occurs
  73808. */
  73809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73810. }
  73811. /**
  73812. * This class can be used to easily import assets into a scene
  73813. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73814. */
  73815. export class AssetsManager {
  73816. private _scene;
  73817. private _isLoading;
  73818. protected _tasks: AbstractAssetTask[];
  73819. protected _waitingTasksCount: number;
  73820. protected _totalTasksCount: number;
  73821. /**
  73822. * Callback called when all tasks are processed
  73823. */
  73824. onFinish: (tasks: AbstractAssetTask[]) => void;
  73825. /**
  73826. * Callback called when a task is successful
  73827. */
  73828. onTaskSuccess: (task: AbstractAssetTask) => void;
  73829. /**
  73830. * Callback called when a task had an error
  73831. */
  73832. onTaskError: (task: AbstractAssetTask) => void;
  73833. /**
  73834. * Callback called when a task is done (whatever the result is)
  73835. */
  73836. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73837. /**
  73838. * Observable called when all tasks are processed
  73839. */
  73840. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73841. /**
  73842. * Observable called when a task had an error
  73843. */
  73844. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73845. /**
  73846. * Observable called when all tasks were executed
  73847. */
  73848. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73849. /**
  73850. * Observable called when a task is done (whatever the result is)
  73851. */
  73852. onProgressObservable: Observable<IAssetsProgressEvent>;
  73853. /**
  73854. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73856. */
  73857. useDefaultLoadingScreen: boolean;
  73858. /**
  73859. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73860. * when all assets have been downloaded.
  73861. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73862. */
  73863. autoHideLoadingUI: boolean;
  73864. /**
  73865. * Creates a new AssetsManager
  73866. * @param scene defines the scene to work on
  73867. */
  73868. constructor(scene: Scene);
  73869. /**
  73870. * Add a MeshAssetTask to the list of active tasks
  73871. * @param taskName defines the name of the new task
  73872. * @param meshesNames defines the name of meshes to load
  73873. * @param rootUrl defines the root url to use to locate files
  73874. * @param sceneFilename defines the filename of the scene file
  73875. * @returns a new MeshAssetTask object
  73876. */
  73877. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73878. /**
  73879. * Add a TextFileAssetTask to the list of active tasks
  73880. * @param taskName defines the name of the new task
  73881. * @param url defines the url of the file to load
  73882. * @returns a new TextFileAssetTask object
  73883. */
  73884. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73885. /**
  73886. * Add a BinaryFileAssetTask to the list of active tasks
  73887. * @param taskName defines the name of the new task
  73888. * @param url defines the url of the file to load
  73889. * @returns a new BinaryFileAssetTask object
  73890. */
  73891. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73892. /**
  73893. * Add a ImageAssetTask to the list of active tasks
  73894. * @param taskName defines the name of the new task
  73895. * @param url defines the url of the file to load
  73896. * @returns a new ImageAssetTask object
  73897. */
  73898. addImageTask(taskName: string, url: string): ImageAssetTask;
  73899. /**
  73900. * Add a TextureAssetTask to the list of active tasks
  73901. * @param taskName defines the name of the new task
  73902. * @param url defines the url of the file to load
  73903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73904. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73905. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73906. * @returns a new TextureAssetTask object
  73907. */
  73908. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73909. /**
  73910. * Add a CubeTextureAssetTask to the list of active tasks
  73911. * @param taskName defines the name of the new task
  73912. * @param url defines the url of the file to load
  73913. * @param extensions defines the extension to use to load the cube map (can be null)
  73914. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73915. * @param files defines the list of files to load (can be null)
  73916. * @returns a new CubeTextureAssetTask object
  73917. */
  73918. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73919. /**
  73920. *
  73921. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73922. * @param taskName defines the name of the new task
  73923. * @param url defines the url of the file to load
  73924. * @param size defines the size you want for the cubemap (can be null)
  73925. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73926. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73927. * @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)
  73928. * @param reserved Internal use only
  73929. * @returns a new HDRCubeTextureAssetTask object
  73930. */
  73931. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73932. /**
  73933. *
  73934. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73935. * @param taskName defines the name of the new task
  73936. * @param url defines the url of the file to load
  73937. * @param size defines the size you want for the cubemap (can be null)
  73938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73939. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73940. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73941. * @returns a new EquiRectangularCubeTextureAssetTask object
  73942. */
  73943. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73944. /**
  73945. * Remove a task from the assets manager.
  73946. * @param task the task to remove
  73947. */
  73948. removeTask(task: AbstractAssetTask): void;
  73949. private _decreaseWaitingTasksCount;
  73950. private _runTask;
  73951. /**
  73952. * Reset the AssetsManager and remove all tasks
  73953. * @return the current instance of the AssetsManager
  73954. */
  73955. reset(): AssetsManager;
  73956. /**
  73957. * Start the loading process
  73958. * @return the current instance of the AssetsManager
  73959. */
  73960. load(): AssetsManager;
  73961. /**
  73962. * Start the loading process as an async operation
  73963. * @return a promise returning the list of failed tasks
  73964. */
  73965. loadAsync(): Promise<void>;
  73966. }
  73967. }
  73968. declare module "babylonjs/Misc/deferred" {
  73969. /**
  73970. * Wrapper class for promise with external resolve and reject.
  73971. */
  73972. export class Deferred<T> {
  73973. /**
  73974. * The promise associated with this deferred object.
  73975. */
  73976. readonly promise: Promise<T>;
  73977. private _resolve;
  73978. private _reject;
  73979. /**
  73980. * The resolve method of the promise associated with this deferred object.
  73981. */
  73982. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73983. /**
  73984. * The reject method of the promise associated with this deferred object.
  73985. */
  73986. get reject(): (reason?: any) => void;
  73987. /**
  73988. * Constructor for this deferred object.
  73989. */
  73990. constructor();
  73991. }
  73992. }
  73993. declare module "babylonjs/Misc/meshExploder" {
  73994. import { Mesh } from "babylonjs/Meshes/mesh";
  73995. /**
  73996. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73997. */
  73998. export class MeshExploder {
  73999. private _centerMesh;
  74000. private _meshes;
  74001. private _meshesOrigins;
  74002. private _toCenterVectors;
  74003. private _scaledDirection;
  74004. private _newPosition;
  74005. private _centerPosition;
  74006. /**
  74007. * Explodes meshes from a center mesh.
  74008. * @param meshes The meshes to explode.
  74009. * @param centerMesh The mesh to be center of explosion.
  74010. */
  74011. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74012. private _setCenterMesh;
  74013. /**
  74014. * Get class name
  74015. * @returns "MeshExploder"
  74016. */
  74017. getClassName(): string;
  74018. /**
  74019. * "Exploded meshes"
  74020. * @returns Array of meshes with the centerMesh at index 0.
  74021. */
  74022. getMeshes(): Array<Mesh>;
  74023. /**
  74024. * Explodes meshes giving a specific direction
  74025. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74026. */
  74027. explode(direction?: number): void;
  74028. }
  74029. }
  74030. declare module "babylonjs/Misc/filesInput" {
  74031. import { Engine } from "babylonjs/Engines/engine";
  74032. import { Scene } from "babylonjs/scene";
  74033. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  74034. /**
  74035. * Class used to help managing file picking and drag'n'drop
  74036. */
  74037. export class FilesInput {
  74038. /**
  74039. * List of files ready to be loaded
  74040. */
  74041. static get FilesToLoad(): {
  74042. [key: string]: File;
  74043. };
  74044. /**
  74045. * Callback called when a file is processed
  74046. */
  74047. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  74048. private _engine;
  74049. private _currentScene;
  74050. private _sceneLoadedCallback;
  74051. private _progressCallback;
  74052. private _additionalRenderLoopLogicCallback;
  74053. private _textureLoadingCallback;
  74054. private _startingProcessingFilesCallback;
  74055. private _onReloadCallback;
  74056. private _errorCallback;
  74057. private _elementToMonitor;
  74058. private _sceneFileToLoad;
  74059. private _filesToLoad;
  74060. /**
  74061. * Creates a new FilesInput
  74062. * @param engine defines the rendering engine
  74063. * @param scene defines the hosting scene
  74064. * @param sceneLoadedCallback callback called when scene is loaded
  74065. * @param progressCallback callback called to track progress
  74066. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74067. * @param textureLoadingCallback callback called when a texture is loading
  74068. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74069. * @param onReloadCallback callback called when a reload is requested
  74070. * @param errorCallback callback call if an error occurs
  74071. */
  74072. 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);
  74073. private _dragEnterHandler;
  74074. private _dragOverHandler;
  74075. private _dropHandler;
  74076. /**
  74077. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74078. * @param elementToMonitor defines the DOM element to track
  74079. */
  74080. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74081. /**
  74082. * Release all associated resources
  74083. */
  74084. dispose(): void;
  74085. private renderFunction;
  74086. private drag;
  74087. private drop;
  74088. private _traverseFolder;
  74089. private _processFiles;
  74090. /**
  74091. * Load files from a drop event
  74092. * @param event defines the drop event to use as source
  74093. */
  74094. loadFiles(event: any): void;
  74095. private _processReload;
  74096. /**
  74097. * Reload the current scene from the loaded files
  74098. */
  74099. reload(): void;
  74100. }
  74101. }
  74102. declare module "babylonjs/Misc/HighDynamicRange/index" {
  74103. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  74104. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  74105. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  74106. }
  74107. declare module "babylonjs/Misc/sceneOptimizer" {
  74108. import { Scene, IDisposable } from "babylonjs/scene";
  74109. import { Observable } from "babylonjs/Misc/observable";
  74110. /**
  74111. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74112. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74113. */
  74114. export class SceneOptimization {
  74115. /**
  74116. * Defines the priority of this optimization (0 by default which means first in the list)
  74117. */
  74118. priority: number;
  74119. /**
  74120. * Gets a string describing the action executed by the current optimization
  74121. * @returns description string
  74122. */
  74123. getDescription(): string;
  74124. /**
  74125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74126. * @param scene defines the current scene where to apply this optimization
  74127. * @param optimizer defines the current optimizer
  74128. * @returns true if everything that can be done was applied
  74129. */
  74130. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74131. /**
  74132. * Creates the SceneOptimization object
  74133. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74134. * @param desc defines the description associated with the optimization
  74135. */
  74136. constructor(
  74137. /**
  74138. * Defines the priority of this optimization (0 by default which means first in the list)
  74139. */
  74140. priority?: number);
  74141. }
  74142. /**
  74143. * Defines an optimization used to reduce the size of render target textures
  74144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74145. */
  74146. export class TextureOptimization extends SceneOptimization {
  74147. /**
  74148. * Defines the priority of this optimization (0 by default which means first in the list)
  74149. */
  74150. priority: number;
  74151. /**
  74152. * 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
  74153. */
  74154. maximumSize: number;
  74155. /**
  74156. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74157. */
  74158. step: number;
  74159. /**
  74160. * Gets a string describing the action executed by the current optimization
  74161. * @returns description string
  74162. */
  74163. getDescription(): string;
  74164. /**
  74165. * Creates the TextureOptimization object
  74166. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74167. * @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
  74168. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74169. */
  74170. constructor(
  74171. /**
  74172. * Defines the priority of this optimization (0 by default which means first in the list)
  74173. */
  74174. priority?: number,
  74175. /**
  74176. * 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
  74177. */
  74178. maximumSize?: number,
  74179. /**
  74180. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74181. */
  74182. step?: number);
  74183. /**
  74184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74185. * @param scene defines the current scene where to apply this optimization
  74186. * @param optimizer defines the current optimizer
  74187. * @returns true if everything that can be done was applied
  74188. */
  74189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74190. }
  74191. /**
  74192. * Defines an optimization used to increase or decrease the rendering resolution
  74193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74194. */
  74195. export class HardwareScalingOptimization extends SceneOptimization {
  74196. /**
  74197. * Defines the priority of this optimization (0 by default which means first in the list)
  74198. */
  74199. priority: number;
  74200. /**
  74201. * Defines the maximum scale to use (2 by default)
  74202. */
  74203. maximumScale: number;
  74204. /**
  74205. * Defines the step to use between two passes (0.5 by default)
  74206. */
  74207. step: number;
  74208. private _currentScale;
  74209. private _directionOffset;
  74210. /**
  74211. * Gets a string describing the action executed by the current optimization
  74212. * @return description string
  74213. */
  74214. getDescription(): string;
  74215. /**
  74216. * Creates the HardwareScalingOptimization object
  74217. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74218. * @param maximumScale defines the maximum scale to use (2 by default)
  74219. * @param step defines the step to use between two passes (0.5 by default)
  74220. */
  74221. constructor(
  74222. /**
  74223. * Defines the priority of this optimization (0 by default which means first in the list)
  74224. */
  74225. priority?: number,
  74226. /**
  74227. * Defines the maximum scale to use (2 by default)
  74228. */
  74229. maximumScale?: number,
  74230. /**
  74231. * Defines the step to use between two passes (0.5 by default)
  74232. */
  74233. step?: number);
  74234. /**
  74235. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74236. * @param scene defines the current scene where to apply this optimization
  74237. * @param optimizer defines the current optimizer
  74238. * @returns true if everything that can be done was applied
  74239. */
  74240. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74241. }
  74242. /**
  74243. * Defines an optimization used to remove shadows
  74244. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74245. */
  74246. export class ShadowsOptimization extends SceneOptimization {
  74247. /**
  74248. * Gets a string describing the action executed by the current optimization
  74249. * @return description string
  74250. */
  74251. getDescription(): string;
  74252. /**
  74253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74254. * @param scene defines the current scene where to apply this optimization
  74255. * @param optimizer defines the current optimizer
  74256. * @returns true if everything that can be done was applied
  74257. */
  74258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74259. }
  74260. /**
  74261. * Defines an optimization used to turn post-processes off
  74262. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74263. */
  74264. export class PostProcessesOptimization extends SceneOptimization {
  74265. /**
  74266. * Gets a string describing the action executed by the current optimization
  74267. * @return description string
  74268. */
  74269. getDescription(): string;
  74270. /**
  74271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74272. * @param scene defines the current scene where to apply this optimization
  74273. * @param optimizer defines the current optimizer
  74274. * @returns true if everything that can be done was applied
  74275. */
  74276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74277. }
  74278. /**
  74279. * Defines an optimization used to turn lens flares off
  74280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74281. */
  74282. export class LensFlaresOptimization extends SceneOptimization {
  74283. /**
  74284. * Gets a string describing the action executed by the current optimization
  74285. * @return description string
  74286. */
  74287. getDescription(): string;
  74288. /**
  74289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74290. * @param scene defines the current scene where to apply this optimization
  74291. * @param optimizer defines the current optimizer
  74292. * @returns true if everything that can be done was applied
  74293. */
  74294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74295. }
  74296. /**
  74297. * Defines an optimization based on user defined callback.
  74298. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74299. */
  74300. export class CustomOptimization extends SceneOptimization {
  74301. /**
  74302. * Callback called to apply the custom optimization.
  74303. */
  74304. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74305. /**
  74306. * Callback called to get custom description
  74307. */
  74308. onGetDescription: () => string;
  74309. /**
  74310. * Gets a string describing the action executed by the current optimization
  74311. * @returns description string
  74312. */
  74313. getDescription(): string;
  74314. /**
  74315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74316. * @param scene defines the current scene where to apply this optimization
  74317. * @param optimizer defines the current optimizer
  74318. * @returns true if everything that can be done was applied
  74319. */
  74320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74321. }
  74322. /**
  74323. * Defines an optimization used to turn particles off
  74324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74325. */
  74326. export class ParticlesOptimization extends SceneOptimization {
  74327. /**
  74328. * Gets a string describing the action executed by the current optimization
  74329. * @return description string
  74330. */
  74331. getDescription(): string;
  74332. /**
  74333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74334. * @param scene defines the current scene where to apply this optimization
  74335. * @param optimizer defines the current optimizer
  74336. * @returns true if everything that can be done was applied
  74337. */
  74338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74339. }
  74340. /**
  74341. * Defines an optimization used to turn render targets off
  74342. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74343. */
  74344. export class RenderTargetsOptimization extends SceneOptimization {
  74345. /**
  74346. * Gets a string describing the action executed by the current optimization
  74347. * @return description string
  74348. */
  74349. getDescription(): string;
  74350. /**
  74351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74352. * @param scene defines the current scene where to apply this optimization
  74353. * @param optimizer defines the current optimizer
  74354. * @returns true if everything that can be done was applied
  74355. */
  74356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74357. }
  74358. /**
  74359. * Defines an optimization used to merge meshes with compatible materials
  74360. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74361. */
  74362. export class MergeMeshesOptimization extends SceneOptimization {
  74363. private static _UpdateSelectionTree;
  74364. /**
  74365. * Gets or sets a boolean which defines if optimization octree has to be updated
  74366. */
  74367. static get UpdateSelectionTree(): boolean;
  74368. /**
  74369. * Gets or sets a boolean which defines if optimization octree has to be updated
  74370. */
  74371. static set UpdateSelectionTree(value: boolean);
  74372. /**
  74373. * Gets a string describing the action executed by the current optimization
  74374. * @return description string
  74375. */
  74376. getDescription(): string;
  74377. private _canBeMerged;
  74378. /**
  74379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74380. * @param scene defines the current scene where to apply this optimization
  74381. * @param optimizer defines the current optimizer
  74382. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74383. * @returns true if everything that can be done was applied
  74384. */
  74385. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74386. }
  74387. /**
  74388. * Defines a list of options used by SceneOptimizer
  74389. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74390. */
  74391. export class SceneOptimizerOptions {
  74392. /**
  74393. * Defines the target frame rate to reach (60 by default)
  74394. */
  74395. targetFrameRate: number;
  74396. /**
  74397. * Defines the interval between two checkes (2000ms by default)
  74398. */
  74399. trackerDuration: number;
  74400. /**
  74401. * Gets the list of optimizations to apply
  74402. */
  74403. optimizations: SceneOptimization[];
  74404. /**
  74405. * Creates a new list of options used by SceneOptimizer
  74406. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74407. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74408. */
  74409. constructor(
  74410. /**
  74411. * Defines the target frame rate to reach (60 by default)
  74412. */
  74413. targetFrameRate?: number,
  74414. /**
  74415. * Defines the interval between two checkes (2000ms by default)
  74416. */
  74417. trackerDuration?: number);
  74418. /**
  74419. * Add a new optimization
  74420. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74421. * @returns the current SceneOptimizerOptions
  74422. */
  74423. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74424. /**
  74425. * Add a new custom optimization
  74426. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74427. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74428. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74429. * @returns the current SceneOptimizerOptions
  74430. */
  74431. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74432. /**
  74433. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74434. * @param targetFrameRate defines the target frame rate (60 by default)
  74435. * @returns a SceneOptimizerOptions object
  74436. */
  74437. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74438. /**
  74439. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74440. * @param targetFrameRate defines the target frame rate (60 by default)
  74441. * @returns a SceneOptimizerOptions object
  74442. */
  74443. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74444. /**
  74445. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74446. * @param targetFrameRate defines the target frame rate (60 by default)
  74447. * @returns a SceneOptimizerOptions object
  74448. */
  74449. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74450. }
  74451. /**
  74452. * Class used to run optimizations in order to reach a target frame rate
  74453. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74454. */
  74455. export class SceneOptimizer implements IDisposable {
  74456. private _isRunning;
  74457. private _options;
  74458. private _scene;
  74459. private _currentPriorityLevel;
  74460. private _targetFrameRate;
  74461. private _trackerDuration;
  74462. private _currentFrameRate;
  74463. private _sceneDisposeObserver;
  74464. private _improvementMode;
  74465. /**
  74466. * Defines an observable called when the optimizer reaches the target frame rate
  74467. */
  74468. onSuccessObservable: Observable<SceneOptimizer>;
  74469. /**
  74470. * Defines an observable called when the optimizer enables an optimization
  74471. */
  74472. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74473. /**
  74474. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74475. */
  74476. onFailureObservable: Observable<SceneOptimizer>;
  74477. /**
  74478. * Gets a boolean indicating if the optimizer is in improvement mode
  74479. */
  74480. get isInImprovementMode(): boolean;
  74481. /**
  74482. * Gets the current priority level (0 at start)
  74483. */
  74484. get currentPriorityLevel(): number;
  74485. /**
  74486. * Gets the current frame rate checked by the SceneOptimizer
  74487. */
  74488. get currentFrameRate(): number;
  74489. /**
  74490. * Gets or sets the current target frame rate (60 by default)
  74491. */
  74492. get targetFrameRate(): number;
  74493. /**
  74494. * Gets or sets the current target frame rate (60 by default)
  74495. */
  74496. set targetFrameRate(value: number);
  74497. /**
  74498. * Gets or sets the current interval between two checks (every 2000ms by default)
  74499. */
  74500. get trackerDuration(): number;
  74501. /**
  74502. * Gets or sets the current interval between two checks (every 2000ms by default)
  74503. */
  74504. set trackerDuration(value: number);
  74505. /**
  74506. * Gets the list of active optimizations
  74507. */
  74508. get optimizations(): SceneOptimization[];
  74509. /**
  74510. * Creates a new SceneOptimizer
  74511. * @param scene defines the scene to work on
  74512. * @param options defines the options to use with the SceneOptimizer
  74513. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74514. * @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)
  74515. */
  74516. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74517. /**
  74518. * Stops the current optimizer
  74519. */
  74520. stop(): void;
  74521. /**
  74522. * Reset the optimizer to initial step (current priority level = 0)
  74523. */
  74524. reset(): void;
  74525. /**
  74526. * Start the optimizer. By default it will try to reach a specific framerate
  74527. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74528. */
  74529. start(): void;
  74530. private _checkCurrentState;
  74531. /**
  74532. * Release all resources
  74533. */
  74534. dispose(): void;
  74535. /**
  74536. * Helper function to create a SceneOptimizer with one single line of code
  74537. * @param scene defines the scene to work on
  74538. * @param options defines the options to use with the SceneOptimizer
  74539. * @param onSuccess defines a callback to call on success
  74540. * @param onFailure defines a callback to call on failure
  74541. * @returns the new SceneOptimizer object
  74542. */
  74543. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74544. }
  74545. }
  74546. declare module "babylonjs/Misc/sceneSerializer" {
  74547. import { Scene } from "babylonjs/scene";
  74548. /**
  74549. * Class used to serialize a scene into a string
  74550. */
  74551. export class SceneSerializer {
  74552. /**
  74553. * Clear cache used by a previous serialization
  74554. */
  74555. static ClearCache(): void;
  74556. /**
  74557. * Serialize a scene into a JSON compatible object
  74558. * @param scene defines the scene to serialize
  74559. * @returns a JSON compatible object
  74560. */
  74561. static Serialize(scene: Scene): any;
  74562. /**
  74563. * Serialize a mesh into a JSON compatible object
  74564. * @param toSerialize defines the mesh to serialize
  74565. * @param withParents defines if parents must be serialized as well
  74566. * @param withChildren defines if children must be serialized as well
  74567. * @returns a JSON compatible object
  74568. */
  74569. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74570. }
  74571. }
  74572. declare module "babylonjs/Misc/textureTools" {
  74573. import { Texture } from "babylonjs/Materials/Textures/texture";
  74574. /**
  74575. * Class used to host texture specific utilities
  74576. */
  74577. export class TextureTools {
  74578. /**
  74579. * Uses the GPU to create a copy texture rescaled at a given size
  74580. * @param texture Texture to copy from
  74581. * @param width defines the desired width
  74582. * @param height defines the desired height
  74583. * @param useBilinearMode defines if bilinear mode has to be used
  74584. * @return the generated texture
  74585. */
  74586. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74587. }
  74588. }
  74589. declare module "babylonjs/Misc/videoRecorder" {
  74590. import { Nullable } from "babylonjs/types";
  74591. import { Engine } from "babylonjs/Engines/engine";
  74592. /**
  74593. * This represents the different options available for the video capture.
  74594. */
  74595. export interface VideoRecorderOptions {
  74596. /** Defines the mime type of the video. */
  74597. mimeType: string;
  74598. /** Defines the FPS the video should be recorded at. */
  74599. fps: number;
  74600. /** Defines the chunk size for the recording data. */
  74601. recordChunckSize: number;
  74602. /** The audio tracks to attach to the recording. */
  74603. audioTracks?: MediaStreamTrack[];
  74604. }
  74605. /**
  74606. * This can help with recording videos from BabylonJS.
  74607. * This is based on the available WebRTC functionalities of the browser.
  74608. *
  74609. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74610. */
  74611. export class VideoRecorder {
  74612. private static readonly _defaultOptions;
  74613. /**
  74614. * Returns whether or not the VideoRecorder is available in your browser.
  74615. * @param engine Defines the Babylon Engine.
  74616. * @returns true if supported otherwise false.
  74617. */
  74618. static IsSupported(engine: Engine): boolean;
  74619. private readonly _options;
  74620. private _canvas;
  74621. private _mediaRecorder;
  74622. private _recordedChunks;
  74623. private _fileName;
  74624. private _resolve;
  74625. private _reject;
  74626. /**
  74627. * True when a recording is already in progress.
  74628. */
  74629. get isRecording(): boolean;
  74630. /**
  74631. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74632. * @param engine Defines the BabylonJS Engine you wish to record.
  74633. * @param options Defines options that can be used to customize the capture.
  74634. */
  74635. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74636. /**
  74637. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74638. */
  74639. stopRecording(): void;
  74640. /**
  74641. * Starts recording the canvas for a max duration specified in parameters.
  74642. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74643. * If null no automatic download will start and you can rely on the promise to get the data back.
  74644. * @param maxDuration Defines the maximum recording time in seconds.
  74645. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74646. * @return A promise callback at the end of the recording with the video data in Blob.
  74647. */
  74648. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74649. /**
  74650. * Releases internal resources used during the recording.
  74651. */
  74652. dispose(): void;
  74653. private _handleDataAvailable;
  74654. private _handleError;
  74655. private _handleStop;
  74656. }
  74657. }
  74658. declare module "babylonjs/Misc/screenshotTools" {
  74659. import { Camera } from "babylonjs/Cameras/camera";
  74660. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74661. import { Engine } from "babylonjs/Engines/engine";
  74662. /**
  74663. * Class containing a set of static utilities functions for screenshots
  74664. */
  74665. export class ScreenshotTools {
  74666. /**
  74667. * Captures a screenshot of the current rendering
  74668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74669. * @param engine defines the rendering engine
  74670. * @param camera defines the source camera
  74671. * @param size This parameter can be set to a single number or to an object with the
  74672. * following (optional) properties: precision, width, height. If a single number is passed,
  74673. * it will be used for both width and height. If an object is passed, the screenshot size
  74674. * will be derived from the parameters. The precision property is a multiplier allowing
  74675. * rendering at a higher or lower resolution
  74676. * @param successCallback defines the callback receives a single parameter which contains the
  74677. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74678. * src parameter of an <img> to display it
  74679. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74680. * Check your browser for supported MIME types
  74681. */
  74682. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74683. /**
  74684. * Captures a screenshot of the current rendering
  74685. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74686. * @param engine defines the rendering engine
  74687. * @param camera defines the source camera
  74688. * @param size This parameter can be set to a single number or to an object with the
  74689. * following (optional) properties: precision, width, height. If a single number is passed,
  74690. * it will be used for both width and height. If an object is passed, the screenshot size
  74691. * will be derived from the parameters. The precision property is a multiplier allowing
  74692. * rendering at a higher or lower resolution
  74693. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74694. * Check your browser for supported MIME types
  74695. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74696. * to the src parameter of an <img> to display it
  74697. */
  74698. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74699. /**
  74700. * Generates an image screenshot from the specified camera.
  74701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74702. * @param engine The engine to use for rendering
  74703. * @param camera The camera to use for rendering
  74704. * @param size This parameter can be set to a single number or to an object with the
  74705. * following (optional) properties: precision, width, height. If a single number is passed,
  74706. * it will be used for both width and height. If an object is passed, the screenshot size
  74707. * will be derived from the parameters. The precision property is a multiplier allowing
  74708. * rendering at a higher or lower resolution
  74709. * @param successCallback The callback receives a single parameter which contains the
  74710. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74711. * src parameter of an <img> to display it
  74712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74713. * Check your browser for supported MIME types
  74714. * @param samples Texture samples (default: 1)
  74715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74716. * @param fileName A name for for the downloaded file.
  74717. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74718. */
  74719. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74720. /**
  74721. * Generates an image screenshot from the specified camera.
  74722. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74723. * @param engine The engine to use for rendering
  74724. * @param camera The camera to use for rendering
  74725. * @param size This parameter can be set to a single number or to an object with the
  74726. * following (optional) properties: precision, width, height. If a single number is passed,
  74727. * it will be used for both width and height. If an object is passed, the screenshot size
  74728. * will be derived from the parameters. The precision property is a multiplier allowing
  74729. * rendering at a higher or lower resolution
  74730. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74731. * Check your browser for supported MIME types
  74732. * @param samples Texture samples (default: 1)
  74733. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74734. * @param fileName A name for for the downloaded file.
  74735. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74736. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74737. * to the src parameter of an <img> to display it
  74738. */
  74739. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74740. /**
  74741. * Gets height and width for screenshot size
  74742. * @private
  74743. */
  74744. private static _getScreenshotSize;
  74745. }
  74746. }
  74747. declare module "babylonjs/Misc/dataReader" {
  74748. /**
  74749. * Interface for a data buffer
  74750. */
  74751. export interface IDataBuffer {
  74752. /**
  74753. * Reads bytes from the data buffer.
  74754. * @param byteOffset The byte offset to read
  74755. * @param byteLength The byte length to read
  74756. * @returns A promise that resolves when the bytes are read
  74757. */
  74758. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74759. /**
  74760. * The byte length of the buffer.
  74761. */
  74762. readonly byteLength: number;
  74763. }
  74764. /**
  74765. * Utility class for reading from a data buffer
  74766. */
  74767. export class DataReader {
  74768. /**
  74769. * The data buffer associated with this data reader.
  74770. */
  74771. readonly buffer: IDataBuffer;
  74772. /**
  74773. * The current byte offset from the beginning of the data buffer.
  74774. */
  74775. byteOffset: number;
  74776. private _dataView;
  74777. private _dataByteOffset;
  74778. /**
  74779. * Constructor
  74780. * @param buffer The buffer to read
  74781. */
  74782. constructor(buffer: IDataBuffer);
  74783. /**
  74784. * Loads the given byte length.
  74785. * @param byteLength The byte length to load
  74786. * @returns A promise that resolves when the load is complete
  74787. */
  74788. loadAsync(byteLength: number): Promise<void>;
  74789. /**
  74790. * Read a unsigned 32-bit integer from the currently loaded data range.
  74791. * @returns The 32-bit integer read
  74792. */
  74793. readUint32(): number;
  74794. /**
  74795. * Read a byte array from the currently loaded data range.
  74796. * @param byteLength The byte length to read
  74797. * @returns The byte array read
  74798. */
  74799. readUint8Array(byteLength: number): Uint8Array;
  74800. /**
  74801. * Read a string from the currently loaded data range.
  74802. * @param byteLength The byte length to read
  74803. * @returns The string read
  74804. */
  74805. readString(byteLength: number): string;
  74806. /**
  74807. * Skips the given byte length the currently loaded data range.
  74808. * @param byteLength The byte length to skip
  74809. */
  74810. skipBytes(byteLength: number): void;
  74811. }
  74812. }
  74813. declare module "babylonjs/Misc/dataStorage" {
  74814. /**
  74815. * Class for storing data to local storage if available or in-memory storage otherwise
  74816. */
  74817. export class DataStorage {
  74818. private static _Storage;
  74819. private static _GetStorage;
  74820. /**
  74821. * Reads a string from the data storage
  74822. * @param key The key to read
  74823. * @param defaultValue The value if the key doesn't exist
  74824. * @returns The string value
  74825. */
  74826. static ReadString(key: string, defaultValue: string): string;
  74827. /**
  74828. * Writes a string to the data storage
  74829. * @param key The key to write
  74830. * @param value The value to write
  74831. */
  74832. static WriteString(key: string, value: string): void;
  74833. /**
  74834. * Reads a boolean from the data storage
  74835. * @param key The key to read
  74836. * @param defaultValue The value if the key doesn't exist
  74837. * @returns The boolean value
  74838. */
  74839. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74840. /**
  74841. * Writes a boolean to the data storage
  74842. * @param key The key to write
  74843. * @param value The value to write
  74844. */
  74845. static WriteBoolean(key: string, value: boolean): void;
  74846. /**
  74847. * Reads a number from the data storage
  74848. * @param key The key to read
  74849. * @param defaultValue The value if the key doesn't exist
  74850. * @returns The number value
  74851. */
  74852. static ReadNumber(key: string, defaultValue: number): number;
  74853. /**
  74854. * Writes a number to the data storage
  74855. * @param key The key to write
  74856. * @param value The value to write
  74857. */
  74858. static WriteNumber(key: string, value: number): void;
  74859. }
  74860. }
  74861. declare module "babylonjs/Misc/index" {
  74862. export * from "babylonjs/Misc/andOrNotEvaluator";
  74863. export * from "babylonjs/Misc/assetsManager";
  74864. export * from "babylonjs/Misc/basis";
  74865. export * from "babylonjs/Misc/dds";
  74866. export * from "babylonjs/Misc/decorators";
  74867. export * from "babylonjs/Misc/deferred";
  74868. export * from "babylonjs/Misc/environmentTextureTools";
  74869. export * from "babylonjs/Misc/meshExploder";
  74870. export * from "babylonjs/Misc/filesInput";
  74871. export * from "babylonjs/Misc/HighDynamicRange/index";
  74872. export * from "babylonjs/Misc/khronosTextureContainer";
  74873. export * from "babylonjs/Misc/observable";
  74874. export * from "babylonjs/Misc/performanceMonitor";
  74875. export * from "babylonjs/Misc/promise";
  74876. export * from "babylonjs/Misc/sceneOptimizer";
  74877. export * from "babylonjs/Misc/sceneSerializer";
  74878. export * from "babylonjs/Misc/smartArray";
  74879. export * from "babylonjs/Misc/stringDictionary";
  74880. export * from "babylonjs/Misc/tags";
  74881. export * from "babylonjs/Misc/textureTools";
  74882. export * from "babylonjs/Misc/tga";
  74883. export * from "babylonjs/Misc/tools";
  74884. export * from "babylonjs/Misc/videoRecorder";
  74885. export * from "babylonjs/Misc/virtualJoystick";
  74886. export * from "babylonjs/Misc/workerPool";
  74887. export * from "babylonjs/Misc/logger";
  74888. export * from "babylonjs/Misc/typeStore";
  74889. export * from "babylonjs/Misc/filesInputStore";
  74890. export * from "babylonjs/Misc/deepCopier";
  74891. export * from "babylonjs/Misc/pivotTools";
  74892. export * from "babylonjs/Misc/precisionDate";
  74893. export * from "babylonjs/Misc/screenshotTools";
  74894. export * from "babylonjs/Misc/typeStore";
  74895. export * from "babylonjs/Misc/webRequest";
  74896. export * from "babylonjs/Misc/iInspectable";
  74897. export * from "babylonjs/Misc/brdfTextureTools";
  74898. export * from "babylonjs/Misc/rgbdTextureTools";
  74899. export * from "babylonjs/Misc/gradients";
  74900. export * from "babylonjs/Misc/perfCounter";
  74901. export * from "babylonjs/Misc/fileRequest";
  74902. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74903. export * from "babylonjs/Misc/retryStrategy";
  74904. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74905. export * from "babylonjs/Misc/canvasGenerator";
  74906. export * from "babylonjs/Misc/fileTools";
  74907. export * from "babylonjs/Misc/stringTools";
  74908. export * from "babylonjs/Misc/dataReader";
  74909. export * from "babylonjs/Misc/minMaxReducer";
  74910. export * from "babylonjs/Misc/depthReducer";
  74911. export * from "babylonjs/Misc/dataStorage";
  74912. }
  74913. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74914. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74915. import { Observable } from "babylonjs/Misc/observable";
  74916. import { Matrix } from "babylonjs/Maths/math.vector";
  74917. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74918. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74919. /**
  74920. * Options used for hit testing
  74921. */
  74922. export interface IWebXRLegacyHitTestOptions {
  74923. /**
  74924. * Only test when user interacted with the scene. Default - hit test every frame
  74925. */
  74926. testOnPointerDownOnly?: boolean;
  74927. /**
  74928. * The node to use to transform the local results to world coordinates
  74929. */
  74930. worldParentNode?: TransformNode;
  74931. }
  74932. /**
  74933. * Interface defining the babylon result of raycasting/hit-test
  74934. */
  74935. export interface IWebXRLegacyHitResult {
  74936. /**
  74937. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74938. */
  74939. transformationMatrix: Matrix;
  74940. /**
  74941. * The native hit test result
  74942. */
  74943. xrHitResult: XRHitResult | XRHitTestResult;
  74944. }
  74945. /**
  74946. * The currently-working hit-test module.
  74947. * Hit test (or Ray-casting) is used to interact with the real world.
  74948. * For further information read here - https://github.com/immersive-web/hit-test
  74949. */
  74950. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74951. /**
  74952. * options to use when constructing this feature
  74953. */
  74954. readonly options: IWebXRLegacyHitTestOptions;
  74955. private _direction;
  74956. private _mat;
  74957. private _onSelectEnabled;
  74958. private _origin;
  74959. /**
  74960. * The module's name
  74961. */
  74962. static readonly Name: string;
  74963. /**
  74964. * The (Babylon) version of this module.
  74965. * This is an integer representing the implementation version.
  74966. * This number does not correspond to the WebXR specs version
  74967. */
  74968. static readonly Version: number;
  74969. /**
  74970. * Populated with the last native XR Hit Results
  74971. */
  74972. lastNativeXRHitResults: XRHitResult[];
  74973. /**
  74974. * Triggered when new babylon (transformed) hit test results are available
  74975. */
  74976. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74977. /**
  74978. * Creates a new instance of the (legacy version) hit test feature
  74979. * @param _xrSessionManager an instance of WebXRSessionManager
  74980. * @param options options to use when constructing this feature
  74981. */
  74982. constructor(_xrSessionManager: WebXRSessionManager,
  74983. /**
  74984. * options to use when constructing this feature
  74985. */
  74986. options?: IWebXRLegacyHitTestOptions);
  74987. /**
  74988. * execute a hit test with an XR Ray
  74989. *
  74990. * @param xrSession a native xrSession that will execute this hit test
  74991. * @param xrRay the ray (position and direction) to use for ray-casting
  74992. * @param referenceSpace native XR reference space to use for the hit-test
  74993. * @param filter filter function that will filter the results
  74994. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74995. */
  74996. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74997. /**
  74998. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74999. * @param event the (select) event to use to select with
  75000. * @param referenceSpace the reference space to use for this hit test
  75001. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75002. */
  75003. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75004. /**
  75005. * attach this feature
  75006. * Will usually be called by the features manager
  75007. *
  75008. * @returns true if successful.
  75009. */
  75010. attach(): boolean;
  75011. /**
  75012. * detach this feature.
  75013. * Will usually be called by the features manager
  75014. *
  75015. * @returns true if successful.
  75016. */
  75017. detach(): boolean;
  75018. /**
  75019. * Dispose this feature and all of the resources attached
  75020. */
  75021. dispose(): void;
  75022. protected _onXRFrame(frame: XRFrame): void;
  75023. private _onHitTestResults;
  75024. private _onSelect;
  75025. }
  75026. }
  75027. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  75028. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75029. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75030. import { Observable } from "babylonjs/Misc/observable";
  75031. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  75032. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75033. /**
  75034. * Options used in the plane detector module
  75035. */
  75036. export interface IWebXRPlaneDetectorOptions {
  75037. /**
  75038. * The node to use to transform the local results to world coordinates
  75039. */
  75040. worldParentNode?: TransformNode;
  75041. }
  75042. /**
  75043. * A babylon interface for a WebXR plane.
  75044. * A Plane is actually a polygon, built from N points in space
  75045. *
  75046. * Supported in chrome 79, not supported in canary 81 ATM
  75047. */
  75048. export interface IWebXRPlane {
  75049. /**
  75050. * a babylon-assigned ID for this polygon
  75051. */
  75052. id: number;
  75053. /**
  75054. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75055. */
  75056. polygonDefinition: Array<Vector3>;
  75057. /**
  75058. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75059. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75060. */
  75061. transformationMatrix: Matrix;
  75062. /**
  75063. * the native xr-plane object
  75064. */
  75065. xrPlane: XRPlane;
  75066. }
  75067. /**
  75068. * The plane detector is used to detect planes in the real world when in AR
  75069. * For more information see https://github.com/immersive-web/real-world-geometry/
  75070. */
  75071. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75072. private _options;
  75073. private _detectedPlanes;
  75074. private _enabled;
  75075. private _lastFrameDetected;
  75076. /**
  75077. * The module's name
  75078. */
  75079. static readonly Name: string;
  75080. /**
  75081. * The (Babylon) version of this module.
  75082. * This is an integer representing the implementation version.
  75083. * This number does not correspond to the WebXR specs version
  75084. */
  75085. static readonly Version: number;
  75086. /**
  75087. * Observers registered here will be executed when a new plane was added to the session
  75088. */
  75089. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75090. /**
  75091. * Observers registered here will be executed when a plane is no longer detected in the session
  75092. */
  75093. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75094. /**
  75095. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75096. * This can execute N times every frame
  75097. */
  75098. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75099. /**
  75100. * construct a new Plane Detector
  75101. * @param _xrSessionManager an instance of xr Session manager
  75102. * @param _options configuration to use when constructing this feature
  75103. */
  75104. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75105. /**
  75106. * Dispose this feature and all of the resources attached
  75107. */
  75108. dispose(): void;
  75109. protected _onXRFrame(frame: XRFrame): void;
  75110. private _init;
  75111. private _updatePlaneWithXRPlane;
  75112. /**
  75113. * avoiding using Array.find for global support.
  75114. * @param xrPlane the plane to find in the array
  75115. */
  75116. private findIndexInPlaneArray;
  75117. }
  75118. }
  75119. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  75120. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75121. import { Observable } from "babylonjs/Misc/observable";
  75122. import { Matrix } from "babylonjs/Maths/math.vector";
  75123. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75124. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  75125. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75126. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75127. /**
  75128. * Configuration options of the anchor system
  75129. */
  75130. export interface IWebXRAnchorSystemOptions {
  75131. /**
  75132. * Should a new anchor be added every time a select event is triggered
  75133. */
  75134. addAnchorOnSelect?: boolean;
  75135. /**
  75136. * should the anchor system use plane detection.
  75137. * If set to true, the plane-detection feature should be set using setPlaneDetector
  75138. */
  75139. usePlaneDetection?: boolean;
  75140. /**
  75141. * a node that will be used to convert local to world coordinates
  75142. */
  75143. worldParentNode?: TransformNode;
  75144. }
  75145. /**
  75146. * A babylon container for an XR Anchor
  75147. */
  75148. export interface IWebXRAnchor {
  75149. /**
  75150. * A babylon-assigned ID for this anchor
  75151. */
  75152. id: number;
  75153. /**
  75154. * Transformation matrix to apply to an object attached to this anchor
  75155. */
  75156. transformationMatrix: Matrix;
  75157. /**
  75158. * The native anchor object
  75159. */
  75160. xrAnchor: XRAnchor;
  75161. }
  75162. /**
  75163. * An implementation of the anchor system of WebXR.
  75164. * Note that the current documented implementation is not available in any browser. Future implementations
  75165. * will use the frame to create an anchor and not the session or a detected plane
  75166. * For further information see https://github.com/immersive-web/anchors/
  75167. */
  75168. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75169. private _options;
  75170. private _enabled;
  75171. private _hitTestModule;
  75172. private _lastFrameDetected;
  75173. private _onSelect;
  75174. private _planeDetector;
  75175. private _trackedAnchors;
  75176. /**
  75177. * The module's name
  75178. */
  75179. static readonly Name: string;
  75180. /**
  75181. * The (Babylon) version of this module.
  75182. * This is an integer representing the implementation version.
  75183. * This number does not correspond to the WebXR specs version
  75184. */
  75185. static readonly Version: number;
  75186. /**
  75187. * Observers registered here will be executed when a new anchor was added to the session
  75188. */
  75189. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75190. /**
  75191. * Observers registered here will be executed when an anchor was removed from the session
  75192. */
  75193. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75194. /**
  75195. * Observers registered here will be executed when an existing anchor updates
  75196. * This can execute N times every frame
  75197. */
  75198. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75199. /**
  75200. * constructs a new anchor system
  75201. * @param _xrSessionManager an instance of WebXRSessionManager
  75202. * @param _options configuration object for this feature
  75203. */
  75204. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75205. /**
  75206. * Add anchor at a specific XR point.
  75207. *
  75208. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75209. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75210. * @returns a promise the fulfills when the anchor was created
  75211. */
  75212. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75213. /**
  75214. * attach this feature
  75215. * Will usually be called by the features manager
  75216. *
  75217. * @returns true if successful.
  75218. */
  75219. attach(): boolean;
  75220. /**
  75221. * detach this feature.
  75222. * Will usually be called by the features manager
  75223. *
  75224. * @returns true if successful.
  75225. */
  75226. detach(): boolean;
  75227. /**
  75228. * Dispose this feature and all of the resources attached
  75229. */
  75230. dispose(): void;
  75231. /**
  75232. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75233. * @param hitTestModule the hit-test module to use.
  75234. */
  75235. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75236. /**
  75237. * set the plane detector to use in order to create anchors from frames
  75238. * @param planeDetector the plane-detector module to use
  75239. * @param enable enable plane-anchors. default is true
  75240. */
  75241. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75242. protected _onXRFrame(frame: XRFrame): void;
  75243. /**
  75244. * avoiding using Array.find for global support.
  75245. * @param xrAnchor the plane to find in the array
  75246. */
  75247. private _findIndexInAnchorArray;
  75248. private _updateAnchorWithXRFrame;
  75249. }
  75250. }
  75251. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75252. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75254. import { Observable } from "babylonjs/Misc/observable";
  75255. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75256. /**
  75257. * Options interface for the background remover plugin
  75258. */
  75259. export interface IWebXRBackgroundRemoverOptions {
  75260. /**
  75261. * Further background meshes to disable when entering AR
  75262. */
  75263. backgroundMeshes?: AbstractMesh[];
  75264. /**
  75265. * flags to configure the removal of the environment helper.
  75266. * If not set, the entire background will be removed. If set, flags should be set as well.
  75267. */
  75268. environmentHelperRemovalFlags?: {
  75269. /**
  75270. * Should the skybox be removed (default false)
  75271. */
  75272. skyBox?: boolean;
  75273. /**
  75274. * Should the ground be removed (default false)
  75275. */
  75276. ground?: boolean;
  75277. };
  75278. /**
  75279. * don't disable the environment helper
  75280. */
  75281. ignoreEnvironmentHelper?: boolean;
  75282. }
  75283. /**
  75284. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75285. */
  75286. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75287. /**
  75288. * read-only options to be used in this module
  75289. */
  75290. readonly options: IWebXRBackgroundRemoverOptions;
  75291. /**
  75292. * The module's name
  75293. */
  75294. static readonly Name: string;
  75295. /**
  75296. * The (Babylon) version of this module.
  75297. * This is an integer representing the implementation version.
  75298. * This number does not correspond to the WebXR specs version
  75299. */
  75300. static readonly Version: number;
  75301. /**
  75302. * registered observers will be triggered when the background state changes
  75303. */
  75304. onBackgroundStateChangedObservable: Observable<boolean>;
  75305. /**
  75306. * constructs a new background remover module
  75307. * @param _xrSessionManager the session manager for this module
  75308. * @param options read-only options to be used in this module
  75309. */
  75310. constructor(_xrSessionManager: WebXRSessionManager,
  75311. /**
  75312. * read-only options to be used in this module
  75313. */
  75314. options?: IWebXRBackgroundRemoverOptions);
  75315. /**
  75316. * attach this feature
  75317. * Will usually be called by the features manager
  75318. *
  75319. * @returns true if successful.
  75320. */
  75321. attach(): boolean;
  75322. /**
  75323. * detach this feature.
  75324. * Will usually be called by the features manager
  75325. *
  75326. * @returns true if successful.
  75327. */
  75328. detach(): boolean;
  75329. /**
  75330. * Dispose this feature and all of the resources attached
  75331. */
  75332. dispose(): void;
  75333. protected _onXRFrame(_xrFrame: XRFrame): void;
  75334. private _setBackgroundState;
  75335. }
  75336. }
  75337. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75338. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75339. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75340. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75341. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75342. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75343. import { Nullable } from "babylonjs/types";
  75344. /**
  75345. * Options for the controller physics feature
  75346. */
  75347. export class IWebXRControllerPhysicsOptions {
  75348. /**
  75349. * Should the headset get its own impostor
  75350. */
  75351. enableHeadsetImpostor?: boolean;
  75352. /**
  75353. * Optional parameters for the headset impostor
  75354. */
  75355. headsetImpostorParams?: {
  75356. /**
  75357. * The type of impostor to create. Default is sphere
  75358. */
  75359. impostorType: number;
  75360. /**
  75361. * the size of the impostor. Defaults to 10cm
  75362. */
  75363. impostorSize?: number | {
  75364. width: number;
  75365. height: number;
  75366. depth: number;
  75367. };
  75368. /**
  75369. * Friction definitions
  75370. */
  75371. friction?: number;
  75372. /**
  75373. * Restitution
  75374. */
  75375. restitution?: number;
  75376. };
  75377. /**
  75378. * The physics properties of the future impostors
  75379. */
  75380. physicsProperties?: {
  75381. /**
  75382. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75383. * Note that this requires a physics engine that supports mesh impostors!
  75384. */
  75385. useControllerMesh?: boolean;
  75386. /**
  75387. * The type of impostor to create. Default is sphere
  75388. */
  75389. impostorType?: number;
  75390. /**
  75391. * the size of the impostor. Defaults to 10cm
  75392. */
  75393. impostorSize?: number | {
  75394. width: number;
  75395. height: number;
  75396. depth: number;
  75397. };
  75398. /**
  75399. * Friction definitions
  75400. */
  75401. friction?: number;
  75402. /**
  75403. * Restitution
  75404. */
  75405. restitution?: number;
  75406. };
  75407. /**
  75408. * the xr input to use with this pointer selection
  75409. */
  75410. xrInput: WebXRInput;
  75411. }
  75412. /**
  75413. * Add physics impostor to your webxr controllers,
  75414. * including naive calculation of their linear and angular velocity
  75415. */
  75416. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75417. private readonly _options;
  75418. private _attachController;
  75419. private _controllers;
  75420. private _debugMode;
  75421. private _delta;
  75422. private _headsetImpostor?;
  75423. private _headsetMesh?;
  75424. private _lastTimestamp;
  75425. private _tmpQuaternion;
  75426. private _tmpVector;
  75427. /**
  75428. * The module's name
  75429. */
  75430. static readonly Name: string;
  75431. /**
  75432. * The (Babylon) version of this module.
  75433. * This is an integer representing the implementation version.
  75434. * This number does not correspond to the webxr specs version
  75435. */
  75436. static readonly Version: number;
  75437. /**
  75438. * Construct a new Controller Physics Feature
  75439. * @param _xrSessionManager the corresponding xr session manager
  75440. * @param _options options to create this feature with
  75441. */
  75442. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75443. /**
  75444. * @hidden
  75445. * enable debugging - will show console outputs and the impostor mesh
  75446. */
  75447. _enablePhysicsDebug(): void;
  75448. /**
  75449. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75450. * @param xrController the controller to add
  75451. */
  75452. addController(xrController: WebXRInputSource): void;
  75453. /**
  75454. * attach this feature
  75455. * Will usually be called by the features manager
  75456. *
  75457. * @returns true if successful.
  75458. */
  75459. attach(): boolean;
  75460. /**
  75461. * detach this feature.
  75462. * Will usually be called by the features manager
  75463. *
  75464. * @returns true if successful.
  75465. */
  75466. detach(): boolean;
  75467. /**
  75468. * Get the headset impostor, if enabled
  75469. * @returns the impostor
  75470. */
  75471. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75472. /**
  75473. * Get the physics impostor of a specific controller.
  75474. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75475. * @param controller the controller or the controller id of which to get the impostor
  75476. * @returns the impostor or null
  75477. */
  75478. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75479. /**
  75480. * Update the physics properties provided in the constructor
  75481. * @param newProperties the new properties object
  75482. */
  75483. setPhysicsProperties(newProperties: {
  75484. impostorType?: number;
  75485. impostorSize?: number | {
  75486. width: number;
  75487. height: number;
  75488. depth: number;
  75489. };
  75490. friction?: number;
  75491. restitution?: number;
  75492. }): void;
  75493. protected _onXRFrame(_xrFrame: any): void;
  75494. private _detachController;
  75495. }
  75496. }
  75497. declare module "babylonjs/XR/features/WebXRHitTest" {
  75498. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75499. import { Observable } from "babylonjs/Misc/observable";
  75500. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75501. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75502. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75503. /**
  75504. * Options used for hit testing (version 2)
  75505. */
  75506. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75507. /**
  75508. * Do not create a permanent hit test. Will usually be used when only
  75509. * transient inputs are needed.
  75510. */
  75511. disablePermanentHitTest?: boolean;
  75512. /**
  75513. * Enable transient (for example touch-based) hit test inspections
  75514. */
  75515. enableTransientHitTest?: boolean;
  75516. /**
  75517. * Offset ray for the permanent hit test
  75518. */
  75519. offsetRay?: Vector3;
  75520. /**
  75521. * Offset ray for the transient hit test
  75522. */
  75523. transientOffsetRay?: Vector3;
  75524. /**
  75525. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75526. */
  75527. useReferenceSpace?: boolean;
  75528. }
  75529. /**
  75530. * Interface defining the babylon result of hit-test
  75531. */
  75532. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75533. /**
  75534. * The input source that generated this hit test (if transient)
  75535. */
  75536. inputSource?: XRInputSource;
  75537. /**
  75538. * Is this a transient hit test
  75539. */
  75540. isTransient?: boolean;
  75541. /**
  75542. * Position of the hit test result
  75543. */
  75544. position: Vector3;
  75545. /**
  75546. * Rotation of the hit test result
  75547. */
  75548. rotationQuaternion: Quaternion;
  75549. }
  75550. /**
  75551. * The currently-working hit-test module.
  75552. * Hit test (or Ray-casting) is used to interact with the real world.
  75553. * For further information read here - https://github.com/immersive-web/hit-test
  75554. *
  75555. * Tested on chrome (mobile) 80.
  75556. */
  75557. export class WebXRHitTest extends WebXRAbstractFeature {
  75558. /**
  75559. * options to use when constructing this feature
  75560. */
  75561. readonly options: IWebXRHitTestOptions;
  75562. private _tmpMat;
  75563. private _tmpPos;
  75564. private _tmpQuat;
  75565. private _transientXrHitTestSource;
  75566. private _xrHitTestSource;
  75567. private initHitTestSource;
  75568. /**
  75569. * The module's name
  75570. */
  75571. static readonly Name: string;
  75572. /**
  75573. * The (Babylon) version of this module.
  75574. * This is an integer representing the implementation version.
  75575. * This number does not correspond to the WebXR specs version
  75576. */
  75577. static readonly Version: number;
  75578. /**
  75579. * When set to true, each hit test will have its own position/rotation objects
  75580. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75581. * the developers will clone them or copy them as they see fit.
  75582. */
  75583. autoCloneTransformation: boolean;
  75584. /**
  75585. * Populated with the last native XR Hit Results
  75586. */
  75587. lastNativeXRHitResults: XRHitResult[];
  75588. /**
  75589. * Triggered when new babylon (transformed) hit test results are available
  75590. */
  75591. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75592. /**
  75593. * Use this to temporarily pause hit test checks.
  75594. */
  75595. paused: boolean;
  75596. /**
  75597. * Creates a new instance of the hit test feature
  75598. * @param _xrSessionManager an instance of WebXRSessionManager
  75599. * @param options options to use when constructing this feature
  75600. */
  75601. constructor(_xrSessionManager: WebXRSessionManager,
  75602. /**
  75603. * options to use when constructing this feature
  75604. */
  75605. options?: IWebXRHitTestOptions);
  75606. /**
  75607. * attach this feature
  75608. * Will usually be called by the features manager
  75609. *
  75610. * @returns true if successful.
  75611. */
  75612. attach(): boolean;
  75613. /**
  75614. * detach this feature.
  75615. * Will usually be called by the features manager
  75616. *
  75617. * @returns true if successful.
  75618. */
  75619. detach(): boolean;
  75620. /**
  75621. * Dispose this feature and all of the resources attached
  75622. */
  75623. dispose(): void;
  75624. protected _onXRFrame(frame: XRFrame): void;
  75625. private _processWebXRHitTestResult;
  75626. }
  75627. }
  75628. declare module "babylonjs/XR/features/index" {
  75629. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75630. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75631. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75632. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75633. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75634. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75635. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75636. export * from "babylonjs/XR/features/WebXRHitTest";
  75637. }
  75638. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75639. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75641. import { Scene } from "babylonjs/scene";
  75642. /**
  75643. * The motion controller class for all microsoft mixed reality controllers
  75644. */
  75645. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75646. protected readonly _mapping: {
  75647. defaultButton: {
  75648. valueNodeName: string;
  75649. unpressedNodeName: string;
  75650. pressedNodeName: string;
  75651. };
  75652. defaultAxis: {
  75653. valueNodeName: string;
  75654. minNodeName: string;
  75655. maxNodeName: string;
  75656. };
  75657. buttons: {
  75658. "xr-standard-trigger": {
  75659. rootNodeName: string;
  75660. componentProperty: string;
  75661. states: string[];
  75662. };
  75663. "xr-standard-squeeze": {
  75664. rootNodeName: string;
  75665. componentProperty: string;
  75666. states: string[];
  75667. };
  75668. "xr-standard-touchpad": {
  75669. rootNodeName: string;
  75670. labelAnchorNodeName: string;
  75671. touchPointNodeName: string;
  75672. };
  75673. "xr-standard-thumbstick": {
  75674. rootNodeName: string;
  75675. componentProperty: string;
  75676. states: string[];
  75677. };
  75678. };
  75679. axes: {
  75680. "xr-standard-touchpad": {
  75681. "x-axis": {
  75682. rootNodeName: string;
  75683. };
  75684. "y-axis": {
  75685. rootNodeName: string;
  75686. };
  75687. };
  75688. "xr-standard-thumbstick": {
  75689. "x-axis": {
  75690. rootNodeName: string;
  75691. };
  75692. "y-axis": {
  75693. rootNodeName: string;
  75694. };
  75695. };
  75696. };
  75697. };
  75698. /**
  75699. * The base url used to load the left and right controller models
  75700. */
  75701. static MODEL_BASE_URL: string;
  75702. /**
  75703. * The name of the left controller model file
  75704. */
  75705. static MODEL_LEFT_FILENAME: string;
  75706. /**
  75707. * The name of the right controller model file
  75708. */
  75709. static MODEL_RIGHT_FILENAME: string;
  75710. profileId: string;
  75711. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75712. protected _getFilenameAndPath(): {
  75713. filename: string;
  75714. path: string;
  75715. };
  75716. protected _getModelLoadingConstraints(): boolean;
  75717. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75718. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75719. protected _updateModel(): void;
  75720. }
  75721. }
  75722. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75723. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75725. import { Scene } from "babylonjs/scene";
  75726. /**
  75727. * The motion controller class for oculus touch (quest, rift).
  75728. * This class supports legacy mapping as well the standard xr mapping
  75729. */
  75730. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75731. private _forceLegacyControllers;
  75732. private _modelRootNode;
  75733. /**
  75734. * The base url used to load the left and right controller models
  75735. */
  75736. static MODEL_BASE_URL: string;
  75737. /**
  75738. * The name of the left controller model file
  75739. */
  75740. static MODEL_LEFT_FILENAME: string;
  75741. /**
  75742. * The name of the right controller model file
  75743. */
  75744. static MODEL_RIGHT_FILENAME: string;
  75745. /**
  75746. * Base Url for the Quest controller model.
  75747. */
  75748. static QUEST_MODEL_BASE_URL: string;
  75749. profileId: string;
  75750. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75751. protected _getFilenameAndPath(): {
  75752. filename: string;
  75753. path: string;
  75754. };
  75755. protected _getModelLoadingConstraints(): boolean;
  75756. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75757. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75758. protected _updateModel(): void;
  75759. /**
  75760. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75761. * between the touch and touch 2.
  75762. */
  75763. private _isQuest;
  75764. }
  75765. }
  75766. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75767. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75768. import { Scene } from "babylonjs/scene";
  75769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75770. /**
  75771. * The motion controller class for the standard HTC-Vive controllers
  75772. */
  75773. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75774. private _modelRootNode;
  75775. /**
  75776. * The base url used to load the left and right controller models
  75777. */
  75778. static MODEL_BASE_URL: string;
  75779. /**
  75780. * File name for the controller model.
  75781. */
  75782. static MODEL_FILENAME: string;
  75783. profileId: string;
  75784. /**
  75785. * Create a new Vive motion controller object
  75786. * @param scene the scene to use to create this controller
  75787. * @param gamepadObject the corresponding gamepad object
  75788. * @param handedness the handedness of the controller
  75789. */
  75790. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75791. protected _getFilenameAndPath(): {
  75792. filename: string;
  75793. path: string;
  75794. };
  75795. protected _getModelLoadingConstraints(): boolean;
  75796. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75797. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75798. protected _updateModel(): void;
  75799. }
  75800. }
  75801. declare module "babylonjs/XR/motionController/index" {
  75802. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75803. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75804. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75805. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75806. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75807. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75808. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75809. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75810. }
  75811. declare module "babylonjs/XR/index" {
  75812. export * from "babylonjs/XR/webXRCamera";
  75813. export * from "babylonjs/XR/webXREnterExitUI";
  75814. export * from "babylonjs/XR/webXRExperienceHelper";
  75815. export * from "babylonjs/XR/webXRInput";
  75816. export * from "babylonjs/XR/webXRInputSource";
  75817. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75818. export * from "babylonjs/XR/webXRTypes";
  75819. export * from "babylonjs/XR/webXRSessionManager";
  75820. export * from "babylonjs/XR/webXRDefaultExperience";
  75821. export * from "babylonjs/XR/webXRFeaturesManager";
  75822. export * from "babylonjs/XR/features/index";
  75823. export * from "babylonjs/XR/motionController/index";
  75824. }
  75825. declare module "babylonjs/index" {
  75826. export * from "babylonjs/abstractScene";
  75827. export * from "babylonjs/Actions/index";
  75828. export * from "babylonjs/Animations/index";
  75829. export * from "babylonjs/assetContainer";
  75830. export * from "babylonjs/Audio/index";
  75831. export * from "babylonjs/Behaviors/index";
  75832. export * from "babylonjs/Bones/index";
  75833. export * from "babylonjs/Cameras/index";
  75834. export * from "babylonjs/Collisions/index";
  75835. export * from "babylonjs/Culling/index";
  75836. export * from "babylonjs/Debug/index";
  75837. export * from "babylonjs/DeviceInput/index";
  75838. export * from "babylonjs/Engines/index";
  75839. export * from "babylonjs/Events/index";
  75840. export * from "babylonjs/Gamepads/index";
  75841. export * from "babylonjs/Gizmos/index";
  75842. export * from "babylonjs/Helpers/index";
  75843. export * from "babylonjs/Instrumentation/index";
  75844. export * from "babylonjs/Layers/index";
  75845. export * from "babylonjs/LensFlares/index";
  75846. export * from "babylonjs/Lights/index";
  75847. export * from "babylonjs/Loading/index";
  75848. export * from "babylonjs/Materials/index";
  75849. export * from "babylonjs/Maths/index";
  75850. export * from "babylonjs/Meshes/index";
  75851. export * from "babylonjs/Morph/index";
  75852. export * from "babylonjs/Navigation/index";
  75853. export * from "babylonjs/node";
  75854. export * from "babylonjs/Offline/index";
  75855. export * from "babylonjs/Particles/index";
  75856. export * from "babylonjs/Physics/index";
  75857. export * from "babylonjs/PostProcesses/index";
  75858. export * from "babylonjs/Probes/index";
  75859. export * from "babylonjs/Rendering/index";
  75860. export * from "babylonjs/scene";
  75861. export * from "babylonjs/sceneComponent";
  75862. export * from "babylonjs/Sprites/index";
  75863. export * from "babylonjs/States/index";
  75864. export * from "babylonjs/Misc/index";
  75865. export * from "babylonjs/XR/index";
  75866. export * from "babylonjs/types";
  75867. }
  75868. declare module "babylonjs/Animations/pathCursor" {
  75869. import { Vector3 } from "babylonjs/Maths/math.vector";
  75870. import { Path2 } from "babylonjs/Maths/math.path";
  75871. /**
  75872. * A cursor which tracks a point on a path
  75873. */
  75874. export class PathCursor {
  75875. private path;
  75876. /**
  75877. * Stores path cursor callbacks for when an onchange event is triggered
  75878. */
  75879. private _onchange;
  75880. /**
  75881. * The value of the path cursor
  75882. */
  75883. value: number;
  75884. /**
  75885. * The animation array of the path cursor
  75886. */
  75887. animations: Animation[];
  75888. /**
  75889. * Initializes the path cursor
  75890. * @param path The path to track
  75891. */
  75892. constructor(path: Path2);
  75893. /**
  75894. * Gets the cursor point on the path
  75895. * @returns A point on the path cursor at the cursor location
  75896. */
  75897. getPoint(): Vector3;
  75898. /**
  75899. * Moves the cursor ahead by the step amount
  75900. * @param step The amount to move the cursor forward
  75901. * @returns This path cursor
  75902. */
  75903. moveAhead(step?: number): PathCursor;
  75904. /**
  75905. * Moves the cursor behind by the step amount
  75906. * @param step The amount to move the cursor back
  75907. * @returns This path cursor
  75908. */
  75909. moveBack(step?: number): PathCursor;
  75910. /**
  75911. * Moves the cursor by the step amount
  75912. * If the step amount is greater than one, an exception is thrown
  75913. * @param step The amount to move the cursor
  75914. * @returns This path cursor
  75915. */
  75916. move(step: number): PathCursor;
  75917. /**
  75918. * Ensures that the value is limited between zero and one
  75919. * @returns This path cursor
  75920. */
  75921. private ensureLimits;
  75922. /**
  75923. * Runs onchange callbacks on change (used by the animation engine)
  75924. * @returns This path cursor
  75925. */
  75926. private raiseOnChange;
  75927. /**
  75928. * Executes a function on change
  75929. * @param f A path cursor onchange callback
  75930. * @returns This path cursor
  75931. */
  75932. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75933. }
  75934. }
  75935. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75936. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75937. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75938. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75939. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75940. }
  75941. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75942. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75943. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75944. }
  75945. declare module "babylonjs/Engines/Processors/index" {
  75946. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75947. export * from "babylonjs/Engines/Processors/Expressions/index";
  75948. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75949. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75950. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75951. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75952. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75953. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75954. }
  75955. declare module "babylonjs/Legacy/legacy" {
  75956. import * as Babylon from "babylonjs/index";
  75957. export * from "babylonjs/index";
  75958. }
  75959. declare module "babylonjs/Shaders/blur.fragment" {
  75960. /** @hidden */
  75961. export var blurPixelShader: {
  75962. name: string;
  75963. shader: string;
  75964. };
  75965. }
  75966. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75967. /** @hidden */
  75968. export var pointCloudVertexDeclaration: {
  75969. name: string;
  75970. shader: string;
  75971. };
  75972. }
  75973. declare module "babylonjs" {
  75974. export * from "babylonjs/Legacy/legacy";
  75975. }
  75976. declare module BABYLON {
  75977. /** Alias type for value that can be null */
  75978. export type Nullable<T> = T | null;
  75979. /**
  75980. * Alias type for number that are floats
  75981. * @ignorenaming
  75982. */
  75983. export type float = number;
  75984. /**
  75985. * Alias type for number that are doubles.
  75986. * @ignorenaming
  75987. */
  75988. export type double = number;
  75989. /**
  75990. * Alias type for number that are integer
  75991. * @ignorenaming
  75992. */
  75993. export type int = number;
  75994. /** Alias type for number array or Float32Array */
  75995. export type FloatArray = number[] | Float32Array;
  75996. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  75997. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  75998. /**
  75999. * Alias for types that can be used by a Buffer or VertexBuffer.
  76000. */
  76001. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  76002. /**
  76003. * Alias type for primitive types
  76004. * @ignorenaming
  76005. */
  76006. type Primitive = undefined | null | boolean | string | number | Function;
  76007. /**
  76008. * Type modifier to make all the properties of an object Readonly
  76009. */
  76010. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  76011. /**
  76012. * Type modifier to make all the properties of an object Readonly recursively
  76013. */
  76014. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  76015. /**
  76016. * Type modifier to make object properties readonly.
  76017. */
  76018. export type DeepImmutableObject<T> = {
  76019. readonly [K in keyof T]: DeepImmutable<T[K]>;
  76020. };
  76021. /** @hidden */
  76022. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  76023. }
  76024. }
  76025. declare module BABYLON {
  76026. /**
  76027. * A class serves as a medium between the observable and its observers
  76028. */
  76029. export class EventState {
  76030. /**
  76031. * Create a new EventState
  76032. * @param mask defines the mask associated with this state
  76033. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76034. * @param target defines the original target of the state
  76035. * @param currentTarget defines the current target of the state
  76036. */
  76037. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  76038. /**
  76039. * Initialize the current event state
  76040. * @param mask defines the mask associated with this state
  76041. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76042. * @param target defines the original target of the state
  76043. * @param currentTarget defines the current target of the state
  76044. * @returns the current event state
  76045. */
  76046. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  76047. /**
  76048. * An Observer can set this property to true to prevent subsequent observers of being notified
  76049. */
  76050. skipNextObservers: boolean;
  76051. /**
  76052. * Get the mask value that were used to trigger the event corresponding to this EventState object
  76053. */
  76054. mask: number;
  76055. /**
  76056. * The object that originally notified the event
  76057. */
  76058. target?: any;
  76059. /**
  76060. * The current object in the bubbling phase
  76061. */
  76062. currentTarget?: any;
  76063. /**
  76064. * This will be populated with the return value of the last function that was executed.
  76065. * If it is the first function in the callback chain it will be the event data.
  76066. */
  76067. lastReturnValue?: any;
  76068. }
  76069. /**
  76070. * Represent an Observer registered to a given Observable object.
  76071. */
  76072. export class Observer<T> {
  76073. /**
  76074. * Defines the callback to call when the observer is notified
  76075. */
  76076. callback: (eventData: T, eventState: EventState) => void;
  76077. /**
  76078. * Defines the mask of the observer (used to filter notifications)
  76079. */
  76080. mask: number;
  76081. /**
  76082. * Defines the current scope used to restore the JS context
  76083. */
  76084. scope: any;
  76085. /** @hidden */
  76086. _willBeUnregistered: boolean;
  76087. /**
  76088. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  76089. */
  76090. unregisterOnNextCall: boolean;
  76091. /**
  76092. * Creates a new observer
  76093. * @param callback defines the callback to call when the observer is notified
  76094. * @param mask defines the mask of the observer (used to filter notifications)
  76095. * @param scope defines the current scope used to restore the JS context
  76096. */
  76097. constructor(
  76098. /**
  76099. * Defines the callback to call when the observer is notified
  76100. */
  76101. callback: (eventData: T, eventState: EventState) => void,
  76102. /**
  76103. * Defines the mask of the observer (used to filter notifications)
  76104. */
  76105. mask: number,
  76106. /**
  76107. * Defines the current scope used to restore the JS context
  76108. */
  76109. scope?: any);
  76110. }
  76111. /**
  76112. * Represent a list of observers registered to multiple Observables object.
  76113. */
  76114. export class MultiObserver<T> {
  76115. private _observers;
  76116. private _observables;
  76117. /**
  76118. * Release associated resources
  76119. */
  76120. dispose(): void;
  76121. /**
  76122. * Raise a callback when one of the observable will notify
  76123. * @param observables defines a list of observables to watch
  76124. * @param callback defines the callback to call on notification
  76125. * @param mask defines the mask used to filter notifications
  76126. * @param scope defines the current scope used to restore the JS context
  76127. * @returns the new MultiObserver
  76128. */
  76129. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  76130. }
  76131. /**
  76132. * The Observable class is a simple implementation of the Observable pattern.
  76133. *
  76134. * 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.
  76135. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  76136. * 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).
  76137. * 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.
  76138. */
  76139. export class Observable<T> {
  76140. private _observers;
  76141. private _eventState;
  76142. private _onObserverAdded;
  76143. /**
  76144. * Gets the list of observers
  76145. */
  76146. get observers(): Array<Observer<T>>;
  76147. /**
  76148. * Creates a new observable
  76149. * @param onObserverAdded defines a callback to call when a new observer is added
  76150. */
  76151. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  76152. /**
  76153. * Create a new Observer with the specified callback
  76154. * @param callback the callback that will be executed for that Observer
  76155. * @param mask the mask used to filter observers
  76156. * @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.
  76157. * @param scope optional scope for the callback to be called from
  76158. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  76159. * @returns the new observer created for the callback
  76160. */
  76161. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  76162. /**
  76163. * Create a new Observer with the specified callback and unregisters after the next notification
  76164. * @param callback the callback that will be executed for that Observer
  76165. * @returns the new observer created for the callback
  76166. */
  76167. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  76168. /**
  76169. * Remove an Observer from the Observable object
  76170. * @param observer the instance of the Observer to remove
  76171. * @returns false if it doesn't belong to this Observable
  76172. */
  76173. remove(observer: Nullable<Observer<T>>): boolean;
  76174. /**
  76175. * Remove a callback from the Observable object
  76176. * @param callback the callback to remove
  76177. * @param scope optional scope. If used only the callbacks with this scope will be removed
  76178. * @returns false if it doesn't belong to this Observable
  76179. */
  76180. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  76181. private _deferUnregister;
  76182. private _remove;
  76183. /**
  76184. * Moves the observable to the top of the observer list making it get called first when notified
  76185. * @param observer the observer to move
  76186. */
  76187. makeObserverTopPriority(observer: Observer<T>): void;
  76188. /**
  76189. * Moves the observable to the bottom of the observer list making it get called last when notified
  76190. * @param observer the observer to move
  76191. */
  76192. makeObserverBottomPriority(observer: Observer<T>): void;
  76193. /**
  76194. * Notify all Observers by calling their respective callback with the given data
  76195. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76196. * @param eventData defines the data to send to all observers
  76197. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76198. * @param target defines the original target of the state
  76199. * @param currentTarget defines the current target of the state
  76200. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76201. */
  76202. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76203. /**
  76204. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76205. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76206. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76207. * and it is crucial that all callbacks will be executed.
  76208. * The order of the callbacks is kept, callbacks are not executed parallel.
  76209. *
  76210. * @param eventData The data to be sent to each callback
  76211. * @param mask is used to filter observers defaults to -1
  76212. * @param target defines the callback target (see EventState)
  76213. * @param currentTarget defines he current object in the bubbling phase
  76214. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76215. */
  76216. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76217. /**
  76218. * Notify a specific observer
  76219. * @param observer defines the observer to notify
  76220. * @param eventData defines the data to be sent to each callback
  76221. * @param mask is used to filter observers defaults to -1
  76222. */
  76223. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76224. /**
  76225. * Gets a boolean indicating if the observable has at least one observer
  76226. * @returns true is the Observable has at least one Observer registered
  76227. */
  76228. hasObservers(): boolean;
  76229. /**
  76230. * Clear the list of observers
  76231. */
  76232. clear(): void;
  76233. /**
  76234. * Clone the current observable
  76235. * @returns a new observable
  76236. */
  76237. clone(): Observable<T>;
  76238. /**
  76239. * Does this observable handles observer registered with a given mask
  76240. * @param mask defines the mask to be tested
  76241. * @return whether or not one observer registered with the given mask is handeled
  76242. **/
  76243. hasSpecificMask(mask?: number): boolean;
  76244. }
  76245. }
  76246. declare module BABYLON {
  76247. /**
  76248. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76249. * Babylon.js
  76250. */
  76251. export class DomManagement {
  76252. /**
  76253. * Checks if the window object exists
  76254. * @returns true if the window object exists
  76255. */
  76256. static IsWindowObjectExist(): boolean;
  76257. /**
  76258. * Checks if the navigator object exists
  76259. * @returns true if the navigator object exists
  76260. */
  76261. static IsNavigatorAvailable(): boolean;
  76262. /**
  76263. * Check if the document object exists
  76264. * @returns true if the document object exists
  76265. */
  76266. static IsDocumentAvailable(): boolean;
  76267. /**
  76268. * Extracts text content from a DOM element hierarchy
  76269. * @param element defines the root element
  76270. * @returns a string
  76271. */
  76272. static GetDOMTextContent(element: HTMLElement): string;
  76273. }
  76274. }
  76275. declare module BABYLON {
  76276. /**
  76277. * Logger used througouht the application to allow configuration of
  76278. * the log level required for the messages.
  76279. */
  76280. export class Logger {
  76281. /**
  76282. * No log
  76283. */
  76284. static readonly NoneLogLevel: number;
  76285. /**
  76286. * Only message logs
  76287. */
  76288. static readonly MessageLogLevel: number;
  76289. /**
  76290. * Only warning logs
  76291. */
  76292. static readonly WarningLogLevel: number;
  76293. /**
  76294. * Only error logs
  76295. */
  76296. static readonly ErrorLogLevel: number;
  76297. /**
  76298. * All logs
  76299. */
  76300. static readonly AllLogLevel: number;
  76301. private static _LogCache;
  76302. /**
  76303. * Gets a value indicating the number of loading errors
  76304. * @ignorenaming
  76305. */
  76306. static errorsCount: number;
  76307. /**
  76308. * Callback called when a new log is added
  76309. */
  76310. static OnNewCacheEntry: (entry: string) => void;
  76311. private static _AddLogEntry;
  76312. private static _FormatMessage;
  76313. private static _LogDisabled;
  76314. private static _LogEnabled;
  76315. private static _WarnDisabled;
  76316. private static _WarnEnabled;
  76317. private static _ErrorDisabled;
  76318. private static _ErrorEnabled;
  76319. /**
  76320. * Log a message to the console
  76321. */
  76322. static Log: (message: string) => void;
  76323. /**
  76324. * Write a warning message to the console
  76325. */
  76326. static Warn: (message: string) => void;
  76327. /**
  76328. * Write an error message to the console
  76329. */
  76330. static Error: (message: string) => void;
  76331. /**
  76332. * Gets current log cache (list of logs)
  76333. */
  76334. static get LogCache(): string;
  76335. /**
  76336. * Clears the log cache
  76337. */
  76338. static ClearLogCache(): void;
  76339. /**
  76340. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76341. */
  76342. static set LogLevels(level: number);
  76343. }
  76344. }
  76345. declare module BABYLON {
  76346. /** @hidden */
  76347. export class _TypeStore {
  76348. /** @hidden */
  76349. static RegisteredTypes: {
  76350. [key: string]: Object;
  76351. };
  76352. /** @hidden */
  76353. static GetClass(fqdn: string): any;
  76354. }
  76355. }
  76356. declare module BABYLON {
  76357. /**
  76358. * Helper to manipulate strings
  76359. */
  76360. export class StringTools {
  76361. /**
  76362. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76363. * @param str Source string
  76364. * @param suffix Suffix to search for in the source string
  76365. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76366. */
  76367. static EndsWith(str: string, suffix: string): boolean;
  76368. /**
  76369. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76370. * @param str Source string
  76371. * @param suffix Suffix to search for in the source string
  76372. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76373. */
  76374. static StartsWith(str: string, suffix: string): boolean;
  76375. /**
  76376. * Decodes a buffer into a string
  76377. * @param buffer The buffer to decode
  76378. * @returns The decoded string
  76379. */
  76380. static Decode(buffer: Uint8Array | Uint16Array): string;
  76381. /**
  76382. * Encode a buffer to a base64 string
  76383. * @param buffer defines the buffer to encode
  76384. * @returns the encoded string
  76385. */
  76386. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76387. /**
  76388. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76389. * @param num the number to convert and pad
  76390. * @param length the expected length of the string
  76391. * @returns the padded string
  76392. */
  76393. static PadNumber(num: number, length: number): string;
  76394. }
  76395. }
  76396. declare module BABYLON {
  76397. /**
  76398. * Class containing a set of static utilities functions for deep copy.
  76399. */
  76400. export class DeepCopier {
  76401. /**
  76402. * Tries to copy an object by duplicating every property
  76403. * @param source defines the source object
  76404. * @param destination defines the target object
  76405. * @param doNotCopyList defines a list of properties to avoid
  76406. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76407. */
  76408. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76409. }
  76410. }
  76411. declare module BABYLON {
  76412. /**
  76413. * Class containing a set of static utilities functions for precision date
  76414. */
  76415. export class PrecisionDate {
  76416. /**
  76417. * Gets either window.performance.now() if supported or Date.now() else
  76418. */
  76419. static get Now(): number;
  76420. }
  76421. }
  76422. declare module BABYLON {
  76423. /** @hidden */
  76424. export class _DevTools {
  76425. static WarnImport(name: string): string;
  76426. }
  76427. }
  76428. declare module BABYLON {
  76429. /**
  76430. * Interface used to define the mechanism to get data from the network
  76431. */
  76432. export interface IWebRequest {
  76433. /**
  76434. * Returns client's response url
  76435. */
  76436. responseURL: string;
  76437. /**
  76438. * Returns client's status
  76439. */
  76440. status: number;
  76441. /**
  76442. * Returns client's status as a text
  76443. */
  76444. statusText: string;
  76445. }
  76446. }
  76447. declare module BABYLON {
  76448. /**
  76449. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76450. */
  76451. export class WebRequest implements IWebRequest {
  76452. private _xhr;
  76453. /**
  76454. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76455. * i.e. when loading files, where the server/service expects an Authorization header
  76456. */
  76457. static CustomRequestHeaders: {
  76458. [key: string]: string;
  76459. };
  76460. /**
  76461. * Add callback functions in this array to update all the requests before they get sent to the network
  76462. */
  76463. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76464. private _injectCustomRequestHeaders;
  76465. /**
  76466. * Gets or sets a function to be called when loading progress changes
  76467. */
  76468. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76469. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76470. /**
  76471. * Returns client's state
  76472. */
  76473. get readyState(): number;
  76474. /**
  76475. * Returns client's status
  76476. */
  76477. get status(): number;
  76478. /**
  76479. * Returns client's status as a text
  76480. */
  76481. get statusText(): string;
  76482. /**
  76483. * Returns client's response
  76484. */
  76485. get response(): any;
  76486. /**
  76487. * Returns client's response url
  76488. */
  76489. get responseURL(): string;
  76490. /**
  76491. * Returns client's response as text
  76492. */
  76493. get responseText(): string;
  76494. /**
  76495. * Gets or sets the expected response type
  76496. */
  76497. get responseType(): XMLHttpRequestResponseType;
  76498. set responseType(value: XMLHttpRequestResponseType);
  76499. /** @hidden */
  76500. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76501. /** @hidden */
  76502. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76503. /**
  76504. * Cancels any network activity
  76505. */
  76506. abort(): void;
  76507. /**
  76508. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76509. * @param body defines an optional request body
  76510. */
  76511. send(body?: Document | BodyInit | null): void;
  76512. /**
  76513. * Sets the request method, request URL
  76514. * @param method defines the method to use (GET, POST, etc..)
  76515. * @param url defines the url to connect with
  76516. */
  76517. open(method: string, url: string): void;
  76518. /**
  76519. * Sets the value of a request header.
  76520. * @param name The name of the header whose value is to be set
  76521. * @param value The value to set as the body of the header
  76522. */
  76523. setRequestHeader(name: string, value: string): void;
  76524. /**
  76525. * Get the string containing the text of a particular header's value.
  76526. * @param name The name of the header
  76527. * @returns The string containing the text of the given header name
  76528. */
  76529. getResponseHeader(name: string): Nullable<string>;
  76530. }
  76531. }
  76532. declare module BABYLON {
  76533. /**
  76534. * File request interface
  76535. */
  76536. export interface IFileRequest {
  76537. /**
  76538. * Raised when the request is complete (success or error).
  76539. */
  76540. onCompleteObservable: Observable<IFileRequest>;
  76541. /**
  76542. * Aborts the request for a file.
  76543. */
  76544. abort: () => void;
  76545. }
  76546. }
  76547. declare module BABYLON {
  76548. /**
  76549. * Define options used to create a render target texture
  76550. */
  76551. export class RenderTargetCreationOptions {
  76552. /**
  76553. * Specifies is mipmaps must be generated
  76554. */
  76555. generateMipMaps?: boolean;
  76556. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76557. generateDepthBuffer?: boolean;
  76558. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76559. generateStencilBuffer?: boolean;
  76560. /** Defines texture type (int by default) */
  76561. type?: number;
  76562. /** Defines sampling mode (trilinear by default) */
  76563. samplingMode?: number;
  76564. /** Defines format (RGBA by default) */
  76565. format?: number;
  76566. }
  76567. }
  76568. declare module BABYLON {
  76569. /** Defines the cross module used constants to avoid circular dependncies */
  76570. export class Constants {
  76571. /** Defines that alpha blending is disabled */
  76572. static readonly ALPHA_DISABLE: number;
  76573. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76574. static readonly ALPHA_ADD: number;
  76575. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76576. static readonly ALPHA_COMBINE: number;
  76577. /** Defines that alpha blending is DEST - SRC * DEST */
  76578. static readonly ALPHA_SUBTRACT: number;
  76579. /** Defines that alpha blending is SRC * DEST */
  76580. static readonly ALPHA_MULTIPLY: number;
  76581. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76582. static readonly ALPHA_MAXIMIZED: number;
  76583. /** Defines that alpha blending is SRC + DEST */
  76584. static readonly ALPHA_ONEONE: number;
  76585. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76586. static readonly ALPHA_PREMULTIPLIED: number;
  76587. /**
  76588. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76589. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76590. */
  76591. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76592. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76593. static readonly ALPHA_INTERPOLATE: number;
  76594. /**
  76595. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76596. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76597. */
  76598. static readonly ALPHA_SCREENMODE: number;
  76599. /**
  76600. * Defines that alpha blending is SRC + DST
  76601. * Alpha will be set to SRC ALPHA + DST ALPHA
  76602. */
  76603. static readonly ALPHA_ONEONE_ONEONE: number;
  76604. /**
  76605. * Defines that alpha blending is SRC * DST ALPHA + DST
  76606. * Alpha will be set to 0
  76607. */
  76608. static readonly ALPHA_ALPHATOCOLOR: number;
  76609. /**
  76610. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76611. */
  76612. static readonly ALPHA_REVERSEONEMINUS: number;
  76613. /**
  76614. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76615. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76616. */
  76617. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76618. /**
  76619. * Defines that alpha blending is SRC + DST
  76620. * Alpha will be set to SRC ALPHA
  76621. */
  76622. static readonly ALPHA_ONEONE_ONEZERO: number;
  76623. /**
  76624. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76625. * Alpha will be set to DST ALPHA
  76626. */
  76627. static readonly ALPHA_EXCLUSION: number;
  76628. /** Defines that alpha blending equation a SUM */
  76629. static readonly ALPHA_EQUATION_ADD: number;
  76630. /** Defines that alpha blending equation a SUBSTRACTION */
  76631. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76632. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76633. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76634. /** Defines that alpha blending equation a MAX operation */
  76635. static readonly ALPHA_EQUATION_MAX: number;
  76636. /** Defines that alpha blending equation a MIN operation */
  76637. static readonly ALPHA_EQUATION_MIN: number;
  76638. /**
  76639. * Defines that alpha blending equation a DARKEN operation:
  76640. * It takes the min of the src and sums the alpha channels.
  76641. */
  76642. static readonly ALPHA_EQUATION_DARKEN: number;
  76643. /** Defines that the ressource is not delayed*/
  76644. static readonly DELAYLOADSTATE_NONE: number;
  76645. /** Defines that the ressource was successfully delay loaded */
  76646. static readonly DELAYLOADSTATE_LOADED: number;
  76647. /** Defines that the ressource is currently delay loading */
  76648. static readonly DELAYLOADSTATE_LOADING: number;
  76649. /** Defines that the ressource is delayed and has not started loading */
  76650. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76651. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76652. static readonly NEVER: number;
  76653. /** 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 */
  76654. static readonly ALWAYS: number;
  76655. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76656. static readonly LESS: number;
  76657. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76658. static readonly EQUAL: number;
  76659. /** 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 */
  76660. static readonly LEQUAL: number;
  76661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76662. static readonly GREATER: number;
  76663. /** 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 */
  76664. static readonly GEQUAL: number;
  76665. /** 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 */
  76666. static readonly NOTEQUAL: number;
  76667. /** Passed to stencilOperation to specify that stencil value must be kept */
  76668. static readonly KEEP: number;
  76669. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76670. static readonly REPLACE: number;
  76671. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76672. static readonly INCR: number;
  76673. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76674. static readonly DECR: number;
  76675. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76676. static readonly INVERT: number;
  76677. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76678. static readonly INCR_WRAP: number;
  76679. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76680. static readonly DECR_WRAP: number;
  76681. /** Texture is not repeating outside of 0..1 UVs */
  76682. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76683. /** Texture is repeating outside of 0..1 UVs */
  76684. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76685. /** Texture is repeating and mirrored */
  76686. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76687. /** ALPHA */
  76688. static readonly TEXTUREFORMAT_ALPHA: number;
  76689. /** LUMINANCE */
  76690. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76691. /** LUMINANCE_ALPHA */
  76692. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76693. /** RGB */
  76694. static readonly TEXTUREFORMAT_RGB: number;
  76695. /** RGBA */
  76696. static readonly TEXTUREFORMAT_RGBA: number;
  76697. /** RED */
  76698. static readonly TEXTUREFORMAT_RED: number;
  76699. /** RED (2nd reference) */
  76700. static readonly TEXTUREFORMAT_R: number;
  76701. /** RG */
  76702. static readonly TEXTUREFORMAT_RG: number;
  76703. /** RED_INTEGER */
  76704. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76705. /** RED_INTEGER (2nd reference) */
  76706. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76707. /** RG_INTEGER */
  76708. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76709. /** RGB_INTEGER */
  76710. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76711. /** RGBA_INTEGER */
  76712. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76713. /** UNSIGNED_BYTE */
  76714. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76715. /** UNSIGNED_BYTE (2nd reference) */
  76716. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76717. /** FLOAT */
  76718. static readonly TEXTURETYPE_FLOAT: number;
  76719. /** HALF_FLOAT */
  76720. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76721. /** BYTE */
  76722. static readonly TEXTURETYPE_BYTE: number;
  76723. /** SHORT */
  76724. static readonly TEXTURETYPE_SHORT: number;
  76725. /** UNSIGNED_SHORT */
  76726. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76727. /** INT */
  76728. static readonly TEXTURETYPE_INT: number;
  76729. /** UNSIGNED_INT */
  76730. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76731. /** UNSIGNED_SHORT_4_4_4_4 */
  76732. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76733. /** UNSIGNED_SHORT_5_5_5_1 */
  76734. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76735. /** UNSIGNED_SHORT_5_6_5 */
  76736. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76737. /** UNSIGNED_INT_2_10_10_10_REV */
  76738. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76739. /** UNSIGNED_INT_24_8 */
  76740. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76741. /** UNSIGNED_INT_10F_11F_11F_REV */
  76742. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76743. /** UNSIGNED_INT_5_9_9_9_REV */
  76744. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76745. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76746. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76747. /** nearest is mag = nearest and min = nearest and no mip */
  76748. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76749. /** mag = nearest and min = nearest and mip = none */
  76750. static readonly TEXTURE_NEAREST_NEAREST: number;
  76751. /** Bilinear is mag = linear and min = linear and no mip */
  76752. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76753. /** mag = linear and min = linear and mip = none */
  76754. static readonly TEXTURE_LINEAR_LINEAR: number;
  76755. /** Trilinear is mag = linear and min = linear and mip = linear */
  76756. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76757. /** Trilinear is mag = linear and min = linear and mip = linear */
  76758. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76759. /** mag = nearest and min = nearest and mip = nearest */
  76760. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76761. /** mag = nearest and min = linear and mip = nearest */
  76762. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76763. /** mag = nearest and min = linear and mip = linear */
  76764. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76765. /** mag = nearest and min = linear and mip = none */
  76766. static readonly TEXTURE_NEAREST_LINEAR: number;
  76767. /** nearest is mag = nearest and min = nearest and mip = linear */
  76768. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76769. /** mag = linear and min = nearest and mip = nearest */
  76770. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76771. /** mag = linear and min = nearest and mip = linear */
  76772. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76774. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76775. /** mag = linear and min = nearest and mip = none */
  76776. static readonly TEXTURE_LINEAR_NEAREST: number;
  76777. /** Explicit coordinates mode */
  76778. static readonly TEXTURE_EXPLICIT_MODE: number;
  76779. /** Spherical coordinates mode */
  76780. static readonly TEXTURE_SPHERICAL_MODE: number;
  76781. /** Planar coordinates mode */
  76782. static readonly TEXTURE_PLANAR_MODE: number;
  76783. /** Cubic coordinates mode */
  76784. static readonly TEXTURE_CUBIC_MODE: number;
  76785. /** Projection coordinates mode */
  76786. static readonly TEXTURE_PROJECTION_MODE: number;
  76787. /** Skybox coordinates mode */
  76788. static readonly TEXTURE_SKYBOX_MODE: number;
  76789. /** Inverse Cubic coordinates mode */
  76790. static readonly TEXTURE_INVCUBIC_MODE: number;
  76791. /** Equirectangular coordinates mode */
  76792. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76793. /** Equirectangular Fixed coordinates mode */
  76794. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76795. /** Equirectangular Fixed Mirrored coordinates mode */
  76796. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76797. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76798. static readonly SCALEMODE_FLOOR: number;
  76799. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76800. static readonly SCALEMODE_NEAREST: number;
  76801. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76802. static readonly SCALEMODE_CEILING: number;
  76803. /**
  76804. * The dirty texture flag value
  76805. */
  76806. static readonly MATERIAL_TextureDirtyFlag: number;
  76807. /**
  76808. * The dirty light flag value
  76809. */
  76810. static readonly MATERIAL_LightDirtyFlag: number;
  76811. /**
  76812. * The dirty fresnel flag value
  76813. */
  76814. static readonly MATERIAL_FresnelDirtyFlag: number;
  76815. /**
  76816. * The dirty attribute flag value
  76817. */
  76818. static readonly MATERIAL_AttributesDirtyFlag: number;
  76819. /**
  76820. * The dirty misc flag value
  76821. */
  76822. static readonly MATERIAL_MiscDirtyFlag: number;
  76823. /**
  76824. * The all dirty flag value
  76825. */
  76826. static readonly MATERIAL_AllDirtyFlag: number;
  76827. /**
  76828. * Returns the triangle fill mode
  76829. */
  76830. static readonly MATERIAL_TriangleFillMode: number;
  76831. /**
  76832. * Returns the wireframe mode
  76833. */
  76834. static readonly MATERIAL_WireFrameFillMode: number;
  76835. /**
  76836. * Returns the point fill mode
  76837. */
  76838. static readonly MATERIAL_PointFillMode: number;
  76839. /**
  76840. * Returns the point list draw mode
  76841. */
  76842. static readonly MATERIAL_PointListDrawMode: number;
  76843. /**
  76844. * Returns the line list draw mode
  76845. */
  76846. static readonly MATERIAL_LineListDrawMode: number;
  76847. /**
  76848. * Returns the line loop draw mode
  76849. */
  76850. static readonly MATERIAL_LineLoopDrawMode: number;
  76851. /**
  76852. * Returns the line strip draw mode
  76853. */
  76854. static readonly MATERIAL_LineStripDrawMode: number;
  76855. /**
  76856. * Returns the triangle strip draw mode
  76857. */
  76858. static readonly MATERIAL_TriangleStripDrawMode: number;
  76859. /**
  76860. * Returns the triangle fan draw mode
  76861. */
  76862. static readonly MATERIAL_TriangleFanDrawMode: number;
  76863. /**
  76864. * Stores the clock-wise side orientation
  76865. */
  76866. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76867. /**
  76868. * Stores the counter clock-wise side orientation
  76869. */
  76870. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76871. /**
  76872. * Nothing
  76873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76874. */
  76875. static readonly ACTION_NothingTrigger: number;
  76876. /**
  76877. * On pick
  76878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76879. */
  76880. static readonly ACTION_OnPickTrigger: number;
  76881. /**
  76882. * On left pick
  76883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76884. */
  76885. static readonly ACTION_OnLeftPickTrigger: number;
  76886. /**
  76887. * On right pick
  76888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76889. */
  76890. static readonly ACTION_OnRightPickTrigger: number;
  76891. /**
  76892. * On center pick
  76893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76894. */
  76895. static readonly ACTION_OnCenterPickTrigger: number;
  76896. /**
  76897. * On pick down
  76898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76899. */
  76900. static readonly ACTION_OnPickDownTrigger: number;
  76901. /**
  76902. * On double pick
  76903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76904. */
  76905. static readonly ACTION_OnDoublePickTrigger: number;
  76906. /**
  76907. * On pick up
  76908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76909. */
  76910. static readonly ACTION_OnPickUpTrigger: number;
  76911. /**
  76912. * On pick out.
  76913. * This trigger will only be raised if you also declared a OnPickDown
  76914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76915. */
  76916. static readonly ACTION_OnPickOutTrigger: number;
  76917. /**
  76918. * On long press
  76919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76920. */
  76921. static readonly ACTION_OnLongPressTrigger: number;
  76922. /**
  76923. * On pointer over
  76924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76925. */
  76926. static readonly ACTION_OnPointerOverTrigger: number;
  76927. /**
  76928. * On pointer out
  76929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76930. */
  76931. static readonly ACTION_OnPointerOutTrigger: number;
  76932. /**
  76933. * On every frame
  76934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76935. */
  76936. static readonly ACTION_OnEveryFrameTrigger: number;
  76937. /**
  76938. * On intersection enter
  76939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76940. */
  76941. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76942. /**
  76943. * On intersection exit
  76944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76945. */
  76946. static readonly ACTION_OnIntersectionExitTrigger: number;
  76947. /**
  76948. * On key down
  76949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76950. */
  76951. static readonly ACTION_OnKeyDownTrigger: number;
  76952. /**
  76953. * On key up
  76954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76955. */
  76956. static readonly ACTION_OnKeyUpTrigger: number;
  76957. /**
  76958. * Billboard mode will only apply to Y axis
  76959. */
  76960. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76961. /**
  76962. * Billboard mode will apply to all axes
  76963. */
  76964. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76965. /**
  76966. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76967. */
  76968. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  76969. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76970. * Test order :
  76971. * Is the bounding sphere outside the frustum ?
  76972. * If not, are the bounding box vertices outside the frustum ?
  76973. * It not, then the cullable object is in the frustum.
  76974. */
  76975. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  76976. /** Culling strategy : Bounding Sphere Only.
  76977. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76978. * It's also less accurate than the standard because some not visible objects can still be selected.
  76979. * Test : is the bounding sphere outside the frustum ?
  76980. * If not, then the cullable object is in the frustum.
  76981. */
  76982. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  76983. /** Culling strategy : Optimistic Inclusion.
  76984. * This in an inclusion test first, then the standard exclusion test.
  76985. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76986. * 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.
  76987. * Anyway, it's as accurate as the standard strategy.
  76988. * Test :
  76989. * Is the cullable object bounding sphere center in the frustum ?
  76990. * If not, apply the default culling strategy.
  76991. */
  76992. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  76993. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76994. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76995. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76996. * 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.
  76997. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76998. * Test :
  76999. * Is the cullable object bounding sphere center in the frustum ?
  77000. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  77001. */
  77002. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  77003. /**
  77004. * No logging while loading
  77005. */
  77006. static readonly SCENELOADER_NO_LOGGING: number;
  77007. /**
  77008. * Minimal logging while loading
  77009. */
  77010. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  77011. /**
  77012. * Summary logging while loading
  77013. */
  77014. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  77015. /**
  77016. * Detailled logging while loading
  77017. */
  77018. static readonly SCENELOADER_DETAILED_LOGGING: number;
  77019. }
  77020. }
  77021. declare module BABYLON {
  77022. /**
  77023. * This represents the required contract to create a new type of texture loader.
  77024. */
  77025. export interface IInternalTextureLoader {
  77026. /**
  77027. * Defines wether the loader supports cascade loading the different faces.
  77028. */
  77029. supportCascades: boolean;
  77030. /**
  77031. * This returns if the loader support the current file information.
  77032. * @param extension defines the file extension of the file being loaded
  77033. * @returns true if the loader can load the specified file
  77034. */
  77035. canLoad(extension: string): boolean;
  77036. /**
  77037. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  77038. * @param data contains the texture data
  77039. * @param texture defines the BabylonJS internal texture
  77040. * @param createPolynomials will be true if polynomials have been requested
  77041. * @param onLoad defines the callback to trigger once the texture is ready
  77042. * @param onError defines the callback to trigger in case of error
  77043. */
  77044. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  77045. /**
  77046. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  77047. * @param data contains the texture data
  77048. * @param texture defines the BabylonJS internal texture
  77049. * @param callback defines the method to call once ready to upload
  77050. */
  77051. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  77052. }
  77053. }
  77054. declare module BABYLON {
  77055. /**
  77056. * Class used to store and describe the pipeline context associated with an effect
  77057. */
  77058. export interface IPipelineContext {
  77059. /**
  77060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  77061. */
  77062. isAsync: boolean;
  77063. /**
  77064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  77065. */
  77066. isReady: boolean;
  77067. /** @hidden */
  77068. _getVertexShaderCode(): string | null;
  77069. /** @hidden */
  77070. _getFragmentShaderCode(): string | null;
  77071. /** @hidden */
  77072. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  77073. }
  77074. }
  77075. declare module BABYLON {
  77076. /**
  77077. * Class used to store gfx data (like WebGLBuffer)
  77078. */
  77079. export class DataBuffer {
  77080. /**
  77081. * Gets or sets the number of objects referencing this buffer
  77082. */
  77083. references: number;
  77084. /** Gets or sets the size of the underlying buffer */
  77085. capacity: number;
  77086. /**
  77087. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  77088. */
  77089. is32Bits: boolean;
  77090. /**
  77091. * Gets the underlying buffer
  77092. */
  77093. get underlyingResource(): any;
  77094. }
  77095. }
  77096. declare module BABYLON {
  77097. /** @hidden */
  77098. export interface IShaderProcessor {
  77099. attributeProcessor?: (attribute: string) => string;
  77100. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  77101. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  77102. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  77103. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  77104. lineProcessor?: (line: string, isFragment: boolean) => string;
  77105. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77106. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  77107. }
  77108. }
  77109. declare module BABYLON {
  77110. /** @hidden */
  77111. export interface ProcessingOptions {
  77112. defines: string[];
  77113. indexParameters: any;
  77114. isFragment: boolean;
  77115. shouldUseHighPrecisionShader: boolean;
  77116. supportsUniformBuffers: boolean;
  77117. shadersRepository: string;
  77118. includesShadersStore: {
  77119. [key: string]: string;
  77120. };
  77121. processor?: IShaderProcessor;
  77122. version: string;
  77123. platformName: string;
  77124. lookForClosingBracketForUniformBuffer?: boolean;
  77125. }
  77126. }
  77127. declare module BABYLON {
  77128. /** @hidden */
  77129. export class ShaderCodeNode {
  77130. line: string;
  77131. children: ShaderCodeNode[];
  77132. additionalDefineKey?: string;
  77133. additionalDefineValue?: string;
  77134. isValid(preprocessors: {
  77135. [key: string]: string;
  77136. }): boolean;
  77137. process(preprocessors: {
  77138. [key: string]: string;
  77139. }, options: ProcessingOptions): string;
  77140. }
  77141. }
  77142. declare module BABYLON {
  77143. /** @hidden */
  77144. export class ShaderCodeCursor {
  77145. private _lines;
  77146. lineIndex: number;
  77147. get currentLine(): string;
  77148. get canRead(): boolean;
  77149. set lines(value: string[]);
  77150. }
  77151. }
  77152. declare module BABYLON {
  77153. /** @hidden */
  77154. export class ShaderCodeConditionNode extends ShaderCodeNode {
  77155. process(preprocessors: {
  77156. [key: string]: string;
  77157. }, options: ProcessingOptions): string;
  77158. }
  77159. }
  77160. declare module BABYLON {
  77161. /** @hidden */
  77162. export class ShaderDefineExpression {
  77163. isTrue(preprocessors: {
  77164. [key: string]: string;
  77165. }): boolean;
  77166. private static _OperatorPriority;
  77167. private static _Stack;
  77168. static postfixToInfix(postfix: string[]): string;
  77169. static infixToPostfix(infix: string): string[];
  77170. }
  77171. }
  77172. declare module BABYLON {
  77173. /** @hidden */
  77174. export class ShaderCodeTestNode extends ShaderCodeNode {
  77175. testExpression: ShaderDefineExpression;
  77176. isValid(preprocessors: {
  77177. [key: string]: string;
  77178. }): boolean;
  77179. }
  77180. }
  77181. declare module BABYLON {
  77182. /** @hidden */
  77183. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77184. define: string;
  77185. not: boolean;
  77186. constructor(define: string, not?: boolean);
  77187. isTrue(preprocessors: {
  77188. [key: string]: string;
  77189. }): boolean;
  77190. }
  77191. }
  77192. declare module BABYLON {
  77193. /** @hidden */
  77194. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77195. leftOperand: ShaderDefineExpression;
  77196. rightOperand: ShaderDefineExpression;
  77197. isTrue(preprocessors: {
  77198. [key: string]: string;
  77199. }): boolean;
  77200. }
  77201. }
  77202. declare module BABYLON {
  77203. /** @hidden */
  77204. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77205. leftOperand: ShaderDefineExpression;
  77206. rightOperand: ShaderDefineExpression;
  77207. isTrue(preprocessors: {
  77208. [key: string]: string;
  77209. }): boolean;
  77210. }
  77211. }
  77212. declare module BABYLON {
  77213. /** @hidden */
  77214. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77215. define: string;
  77216. operand: string;
  77217. testValue: string;
  77218. constructor(define: string, operand: string, testValue: string);
  77219. isTrue(preprocessors: {
  77220. [key: string]: string;
  77221. }): boolean;
  77222. }
  77223. }
  77224. declare module BABYLON {
  77225. /**
  77226. * Class used to enable access to offline support
  77227. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77228. */
  77229. export interface IOfflineProvider {
  77230. /**
  77231. * Gets a boolean indicating if scene must be saved in the database
  77232. */
  77233. enableSceneOffline: boolean;
  77234. /**
  77235. * Gets a boolean indicating if textures must be saved in the database
  77236. */
  77237. enableTexturesOffline: boolean;
  77238. /**
  77239. * Open the offline support and make it available
  77240. * @param successCallback defines the callback to call on success
  77241. * @param errorCallback defines the callback to call on error
  77242. */
  77243. open(successCallback: () => void, errorCallback: () => void): void;
  77244. /**
  77245. * Loads an image from the offline support
  77246. * @param url defines the url to load from
  77247. * @param image defines the target DOM image
  77248. */
  77249. loadImage(url: string, image: HTMLImageElement): void;
  77250. /**
  77251. * Loads a file from offline support
  77252. * @param url defines the URL to load from
  77253. * @param sceneLoaded defines a callback to call on success
  77254. * @param progressCallBack defines a callback to call when progress changed
  77255. * @param errorCallback defines a callback to call on error
  77256. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77257. */
  77258. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77259. }
  77260. }
  77261. declare module BABYLON {
  77262. /**
  77263. * Class used to help managing file picking and drag'n'drop
  77264. * File Storage
  77265. */
  77266. export class FilesInputStore {
  77267. /**
  77268. * List of files ready to be loaded
  77269. */
  77270. static FilesToLoad: {
  77271. [key: string]: File;
  77272. };
  77273. }
  77274. }
  77275. declare module BABYLON {
  77276. /**
  77277. * Class used to define a retry strategy when error happens while loading assets
  77278. */
  77279. export class RetryStrategy {
  77280. /**
  77281. * Function used to defines an exponential back off strategy
  77282. * @param maxRetries defines the maximum number of retries (3 by default)
  77283. * @param baseInterval defines the interval between retries
  77284. * @returns the strategy function to use
  77285. */
  77286. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77287. }
  77288. }
  77289. declare module BABYLON {
  77290. /**
  77291. * @ignore
  77292. * Application error to support additional information when loading a file
  77293. */
  77294. export abstract class BaseError extends Error {
  77295. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77296. }
  77297. }
  77298. declare module BABYLON {
  77299. /** @ignore */
  77300. export class LoadFileError extends BaseError {
  77301. request?: WebRequest;
  77302. file?: File;
  77303. /**
  77304. * Creates a new LoadFileError
  77305. * @param message defines the message of the error
  77306. * @param request defines the optional web request
  77307. * @param file defines the optional file
  77308. */
  77309. constructor(message: string, object?: WebRequest | File);
  77310. }
  77311. /** @ignore */
  77312. export class RequestFileError extends BaseError {
  77313. request: WebRequest;
  77314. /**
  77315. * Creates a new LoadFileError
  77316. * @param message defines the message of the error
  77317. * @param request defines the optional web request
  77318. */
  77319. constructor(message: string, request: WebRequest);
  77320. }
  77321. /** @ignore */
  77322. export class ReadFileError extends BaseError {
  77323. file: File;
  77324. /**
  77325. * Creates a new ReadFileError
  77326. * @param message defines the message of the error
  77327. * @param file defines the optional file
  77328. */
  77329. constructor(message: string, file: File);
  77330. }
  77331. /**
  77332. * @hidden
  77333. */
  77334. export class FileTools {
  77335. /**
  77336. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77337. */
  77338. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77339. /**
  77340. * Gets or sets the base URL to use to load assets
  77341. */
  77342. static BaseUrl: string;
  77343. /**
  77344. * Default behaviour for cors in the application.
  77345. * It can be a string if the expected behavior is identical in the entire app.
  77346. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77347. */
  77348. static CorsBehavior: string | ((url: string | string[]) => string);
  77349. /**
  77350. * Gets or sets a function used to pre-process url before using them to load assets
  77351. */
  77352. static PreprocessUrl: (url: string) => string;
  77353. /**
  77354. * Removes unwanted characters from an url
  77355. * @param url defines the url to clean
  77356. * @returns the cleaned url
  77357. */
  77358. private static _CleanUrl;
  77359. /**
  77360. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77361. * @param url define the url we are trying
  77362. * @param element define the dom element where to configure the cors policy
  77363. */
  77364. static SetCorsBehavior(url: string | string[], element: {
  77365. crossOrigin: string | null;
  77366. }): void;
  77367. /**
  77368. * Loads an image as an HTMLImageElement.
  77369. * @param input url string, ArrayBuffer, or Blob to load
  77370. * @param onLoad callback called when the image successfully loads
  77371. * @param onError callback called when the image fails to load
  77372. * @param offlineProvider offline provider for caching
  77373. * @param mimeType optional mime type
  77374. * @returns the HTMLImageElement of the loaded image
  77375. */
  77376. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  77377. /**
  77378. * Reads a file from a File object
  77379. * @param file defines the file to load
  77380. * @param onSuccess defines the callback to call when data is loaded
  77381. * @param onProgress defines the callback to call during loading process
  77382. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77383. * @param onError defines the callback to call when an error occurs
  77384. * @returns a file request object
  77385. */
  77386. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77387. /**
  77388. * Loads a file from a url
  77389. * @param url url to load
  77390. * @param onSuccess callback called when the file successfully loads
  77391. * @param onProgress callback called while file is loading (if the server supports this mode)
  77392. * @param offlineProvider defines the offline provider for caching
  77393. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77394. * @param onError callback called when the file fails to load
  77395. * @returns a file request object
  77396. */
  77397. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  77398. /**
  77399. * Loads a file
  77400. * @param url url to load
  77401. * @param onSuccess callback called when the file successfully loads
  77402. * @param onProgress callback called while file is loading (if the server supports this mode)
  77403. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77404. * @param onError callback called when the file fails to load
  77405. * @param onOpened callback called when the web request is opened
  77406. * @returns a file request object
  77407. */
  77408. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  77409. /**
  77410. * Checks if the loaded document was accessed via `file:`-Protocol.
  77411. * @returns boolean
  77412. */
  77413. static IsFileURL(): boolean;
  77414. }
  77415. }
  77416. declare module BABYLON {
  77417. /** @hidden */
  77418. export class ShaderProcessor {
  77419. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77420. private static _ProcessPrecision;
  77421. private static _ExtractOperation;
  77422. private static _BuildSubExpression;
  77423. private static _BuildExpression;
  77424. private static _MoveCursorWithinIf;
  77425. private static _MoveCursor;
  77426. private static _EvaluatePreProcessors;
  77427. private static _PreparePreProcessors;
  77428. private static _ProcessShaderConversion;
  77429. private static _ProcessIncludes;
  77430. /**
  77431. * Loads a file from a url
  77432. * @param url url to load
  77433. * @param onSuccess callback called when the file successfully loads
  77434. * @param onProgress callback called while file is loading (if the server supports this mode)
  77435. * @param offlineProvider defines the offline provider for caching
  77436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77437. * @param onError callback called when the file fails to load
  77438. * @returns a file request object
  77439. * @hidden
  77440. */
  77441. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  77442. }
  77443. }
  77444. declare module BABYLON {
  77445. /**
  77446. * @hidden
  77447. */
  77448. export interface IColor4Like {
  77449. r: float;
  77450. g: float;
  77451. b: float;
  77452. a: float;
  77453. }
  77454. /**
  77455. * @hidden
  77456. */
  77457. export interface IColor3Like {
  77458. r: float;
  77459. g: float;
  77460. b: float;
  77461. }
  77462. /**
  77463. * @hidden
  77464. */
  77465. export interface IVector4Like {
  77466. x: float;
  77467. y: float;
  77468. z: float;
  77469. w: float;
  77470. }
  77471. /**
  77472. * @hidden
  77473. */
  77474. export interface IVector3Like {
  77475. x: float;
  77476. y: float;
  77477. z: float;
  77478. }
  77479. /**
  77480. * @hidden
  77481. */
  77482. export interface IVector2Like {
  77483. x: float;
  77484. y: float;
  77485. }
  77486. /**
  77487. * @hidden
  77488. */
  77489. export interface IMatrixLike {
  77490. toArray(): DeepImmutable<Float32Array>;
  77491. updateFlag: int;
  77492. }
  77493. /**
  77494. * @hidden
  77495. */
  77496. export interface IViewportLike {
  77497. x: float;
  77498. y: float;
  77499. width: float;
  77500. height: float;
  77501. }
  77502. /**
  77503. * @hidden
  77504. */
  77505. export interface IPlaneLike {
  77506. normal: IVector3Like;
  77507. d: float;
  77508. normalize(): void;
  77509. }
  77510. }
  77511. declare module BABYLON {
  77512. /**
  77513. * Interface used to define common properties for effect fallbacks
  77514. */
  77515. export interface IEffectFallbacks {
  77516. /**
  77517. * Removes the defines that should be removed when falling back.
  77518. * @param currentDefines defines the current define statements for the shader.
  77519. * @param effect defines the current effect we try to compile
  77520. * @returns The resulting defines with defines of the current rank removed.
  77521. */
  77522. reduce(currentDefines: string, effect: Effect): string;
  77523. /**
  77524. * Removes the fallback from the bound mesh.
  77525. */
  77526. unBindMesh(): void;
  77527. /**
  77528. * Checks to see if more fallbacks are still availible.
  77529. */
  77530. hasMoreFallbacks: boolean;
  77531. }
  77532. }
  77533. declare module BABYLON {
  77534. /**
  77535. * Class used to evalaute queries containing `and` and `or` operators
  77536. */
  77537. export class AndOrNotEvaluator {
  77538. /**
  77539. * Evaluate a query
  77540. * @param query defines the query to evaluate
  77541. * @param evaluateCallback defines the callback used to filter result
  77542. * @returns true if the query matches
  77543. */
  77544. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77545. private static _HandleParenthesisContent;
  77546. private static _SimplifyNegation;
  77547. }
  77548. }
  77549. declare module BABYLON {
  77550. /**
  77551. * Class used to store custom tags
  77552. */
  77553. export class Tags {
  77554. /**
  77555. * Adds support for tags on the given object
  77556. * @param obj defines the object to use
  77557. */
  77558. static EnableFor(obj: any): void;
  77559. /**
  77560. * Removes tags support
  77561. * @param obj defines the object to use
  77562. */
  77563. static DisableFor(obj: any): void;
  77564. /**
  77565. * Gets a boolean indicating if the given object has tags
  77566. * @param obj defines the object to use
  77567. * @returns a boolean
  77568. */
  77569. static HasTags(obj: any): boolean;
  77570. /**
  77571. * Gets the tags available on a given object
  77572. * @param obj defines the object to use
  77573. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77574. * @returns the tags
  77575. */
  77576. static GetTags(obj: any, asString?: boolean): any;
  77577. /**
  77578. * Adds tags to an object
  77579. * @param obj defines the object to use
  77580. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77581. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77582. */
  77583. static AddTagsTo(obj: any, tagsString: string): void;
  77584. /**
  77585. * @hidden
  77586. */
  77587. static _AddTagTo(obj: any, tag: string): void;
  77588. /**
  77589. * Removes specific tags from a specific object
  77590. * @param obj defines the object to use
  77591. * @param tagsString defines the tags to remove
  77592. */
  77593. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77594. /**
  77595. * @hidden
  77596. */
  77597. static _RemoveTagFrom(obj: any, tag: string): void;
  77598. /**
  77599. * Defines if tags hosted on an object match a given query
  77600. * @param obj defines the object to use
  77601. * @param tagsQuery defines the tag query
  77602. * @returns a boolean
  77603. */
  77604. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77605. }
  77606. }
  77607. declare module BABYLON {
  77608. /**
  77609. * Scalar computation library
  77610. */
  77611. export class Scalar {
  77612. /**
  77613. * Two pi constants convenient for computation.
  77614. */
  77615. static TwoPi: number;
  77616. /**
  77617. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77618. * @param a number
  77619. * @param b number
  77620. * @param epsilon (default = 1.401298E-45)
  77621. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77622. */
  77623. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77624. /**
  77625. * Returns a string : the upper case translation of the number i to hexadecimal.
  77626. * @param i number
  77627. * @returns the upper case translation of the number i to hexadecimal.
  77628. */
  77629. static ToHex(i: number): string;
  77630. /**
  77631. * Returns -1 if value is negative and +1 is value is positive.
  77632. * @param value the value
  77633. * @returns the value itself if it's equal to zero.
  77634. */
  77635. static Sign(value: number): number;
  77636. /**
  77637. * Returns the value itself if it's between min and max.
  77638. * Returns min if the value is lower than min.
  77639. * Returns max if the value is greater than max.
  77640. * @param value the value to clmap
  77641. * @param min the min value to clamp to (default: 0)
  77642. * @param max the max value to clamp to (default: 1)
  77643. * @returns the clamped value
  77644. */
  77645. static Clamp(value: number, min?: number, max?: number): number;
  77646. /**
  77647. * the log2 of value.
  77648. * @param value the value to compute log2 of
  77649. * @returns the log2 of value.
  77650. */
  77651. static Log2(value: number): number;
  77652. /**
  77653. * Loops the value, so that it is never larger than length and never smaller than 0.
  77654. *
  77655. * This is similar to the modulo operator but it works with floating point numbers.
  77656. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77657. * With t = 5 and length = 2.5, the result would be 0.0.
  77658. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77659. * @param value the value
  77660. * @param length the length
  77661. * @returns the looped value
  77662. */
  77663. static Repeat(value: number, length: number): number;
  77664. /**
  77665. * Normalize the value between 0.0 and 1.0 using min and max values
  77666. * @param value value to normalize
  77667. * @param min max to normalize between
  77668. * @param max min to normalize between
  77669. * @returns the normalized value
  77670. */
  77671. static Normalize(value: number, min: number, max: number): number;
  77672. /**
  77673. * Denormalize the value from 0.0 and 1.0 using min and max values
  77674. * @param normalized value to denormalize
  77675. * @param min max to denormalize between
  77676. * @param max min to denormalize between
  77677. * @returns the denormalized value
  77678. */
  77679. static Denormalize(normalized: number, min: number, max: number): number;
  77680. /**
  77681. * Calculates the shortest difference between two given angles given in degrees.
  77682. * @param current current angle in degrees
  77683. * @param target target angle in degrees
  77684. * @returns the delta
  77685. */
  77686. static DeltaAngle(current: number, target: number): number;
  77687. /**
  77688. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77689. * @param tx value
  77690. * @param length length
  77691. * @returns The returned value will move back and forth between 0 and length
  77692. */
  77693. static PingPong(tx: number, length: number): number;
  77694. /**
  77695. * Interpolates between min and max with smoothing at the limits.
  77696. *
  77697. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77698. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77699. * @param from from
  77700. * @param to to
  77701. * @param tx value
  77702. * @returns the smooth stepped value
  77703. */
  77704. static SmoothStep(from: number, to: number, tx: number): number;
  77705. /**
  77706. * Moves a value current towards target.
  77707. *
  77708. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77709. * Negative values of maxDelta pushes the value away from target.
  77710. * @param current current value
  77711. * @param target target value
  77712. * @param maxDelta max distance to move
  77713. * @returns resulting value
  77714. */
  77715. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77716. /**
  77717. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77718. *
  77719. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77720. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77721. * @param current current value
  77722. * @param target target value
  77723. * @param maxDelta max distance to move
  77724. * @returns resulting angle
  77725. */
  77726. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77727. /**
  77728. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77729. * @param start start value
  77730. * @param end target value
  77731. * @param amount amount to lerp between
  77732. * @returns the lerped value
  77733. */
  77734. static Lerp(start: number, end: number, amount: number): number;
  77735. /**
  77736. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77737. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77738. * @param start start value
  77739. * @param end target value
  77740. * @param amount amount to lerp between
  77741. * @returns the lerped value
  77742. */
  77743. static LerpAngle(start: number, end: number, amount: number): number;
  77744. /**
  77745. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77746. * @param a start value
  77747. * @param b target value
  77748. * @param value value between a and b
  77749. * @returns the inverseLerp value
  77750. */
  77751. static InverseLerp(a: number, b: number, value: number): number;
  77752. /**
  77753. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77754. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77755. * @param value1 spline value
  77756. * @param tangent1 spline value
  77757. * @param value2 spline value
  77758. * @param tangent2 spline value
  77759. * @param amount input value
  77760. * @returns hermite result
  77761. */
  77762. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77763. /**
  77764. * Returns a random float number between and min and max values
  77765. * @param min min value of random
  77766. * @param max max value of random
  77767. * @returns random value
  77768. */
  77769. static RandomRange(min: number, max: number): number;
  77770. /**
  77771. * This function returns percentage of a number in a given range.
  77772. *
  77773. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77774. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77775. * @param number to convert to percentage
  77776. * @param min min range
  77777. * @param max max range
  77778. * @returns the percentage
  77779. */
  77780. static RangeToPercent(number: number, min: number, max: number): number;
  77781. /**
  77782. * This function returns number that corresponds to the percentage in a given range.
  77783. *
  77784. * PercentToRange(0.34,0,100) will return 34.
  77785. * @param percent to convert to number
  77786. * @param min min range
  77787. * @param max max range
  77788. * @returns the number
  77789. */
  77790. static PercentToRange(percent: number, min: number, max: number): number;
  77791. /**
  77792. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77793. * @param angle The angle to normalize in radian.
  77794. * @return The converted angle.
  77795. */
  77796. static NormalizeRadians(angle: number): number;
  77797. }
  77798. }
  77799. declare module BABYLON {
  77800. /**
  77801. * Constant used to convert a value to gamma space
  77802. * @ignorenaming
  77803. */
  77804. export const ToGammaSpace: number;
  77805. /**
  77806. * Constant used to convert a value to linear space
  77807. * @ignorenaming
  77808. */
  77809. export const ToLinearSpace = 2.2;
  77810. /**
  77811. * Constant used to define the minimal number value in Babylon.js
  77812. * @ignorenaming
  77813. */
  77814. let Epsilon: number;
  77815. }
  77816. declare module BABYLON {
  77817. /**
  77818. * Class used to represent a viewport on screen
  77819. */
  77820. export class Viewport {
  77821. /** viewport left coordinate */
  77822. x: number;
  77823. /** viewport top coordinate */
  77824. y: number;
  77825. /**viewport width */
  77826. width: number;
  77827. /** viewport height */
  77828. height: number;
  77829. /**
  77830. * Creates a Viewport object located at (x, y) and sized (width, height)
  77831. * @param x defines viewport left coordinate
  77832. * @param y defines viewport top coordinate
  77833. * @param width defines the viewport width
  77834. * @param height defines the viewport height
  77835. */
  77836. constructor(
  77837. /** viewport left coordinate */
  77838. x: number,
  77839. /** viewport top coordinate */
  77840. y: number,
  77841. /**viewport width */
  77842. width: number,
  77843. /** viewport height */
  77844. height: number);
  77845. /**
  77846. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77847. * @param renderWidth defines the rendering width
  77848. * @param renderHeight defines the rendering height
  77849. * @returns a new Viewport
  77850. */
  77851. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77852. /**
  77853. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77854. * @param renderWidth defines the rendering width
  77855. * @param renderHeight defines the rendering height
  77856. * @param ref defines the target viewport
  77857. * @returns the current viewport
  77858. */
  77859. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77860. /**
  77861. * Returns a new Viewport copied from the current one
  77862. * @returns a new Viewport
  77863. */
  77864. clone(): Viewport;
  77865. }
  77866. }
  77867. declare module BABYLON {
  77868. /**
  77869. * Class containing a set of static utilities functions for arrays.
  77870. */
  77871. export class ArrayTools {
  77872. /**
  77873. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77874. * @param size the number of element to construct and put in the array
  77875. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77876. * @returns a new array filled with new objects
  77877. */
  77878. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77879. }
  77880. }
  77881. declare module BABYLON {
  77882. /**
  77883. * Represens a plane by the equation ax + by + cz + d = 0
  77884. */
  77885. export class Plane {
  77886. private static _TmpMatrix;
  77887. /**
  77888. * Normal of the plane (a,b,c)
  77889. */
  77890. normal: Vector3;
  77891. /**
  77892. * d component of the plane
  77893. */
  77894. d: number;
  77895. /**
  77896. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77897. * @param a a component of the plane
  77898. * @param b b component of the plane
  77899. * @param c c component of the plane
  77900. * @param d d component of the plane
  77901. */
  77902. constructor(a: number, b: number, c: number, d: number);
  77903. /**
  77904. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77905. */
  77906. asArray(): number[];
  77907. /**
  77908. * @returns a new plane copied from the current Plane.
  77909. */
  77910. clone(): Plane;
  77911. /**
  77912. * @returns the string "Plane".
  77913. */
  77914. getClassName(): string;
  77915. /**
  77916. * @returns the Plane hash code.
  77917. */
  77918. getHashCode(): number;
  77919. /**
  77920. * Normalize the current Plane in place.
  77921. * @returns the updated Plane.
  77922. */
  77923. normalize(): Plane;
  77924. /**
  77925. * Applies a transformation the plane and returns the result
  77926. * @param transformation the transformation matrix to be applied to the plane
  77927. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77928. */
  77929. transform(transformation: DeepImmutable<Matrix>): Plane;
  77930. /**
  77931. * Compute the dot product between the point and the plane normal
  77932. * @param point point to calculate the dot product with
  77933. * @returns the dot product (float) of the point coordinates and the plane normal.
  77934. */
  77935. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77936. /**
  77937. * Updates the current Plane from the plane defined by the three given points.
  77938. * @param point1 one of the points used to contruct the plane
  77939. * @param point2 one of the points used to contruct the plane
  77940. * @param point3 one of the points used to contruct the plane
  77941. * @returns the updated Plane.
  77942. */
  77943. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77944. /**
  77945. * Checks if the plane is facing a given direction
  77946. * @param direction the direction to check if the plane is facing
  77947. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77948. * @returns True is the vector "direction" is the same side than the plane normal.
  77949. */
  77950. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77951. /**
  77952. * Calculates the distance to a point
  77953. * @param point point to calculate distance to
  77954. * @returns the signed distance (float) from the given point to the Plane.
  77955. */
  77956. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77957. /**
  77958. * Creates a plane from an array
  77959. * @param array the array to create a plane from
  77960. * @returns a new Plane from the given array.
  77961. */
  77962. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77963. /**
  77964. * Creates a plane from three points
  77965. * @param point1 point used to create the plane
  77966. * @param point2 point used to create the plane
  77967. * @param point3 point used to create the plane
  77968. * @returns a new Plane defined by the three given points.
  77969. */
  77970. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77971. /**
  77972. * Creates a plane from an origin point and a normal
  77973. * @param origin origin of the plane to be constructed
  77974. * @param normal normal of the plane to be constructed
  77975. * @returns a new Plane the normal vector to this plane at the given origin point.
  77976. * Note : the vector "normal" is updated because normalized.
  77977. */
  77978. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77979. /**
  77980. * Calculates the distance from a plane and a point
  77981. * @param origin origin of the plane to be constructed
  77982. * @param normal normal of the plane to be constructed
  77983. * @param point point to calculate distance to
  77984. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77985. */
  77986. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77987. }
  77988. }
  77989. declare module BABYLON {
  77990. /**
  77991. * Class representing a vector containing 2 coordinates
  77992. */
  77993. export class Vector2 {
  77994. /** defines the first coordinate */
  77995. x: number;
  77996. /** defines the second coordinate */
  77997. y: number;
  77998. /**
  77999. * Creates a new Vector2 from the given x and y coordinates
  78000. * @param x defines the first coordinate
  78001. * @param y defines the second coordinate
  78002. */
  78003. constructor(
  78004. /** defines the first coordinate */
  78005. x?: number,
  78006. /** defines the second coordinate */
  78007. y?: number);
  78008. /**
  78009. * Gets a string with the Vector2 coordinates
  78010. * @returns a string with the Vector2 coordinates
  78011. */
  78012. toString(): string;
  78013. /**
  78014. * Gets class name
  78015. * @returns the string "Vector2"
  78016. */
  78017. getClassName(): string;
  78018. /**
  78019. * Gets current vector hash code
  78020. * @returns the Vector2 hash code as a number
  78021. */
  78022. getHashCode(): number;
  78023. /**
  78024. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  78025. * @param array defines the source array
  78026. * @param index defines the offset in source array
  78027. * @returns the current Vector2
  78028. */
  78029. toArray(array: FloatArray, index?: number): Vector2;
  78030. /**
  78031. * Copy the current vector to an array
  78032. * @returns a new array with 2 elements: the Vector2 coordinates.
  78033. */
  78034. asArray(): number[];
  78035. /**
  78036. * Sets the Vector2 coordinates with the given Vector2 coordinates
  78037. * @param source defines the source Vector2
  78038. * @returns the current updated Vector2
  78039. */
  78040. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  78041. /**
  78042. * Sets the Vector2 coordinates with the given floats
  78043. * @param x defines the first coordinate
  78044. * @param y defines the second coordinate
  78045. * @returns the current updated Vector2
  78046. */
  78047. copyFromFloats(x: number, y: number): Vector2;
  78048. /**
  78049. * Sets the Vector2 coordinates with the given floats
  78050. * @param x defines the first coordinate
  78051. * @param y defines the second coordinate
  78052. * @returns the current updated Vector2
  78053. */
  78054. set(x: number, y: number): Vector2;
  78055. /**
  78056. * Add another vector with the current one
  78057. * @param otherVector defines the other vector
  78058. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  78059. */
  78060. add(otherVector: DeepImmutable<Vector2>): Vector2;
  78061. /**
  78062. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  78063. * @param otherVector defines the other vector
  78064. * @param result defines the target vector
  78065. * @returns the unmodified current Vector2
  78066. */
  78067. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78068. /**
  78069. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  78070. * @param otherVector defines the other vector
  78071. * @returns the current updated Vector2
  78072. */
  78073. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78074. /**
  78075. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  78076. * @param otherVector defines the other vector
  78077. * @returns a new Vector2
  78078. */
  78079. addVector3(otherVector: Vector3): Vector2;
  78080. /**
  78081. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  78082. * @param otherVector defines the other vector
  78083. * @returns a new Vector2
  78084. */
  78085. subtract(otherVector: Vector2): Vector2;
  78086. /**
  78087. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  78088. * @param otherVector defines the other vector
  78089. * @param result defines the target vector
  78090. * @returns the unmodified current Vector2
  78091. */
  78092. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78093. /**
  78094. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  78095. * @param otherVector defines the other vector
  78096. * @returns the current updated Vector2
  78097. */
  78098. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78099. /**
  78100. * Multiplies in place the current Vector2 coordinates by the given ones
  78101. * @param otherVector defines the other vector
  78102. * @returns the current updated Vector2
  78103. */
  78104. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78105. /**
  78106. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  78107. * @param otherVector defines the other vector
  78108. * @returns a new Vector2
  78109. */
  78110. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  78111. /**
  78112. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  78113. * @param otherVector defines the other vector
  78114. * @param result defines the target vector
  78115. * @returns the unmodified current Vector2
  78116. */
  78117. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78118. /**
  78119. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  78120. * @param x defines the first coordinate
  78121. * @param y defines the second coordinate
  78122. * @returns a new Vector2
  78123. */
  78124. multiplyByFloats(x: number, y: number): Vector2;
  78125. /**
  78126. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  78127. * @param otherVector defines the other vector
  78128. * @returns a new Vector2
  78129. */
  78130. divide(otherVector: Vector2): Vector2;
  78131. /**
  78132. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  78133. * @param otherVector defines the other vector
  78134. * @param result defines the target vector
  78135. * @returns the unmodified current Vector2
  78136. */
  78137. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  78138. /**
  78139. * Divides the current Vector2 coordinates by the given ones
  78140. * @param otherVector defines the other vector
  78141. * @returns the current updated Vector2
  78142. */
  78143. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  78144. /**
  78145. * Gets a new Vector2 with current Vector2 negated coordinates
  78146. * @returns a new Vector2
  78147. */
  78148. negate(): Vector2;
  78149. /**
  78150. * Negate this vector in place
  78151. * @returns this
  78152. */
  78153. negateInPlace(): Vector2;
  78154. /**
  78155. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  78156. * @param result defines the Vector3 object where to store the result
  78157. * @returns the current Vector2
  78158. */
  78159. negateToRef(result: Vector2): Vector2;
  78160. /**
  78161. * Multiply the Vector2 coordinates by scale
  78162. * @param scale defines the scaling factor
  78163. * @returns the current updated Vector2
  78164. */
  78165. scaleInPlace(scale: number): Vector2;
  78166. /**
  78167. * Returns a new Vector2 scaled by "scale" from the current Vector2
  78168. * @param scale defines the scaling factor
  78169. * @returns a new Vector2
  78170. */
  78171. scale(scale: number): Vector2;
  78172. /**
  78173. * Scale the current Vector2 values by a factor to a given Vector2
  78174. * @param scale defines the scale factor
  78175. * @param result defines the Vector2 object where to store the result
  78176. * @returns the unmodified current Vector2
  78177. */
  78178. scaleToRef(scale: number, result: Vector2): Vector2;
  78179. /**
  78180. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  78181. * @param scale defines the scale factor
  78182. * @param result defines the Vector2 object where to store the result
  78183. * @returns the unmodified current Vector2
  78184. */
  78185. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78186. /**
  78187. * Gets a boolean if two vectors are equals
  78188. * @param otherVector defines the other vector
  78189. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78190. */
  78191. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78192. /**
  78193. * Gets a boolean if two vectors are equals (using an epsilon value)
  78194. * @param otherVector defines the other vector
  78195. * @param epsilon defines the minimal distance to consider equality
  78196. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78197. */
  78198. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78199. /**
  78200. * Gets a new Vector2 from current Vector2 floored values
  78201. * @returns a new Vector2
  78202. */
  78203. floor(): Vector2;
  78204. /**
  78205. * Gets a new Vector2 from current Vector2 floored values
  78206. * @returns a new Vector2
  78207. */
  78208. fract(): Vector2;
  78209. /**
  78210. * Gets the length of the vector
  78211. * @returns the vector length (float)
  78212. */
  78213. length(): number;
  78214. /**
  78215. * Gets the vector squared length
  78216. * @returns the vector squared length (float)
  78217. */
  78218. lengthSquared(): number;
  78219. /**
  78220. * Normalize the vector
  78221. * @returns the current updated Vector2
  78222. */
  78223. normalize(): Vector2;
  78224. /**
  78225. * Gets a new Vector2 copied from the Vector2
  78226. * @returns a new Vector2
  78227. */
  78228. clone(): Vector2;
  78229. /**
  78230. * Gets a new Vector2(0, 0)
  78231. * @returns a new Vector2
  78232. */
  78233. static Zero(): Vector2;
  78234. /**
  78235. * Gets a new Vector2(1, 1)
  78236. * @returns a new Vector2
  78237. */
  78238. static One(): Vector2;
  78239. /**
  78240. * Gets a new Vector2 set from the given index element of the given array
  78241. * @param array defines the data source
  78242. * @param offset defines the offset in the data source
  78243. * @returns a new Vector2
  78244. */
  78245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78246. /**
  78247. * Sets "result" from the given index element of the given array
  78248. * @param array defines the data source
  78249. * @param offset defines the offset in the data source
  78250. * @param result defines the target vector
  78251. */
  78252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78253. /**
  78254. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78255. * @param value1 defines 1st point of control
  78256. * @param value2 defines 2nd point of control
  78257. * @param value3 defines 3rd point of control
  78258. * @param value4 defines 4th point of control
  78259. * @param amount defines the interpolation factor
  78260. * @returns a new Vector2
  78261. */
  78262. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78263. /**
  78264. * 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".
  78265. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78266. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78267. * @param value defines the value to clamp
  78268. * @param min defines the lower limit
  78269. * @param max defines the upper limit
  78270. * @returns a new Vector2
  78271. */
  78272. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78273. /**
  78274. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78275. * @param value1 defines the 1st control point
  78276. * @param tangent1 defines the outgoing tangent
  78277. * @param value2 defines the 2nd control point
  78278. * @param tangent2 defines the incoming tangent
  78279. * @param amount defines the interpolation factor
  78280. * @returns a new Vector2
  78281. */
  78282. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78283. /**
  78284. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78285. * @param start defines the start vector
  78286. * @param end defines the end vector
  78287. * @param amount defines the interpolation factor
  78288. * @returns a new Vector2
  78289. */
  78290. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78291. /**
  78292. * Gets the dot product of the vector "left" and the vector "right"
  78293. * @param left defines first vector
  78294. * @param right defines second vector
  78295. * @returns the dot product (float)
  78296. */
  78297. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78298. /**
  78299. * Returns a new Vector2 equal to the normalized given vector
  78300. * @param vector defines the vector to normalize
  78301. * @returns a new Vector2
  78302. */
  78303. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78304. /**
  78305. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78306. * @param left defines 1st vector
  78307. * @param right defines 2nd vector
  78308. * @returns a new Vector2
  78309. */
  78310. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78311. /**
  78312. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78313. * @param left defines 1st vector
  78314. * @param right defines 2nd vector
  78315. * @returns a new Vector2
  78316. */
  78317. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78318. /**
  78319. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78320. * @param vector defines the vector to transform
  78321. * @param transformation defines the matrix to apply
  78322. * @returns a new Vector2
  78323. */
  78324. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78325. /**
  78326. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78327. * @param vector defines the vector to transform
  78328. * @param transformation defines the matrix to apply
  78329. * @param result defines the target vector
  78330. */
  78331. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78332. /**
  78333. * Determines if a given vector is included in a triangle
  78334. * @param p defines the vector to test
  78335. * @param p0 defines 1st triangle point
  78336. * @param p1 defines 2nd triangle point
  78337. * @param p2 defines 3rd triangle point
  78338. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78339. */
  78340. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78341. /**
  78342. * Gets the distance between the vectors "value1" and "value2"
  78343. * @param value1 defines first vector
  78344. * @param value2 defines second vector
  78345. * @returns the distance between vectors
  78346. */
  78347. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78348. /**
  78349. * Returns the squared distance between the vectors "value1" and "value2"
  78350. * @param value1 defines first vector
  78351. * @param value2 defines second vector
  78352. * @returns the squared distance between vectors
  78353. */
  78354. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78355. /**
  78356. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78357. * @param value1 defines first vector
  78358. * @param value2 defines second vector
  78359. * @returns a new Vector2
  78360. */
  78361. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78362. /**
  78363. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78364. * @param p defines the middle point
  78365. * @param segA defines one point of the segment
  78366. * @param segB defines the other point of the segment
  78367. * @returns the shortest distance
  78368. */
  78369. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78370. }
  78371. /**
  78372. * Class used to store (x,y,z) vector representation
  78373. * A Vector3 is the main object used in 3D geometry
  78374. * It can represent etiher the coordinates of a point the space, either a direction
  78375. * Reminder: js uses a left handed forward facing system
  78376. */
  78377. export class Vector3 {
  78378. /**
  78379. * Defines the first coordinates (on X axis)
  78380. */
  78381. x: number;
  78382. /**
  78383. * Defines the second coordinates (on Y axis)
  78384. */
  78385. y: number;
  78386. /**
  78387. * Defines the third coordinates (on Z axis)
  78388. */
  78389. z: number;
  78390. private static _UpReadOnly;
  78391. private static _ZeroReadOnly;
  78392. /**
  78393. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78394. * @param x defines the first coordinates (on X axis)
  78395. * @param y defines the second coordinates (on Y axis)
  78396. * @param z defines the third coordinates (on Z axis)
  78397. */
  78398. constructor(
  78399. /**
  78400. * Defines the first coordinates (on X axis)
  78401. */
  78402. x?: number,
  78403. /**
  78404. * Defines the second coordinates (on Y axis)
  78405. */
  78406. y?: number,
  78407. /**
  78408. * Defines the third coordinates (on Z axis)
  78409. */
  78410. z?: number);
  78411. /**
  78412. * Creates a string representation of the Vector3
  78413. * @returns a string with the Vector3 coordinates.
  78414. */
  78415. toString(): string;
  78416. /**
  78417. * Gets the class name
  78418. * @returns the string "Vector3"
  78419. */
  78420. getClassName(): string;
  78421. /**
  78422. * Creates the Vector3 hash code
  78423. * @returns a number which tends to be unique between Vector3 instances
  78424. */
  78425. getHashCode(): number;
  78426. /**
  78427. * Creates an array containing three elements : the coordinates of the Vector3
  78428. * @returns a new array of numbers
  78429. */
  78430. asArray(): number[];
  78431. /**
  78432. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78433. * @param array defines the destination array
  78434. * @param index defines the offset in the destination array
  78435. * @returns the current Vector3
  78436. */
  78437. toArray(array: FloatArray, index?: number): Vector3;
  78438. /**
  78439. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78440. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78441. */
  78442. toQuaternion(): Quaternion;
  78443. /**
  78444. * Adds the given vector to the current Vector3
  78445. * @param otherVector defines the second operand
  78446. * @returns the current updated Vector3
  78447. */
  78448. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78449. /**
  78450. * Adds the given coordinates to the current Vector3
  78451. * @param x defines the x coordinate of the operand
  78452. * @param y defines the y coordinate of the operand
  78453. * @param z defines the z coordinate of the operand
  78454. * @returns the current updated Vector3
  78455. */
  78456. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78457. /**
  78458. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78459. * @param otherVector defines the second operand
  78460. * @returns the resulting Vector3
  78461. */
  78462. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78463. /**
  78464. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78465. * @param otherVector defines the second operand
  78466. * @param result defines the Vector3 object where to store the result
  78467. * @returns the current Vector3
  78468. */
  78469. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78470. /**
  78471. * Subtract the given vector from the current Vector3
  78472. * @param otherVector defines the second operand
  78473. * @returns the current updated Vector3
  78474. */
  78475. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78476. /**
  78477. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78478. * @param otherVector defines the second operand
  78479. * @returns the resulting Vector3
  78480. */
  78481. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78482. /**
  78483. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78484. * @param otherVector defines the second operand
  78485. * @param result defines the Vector3 object where to store the result
  78486. * @returns the current Vector3
  78487. */
  78488. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78489. /**
  78490. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78491. * @param x defines the x coordinate of the operand
  78492. * @param y defines the y coordinate of the operand
  78493. * @param z defines the z coordinate of the operand
  78494. * @returns the resulting Vector3
  78495. */
  78496. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78497. /**
  78498. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78499. * @param x defines the x coordinate of the operand
  78500. * @param y defines the y coordinate of the operand
  78501. * @param z defines the z coordinate of the operand
  78502. * @param result defines the Vector3 object where to store the result
  78503. * @returns the current Vector3
  78504. */
  78505. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78506. /**
  78507. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78508. * @returns a new Vector3
  78509. */
  78510. negate(): Vector3;
  78511. /**
  78512. * Negate this vector in place
  78513. * @returns this
  78514. */
  78515. negateInPlace(): Vector3;
  78516. /**
  78517. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78518. * @param result defines the Vector3 object where to store the result
  78519. * @returns the current Vector3
  78520. */
  78521. negateToRef(result: Vector3): Vector3;
  78522. /**
  78523. * Multiplies the Vector3 coordinates by the float "scale"
  78524. * @param scale defines the multiplier factor
  78525. * @returns the current updated Vector3
  78526. */
  78527. scaleInPlace(scale: number): Vector3;
  78528. /**
  78529. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78530. * @param scale defines the multiplier factor
  78531. * @returns a new Vector3
  78532. */
  78533. scale(scale: number): Vector3;
  78534. /**
  78535. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78536. * @param scale defines the multiplier factor
  78537. * @param result defines the Vector3 object where to store the result
  78538. * @returns the current Vector3
  78539. */
  78540. scaleToRef(scale: number, result: Vector3): Vector3;
  78541. /**
  78542. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78543. * @param scale defines the scale factor
  78544. * @param result defines the Vector3 object where to store the result
  78545. * @returns the unmodified current Vector3
  78546. */
  78547. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78548. /**
  78549. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78550. * @param origin defines the origin of the projection ray
  78551. * @param plane defines the plane to project to
  78552. * @returns the projected vector3
  78553. */
  78554. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78555. /**
  78556. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78557. * @param origin defines the origin of the projection ray
  78558. * @param plane defines the plane to project to
  78559. * @param result defines the Vector3 where to store the result
  78560. */
  78561. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78562. /**
  78563. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78564. * @param otherVector defines the second operand
  78565. * @returns true if both vectors are equals
  78566. */
  78567. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78568. /**
  78569. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78570. * @param otherVector defines the second operand
  78571. * @param epsilon defines the minimal distance to define values as equals
  78572. * @returns true if both vectors are distant less than epsilon
  78573. */
  78574. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78575. /**
  78576. * Returns true if the current Vector3 coordinates equals the given floats
  78577. * @param x defines the x coordinate of the operand
  78578. * @param y defines the y coordinate of the operand
  78579. * @param z defines the z coordinate of the operand
  78580. * @returns true if both vectors are equals
  78581. */
  78582. equalsToFloats(x: number, y: number, z: number): boolean;
  78583. /**
  78584. * Multiplies the current Vector3 coordinates by the given ones
  78585. * @param otherVector defines the second operand
  78586. * @returns the current updated Vector3
  78587. */
  78588. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78589. /**
  78590. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78591. * @param otherVector defines the second operand
  78592. * @returns the new Vector3
  78593. */
  78594. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78595. /**
  78596. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78597. * @param otherVector defines the second operand
  78598. * @param result defines the Vector3 object where to store the result
  78599. * @returns the current Vector3
  78600. */
  78601. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78602. /**
  78603. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78604. * @param x defines the x coordinate of the operand
  78605. * @param y defines the y coordinate of the operand
  78606. * @param z defines the z coordinate of the operand
  78607. * @returns the new Vector3
  78608. */
  78609. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78610. /**
  78611. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78612. * @param otherVector defines the second operand
  78613. * @returns the new Vector3
  78614. */
  78615. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78616. /**
  78617. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78618. * @param otherVector defines the second operand
  78619. * @param result defines the Vector3 object where to store the result
  78620. * @returns the current Vector3
  78621. */
  78622. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78623. /**
  78624. * Divides the current Vector3 coordinates by the given ones.
  78625. * @param otherVector defines the second operand
  78626. * @returns the current updated Vector3
  78627. */
  78628. divideInPlace(otherVector: Vector3): Vector3;
  78629. /**
  78630. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78631. * @param other defines the second operand
  78632. * @returns the current updated Vector3
  78633. */
  78634. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78635. /**
  78636. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78637. * @param other defines the second operand
  78638. * @returns the current updated Vector3
  78639. */
  78640. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78641. /**
  78642. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78643. * @param x defines the x coordinate of the operand
  78644. * @param y defines the y coordinate of the operand
  78645. * @param z defines the z coordinate of the operand
  78646. * @returns the current updated Vector3
  78647. */
  78648. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78649. /**
  78650. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78651. * @param x defines the x coordinate of the operand
  78652. * @param y defines the y coordinate of the operand
  78653. * @param z defines the z coordinate of the operand
  78654. * @returns the current updated Vector3
  78655. */
  78656. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78657. /**
  78658. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78659. * Check if is non uniform within a certain amount of decimal places to account for this
  78660. * @param epsilon the amount the values can differ
  78661. * @returns if the the vector is non uniform to a certain number of decimal places
  78662. */
  78663. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78664. /**
  78665. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78666. */
  78667. get isNonUniform(): boolean;
  78668. /**
  78669. * Gets a new Vector3 from current Vector3 floored values
  78670. * @returns a new Vector3
  78671. */
  78672. floor(): Vector3;
  78673. /**
  78674. * Gets a new Vector3 from current Vector3 floored values
  78675. * @returns a new Vector3
  78676. */
  78677. fract(): Vector3;
  78678. /**
  78679. * Gets the length of the Vector3
  78680. * @returns the length of the Vector3
  78681. */
  78682. length(): number;
  78683. /**
  78684. * Gets the squared length of the Vector3
  78685. * @returns squared length of the Vector3
  78686. */
  78687. lengthSquared(): number;
  78688. /**
  78689. * Normalize the current Vector3.
  78690. * Please note that this is an in place operation.
  78691. * @returns the current updated Vector3
  78692. */
  78693. normalize(): Vector3;
  78694. /**
  78695. * Reorders the x y z properties of the vector in place
  78696. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78697. * @returns the current updated vector
  78698. */
  78699. reorderInPlace(order: string): this;
  78700. /**
  78701. * Rotates the vector around 0,0,0 by a quaternion
  78702. * @param quaternion the rotation quaternion
  78703. * @param result vector to store the result
  78704. * @returns the resulting vector
  78705. */
  78706. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78707. /**
  78708. * Rotates a vector around a given point
  78709. * @param quaternion the rotation quaternion
  78710. * @param point the point to rotate around
  78711. * @param result vector to store the result
  78712. * @returns the resulting vector
  78713. */
  78714. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78715. /**
  78716. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78717. * The cross product is then orthogonal to both current and "other"
  78718. * @param other defines the right operand
  78719. * @returns the cross product
  78720. */
  78721. cross(other: Vector3): Vector3;
  78722. /**
  78723. * Normalize the current Vector3 with the given input length.
  78724. * Please note that this is an in place operation.
  78725. * @param len the length of the vector
  78726. * @returns the current updated Vector3
  78727. */
  78728. normalizeFromLength(len: number): Vector3;
  78729. /**
  78730. * Normalize the current Vector3 to a new vector
  78731. * @returns the new Vector3
  78732. */
  78733. normalizeToNew(): Vector3;
  78734. /**
  78735. * Normalize the current Vector3 to the reference
  78736. * @param reference define the Vector3 to update
  78737. * @returns the updated Vector3
  78738. */
  78739. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78740. /**
  78741. * Creates a new Vector3 copied from the current Vector3
  78742. * @returns the new Vector3
  78743. */
  78744. clone(): Vector3;
  78745. /**
  78746. * Copies the given vector coordinates to the current Vector3 ones
  78747. * @param source defines the source Vector3
  78748. * @returns the current updated Vector3
  78749. */
  78750. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78751. /**
  78752. * Copies the given floats to the current Vector3 coordinates
  78753. * @param x defines the x coordinate of the operand
  78754. * @param y defines the y coordinate of the operand
  78755. * @param z defines the z coordinate of the operand
  78756. * @returns the current updated Vector3
  78757. */
  78758. copyFromFloats(x: number, y: number, z: number): Vector3;
  78759. /**
  78760. * Copies the given floats to the current Vector3 coordinates
  78761. * @param x defines the x coordinate of the operand
  78762. * @param y defines the y coordinate of the operand
  78763. * @param z defines the z coordinate of the operand
  78764. * @returns the current updated Vector3
  78765. */
  78766. set(x: number, y: number, z: number): Vector3;
  78767. /**
  78768. * Copies the given float to the current Vector3 coordinates
  78769. * @param v defines the x, y and z coordinates of the operand
  78770. * @returns the current updated Vector3
  78771. */
  78772. setAll(v: number): Vector3;
  78773. /**
  78774. * Get the clip factor between two vectors
  78775. * @param vector0 defines the first operand
  78776. * @param vector1 defines the second operand
  78777. * @param axis defines the axis to use
  78778. * @param size defines the size along the axis
  78779. * @returns the clip factor
  78780. */
  78781. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78782. /**
  78783. * Get angle between two vectors
  78784. * @param vector0 angle between vector0 and vector1
  78785. * @param vector1 angle between vector0 and vector1
  78786. * @param normal direction of the normal
  78787. * @return the angle between vector0 and vector1
  78788. */
  78789. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78790. /**
  78791. * Returns a new Vector3 set from the index "offset" of the given array
  78792. * @param array defines the source array
  78793. * @param offset defines the offset in the source array
  78794. * @returns the new Vector3
  78795. */
  78796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78797. /**
  78798. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78799. * @param array defines the source array
  78800. * @param offset defines the offset in the source array
  78801. * @returns the new Vector3
  78802. * @deprecated Please use FromArray instead.
  78803. */
  78804. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78805. /**
  78806. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78807. * @param array defines the source array
  78808. * @param offset defines the offset in the source array
  78809. * @param result defines the Vector3 where to store the result
  78810. */
  78811. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78812. /**
  78813. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78814. * @param array defines the source array
  78815. * @param offset defines the offset in the source array
  78816. * @param result defines the Vector3 where to store the result
  78817. * @deprecated Please use FromArrayToRef instead.
  78818. */
  78819. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78820. /**
  78821. * Sets the given vector "result" with the given floats.
  78822. * @param x defines the x coordinate of the source
  78823. * @param y defines the y coordinate of the source
  78824. * @param z defines the z coordinate of the source
  78825. * @param result defines the Vector3 where to store the result
  78826. */
  78827. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78828. /**
  78829. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78830. * @returns a new empty Vector3
  78831. */
  78832. static Zero(): Vector3;
  78833. /**
  78834. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78835. * @returns a new unit Vector3
  78836. */
  78837. static One(): Vector3;
  78838. /**
  78839. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78840. * @returns a new up Vector3
  78841. */
  78842. static Up(): Vector3;
  78843. /**
  78844. * Gets a up Vector3 that must not be updated
  78845. */
  78846. static get UpReadOnly(): DeepImmutable<Vector3>;
  78847. /**
  78848. * Gets a zero Vector3 that must not be updated
  78849. */
  78850. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78851. /**
  78852. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78853. * @returns a new down Vector3
  78854. */
  78855. static Down(): Vector3;
  78856. /**
  78857. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78858. * @param rightHandedSystem is the scene right-handed (negative z)
  78859. * @returns a new forward Vector3
  78860. */
  78861. static Forward(rightHandedSystem?: boolean): Vector3;
  78862. /**
  78863. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78864. * @param rightHandedSystem is the scene right-handed (negative-z)
  78865. * @returns a new forward Vector3
  78866. */
  78867. static Backward(rightHandedSystem?: boolean): Vector3;
  78868. /**
  78869. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78870. * @returns a new right Vector3
  78871. */
  78872. static Right(): Vector3;
  78873. /**
  78874. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78875. * @returns a new left Vector3
  78876. */
  78877. static Left(): Vector3;
  78878. /**
  78879. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78880. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78881. * @param vector defines the Vector3 to transform
  78882. * @param transformation defines the transformation matrix
  78883. * @returns the transformed Vector3
  78884. */
  78885. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78886. /**
  78887. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78888. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78889. * @param vector defines the Vector3 to transform
  78890. * @param transformation defines the transformation matrix
  78891. * @param result defines the Vector3 where to store the result
  78892. */
  78893. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78894. /**
  78895. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78896. * This method computes tranformed coordinates only, not transformed direction vectors
  78897. * @param x define the x coordinate of the source vector
  78898. * @param y define the y coordinate of the source vector
  78899. * @param z define the z coordinate of the source vector
  78900. * @param transformation defines the transformation matrix
  78901. * @param result defines the Vector3 where to store the result
  78902. */
  78903. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78904. /**
  78905. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78906. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78907. * @param vector defines the Vector3 to transform
  78908. * @param transformation defines the transformation matrix
  78909. * @returns the new Vector3
  78910. */
  78911. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78912. /**
  78913. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78914. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78915. * @param vector defines the Vector3 to transform
  78916. * @param transformation defines the transformation matrix
  78917. * @param result defines the Vector3 where to store the result
  78918. */
  78919. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78920. /**
  78921. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78922. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78923. * @param x define the x coordinate of the source vector
  78924. * @param y define the y coordinate of the source vector
  78925. * @param z define the z coordinate of the source vector
  78926. * @param transformation defines the transformation matrix
  78927. * @param result defines the Vector3 where to store the result
  78928. */
  78929. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78930. /**
  78931. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78932. * @param value1 defines the first control point
  78933. * @param value2 defines the second control point
  78934. * @param value3 defines the third control point
  78935. * @param value4 defines the fourth control point
  78936. * @param amount defines the amount on the spline to use
  78937. * @returns the new Vector3
  78938. */
  78939. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78940. /**
  78941. * 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"
  78942. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78943. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78944. * @param value defines the current value
  78945. * @param min defines the lower range value
  78946. * @param max defines the upper range value
  78947. * @returns the new Vector3
  78948. */
  78949. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78950. /**
  78951. * 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"
  78952. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78953. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78954. * @param value defines the current value
  78955. * @param min defines the lower range value
  78956. * @param max defines the upper range value
  78957. * @param result defines the Vector3 where to store the result
  78958. */
  78959. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78960. /**
  78961. * Checks if a given vector is inside a specific range
  78962. * @param v defines the vector to test
  78963. * @param min defines the minimum range
  78964. * @param max defines the maximum range
  78965. */
  78966. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78967. /**
  78968. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  78969. * @param value1 defines the first control point
  78970. * @param tangent1 defines the first tangent vector
  78971. * @param value2 defines the second control point
  78972. * @param tangent2 defines the second tangent vector
  78973. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  78974. * @returns the new Vector3
  78975. */
  78976. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  78977. /**
  78978. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  78979. * @param start defines the start value
  78980. * @param end defines the end value
  78981. * @param amount max defines amount between both (between 0 and 1)
  78982. * @returns the new Vector3
  78983. */
  78984. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  78985. /**
  78986. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  78987. * @param start defines the start value
  78988. * @param end defines the end value
  78989. * @param amount max defines amount between both (between 0 and 1)
  78990. * @param result defines the Vector3 where to store the result
  78991. */
  78992. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  78993. /**
  78994. * Returns the dot product (float) between the vectors "left" and "right"
  78995. * @param left defines the left operand
  78996. * @param right defines the right operand
  78997. * @returns the dot product
  78998. */
  78999. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  79000. /**
  79001. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  79002. * The cross product is then orthogonal to both "left" and "right"
  79003. * @param left defines the left operand
  79004. * @param right defines the right operand
  79005. * @returns the cross product
  79006. */
  79007. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79008. /**
  79009. * Sets the given vector "result" with the cross product of "left" and "right"
  79010. * The cross product is then orthogonal to both "left" and "right"
  79011. * @param left defines the left operand
  79012. * @param right defines the right operand
  79013. * @param result defines the Vector3 where to store the result
  79014. */
  79015. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  79016. /**
  79017. * Returns a new Vector3 as the normalization of the given vector
  79018. * @param vector defines the Vector3 to normalize
  79019. * @returns the new Vector3
  79020. */
  79021. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  79022. /**
  79023. * Sets the given vector "result" with the normalization of the given first vector
  79024. * @param vector defines the Vector3 to normalize
  79025. * @param result defines the Vector3 where to store the result
  79026. */
  79027. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  79028. /**
  79029. * Project a Vector3 onto screen space
  79030. * @param vector defines the Vector3 to project
  79031. * @param world defines the world matrix to use
  79032. * @param transform defines the transform (view x projection) matrix to use
  79033. * @param viewport defines the screen viewport to use
  79034. * @returns the new Vector3
  79035. */
  79036. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  79037. /** @hidden */
  79038. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  79039. /**
  79040. * Unproject from screen space to object space
  79041. * @param source defines the screen space Vector3 to use
  79042. * @param viewportWidth defines the current width of the viewport
  79043. * @param viewportHeight defines the current height of the viewport
  79044. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79045. * @param transform defines the transform (view x projection) matrix to use
  79046. * @returns the new Vector3
  79047. */
  79048. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  79049. /**
  79050. * Unproject from screen space to object space
  79051. * @param source defines the screen space Vector3 to use
  79052. * @param viewportWidth defines the current width of the viewport
  79053. * @param viewportHeight defines the current height of the viewport
  79054. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79055. * @param view defines the view matrix to use
  79056. * @param projection defines the projection matrix to use
  79057. * @returns the new Vector3
  79058. */
  79059. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  79060. /**
  79061. * Unproject from screen space to object space
  79062. * @param source defines the screen space Vector3 to use
  79063. * @param viewportWidth defines the current width of the viewport
  79064. * @param viewportHeight defines the current height of the viewport
  79065. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79066. * @param view defines the view matrix to use
  79067. * @param projection defines the projection matrix to use
  79068. * @param result defines the Vector3 where to store the result
  79069. */
  79070. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79071. /**
  79072. * Unproject from screen space to object space
  79073. * @param sourceX defines the screen space x coordinate to use
  79074. * @param sourceY defines the screen space y coordinate to use
  79075. * @param sourceZ defines the screen space z coordinate to use
  79076. * @param viewportWidth defines the current width of the viewport
  79077. * @param viewportHeight defines the current height of the viewport
  79078. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79079. * @param view defines the view matrix to use
  79080. * @param projection defines the projection matrix to use
  79081. * @param result defines the Vector3 where to store the result
  79082. */
  79083. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  79084. /**
  79085. * Gets the minimal coordinate values between two Vector3
  79086. * @param left defines the first operand
  79087. * @param right defines the second operand
  79088. * @returns the new Vector3
  79089. */
  79090. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79091. /**
  79092. * Gets the maximal coordinate values between two Vector3
  79093. * @param left defines the first operand
  79094. * @param right defines the second operand
  79095. * @returns the new Vector3
  79096. */
  79097. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79098. /**
  79099. * Returns the distance between the vectors "value1" and "value2"
  79100. * @param value1 defines the first operand
  79101. * @param value2 defines the second operand
  79102. * @returns the distance
  79103. */
  79104. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79105. /**
  79106. * Returns the squared distance between the vectors "value1" and "value2"
  79107. * @param value1 defines the first operand
  79108. * @param value2 defines the second operand
  79109. * @returns the squared distance
  79110. */
  79111. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  79112. /**
  79113. * Returns a new Vector3 located at the center between "value1" and "value2"
  79114. * @param value1 defines the first operand
  79115. * @param value2 defines the second operand
  79116. * @returns the new Vector3
  79117. */
  79118. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  79119. /**
  79120. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  79121. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  79122. * to something in order to rotate it from its local system to the given target system
  79123. * Note: axis1, axis2 and axis3 are normalized during this operation
  79124. * @param axis1 defines the first axis
  79125. * @param axis2 defines the second axis
  79126. * @param axis3 defines the third axis
  79127. * @returns a new Vector3
  79128. */
  79129. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  79130. /**
  79131. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  79132. * @param axis1 defines the first axis
  79133. * @param axis2 defines the second axis
  79134. * @param axis3 defines the third axis
  79135. * @param ref defines the Vector3 where to store the result
  79136. */
  79137. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  79138. }
  79139. /**
  79140. * Vector4 class created for EulerAngle class conversion to Quaternion
  79141. */
  79142. export class Vector4 {
  79143. /** x value of the vector */
  79144. x: number;
  79145. /** y value of the vector */
  79146. y: number;
  79147. /** z value of the vector */
  79148. z: number;
  79149. /** w value of the vector */
  79150. w: number;
  79151. /**
  79152. * Creates a Vector4 object from the given floats.
  79153. * @param x x value of the vector
  79154. * @param y y value of the vector
  79155. * @param z z value of the vector
  79156. * @param w w value of the vector
  79157. */
  79158. constructor(
  79159. /** x value of the vector */
  79160. x: number,
  79161. /** y value of the vector */
  79162. y: number,
  79163. /** z value of the vector */
  79164. z: number,
  79165. /** w value of the vector */
  79166. w: number);
  79167. /**
  79168. * Returns the string with the Vector4 coordinates.
  79169. * @returns a string containing all the vector values
  79170. */
  79171. toString(): string;
  79172. /**
  79173. * Returns the string "Vector4".
  79174. * @returns "Vector4"
  79175. */
  79176. getClassName(): string;
  79177. /**
  79178. * Returns the Vector4 hash code.
  79179. * @returns a unique hash code
  79180. */
  79181. getHashCode(): number;
  79182. /**
  79183. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79184. * @returns the resulting array
  79185. */
  79186. asArray(): number[];
  79187. /**
  79188. * Populates the given array from the given index with the Vector4 coordinates.
  79189. * @param array array to populate
  79190. * @param index index of the array to start at (default: 0)
  79191. * @returns the Vector4.
  79192. */
  79193. toArray(array: FloatArray, index?: number): Vector4;
  79194. /**
  79195. * Adds the given vector to the current Vector4.
  79196. * @param otherVector the vector to add
  79197. * @returns the updated Vector4.
  79198. */
  79199. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79200. /**
  79201. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79202. * @param otherVector the vector to add
  79203. * @returns the resulting vector
  79204. */
  79205. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79206. /**
  79207. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79208. * @param otherVector the vector to add
  79209. * @param result the vector to store the result
  79210. * @returns the current Vector4.
  79211. */
  79212. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79213. /**
  79214. * Subtract in place the given vector from the current Vector4.
  79215. * @param otherVector the vector to subtract
  79216. * @returns the updated Vector4.
  79217. */
  79218. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79219. /**
  79220. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79221. * @param otherVector the vector to add
  79222. * @returns the new vector with the result
  79223. */
  79224. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79225. /**
  79226. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79227. * @param otherVector the vector to subtract
  79228. * @param result the vector to store the result
  79229. * @returns the current Vector4.
  79230. */
  79231. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79232. /**
  79233. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79234. */
  79235. /**
  79236. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79237. * @param x value to subtract
  79238. * @param y value to subtract
  79239. * @param z value to subtract
  79240. * @param w value to subtract
  79241. * @returns new vector containing the result
  79242. */
  79243. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79244. /**
  79245. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79246. * @param x value to subtract
  79247. * @param y value to subtract
  79248. * @param z value to subtract
  79249. * @param w value to subtract
  79250. * @param result the vector to store the result in
  79251. * @returns the current Vector4.
  79252. */
  79253. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79254. /**
  79255. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79256. * @returns a new vector with the negated values
  79257. */
  79258. negate(): Vector4;
  79259. /**
  79260. * Negate this vector in place
  79261. * @returns this
  79262. */
  79263. negateInPlace(): Vector4;
  79264. /**
  79265. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79266. * @param result defines the Vector3 object where to store the result
  79267. * @returns the current Vector4
  79268. */
  79269. negateToRef(result: Vector4): Vector4;
  79270. /**
  79271. * Multiplies the current Vector4 coordinates by scale (float).
  79272. * @param scale the number to scale with
  79273. * @returns the updated Vector4.
  79274. */
  79275. scaleInPlace(scale: number): Vector4;
  79276. /**
  79277. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79278. * @param scale the number to scale with
  79279. * @returns a new vector with the result
  79280. */
  79281. scale(scale: number): Vector4;
  79282. /**
  79283. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79284. * @param scale the number to scale with
  79285. * @param result a vector to store the result in
  79286. * @returns the current Vector4.
  79287. */
  79288. scaleToRef(scale: number, result: Vector4): Vector4;
  79289. /**
  79290. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79291. * @param scale defines the scale factor
  79292. * @param result defines the Vector4 object where to store the result
  79293. * @returns the unmodified current Vector4
  79294. */
  79295. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79296. /**
  79297. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79298. * @param otherVector the vector to compare against
  79299. * @returns true if they are equal
  79300. */
  79301. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79302. /**
  79303. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79304. * @param otherVector vector to compare against
  79305. * @param epsilon (Default: very small number)
  79306. * @returns true if they are equal
  79307. */
  79308. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79309. /**
  79310. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79311. * @param x x value to compare against
  79312. * @param y y value to compare against
  79313. * @param z z value to compare against
  79314. * @param w w value to compare against
  79315. * @returns true if equal
  79316. */
  79317. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79318. /**
  79319. * Multiplies in place the current Vector4 by the given one.
  79320. * @param otherVector vector to multiple with
  79321. * @returns the updated Vector4.
  79322. */
  79323. multiplyInPlace(otherVector: Vector4): Vector4;
  79324. /**
  79325. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79326. * @param otherVector vector to multiple with
  79327. * @returns resulting new vector
  79328. */
  79329. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79330. /**
  79331. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79332. * @param otherVector vector to multiple with
  79333. * @param result vector to store the result
  79334. * @returns the current Vector4.
  79335. */
  79336. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79337. /**
  79338. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79339. * @param x x value multiply with
  79340. * @param y y value multiply with
  79341. * @param z z value multiply with
  79342. * @param w w value multiply with
  79343. * @returns resulting new vector
  79344. */
  79345. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79346. /**
  79347. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79348. * @param otherVector vector to devide with
  79349. * @returns resulting new vector
  79350. */
  79351. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79352. /**
  79353. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79354. * @param otherVector vector to devide with
  79355. * @param result vector to store the result
  79356. * @returns the current Vector4.
  79357. */
  79358. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79359. /**
  79360. * Divides the current Vector3 coordinates by the given ones.
  79361. * @param otherVector vector to devide with
  79362. * @returns the updated Vector3.
  79363. */
  79364. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79365. /**
  79366. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79367. * @param other defines the second operand
  79368. * @returns the current updated Vector4
  79369. */
  79370. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79371. /**
  79372. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79373. * @param other defines the second operand
  79374. * @returns the current updated Vector4
  79375. */
  79376. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79377. /**
  79378. * Gets a new Vector4 from current Vector4 floored values
  79379. * @returns a new Vector4
  79380. */
  79381. floor(): Vector4;
  79382. /**
  79383. * Gets a new Vector4 from current Vector3 floored values
  79384. * @returns a new Vector4
  79385. */
  79386. fract(): Vector4;
  79387. /**
  79388. * Returns the Vector4 length (float).
  79389. * @returns the length
  79390. */
  79391. length(): number;
  79392. /**
  79393. * Returns the Vector4 squared length (float).
  79394. * @returns the length squared
  79395. */
  79396. lengthSquared(): number;
  79397. /**
  79398. * Normalizes in place the Vector4.
  79399. * @returns the updated Vector4.
  79400. */
  79401. normalize(): Vector4;
  79402. /**
  79403. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79404. * @returns this converted to a new vector3
  79405. */
  79406. toVector3(): Vector3;
  79407. /**
  79408. * Returns a new Vector4 copied from the current one.
  79409. * @returns the new cloned vector
  79410. */
  79411. clone(): Vector4;
  79412. /**
  79413. * Updates the current Vector4 with the given one coordinates.
  79414. * @param source the source vector to copy from
  79415. * @returns the updated Vector4.
  79416. */
  79417. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79418. /**
  79419. * Updates the current Vector4 coordinates with the given floats.
  79420. * @param x float to copy from
  79421. * @param y float to copy from
  79422. * @param z float to copy from
  79423. * @param w float to copy from
  79424. * @returns the updated Vector4.
  79425. */
  79426. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79427. /**
  79428. * Updates the current Vector4 coordinates with the given floats.
  79429. * @param x float to set from
  79430. * @param y float to set from
  79431. * @param z float to set from
  79432. * @param w float to set from
  79433. * @returns the updated Vector4.
  79434. */
  79435. set(x: number, y: number, z: number, w: number): Vector4;
  79436. /**
  79437. * Copies the given float to the current Vector3 coordinates
  79438. * @param v defines the x, y, z and w coordinates of the operand
  79439. * @returns the current updated Vector3
  79440. */
  79441. setAll(v: number): Vector4;
  79442. /**
  79443. * Returns a new Vector4 set from the starting index of the given array.
  79444. * @param array the array to pull values from
  79445. * @param offset the offset into the array to start at
  79446. * @returns the new vector
  79447. */
  79448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79449. /**
  79450. * Updates the given vector "result" from the starting index of the given array.
  79451. * @param array the array to pull values from
  79452. * @param offset the offset into the array to start at
  79453. * @param result the vector to store the result in
  79454. */
  79455. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79456. /**
  79457. * Updates the given vector "result" from the starting index of the given Float32Array.
  79458. * @param array the array to pull values from
  79459. * @param offset the offset into the array to start at
  79460. * @param result the vector to store the result in
  79461. */
  79462. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79463. /**
  79464. * Updates the given vector "result" coordinates from the given floats.
  79465. * @param x float to set from
  79466. * @param y float to set from
  79467. * @param z float to set from
  79468. * @param w float to set from
  79469. * @param result the vector to the floats in
  79470. */
  79471. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79472. /**
  79473. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79474. * @returns the new vector
  79475. */
  79476. static Zero(): Vector4;
  79477. /**
  79478. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79479. * @returns the new vector
  79480. */
  79481. static One(): Vector4;
  79482. /**
  79483. * Returns a new normalized Vector4 from the given one.
  79484. * @param vector the vector to normalize
  79485. * @returns the vector
  79486. */
  79487. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79488. /**
  79489. * Updates the given vector "result" from the normalization of the given one.
  79490. * @param vector the vector to normalize
  79491. * @param result the vector to store the result in
  79492. */
  79493. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79494. /**
  79495. * Returns a vector with the minimum values from the left and right vectors
  79496. * @param left left vector to minimize
  79497. * @param right right vector to minimize
  79498. * @returns a new vector with the minimum of the left and right vector values
  79499. */
  79500. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79501. /**
  79502. * Returns a vector with the maximum values from the left and right vectors
  79503. * @param left left vector to maximize
  79504. * @param right right vector to maximize
  79505. * @returns a new vector with the maximum of the left and right vector values
  79506. */
  79507. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79508. /**
  79509. * Returns the distance (float) between the vectors "value1" and "value2".
  79510. * @param value1 value to calulate the distance between
  79511. * @param value2 value to calulate the distance between
  79512. * @return the distance between the two vectors
  79513. */
  79514. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79515. /**
  79516. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79517. * @param value1 value to calulate the distance between
  79518. * @param value2 value to calulate the distance between
  79519. * @return the distance between the two vectors squared
  79520. */
  79521. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79522. /**
  79523. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79524. * @param value1 value to calulate the center between
  79525. * @param value2 value to calulate the center between
  79526. * @return the center between the two vectors
  79527. */
  79528. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79529. /**
  79530. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79531. * This methods computes transformed normalized direction vectors only.
  79532. * @param vector the vector to transform
  79533. * @param transformation the transformation matrix to apply
  79534. * @returns the new vector
  79535. */
  79536. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79537. /**
  79538. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79539. * This methods computes transformed normalized direction vectors only.
  79540. * @param vector the vector to transform
  79541. * @param transformation the transformation matrix to apply
  79542. * @param result the vector to store the result in
  79543. */
  79544. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79545. /**
  79546. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79547. * This methods computes transformed normalized direction vectors only.
  79548. * @param x value to transform
  79549. * @param y value to transform
  79550. * @param z value to transform
  79551. * @param w value to transform
  79552. * @param transformation the transformation matrix to apply
  79553. * @param result the vector to store the results in
  79554. */
  79555. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79556. /**
  79557. * Creates a new Vector4 from a Vector3
  79558. * @param source defines the source data
  79559. * @param w defines the 4th component (default is 0)
  79560. * @returns a new Vector4
  79561. */
  79562. static FromVector3(source: Vector3, w?: number): Vector4;
  79563. }
  79564. /**
  79565. * Class used to store quaternion data
  79566. * @see https://en.wikipedia.org/wiki/Quaternion
  79567. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79568. */
  79569. export class Quaternion {
  79570. /** defines the first component (0 by default) */
  79571. x: number;
  79572. /** defines the second component (0 by default) */
  79573. y: number;
  79574. /** defines the third component (0 by default) */
  79575. z: number;
  79576. /** defines the fourth component (1.0 by default) */
  79577. w: number;
  79578. /**
  79579. * Creates a new Quaternion from the given floats
  79580. * @param x defines the first component (0 by default)
  79581. * @param y defines the second component (0 by default)
  79582. * @param z defines the third component (0 by default)
  79583. * @param w defines the fourth component (1.0 by default)
  79584. */
  79585. constructor(
  79586. /** defines the first component (0 by default) */
  79587. x?: number,
  79588. /** defines the second component (0 by default) */
  79589. y?: number,
  79590. /** defines the third component (0 by default) */
  79591. z?: number,
  79592. /** defines the fourth component (1.0 by default) */
  79593. w?: number);
  79594. /**
  79595. * Gets a string representation for the current quaternion
  79596. * @returns a string with the Quaternion coordinates
  79597. */
  79598. toString(): string;
  79599. /**
  79600. * Gets the class name of the quaternion
  79601. * @returns the string "Quaternion"
  79602. */
  79603. getClassName(): string;
  79604. /**
  79605. * Gets a hash code for this quaternion
  79606. * @returns the quaternion hash code
  79607. */
  79608. getHashCode(): number;
  79609. /**
  79610. * Copy the quaternion to an array
  79611. * @returns a new array populated with 4 elements from the quaternion coordinates
  79612. */
  79613. asArray(): number[];
  79614. /**
  79615. * Check if two quaternions are equals
  79616. * @param otherQuaternion defines the second operand
  79617. * @return true if the current quaternion and the given one coordinates are strictly equals
  79618. */
  79619. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79620. /**
  79621. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79622. * @param otherQuaternion defines the other quaternion
  79623. * @param epsilon defines the minimal distance to consider equality
  79624. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79625. */
  79626. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79627. /**
  79628. * Clone the current quaternion
  79629. * @returns a new quaternion copied from the current one
  79630. */
  79631. clone(): Quaternion;
  79632. /**
  79633. * Copy a quaternion to the current one
  79634. * @param other defines the other quaternion
  79635. * @returns the updated current quaternion
  79636. */
  79637. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79638. /**
  79639. * Updates the current quaternion with the given float coordinates
  79640. * @param x defines the x coordinate
  79641. * @param y defines the y coordinate
  79642. * @param z defines the z coordinate
  79643. * @param w defines the w coordinate
  79644. * @returns the updated current quaternion
  79645. */
  79646. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79647. /**
  79648. * Updates the current quaternion from the given float coordinates
  79649. * @param x defines the x coordinate
  79650. * @param y defines the y coordinate
  79651. * @param z defines the z coordinate
  79652. * @param w defines the w coordinate
  79653. * @returns the updated current quaternion
  79654. */
  79655. set(x: number, y: number, z: number, w: number): Quaternion;
  79656. /**
  79657. * Adds two quaternions
  79658. * @param other defines the second operand
  79659. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79660. */
  79661. add(other: DeepImmutable<Quaternion>): Quaternion;
  79662. /**
  79663. * Add a quaternion to the current one
  79664. * @param other defines the quaternion to add
  79665. * @returns the current quaternion
  79666. */
  79667. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79668. /**
  79669. * Subtract two quaternions
  79670. * @param other defines the second operand
  79671. * @returns a new quaternion as the subtraction result of the given one from the current one
  79672. */
  79673. subtract(other: Quaternion): Quaternion;
  79674. /**
  79675. * Multiplies the current quaternion by a scale factor
  79676. * @param value defines the scale factor
  79677. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79678. */
  79679. scale(value: number): Quaternion;
  79680. /**
  79681. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79682. * @param scale defines the scale factor
  79683. * @param result defines the Quaternion object where to store the result
  79684. * @returns the unmodified current quaternion
  79685. */
  79686. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79687. /**
  79688. * Multiplies in place the current quaternion by a scale factor
  79689. * @param value defines the scale factor
  79690. * @returns the current modified quaternion
  79691. */
  79692. scaleInPlace(value: number): Quaternion;
  79693. /**
  79694. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79695. * @param scale defines the scale factor
  79696. * @param result defines the Quaternion object where to store the result
  79697. * @returns the unmodified current quaternion
  79698. */
  79699. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79700. /**
  79701. * Multiplies two quaternions
  79702. * @param q1 defines the second operand
  79703. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79704. */
  79705. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79706. /**
  79707. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79708. * @param q1 defines the second operand
  79709. * @param result defines the target quaternion
  79710. * @returns the current quaternion
  79711. */
  79712. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79713. /**
  79714. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79715. * @param q1 defines the second operand
  79716. * @returns the currentupdated quaternion
  79717. */
  79718. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79719. /**
  79720. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79721. * @param ref defines the target quaternion
  79722. * @returns the current quaternion
  79723. */
  79724. conjugateToRef(ref: Quaternion): Quaternion;
  79725. /**
  79726. * Conjugates in place (1-q) the current quaternion
  79727. * @returns the current updated quaternion
  79728. */
  79729. conjugateInPlace(): Quaternion;
  79730. /**
  79731. * Conjugates in place (1-q) the current quaternion
  79732. * @returns a new quaternion
  79733. */
  79734. conjugate(): Quaternion;
  79735. /**
  79736. * Gets length of current quaternion
  79737. * @returns the quaternion length (float)
  79738. */
  79739. length(): number;
  79740. /**
  79741. * Normalize in place the current quaternion
  79742. * @returns the current updated quaternion
  79743. */
  79744. normalize(): Quaternion;
  79745. /**
  79746. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79747. * @param order is a reserved parameter and is ignore for now
  79748. * @returns a new Vector3 containing the Euler angles
  79749. */
  79750. toEulerAngles(order?: string): Vector3;
  79751. /**
  79752. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79753. * @param result defines the vector which will be filled with the Euler angles
  79754. * @param order is a reserved parameter and is ignore for now
  79755. * @returns the current unchanged quaternion
  79756. */
  79757. toEulerAnglesToRef(result: Vector3): Quaternion;
  79758. /**
  79759. * Updates the given rotation matrix with the current quaternion values
  79760. * @param result defines the target matrix
  79761. * @returns the current unchanged quaternion
  79762. */
  79763. toRotationMatrix(result: Matrix): Quaternion;
  79764. /**
  79765. * Updates the current quaternion from the given rotation matrix values
  79766. * @param matrix defines the source matrix
  79767. * @returns the current updated quaternion
  79768. */
  79769. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79770. /**
  79771. * Creates a new quaternion from a rotation matrix
  79772. * @param matrix defines the source matrix
  79773. * @returns a new quaternion created from the given rotation matrix values
  79774. */
  79775. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79776. /**
  79777. * Updates the given quaternion with the given rotation matrix values
  79778. * @param matrix defines the source matrix
  79779. * @param result defines the target quaternion
  79780. */
  79781. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79782. /**
  79783. * Returns the dot product (float) between the quaternions "left" and "right"
  79784. * @param left defines the left operand
  79785. * @param right defines the right operand
  79786. * @returns the dot product
  79787. */
  79788. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79789. /**
  79790. * Checks if the two quaternions are close to each other
  79791. * @param quat0 defines the first quaternion to check
  79792. * @param quat1 defines the second quaternion to check
  79793. * @returns true if the two quaternions are close to each other
  79794. */
  79795. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79796. /**
  79797. * Creates an empty quaternion
  79798. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79799. */
  79800. static Zero(): Quaternion;
  79801. /**
  79802. * Inverse a given quaternion
  79803. * @param q defines the source quaternion
  79804. * @returns a new quaternion as the inverted current quaternion
  79805. */
  79806. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79807. /**
  79808. * Inverse a given quaternion
  79809. * @param q defines the source quaternion
  79810. * @param result the quaternion the result will be stored in
  79811. * @returns the result quaternion
  79812. */
  79813. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79814. /**
  79815. * Creates an identity quaternion
  79816. * @returns the identity quaternion
  79817. */
  79818. static Identity(): Quaternion;
  79819. /**
  79820. * Gets a boolean indicating if the given quaternion is identity
  79821. * @param quaternion defines the quaternion to check
  79822. * @returns true if the quaternion is identity
  79823. */
  79824. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79825. /**
  79826. * Creates a quaternion from a rotation around an axis
  79827. * @param axis defines the axis to use
  79828. * @param angle defines the angle to use
  79829. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79830. */
  79831. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79832. /**
  79833. * Creates a rotation around an axis and stores it into the given quaternion
  79834. * @param axis defines the axis to use
  79835. * @param angle defines the angle to use
  79836. * @param result defines the target quaternion
  79837. * @returns the target quaternion
  79838. */
  79839. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79840. /**
  79841. * Creates a new quaternion from data stored into an array
  79842. * @param array defines the data source
  79843. * @param offset defines the offset in the source array where the data starts
  79844. * @returns a new quaternion
  79845. */
  79846. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79847. /**
  79848. * Updates the given quaternion "result" from the starting index of the given array.
  79849. * @param array the array to pull values from
  79850. * @param offset the offset into the array to start at
  79851. * @param result the quaternion to store the result in
  79852. */
  79853. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79854. /**
  79855. * Create a quaternion from Euler rotation angles
  79856. * @param x Pitch
  79857. * @param y Yaw
  79858. * @param z Roll
  79859. * @returns the new Quaternion
  79860. */
  79861. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79862. /**
  79863. * Updates a quaternion from Euler rotation angles
  79864. * @param x Pitch
  79865. * @param y Yaw
  79866. * @param z Roll
  79867. * @param result the quaternion to store the result
  79868. * @returns the updated quaternion
  79869. */
  79870. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79871. /**
  79872. * Create a quaternion from Euler rotation vector
  79873. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79874. * @returns the new Quaternion
  79875. */
  79876. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79877. /**
  79878. * Updates a quaternion from Euler rotation vector
  79879. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79880. * @param result the quaternion to store the result
  79881. * @returns the updated quaternion
  79882. */
  79883. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79884. /**
  79885. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79886. * @param yaw defines the rotation around Y axis
  79887. * @param pitch defines the rotation around X axis
  79888. * @param roll defines the rotation around Z axis
  79889. * @returns the new quaternion
  79890. */
  79891. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79892. /**
  79893. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79894. * @param yaw defines the rotation around Y axis
  79895. * @param pitch defines the rotation around X axis
  79896. * @param roll defines the rotation around Z axis
  79897. * @param result defines the target quaternion
  79898. */
  79899. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79900. /**
  79901. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79902. * @param alpha defines the rotation around first axis
  79903. * @param beta defines the rotation around second axis
  79904. * @param gamma defines the rotation around third axis
  79905. * @returns the new quaternion
  79906. */
  79907. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79908. /**
  79909. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79910. * @param alpha defines the rotation around first axis
  79911. * @param beta defines the rotation around second axis
  79912. * @param gamma defines the rotation around third axis
  79913. * @param result defines the target quaternion
  79914. */
  79915. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79916. /**
  79917. * 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)
  79918. * @param axis1 defines the first axis
  79919. * @param axis2 defines the second axis
  79920. * @param axis3 defines the third axis
  79921. * @returns the new quaternion
  79922. */
  79923. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79924. /**
  79925. * 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
  79926. * @param axis1 defines the first axis
  79927. * @param axis2 defines the second axis
  79928. * @param axis3 defines the third axis
  79929. * @param ref defines the target quaternion
  79930. */
  79931. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79932. /**
  79933. * Interpolates between two quaternions
  79934. * @param left defines first quaternion
  79935. * @param right defines second quaternion
  79936. * @param amount defines the gradient to use
  79937. * @returns the new interpolated quaternion
  79938. */
  79939. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79940. /**
  79941. * Interpolates between two quaternions and stores it into a target quaternion
  79942. * @param left defines first quaternion
  79943. * @param right defines second quaternion
  79944. * @param amount defines the gradient to use
  79945. * @param result defines the target quaternion
  79946. */
  79947. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79948. /**
  79949. * Interpolate between two quaternions using Hermite interpolation
  79950. * @param value1 defines first quaternion
  79951. * @param tangent1 defines the incoming tangent
  79952. * @param value2 defines second quaternion
  79953. * @param tangent2 defines the outgoing tangent
  79954. * @param amount defines the target quaternion
  79955. * @returns the new interpolated quaternion
  79956. */
  79957. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79958. }
  79959. /**
  79960. * Class used to store matrix data (4x4)
  79961. */
  79962. export class Matrix {
  79963. private static _updateFlagSeed;
  79964. private static _identityReadOnly;
  79965. private _isIdentity;
  79966. private _isIdentityDirty;
  79967. private _isIdentity3x2;
  79968. private _isIdentity3x2Dirty;
  79969. /**
  79970. * Gets the update flag of the matrix which is an unique number for the matrix.
  79971. * It will be incremented every time the matrix data change.
  79972. * You can use it to speed the comparison between two versions of the same matrix.
  79973. */
  79974. updateFlag: number;
  79975. private readonly _m;
  79976. /**
  79977. * Gets the internal data of the matrix
  79978. */
  79979. get m(): DeepImmutable<Float32Array>;
  79980. /** @hidden */
  79981. _markAsUpdated(): void;
  79982. /** @hidden */
  79983. private _updateIdentityStatus;
  79984. /**
  79985. * Creates an empty matrix (filled with zeros)
  79986. */
  79987. constructor();
  79988. /**
  79989. * Check if the current matrix is identity
  79990. * @returns true is the matrix is the identity matrix
  79991. */
  79992. isIdentity(): boolean;
  79993. /**
  79994. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  79995. * @returns true is the matrix is the identity matrix
  79996. */
  79997. isIdentityAs3x2(): boolean;
  79998. /**
  79999. * Gets the determinant of the matrix
  80000. * @returns the matrix determinant
  80001. */
  80002. determinant(): number;
  80003. /**
  80004. * Returns the matrix as a Float32Array
  80005. * @returns the matrix underlying array
  80006. */
  80007. toArray(): DeepImmutable<Float32Array>;
  80008. /**
  80009. * Returns the matrix as a Float32Array
  80010. * @returns the matrix underlying array.
  80011. */
  80012. asArray(): DeepImmutable<Float32Array>;
  80013. /**
  80014. * Inverts the current matrix in place
  80015. * @returns the current inverted matrix
  80016. */
  80017. invert(): Matrix;
  80018. /**
  80019. * Sets all the matrix elements to zero
  80020. * @returns the current matrix
  80021. */
  80022. reset(): Matrix;
  80023. /**
  80024. * Adds the current matrix with a second one
  80025. * @param other defines the matrix to add
  80026. * @returns a new matrix as the addition of the current matrix and the given one
  80027. */
  80028. add(other: DeepImmutable<Matrix>): Matrix;
  80029. /**
  80030. * Sets the given matrix "result" to the addition of the current matrix and the given one
  80031. * @param other defines the matrix to add
  80032. * @param result defines the target matrix
  80033. * @returns the current matrix
  80034. */
  80035. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80036. /**
  80037. * Adds in place the given matrix to the current matrix
  80038. * @param other defines the second operand
  80039. * @returns the current updated matrix
  80040. */
  80041. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  80042. /**
  80043. * Sets the given matrix to the current inverted Matrix
  80044. * @param other defines the target matrix
  80045. * @returns the unmodified current matrix
  80046. */
  80047. invertToRef(other: Matrix): Matrix;
  80048. /**
  80049. * add a value at the specified position in the current Matrix
  80050. * @param index the index of the value within the matrix. between 0 and 15.
  80051. * @param value the value to be added
  80052. * @returns the current updated matrix
  80053. */
  80054. addAtIndex(index: number, value: number): Matrix;
  80055. /**
  80056. * mutiply the specified position in the current Matrix by a value
  80057. * @param index the index of the value within the matrix. between 0 and 15.
  80058. * @param value the value to be added
  80059. * @returns the current updated matrix
  80060. */
  80061. multiplyAtIndex(index: number, value: number): Matrix;
  80062. /**
  80063. * Inserts the translation vector (using 3 floats) in the current matrix
  80064. * @param x defines the 1st component of the translation
  80065. * @param y defines the 2nd component of the translation
  80066. * @param z defines the 3rd component of the translation
  80067. * @returns the current updated matrix
  80068. */
  80069. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80070. /**
  80071. * Adds the translation vector (using 3 floats) in the current matrix
  80072. * @param x defines the 1st component of the translation
  80073. * @param y defines the 2nd component of the translation
  80074. * @param z defines the 3rd component of the translation
  80075. * @returns the current updated matrix
  80076. */
  80077. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  80078. /**
  80079. * Inserts the translation vector in the current matrix
  80080. * @param vector3 defines the translation to insert
  80081. * @returns the current updated matrix
  80082. */
  80083. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  80084. /**
  80085. * Gets the translation value of the current matrix
  80086. * @returns a new Vector3 as the extracted translation from the matrix
  80087. */
  80088. getTranslation(): Vector3;
  80089. /**
  80090. * Fill a Vector3 with the extracted translation from the matrix
  80091. * @param result defines the Vector3 where to store the translation
  80092. * @returns the current matrix
  80093. */
  80094. getTranslationToRef(result: Vector3): Matrix;
  80095. /**
  80096. * Remove rotation and scaling part from the matrix
  80097. * @returns the updated matrix
  80098. */
  80099. removeRotationAndScaling(): Matrix;
  80100. /**
  80101. * Multiply two matrices
  80102. * @param other defines the second operand
  80103. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  80104. */
  80105. multiply(other: DeepImmutable<Matrix>): Matrix;
  80106. /**
  80107. * Copy the current matrix from the given one
  80108. * @param other defines the source matrix
  80109. * @returns the current updated matrix
  80110. */
  80111. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  80112. /**
  80113. * Populates the given array from the starting index with the current matrix values
  80114. * @param array defines the target array
  80115. * @param offset defines the offset in the target array where to start storing values
  80116. * @returns the current matrix
  80117. */
  80118. copyToArray(array: Float32Array, offset?: number): Matrix;
  80119. /**
  80120. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  80121. * @param other defines the second operand
  80122. * @param result defines the matrix where to store the multiplication
  80123. * @returns the current matrix
  80124. */
  80125. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  80126. /**
  80127. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  80128. * @param other defines the second operand
  80129. * @param result defines the array where to store the multiplication
  80130. * @param offset defines the offset in the target array where to start storing values
  80131. * @returns the current matrix
  80132. */
  80133. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  80134. /**
  80135. * Check equality between this matrix and a second one
  80136. * @param value defines the second matrix to compare
  80137. * @returns true is the current matrix and the given one values are strictly equal
  80138. */
  80139. equals(value: DeepImmutable<Matrix>): boolean;
  80140. /**
  80141. * Clone the current matrix
  80142. * @returns a new matrix from the current matrix
  80143. */
  80144. clone(): Matrix;
  80145. /**
  80146. * Returns the name of the current matrix class
  80147. * @returns the string "Matrix"
  80148. */
  80149. getClassName(): string;
  80150. /**
  80151. * Gets the hash code of the current matrix
  80152. * @returns the hash code
  80153. */
  80154. getHashCode(): number;
  80155. /**
  80156. * Decomposes the current Matrix into a translation, rotation and scaling components
  80157. * @param scale defines the scale vector3 given as a reference to update
  80158. * @param rotation defines the rotation quaternion given as a reference to update
  80159. * @param translation defines the translation vector3 given as a reference to update
  80160. * @returns true if operation was successful
  80161. */
  80162. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  80163. /**
  80164. * Gets specific row of the matrix
  80165. * @param index defines the number of the row to get
  80166. * @returns the index-th row of the current matrix as a new Vector4
  80167. */
  80168. getRow(index: number): Nullable<Vector4>;
  80169. /**
  80170. * Sets the index-th row of the current matrix to the vector4 values
  80171. * @param index defines the number of the row to set
  80172. * @param row defines the target vector4
  80173. * @returns the updated current matrix
  80174. */
  80175. setRow(index: number, row: Vector4): Matrix;
  80176. /**
  80177. * Compute the transpose of the matrix
  80178. * @returns the new transposed matrix
  80179. */
  80180. transpose(): Matrix;
  80181. /**
  80182. * Compute the transpose of the matrix and store it in a given matrix
  80183. * @param result defines the target matrix
  80184. * @returns the current matrix
  80185. */
  80186. transposeToRef(result: Matrix): Matrix;
  80187. /**
  80188. * Sets the index-th row of the current matrix with the given 4 x float values
  80189. * @param index defines the row index
  80190. * @param x defines the x component to set
  80191. * @param y defines the y component to set
  80192. * @param z defines the z component to set
  80193. * @param w defines the w component to set
  80194. * @returns the updated current matrix
  80195. */
  80196. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80197. /**
  80198. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80199. * @param scale defines the scale factor
  80200. * @returns a new matrix
  80201. */
  80202. scale(scale: number): Matrix;
  80203. /**
  80204. * Scale the current matrix values by a factor to a given result matrix
  80205. * @param scale defines the scale factor
  80206. * @param result defines the matrix to store the result
  80207. * @returns the current matrix
  80208. */
  80209. scaleToRef(scale: number, result: Matrix): Matrix;
  80210. /**
  80211. * Scale the current matrix values by a factor and add the result to a given matrix
  80212. * @param scale defines the scale factor
  80213. * @param result defines the Matrix to store the result
  80214. * @returns the current matrix
  80215. */
  80216. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80217. /**
  80218. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80219. * @param ref matrix to store the result
  80220. */
  80221. toNormalMatrix(ref: Matrix): void;
  80222. /**
  80223. * Gets only rotation part of the current matrix
  80224. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80225. */
  80226. getRotationMatrix(): Matrix;
  80227. /**
  80228. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80229. * @param result defines the target matrix to store data to
  80230. * @returns the current matrix
  80231. */
  80232. getRotationMatrixToRef(result: Matrix): Matrix;
  80233. /**
  80234. * Toggles model matrix from being right handed to left handed in place and vice versa
  80235. */
  80236. toggleModelMatrixHandInPlace(): void;
  80237. /**
  80238. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80239. */
  80240. toggleProjectionMatrixHandInPlace(): void;
  80241. /**
  80242. * Creates a matrix from an array
  80243. * @param array defines the source array
  80244. * @param offset defines an offset in the source array
  80245. * @returns a new Matrix set from the starting index of the given array
  80246. */
  80247. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80248. /**
  80249. * Copy the content of an array into a given matrix
  80250. * @param array defines the source array
  80251. * @param offset defines an offset in the source array
  80252. * @param result defines the target matrix
  80253. */
  80254. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80255. /**
  80256. * Stores an array into a matrix after having multiplied each component by a given factor
  80257. * @param array defines the source array
  80258. * @param offset defines the offset in the source array
  80259. * @param scale defines the scaling factor
  80260. * @param result defines the target matrix
  80261. */
  80262. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80263. /**
  80264. * Gets an identity matrix that must not be updated
  80265. */
  80266. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80267. /**
  80268. * Stores a list of values (16) inside a given matrix
  80269. * @param initialM11 defines 1st value of 1st row
  80270. * @param initialM12 defines 2nd value of 1st row
  80271. * @param initialM13 defines 3rd value of 1st row
  80272. * @param initialM14 defines 4th value of 1st row
  80273. * @param initialM21 defines 1st value of 2nd row
  80274. * @param initialM22 defines 2nd value of 2nd row
  80275. * @param initialM23 defines 3rd value of 2nd row
  80276. * @param initialM24 defines 4th value of 2nd row
  80277. * @param initialM31 defines 1st value of 3rd row
  80278. * @param initialM32 defines 2nd value of 3rd row
  80279. * @param initialM33 defines 3rd value of 3rd row
  80280. * @param initialM34 defines 4th value of 3rd row
  80281. * @param initialM41 defines 1st value of 4th row
  80282. * @param initialM42 defines 2nd value of 4th row
  80283. * @param initialM43 defines 3rd value of 4th row
  80284. * @param initialM44 defines 4th value of 4th row
  80285. * @param result defines the target matrix
  80286. */
  80287. 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;
  80288. /**
  80289. * Creates new matrix from a list of values (16)
  80290. * @param initialM11 defines 1st value of 1st row
  80291. * @param initialM12 defines 2nd value of 1st row
  80292. * @param initialM13 defines 3rd value of 1st row
  80293. * @param initialM14 defines 4th value of 1st row
  80294. * @param initialM21 defines 1st value of 2nd row
  80295. * @param initialM22 defines 2nd value of 2nd row
  80296. * @param initialM23 defines 3rd value of 2nd row
  80297. * @param initialM24 defines 4th value of 2nd row
  80298. * @param initialM31 defines 1st value of 3rd row
  80299. * @param initialM32 defines 2nd value of 3rd row
  80300. * @param initialM33 defines 3rd value of 3rd row
  80301. * @param initialM34 defines 4th value of 3rd row
  80302. * @param initialM41 defines 1st value of 4th row
  80303. * @param initialM42 defines 2nd value of 4th row
  80304. * @param initialM43 defines 3rd value of 4th row
  80305. * @param initialM44 defines 4th value of 4th row
  80306. * @returns the new matrix
  80307. */
  80308. 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;
  80309. /**
  80310. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80311. * @param scale defines the scale vector3
  80312. * @param rotation defines the rotation quaternion
  80313. * @param translation defines the translation vector3
  80314. * @returns a new matrix
  80315. */
  80316. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80317. /**
  80318. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80319. * @param scale defines the scale vector3
  80320. * @param rotation defines the rotation quaternion
  80321. * @param translation defines the translation vector3
  80322. * @param result defines the target matrix
  80323. */
  80324. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80325. /**
  80326. * Creates a new identity matrix
  80327. * @returns a new identity matrix
  80328. */
  80329. static Identity(): Matrix;
  80330. /**
  80331. * Creates a new identity matrix and stores the result in a given matrix
  80332. * @param result defines the target matrix
  80333. */
  80334. static IdentityToRef(result: Matrix): void;
  80335. /**
  80336. * Creates a new zero matrix
  80337. * @returns a new zero matrix
  80338. */
  80339. static Zero(): Matrix;
  80340. /**
  80341. * Creates a new rotation matrix for "angle" radians around the X axis
  80342. * @param angle defines the angle (in radians) to use
  80343. * @return the new matrix
  80344. */
  80345. static RotationX(angle: number): Matrix;
  80346. /**
  80347. * Creates a new matrix as the invert of a given matrix
  80348. * @param source defines the source matrix
  80349. * @returns the new matrix
  80350. */
  80351. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80352. /**
  80353. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80354. * @param angle defines the angle (in radians) to use
  80355. * @param result defines the target matrix
  80356. */
  80357. static RotationXToRef(angle: number, result: Matrix): void;
  80358. /**
  80359. * Creates a new rotation matrix for "angle" radians around the Y axis
  80360. * @param angle defines the angle (in radians) to use
  80361. * @return the new matrix
  80362. */
  80363. static RotationY(angle: number): Matrix;
  80364. /**
  80365. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80366. * @param angle defines the angle (in radians) to use
  80367. * @param result defines the target matrix
  80368. */
  80369. static RotationYToRef(angle: number, result: Matrix): void;
  80370. /**
  80371. * Creates a new rotation matrix for "angle" radians around the Z axis
  80372. * @param angle defines the angle (in radians) to use
  80373. * @return the new matrix
  80374. */
  80375. static RotationZ(angle: number): Matrix;
  80376. /**
  80377. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80378. * @param angle defines the angle (in radians) to use
  80379. * @param result defines the target matrix
  80380. */
  80381. static RotationZToRef(angle: number, result: Matrix): void;
  80382. /**
  80383. * Creates a new rotation matrix for "angle" radians around the given axis
  80384. * @param axis defines the axis to use
  80385. * @param angle defines the angle (in radians) to use
  80386. * @return the new matrix
  80387. */
  80388. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80389. /**
  80390. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80391. * @param axis defines the axis to use
  80392. * @param angle defines the angle (in radians) to use
  80393. * @param result defines the target matrix
  80394. */
  80395. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80396. /**
  80397. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80398. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80399. * @param from defines the vector to align
  80400. * @param to defines the vector to align to
  80401. * @param result defines the target matrix
  80402. */
  80403. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80404. /**
  80405. * Creates a rotation matrix
  80406. * @param yaw defines the yaw angle in radians (Y axis)
  80407. * @param pitch defines the pitch angle in radians (X axis)
  80408. * @param roll defines the roll angle in radians (X axis)
  80409. * @returns the new rotation matrix
  80410. */
  80411. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80412. /**
  80413. * Creates a rotation matrix and stores it in a given matrix
  80414. * @param yaw defines the yaw angle in radians (Y axis)
  80415. * @param pitch defines the pitch angle in radians (X axis)
  80416. * @param roll defines the roll angle in radians (X axis)
  80417. * @param result defines the target matrix
  80418. */
  80419. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80420. /**
  80421. * Creates a scaling matrix
  80422. * @param x defines the scale factor on X axis
  80423. * @param y defines the scale factor on Y axis
  80424. * @param z defines the scale factor on Z axis
  80425. * @returns the new matrix
  80426. */
  80427. static Scaling(x: number, y: number, z: number): Matrix;
  80428. /**
  80429. * Creates a scaling matrix and stores it in a given matrix
  80430. * @param x defines the scale factor on X axis
  80431. * @param y defines the scale factor on Y axis
  80432. * @param z defines the scale factor on Z axis
  80433. * @param result defines the target matrix
  80434. */
  80435. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80436. /**
  80437. * Creates a translation matrix
  80438. * @param x defines the translation on X axis
  80439. * @param y defines the translation on Y axis
  80440. * @param z defines the translationon Z axis
  80441. * @returns the new matrix
  80442. */
  80443. static Translation(x: number, y: number, z: number): Matrix;
  80444. /**
  80445. * Creates a translation matrix and stores it in a given matrix
  80446. * @param x defines the translation on X axis
  80447. * @param y defines the translation on Y axis
  80448. * @param z defines the translationon Z axis
  80449. * @param result defines the target matrix
  80450. */
  80451. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80452. /**
  80453. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80454. * @param startValue defines the start value
  80455. * @param endValue defines the end value
  80456. * @param gradient defines the gradient factor
  80457. * @returns the new matrix
  80458. */
  80459. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80460. /**
  80461. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80462. * @param startValue defines the start value
  80463. * @param endValue defines the end value
  80464. * @param gradient defines the gradient factor
  80465. * @param result defines the Matrix object where to store data
  80466. */
  80467. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80468. /**
  80469. * Builds a new matrix whose values are computed by:
  80470. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80471. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80472. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80473. * @param startValue defines the first matrix
  80474. * @param endValue defines the second matrix
  80475. * @param gradient defines the gradient between the two matrices
  80476. * @returns the new matrix
  80477. */
  80478. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80479. /**
  80480. * Update a matrix to values which are computed by:
  80481. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80482. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80483. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80484. * @param startValue defines the first matrix
  80485. * @param endValue defines the second matrix
  80486. * @param gradient defines the gradient between the two matrices
  80487. * @param result defines the target matrix
  80488. */
  80489. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80490. /**
  80491. * 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"
  80492. * This function works in left handed mode
  80493. * @param eye defines the final position of the entity
  80494. * @param target defines where the entity should look at
  80495. * @param up defines the up vector for the entity
  80496. * @returns the new matrix
  80497. */
  80498. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80499. /**
  80500. * 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".
  80501. * This function works in left handed mode
  80502. * @param eye defines the final position of the entity
  80503. * @param target defines where the entity should look at
  80504. * @param up defines the up vector for the entity
  80505. * @param result defines the target matrix
  80506. */
  80507. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80508. /**
  80509. * 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"
  80510. * This function works in right handed mode
  80511. * @param eye defines the final position of the entity
  80512. * @param target defines where the entity should look at
  80513. * @param up defines the up vector for the entity
  80514. * @returns the new matrix
  80515. */
  80516. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80517. /**
  80518. * 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".
  80519. * This function works in right handed mode
  80520. * @param eye defines the final position of the entity
  80521. * @param target defines where the entity should look at
  80522. * @param up defines the up vector for the entity
  80523. * @param result defines the target matrix
  80524. */
  80525. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80526. /**
  80527. * Create a left-handed orthographic projection matrix
  80528. * @param width defines the viewport width
  80529. * @param height defines the viewport height
  80530. * @param znear defines the near clip plane
  80531. * @param zfar defines the far clip plane
  80532. * @returns a new matrix as a left-handed orthographic projection matrix
  80533. */
  80534. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80535. /**
  80536. * Store a left-handed orthographic projection to a given matrix
  80537. * @param width defines the viewport width
  80538. * @param height defines the viewport height
  80539. * @param znear defines the near clip plane
  80540. * @param zfar defines the far clip plane
  80541. * @param result defines the target matrix
  80542. */
  80543. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80544. /**
  80545. * Create a left-handed orthographic projection matrix
  80546. * @param left defines the viewport left coordinate
  80547. * @param right defines the viewport right coordinate
  80548. * @param bottom defines the viewport bottom coordinate
  80549. * @param top defines the viewport top coordinate
  80550. * @param znear defines the near clip plane
  80551. * @param zfar defines the far clip plane
  80552. * @returns a new matrix as a left-handed orthographic projection matrix
  80553. */
  80554. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80555. /**
  80556. * Stores a left-handed orthographic projection into a given matrix
  80557. * @param left defines the viewport left coordinate
  80558. * @param right defines the viewport right coordinate
  80559. * @param bottom defines the viewport bottom coordinate
  80560. * @param top defines the viewport top coordinate
  80561. * @param znear defines the near clip plane
  80562. * @param zfar defines the far clip plane
  80563. * @param result defines the target matrix
  80564. */
  80565. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80566. /**
  80567. * Creates a right-handed orthographic projection matrix
  80568. * @param left defines the viewport left coordinate
  80569. * @param right defines the viewport right coordinate
  80570. * @param bottom defines the viewport bottom coordinate
  80571. * @param top defines the viewport top coordinate
  80572. * @param znear defines the near clip plane
  80573. * @param zfar defines the far clip plane
  80574. * @returns a new matrix as a right-handed orthographic projection matrix
  80575. */
  80576. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80577. /**
  80578. * Stores a right-handed orthographic projection into a given matrix
  80579. * @param left defines the viewport left coordinate
  80580. * @param right defines the viewport right coordinate
  80581. * @param bottom defines the viewport bottom coordinate
  80582. * @param top defines the viewport top coordinate
  80583. * @param znear defines the near clip plane
  80584. * @param zfar defines the far clip plane
  80585. * @param result defines the target matrix
  80586. */
  80587. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80588. /**
  80589. * Creates a left-handed perspective projection matrix
  80590. * @param width defines the viewport width
  80591. * @param height defines the viewport height
  80592. * @param znear defines the near clip plane
  80593. * @param zfar defines the far clip plane
  80594. * @returns a new matrix as a left-handed perspective projection matrix
  80595. */
  80596. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80597. /**
  80598. * Creates a left-handed perspective projection matrix
  80599. * @param fov defines the horizontal field of view
  80600. * @param aspect defines the aspect ratio
  80601. * @param znear defines the near clip plane
  80602. * @param zfar defines the far clip plane
  80603. * @returns a new matrix as a left-handed perspective projection matrix
  80604. */
  80605. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80606. /**
  80607. * Stores a left-handed perspective projection into a given matrix
  80608. * @param fov defines the horizontal field of view
  80609. * @param aspect defines the aspect ratio
  80610. * @param znear defines the near clip plane
  80611. * @param zfar defines the far clip plane
  80612. * @param result defines the target matrix
  80613. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80614. */
  80615. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80616. /**
  80617. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80618. * @param fov defines the horizontal field of view
  80619. * @param aspect defines the aspect ratio
  80620. * @param znear defines the near clip plane
  80621. * @param zfar not used as infinity is used as far clip
  80622. * @param result defines the target matrix
  80623. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80624. */
  80625. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80626. /**
  80627. * Creates a right-handed perspective projection matrix
  80628. * @param fov defines the horizontal field of view
  80629. * @param aspect defines the aspect ratio
  80630. * @param znear defines the near clip plane
  80631. * @param zfar defines the far clip plane
  80632. * @returns a new matrix as a right-handed perspective projection matrix
  80633. */
  80634. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80635. /**
  80636. * Stores a right-handed perspective projection into a given matrix
  80637. * @param fov defines the horizontal field of view
  80638. * @param aspect defines the aspect ratio
  80639. * @param znear defines the near clip plane
  80640. * @param zfar defines the far clip plane
  80641. * @param result defines the target matrix
  80642. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80643. */
  80644. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80645. /**
  80646. * Stores a right-handed perspective projection into a given matrix
  80647. * @param fov defines the horizontal field of view
  80648. * @param aspect defines the aspect ratio
  80649. * @param znear defines the near clip plane
  80650. * @param zfar not used as infinity is used as far clip
  80651. * @param result defines the target matrix
  80652. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80653. */
  80654. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80655. /**
  80656. * Stores a perspective projection for WebVR info a given matrix
  80657. * @param fov defines the field of view
  80658. * @param znear defines the near clip plane
  80659. * @param zfar defines the far clip plane
  80660. * @param result defines the target matrix
  80661. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80662. */
  80663. static PerspectiveFovWebVRToRef(fov: {
  80664. upDegrees: number;
  80665. downDegrees: number;
  80666. leftDegrees: number;
  80667. rightDegrees: number;
  80668. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80669. /**
  80670. * Computes a complete transformation matrix
  80671. * @param viewport defines the viewport to use
  80672. * @param world defines the world matrix
  80673. * @param view defines the view matrix
  80674. * @param projection defines the projection matrix
  80675. * @param zmin defines the near clip plane
  80676. * @param zmax defines the far clip plane
  80677. * @returns the transformation matrix
  80678. */
  80679. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80680. /**
  80681. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80682. * @param matrix defines the matrix to use
  80683. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80684. */
  80685. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80686. /**
  80687. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80688. * @param matrix defines the matrix to use
  80689. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80690. */
  80691. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80692. /**
  80693. * Compute the transpose of a given matrix
  80694. * @param matrix defines the matrix to transpose
  80695. * @returns the new matrix
  80696. */
  80697. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80698. /**
  80699. * Compute the transpose of a matrix and store it in a target matrix
  80700. * @param matrix defines the matrix to transpose
  80701. * @param result defines the target matrix
  80702. */
  80703. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80704. /**
  80705. * Computes a reflection matrix from a plane
  80706. * @param plane defines the reflection plane
  80707. * @returns a new matrix
  80708. */
  80709. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80710. /**
  80711. * Computes a reflection matrix from a plane
  80712. * @param plane defines the reflection plane
  80713. * @param result defines the target matrix
  80714. */
  80715. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80716. /**
  80717. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80718. * @param xaxis defines the value of the 1st axis
  80719. * @param yaxis defines the value of the 2nd axis
  80720. * @param zaxis defines the value of the 3rd axis
  80721. * @param result defines the target matrix
  80722. */
  80723. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80724. /**
  80725. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80726. * @param quat defines the quaternion to use
  80727. * @param result defines the target matrix
  80728. */
  80729. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80730. }
  80731. /**
  80732. * @hidden
  80733. */
  80734. export class TmpVectors {
  80735. static Vector2: Vector2[];
  80736. static Vector3: Vector3[];
  80737. static Vector4: Vector4[];
  80738. static Quaternion: Quaternion[];
  80739. static Matrix: Matrix[];
  80740. }
  80741. }
  80742. declare module BABYLON {
  80743. /**
  80744. * Defines potential orientation for back face culling
  80745. */
  80746. export enum Orientation {
  80747. /**
  80748. * Clockwise
  80749. */
  80750. CW = 0,
  80751. /** Counter clockwise */
  80752. CCW = 1
  80753. }
  80754. /** Class used to represent a Bezier curve */
  80755. export class BezierCurve {
  80756. /**
  80757. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80758. * @param t defines the time
  80759. * @param x1 defines the left coordinate on X axis
  80760. * @param y1 defines the left coordinate on Y axis
  80761. * @param x2 defines the right coordinate on X axis
  80762. * @param y2 defines the right coordinate on Y axis
  80763. * @returns the interpolated value
  80764. */
  80765. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80766. }
  80767. /**
  80768. * Defines angle representation
  80769. */
  80770. export class Angle {
  80771. private _radians;
  80772. /**
  80773. * Creates an Angle object of "radians" radians (float).
  80774. * @param radians the angle in radians
  80775. */
  80776. constructor(radians: number);
  80777. /**
  80778. * Get value in degrees
  80779. * @returns the Angle value in degrees (float)
  80780. */
  80781. degrees(): number;
  80782. /**
  80783. * Get value in radians
  80784. * @returns the Angle value in radians (float)
  80785. */
  80786. radians(): number;
  80787. /**
  80788. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80789. * @param a defines first vector
  80790. * @param b defines second vector
  80791. * @returns a new Angle
  80792. */
  80793. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80794. /**
  80795. * Gets a new Angle object from the given float in radians
  80796. * @param radians defines the angle value in radians
  80797. * @returns a new Angle
  80798. */
  80799. static FromRadians(radians: number): Angle;
  80800. /**
  80801. * Gets a new Angle object from the given float in degrees
  80802. * @param degrees defines the angle value in degrees
  80803. * @returns a new Angle
  80804. */
  80805. static FromDegrees(degrees: number): Angle;
  80806. }
  80807. /**
  80808. * This represents an arc in a 2d space.
  80809. */
  80810. export class Arc2 {
  80811. /** Defines the start point of the arc */
  80812. startPoint: Vector2;
  80813. /** Defines the mid point of the arc */
  80814. midPoint: Vector2;
  80815. /** Defines the end point of the arc */
  80816. endPoint: Vector2;
  80817. /**
  80818. * Defines the center point of the arc.
  80819. */
  80820. centerPoint: Vector2;
  80821. /**
  80822. * Defines the radius of the arc.
  80823. */
  80824. radius: number;
  80825. /**
  80826. * Defines the angle of the arc (from mid point to end point).
  80827. */
  80828. angle: Angle;
  80829. /**
  80830. * Defines the start angle of the arc (from start point to middle point).
  80831. */
  80832. startAngle: Angle;
  80833. /**
  80834. * Defines the orientation of the arc (clock wise/counter clock wise).
  80835. */
  80836. orientation: Orientation;
  80837. /**
  80838. * Creates an Arc object from the three given points : start, middle and end.
  80839. * @param startPoint Defines the start point of the arc
  80840. * @param midPoint Defines the midlle point of the arc
  80841. * @param endPoint Defines the end point of the arc
  80842. */
  80843. constructor(
  80844. /** Defines the start point of the arc */
  80845. startPoint: Vector2,
  80846. /** Defines the mid point of the arc */
  80847. midPoint: Vector2,
  80848. /** Defines the end point of the arc */
  80849. endPoint: Vector2);
  80850. }
  80851. /**
  80852. * Represents a 2D path made up of multiple 2D points
  80853. */
  80854. export class Path2 {
  80855. private _points;
  80856. private _length;
  80857. /**
  80858. * If the path start and end point are the same
  80859. */
  80860. closed: boolean;
  80861. /**
  80862. * Creates a Path2 object from the starting 2D coordinates x and y.
  80863. * @param x the starting points x value
  80864. * @param y the starting points y value
  80865. */
  80866. constructor(x: number, y: number);
  80867. /**
  80868. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80869. * @param x the added points x value
  80870. * @param y the added points y value
  80871. * @returns the updated Path2.
  80872. */
  80873. addLineTo(x: number, y: number): Path2;
  80874. /**
  80875. * 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.
  80876. * @param midX middle point x value
  80877. * @param midY middle point y value
  80878. * @param endX end point x value
  80879. * @param endY end point y value
  80880. * @param numberOfSegments (default: 36)
  80881. * @returns the updated Path2.
  80882. */
  80883. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80884. /**
  80885. * Closes the Path2.
  80886. * @returns the Path2.
  80887. */
  80888. close(): Path2;
  80889. /**
  80890. * Gets the sum of the distance between each sequential point in the path
  80891. * @returns the Path2 total length (float).
  80892. */
  80893. length(): number;
  80894. /**
  80895. * Gets the points which construct the path
  80896. * @returns the Path2 internal array of points.
  80897. */
  80898. getPoints(): Vector2[];
  80899. /**
  80900. * Retreives the point at the distance aways from the starting point
  80901. * @param normalizedLengthPosition the length along the path to retreive the point from
  80902. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80903. */
  80904. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80905. /**
  80906. * Creates a new path starting from an x and y position
  80907. * @param x starting x value
  80908. * @param y starting y value
  80909. * @returns a new Path2 starting at the coordinates (x, y).
  80910. */
  80911. static StartingAt(x: number, y: number): Path2;
  80912. }
  80913. /**
  80914. * Represents a 3D path made up of multiple 3D points
  80915. */
  80916. export class Path3D {
  80917. /**
  80918. * an array of Vector3, the curve axis of the Path3D
  80919. */
  80920. path: Vector3[];
  80921. private _curve;
  80922. private _distances;
  80923. private _tangents;
  80924. private _normals;
  80925. private _binormals;
  80926. private _raw;
  80927. private _alignTangentsWithPath;
  80928. private readonly _pointAtData;
  80929. /**
  80930. * new Path3D(path, normal, raw)
  80931. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80932. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80933. * @param path an array of Vector3, the curve axis of the Path3D
  80934. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80935. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80936. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80937. */
  80938. constructor(
  80939. /**
  80940. * an array of Vector3, the curve axis of the Path3D
  80941. */
  80942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80943. /**
  80944. * Returns the Path3D array of successive Vector3 designing its curve.
  80945. * @returns the Path3D array of successive Vector3 designing its curve.
  80946. */
  80947. getCurve(): Vector3[];
  80948. /**
  80949. * Returns the Path3D array of successive Vector3 designing its curve.
  80950. * @returns the Path3D array of successive Vector3 designing its curve.
  80951. */
  80952. getPoints(): Vector3[];
  80953. /**
  80954. * @returns the computed length (float) of the path.
  80955. */
  80956. length(): number;
  80957. /**
  80958. * Returns an array populated with tangent vectors on each Path3D curve point.
  80959. * @returns an array populated with tangent vectors on each Path3D curve point.
  80960. */
  80961. getTangents(): Vector3[];
  80962. /**
  80963. * Returns an array populated with normal vectors on each Path3D curve point.
  80964. * @returns an array populated with normal vectors on each Path3D curve point.
  80965. */
  80966. getNormals(): Vector3[];
  80967. /**
  80968. * Returns an array populated with binormal vectors on each Path3D curve point.
  80969. * @returns an array populated with binormal vectors on each Path3D curve point.
  80970. */
  80971. getBinormals(): Vector3[];
  80972. /**
  80973. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  80974. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  80975. */
  80976. getDistances(): number[];
  80977. /**
  80978. * Returns an interpolated point along this path
  80979. * @param position the position of the point along this path, from 0.0 to 1.0
  80980. * @returns a new Vector3 as the point
  80981. */
  80982. getPointAt(position: number): Vector3;
  80983. /**
  80984. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80985. * @param position the position of the point along this path, from 0.0 to 1.0
  80986. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  80987. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  80988. */
  80989. getTangentAt(position: number, interpolated?: boolean): Vector3;
  80990. /**
  80991. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80992. * @param position the position of the point along this path, from 0.0 to 1.0
  80993. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  80994. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  80995. */
  80996. getNormalAt(position: number, interpolated?: boolean): Vector3;
  80997. /**
  80998. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  80999. * @param position the position of the point along this path, from 0.0 to 1.0
  81000. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  81001. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  81002. */
  81003. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  81004. /**
  81005. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  81006. * @param position the position of the point along this path, from 0.0 to 1.0
  81007. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  81008. */
  81009. getDistanceAt(position: number): number;
  81010. /**
  81011. * Returns the array index of the previous point of an interpolated point along this path
  81012. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81013. * @returns the array index
  81014. */
  81015. getPreviousPointIndexAt(position: number): number;
  81016. /**
  81017. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  81018. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81019. * @returns the sub position
  81020. */
  81021. getSubPositionAt(position: number): number;
  81022. /**
  81023. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  81024. * @param target the vector of which to get the closest position to
  81025. * @returns the position of the closest virtual point on this path to the target vector
  81026. */
  81027. getClosestPositionTo(target: Vector3): number;
  81028. /**
  81029. * Returns a sub path (slice) of this path
  81030. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  81031. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  81032. * @returns a sub path (slice) of this path
  81033. */
  81034. slice(start?: number, end?: number): Path3D;
  81035. /**
  81036. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  81037. * @param path path which all values are copied into the curves points
  81038. * @param firstNormal which should be projected onto the curve
  81039. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  81040. * @returns the same object updated.
  81041. */
  81042. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  81043. private _compute;
  81044. private _getFirstNonNullVector;
  81045. private _getLastNonNullVector;
  81046. private _normalVector;
  81047. /**
  81048. * Updates the point at data for an interpolated point along this curve
  81049. * @param position the position of the point along this curve, from 0.0 to 1.0
  81050. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  81051. * @returns the (updated) point at data
  81052. */
  81053. private _updatePointAtData;
  81054. /**
  81055. * Updates the point at data from the specified parameters
  81056. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  81057. * @param point the interpolated point
  81058. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  81059. */
  81060. private _setPointAtData;
  81061. /**
  81062. * Updates the point at interpolation matrix for the tangents, normals and binormals
  81063. */
  81064. private _updateInterpolationMatrix;
  81065. }
  81066. /**
  81067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81068. * A Curve3 is designed from a series of successive Vector3.
  81069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  81070. */
  81071. export class Curve3 {
  81072. private _points;
  81073. private _length;
  81074. /**
  81075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  81076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  81077. * @param v1 (Vector3) the control point
  81078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  81079. * @param nbPoints (integer) the wanted number of points in the curve
  81080. * @returns the created Curve3
  81081. */
  81082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81083. /**
  81084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  81085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  81086. * @param v1 (Vector3) the first control point
  81087. * @param v2 (Vector3) the second control point
  81088. * @param v3 (Vector3) the end point of the Cubic Bezier
  81089. * @param nbPoints (integer) the wanted number of points in the curve
  81090. * @returns the created Curve3
  81091. */
  81092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81093. /**
  81094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  81095. * @param p1 (Vector3) the origin point of the Hermite Spline
  81096. * @param t1 (Vector3) the tangent vector at the origin point
  81097. * @param p2 (Vector3) the end point of the Hermite Spline
  81098. * @param t2 (Vector3) the tangent vector at the end point
  81099. * @param nbPoints (integer) the wanted number of points in the curve
  81100. * @returns the created Curve3
  81101. */
  81102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  81103. /**
  81104. * Returns a Curve3 object along a CatmullRom Spline curve :
  81105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  81106. * @param nbPoints (integer) the wanted number of points between each curve control points
  81107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  81108. * @returns the created Curve3
  81109. */
  81110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  81111. /**
  81112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  81113. * A Curve3 is designed from a series of successive Vector3.
  81114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  81115. * @param points points which make up the curve
  81116. */
  81117. constructor(points: Vector3[]);
  81118. /**
  81119. * @returns the Curve3 stored array of successive Vector3
  81120. */
  81121. getPoints(): Vector3[];
  81122. /**
  81123. * @returns the computed length (float) of the curve.
  81124. */
  81125. length(): number;
  81126. /**
  81127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  81128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  81129. * curveA and curveB keep unchanged.
  81130. * @param curve the curve to continue from this curve
  81131. * @returns the newly constructed curve
  81132. */
  81133. continue(curve: DeepImmutable<Curve3>): Curve3;
  81134. private _computeLength;
  81135. }
  81136. }
  81137. declare module BABYLON {
  81138. /**
  81139. * This represents the main contract an easing function should follow.
  81140. * Easing functions are used throughout the animation system.
  81141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81142. */
  81143. export interface IEasingFunction {
  81144. /**
  81145. * Given an input gradient between 0 and 1, this returns the corrseponding value
  81146. * of the easing function.
  81147. * The link below provides some of the most common examples of easing functions.
  81148. * @see https://easings.net/
  81149. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81150. * @returns the corresponding value on the curve defined by the easing function
  81151. */
  81152. ease(gradient: number): number;
  81153. }
  81154. /**
  81155. * Base class used for every default easing function.
  81156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81157. */
  81158. export class EasingFunction implements IEasingFunction {
  81159. /**
  81160. * Interpolation follows the mathematical formula associated with the easing function.
  81161. */
  81162. static readonly EASINGMODE_EASEIN: number;
  81163. /**
  81164. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  81165. */
  81166. static readonly EASINGMODE_EASEOUT: number;
  81167. /**
  81168. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  81169. */
  81170. static readonly EASINGMODE_EASEINOUT: number;
  81171. private _easingMode;
  81172. /**
  81173. * Sets the easing mode of the current function.
  81174. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  81175. */
  81176. setEasingMode(easingMode: number): void;
  81177. /**
  81178. * Gets the current easing mode.
  81179. * @returns the easing mode
  81180. */
  81181. getEasingMode(): number;
  81182. /**
  81183. * @hidden
  81184. */
  81185. easeInCore(gradient: number): number;
  81186. /**
  81187. * Given an input gradient between 0 and 1, this returns the corresponding value
  81188. * of the easing function.
  81189. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81190. * @returns the corresponding value on the curve defined by the easing function
  81191. */
  81192. ease(gradient: number): number;
  81193. }
  81194. /**
  81195. * Easing function with a circle shape (see link below).
  81196. * @see https://easings.net/#easeInCirc
  81197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81198. */
  81199. export class CircleEase extends EasingFunction implements IEasingFunction {
  81200. /** @hidden */
  81201. easeInCore(gradient: number): number;
  81202. }
  81203. /**
  81204. * Easing function with a ease back shape (see link below).
  81205. * @see https://easings.net/#easeInBack
  81206. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81207. */
  81208. export class BackEase extends EasingFunction implements IEasingFunction {
  81209. /** Defines the amplitude of the function */
  81210. amplitude: number;
  81211. /**
  81212. * Instantiates a back ease easing
  81213. * @see https://easings.net/#easeInBack
  81214. * @param amplitude Defines the amplitude of the function
  81215. */
  81216. constructor(
  81217. /** Defines the amplitude of the function */
  81218. amplitude?: number);
  81219. /** @hidden */
  81220. easeInCore(gradient: number): number;
  81221. }
  81222. /**
  81223. * Easing function with a bouncing shape (see link below).
  81224. * @see https://easings.net/#easeInBounce
  81225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81226. */
  81227. export class BounceEase extends EasingFunction implements IEasingFunction {
  81228. /** Defines the number of bounces */
  81229. bounces: number;
  81230. /** Defines the amplitude of the bounce */
  81231. bounciness: number;
  81232. /**
  81233. * Instantiates a bounce easing
  81234. * @see https://easings.net/#easeInBounce
  81235. * @param bounces Defines the number of bounces
  81236. * @param bounciness Defines the amplitude of the bounce
  81237. */
  81238. constructor(
  81239. /** Defines the number of bounces */
  81240. bounces?: number,
  81241. /** Defines the amplitude of the bounce */
  81242. bounciness?: number);
  81243. /** @hidden */
  81244. easeInCore(gradient: number): number;
  81245. }
  81246. /**
  81247. * Easing function with a power of 3 shape (see link below).
  81248. * @see https://easings.net/#easeInCubic
  81249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81250. */
  81251. export class CubicEase extends EasingFunction implements IEasingFunction {
  81252. /** @hidden */
  81253. easeInCore(gradient: number): number;
  81254. }
  81255. /**
  81256. * Easing function with an elastic shape (see link below).
  81257. * @see https://easings.net/#easeInElastic
  81258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81259. */
  81260. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81261. /** Defines the number of oscillations*/
  81262. oscillations: number;
  81263. /** Defines the amplitude of the oscillations*/
  81264. springiness: number;
  81265. /**
  81266. * Instantiates an elastic easing function
  81267. * @see https://easings.net/#easeInElastic
  81268. * @param oscillations Defines the number of oscillations
  81269. * @param springiness Defines the amplitude of the oscillations
  81270. */
  81271. constructor(
  81272. /** Defines the number of oscillations*/
  81273. oscillations?: number,
  81274. /** Defines the amplitude of the oscillations*/
  81275. springiness?: number);
  81276. /** @hidden */
  81277. easeInCore(gradient: number): number;
  81278. }
  81279. /**
  81280. * Easing function with an exponential shape (see link below).
  81281. * @see https://easings.net/#easeInExpo
  81282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81283. */
  81284. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81285. /** Defines the exponent of the function */
  81286. exponent: number;
  81287. /**
  81288. * Instantiates an exponential easing function
  81289. * @see https://easings.net/#easeInExpo
  81290. * @param exponent Defines the exponent of the function
  81291. */
  81292. constructor(
  81293. /** Defines the exponent of the function */
  81294. exponent?: number);
  81295. /** @hidden */
  81296. easeInCore(gradient: number): number;
  81297. }
  81298. /**
  81299. * Easing function with a power shape (see link below).
  81300. * @see https://easings.net/#easeInQuad
  81301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81302. */
  81303. export class PowerEase extends EasingFunction implements IEasingFunction {
  81304. /** Defines the power of the function */
  81305. power: number;
  81306. /**
  81307. * Instantiates an power base easing function
  81308. * @see https://easings.net/#easeInQuad
  81309. * @param power Defines the power of the function
  81310. */
  81311. constructor(
  81312. /** Defines the power of the function */
  81313. power?: number);
  81314. /** @hidden */
  81315. easeInCore(gradient: number): number;
  81316. }
  81317. /**
  81318. * Easing function with a power of 2 shape (see link below).
  81319. * @see https://easings.net/#easeInQuad
  81320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81321. */
  81322. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81323. /** @hidden */
  81324. easeInCore(gradient: number): number;
  81325. }
  81326. /**
  81327. * Easing function with a power of 4 shape (see link below).
  81328. * @see https://easings.net/#easeInQuart
  81329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81330. */
  81331. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81332. /** @hidden */
  81333. easeInCore(gradient: number): number;
  81334. }
  81335. /**
  81336. * Easing function with a power of 5 shape (see link below).
  81337. * @see https://easings.net/#easeInQuint
  81338. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81339. */
  81340. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81341. /** @hidden */
  81342. easeInCore(gradient: number): number;
  81343. }
  81344. /**
  81345. * Easing function with a sin shape (see link below).
  81346. * @see https://easings.net/#easeInSine
  81347. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81348. */
  81349. export class SineEase extends EasingFunction implements IEasingFunction {
  81350. /** @hidden */
  81351. easeInCore(gradient: number): number;
  81352. }
  81353. /**
  81354. * Easing function with a bezier shape (see link below).
  81355. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81356. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81357. */
  81358. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81359. /** Defines the x component of the start tangent in the bezier curve */
  81360. x1: number;
  81361. /** Defines the y component of the start tangent in the bezier curve */
  81362. y1: number;
  81363. /** Defines the x component of the end tangent in the bezier curve */
  81364. x2: number;
  81365. /** Defines the y component of the end tangent in the bezier curve */
  81366. y2: number;
  81367. /**
  81368. * Instantiates a bezier function
  81369. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81370. * @param x1 Defines the x component of the start tangent in the bezier curve
  81371. * @param y1 Defines the y component of the start tangent in the bezier curve
  81372. * @param x2 Defines the x component of the end tangent in the bezier curve
  81373. * @param y2 Defines the y component of the end tangent in the bezier curve
  81374. */
  81375. constructor(
  81376. /** Defines the x component of the start tangent in the bezier curve */
  81377. x1?: number,
  81378. /** Defines the y component of the start tangent in the bezier curve */
  81379. y1?: number,
  81380. /** Defines the x component of the end tangent in the bezier curve */
  81381. x2?: number,
  81382. /** Defines the y component of the end tangent in the bezier curve */
  81383. y2?: number);
  81384. /** @hidden */
  81385. easeInCore(gradient: number): number;
  81386. }
  81387. }
  81388. declare module BABYLON {
  81389. /**
  81390. * Class used to hold a RBG color
  81391. */
  81392. export class Color3 {
  81393. /**
  81394. * Defines the red component (between 0 and 1, default is 0)
  81395. */
  81396. r: number;
  81397. /**
  81398. * Defines the green component (between 0 and 1, default is 0)
  81399. */
  81400. g: number;
  81401. /**
  81402. * Defines the blue component (between 0 and 1, default is 0)
  81403. */
  81404. b: number;
  81405. /**
  81406. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81407. * @param r defines the red component (between 0 and 1, default is 0)
  81408. * @param g defines the green component (between 0 and 1, default is 0)
  81409. * @param b defines the blue component (between 0 and 1, default is 0)
  81410. */
  81411. constructor(
  81412. /**
  81413. * Defines the red component (between 0 and 1, default is 0)
  81414. */
  81415. r?: number,
  81416. /**
  81417. * Defines the green component (between 0 and 1, default is 0)
  81418. */
  81419. g?: number,
  81420. /**
  81421. * Defines the blue component (between 0 and 1, default is 0)
  81422. */
  81423. b?: number);
  81424. /**
  81425. * Creates a string with the Color3 current values
  81426. * @returns the string representation of the Color3 object
  81427. */
  81428. toString(): string;
  81429. /**
  81430. * Returns the string "Color3"
  81431. * @returns "Color3"
  81432. */
  81433. getClassName(): string;
  81434. /**
  81435. * Compute the Color3 hash code
  81436. * @returns an unique number that can be used to hash Color3 objects
  81437. */
  81438. getHashCode(): number;
  81439. /**
  81440. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81441. * @param array defines the array where to store the r,g,b components
  81442. * @param index defines an optional index in the target array to define where to start storing values
  81443. * @returns the current Color3 object
  81444. */
  81445. toArray(array: FloatArray, index?: number): Color3;
  81446. /**
  81447. * Returns a new Color4 object from the current Color3 and the given alpha
  81448. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81449. * @returns a new Color4 object
  81450. */
  81451. toColor4(alpha?: number): Color4;
  81452. /**
  81453. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81454. * @returns the new array
  81455. */
  81456. asArray(): number[];
  81457. /**
  81458. * Returns the luminance value
  81459. * @returns a float value
  81460. */
  81461. toLuminance(): number;
  81462. /**
  81463. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81464. * @param otherColor defines the second operand
  81465. * @returns the new Color3 object
  81466. */
  81467. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81468. /**
  81469. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81470. * @param otherColor defines the second operand
  81471. * @param result defines the Color3 object where to store the result
  81472. * @returns the current Color3
  81473. */
  81474. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81475. /**
  81476. * Determines equality between Color3 objects
  81477. * @param otherColor defines the second operand
  81478. * @returns true if the rgb values are equal to the given ones
  81479. */
  81480. equals(otherColor: DeepImmutable<Color3>): boolean;
  81481. /**
  81482. * Determines equality between the current Color3 object and a set of r,b,g values
  81483. * @param r defines the red component to check
  81484. * @param g defines the green component to check
  81485. * @param b defines the blue component to check
  81486. * @returns true if the rgb values are equal to the given ones
  81487. */
  81488. equalsFloats(r: number, g: number, b: number): boolean;
  81489. /**
  81490. * Multiplies in place each rgb value by scale
  81491. * @param scale defines the scaling factor
  81492. * @returns the updated Color3
  81493. */
  81494. scale(scale: number): Color3;
  81495. /**
  81496. * Multiplies the rgb values by scale and stores the result into "result"
  81497. * @param scale defines the scaling factor
  81498. * @param result defines the Color3 object where to store the result
  81499. * @returns the unmodified current Color3
  81500. */
  81501. scaleToRef(scale: number, result: Color3): Color3;
  81502. /**
  81503. * Scale the current Color3 values by a factor and add the result to a given Color3
  81504. * @param scale defines the scale factor
  81505. * @param result defines color to store the result into
  81506. * @returns the unmodified current Color3
  81507. */
  81508. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81509. /**
  81510. * Clamps the rgb values by the min and max values and stores the result into "result"
  81511. * @param min defines minimum clamping value (default is 0)
  81512. * @param max defines maximum clamping value (default is 1)
  81513. * @param result defines color to store the result into
  81514. * @returns the original Color3
  81515. */
  81516. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81517. /**
  81518. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81519. * @param otherColor defines the second operand
  81520. * @returns the new Color3
  81521. */
  81522. add(otherColor: DeepImmutable<Color3>): Color3;
  81523. /**
  81524. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81525. * @param otherColor defines the second operand
  81526. * @param result defines Color3 object to store the result into
  81527. * @returns the unmodified current Color3
  81528. */
  81529. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81530. /**
  81531. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81532. * @param otherColor defines the second operand
  81533. * @returns the new Color3
  81534. */
  81535. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81536. /**
  81537. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81538. * @param otherColor defines the second operand
  81539. * @param result defines Color3 object to store the result into
  81540. * @returns the unmodified current Color3
  81541. */
  81542. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81543. /**
  81544. * Copy the current object
  81545. * @returns a new Color3 copied the current one
  81546. */
  81547. clone(): Color3;
  81548. /**
  81549. * Copies the rgb values from the source in the current Color3
  81550. * @param source defines the source Color3 object
  81551. * @returns the updated Color3 object
  81552. */
  81553. copyFrom(source: DeepImmutable<Color3>): Color3;
  81554. /**
  81555. * Updates the Color3 rgb values from the given floats
  81556. * @param r defines the red component to read from
  81557. * @param g defines the green component to read from
  81558. * @param b defines the blue component to read from
  81559. * @returns the current Color3 object
  81560. */
  81561. copyFromFloats(r: number, g: number, b: number): Color3;
  81562. /**
  81563. * Updates the Color3 rgb values from the given floats
  81564. * @param r defines the red component to read from
  81565. * @param g defines the green component to read from
  81566. * @param b defines the blue component to read from
  81567. * @returns the current Color3 object
  81568. */
  81569. set(r: number, g: number, b: number): Color3;
  81570. /**
  81571. * Compute the Color3 hexadecimal code as a string
  81572. * @returns a string containing the hexadecimal representation of the Color3 object
  81573. */
  81574. toHexString(): string;
  81575. /**
  81576. * Computes a new Color3 converted from the current one to linear space
  81577. * @returns a new Color3 object
  81578. */
  81579. toLinearSpace(): Color3;
  81580. /**
  81581. * Converts current color in rgb space to HSV values
  81582. * @returns a new color3 representing the HSV values
  81583. */
  81584. toHSV(): Color3;
  81585. /**
  81586. * Converts current color in rgb space to HSV values
  81587. * @param result defines the Color3 where to store the HSV values
  81588. */
  81589. toHSVToRef(result: Color3): void;
  81590. /**
  81591. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81592. * @param convertedColor defines the Color3 object where to store the linear space version
  81593. * @returns the unmodified Color3
  81594. */
  81595. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81596. /**
  81597. * Computes a new Color3 converted from the current one to gamma space
  81598. * @returns a new Color3 object
  81599. */
  81600. toGammaSpace(): Color3;
  81601. /**
  81602. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81603. * @param convertedColor defines the Color3 object where to store the gamma space version
  81604. * @returns the unmodified Color3
  81605. */
  81606. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81607. private static _BlackReadOnly;
  81608. /**
  81609. * Convert Hue, saturation and value to a Color3 (RGB)
  81610. * @param hue defines the hue
  81611. * @param saturation defines the saturation
  81612. * @param value defines the value
  81613. * @param result defines the Color3 where to store the RGB values
  81614. */
  81615. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81616. /**
  81617. * Creates a new Color3 from the string containing valid hexadecimal values
  81618. * @param hex defines a string containing valid hexadecimal values
  81619. * @returns a new Color3 object
  81620. */
  81621. static FromHexString(hex: string): Color3;
  81622. /**
  81623. * Creates a new Color3 from the starting index of the given array
  81624. * @param array defines the source array
  81625. * @param offset defines an offset in the source array
  81626. * @returns a new Color3 object
  81627. */
  81628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81629. /**
  81630. * Creates a new Color3 from integer values (< 256)
  81631. * @param r defines the red component to read from (value between 0 and 255)
  81632. * @param g defines the green component to read from (value between 0 and 255)
  81633. * @param b defines the blue component to read from (value between 0 and 255)
  81634. * @returns a new Color3 object
  81635. */
  81636. static FromInts(r: number, g: number, b: number): Color3;
  81637. /**
  81638. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81639. * @param start defines the start Color3 value
  81640. * @param end defines the end Color3 value
  81641. * @param amount defines the gradient value between start and end
  81642. * @returns a new Color3 object
  81643. */
  81644. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81645. /**
  81646. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81647. * @param left defines the start value
  81648. * @param right defines the end value
  81649. * @param amount defines the gradient factor
  81650. * @param result defines the Color3 object where to store the result
  81651. */
  81652. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81653. /**
  81654. * Returns a Color3 value containing a red color
  81655. * @returns a new Color3 object
  81656. */
  81657. static Red(): Color3;
  81658. /**
  81659. * Returns a Color3 value containing a green color
  81660. * @returns a new Color3 object
  81661. */
  81662. static Green(): Color3;
  81663. /**
  81664. * Returns a Color3 value containing a blue color
  81665. * @returns a new Color3 object
  81666. */
  81667. static Blue(): Color3;
  81668. /**
  81669. * Returns a Color3 value containing a black color
  81670. * @returns a new Color3 object
  81671. */
  81672. static Black(): Color3;
  81673. /**
  81674. * Gets a Color3 value containing a black color that must not be updated
  81675. */
  81676. static get BlackReadOnly(): DeepImmutable<Color3>;
  81677. /**
  81678. * Returns a Color3 value containing a white color
  81679. * @returns a new Color3 object
  81680. */
  81681. static White(): Color3;
  81682. /**
  81683. * Returns a Color3 value containing a purple color
  81684. * @returns a new Color3 object
  81685. */
  81686. static Purple(): Color3;
  81687. /**
  81688. * Returns a Color3 value containing a magenta color
  81689. * @returns a new Color3 object
  81690. */
  81691. static Magenta(): Color3;
  81692. /**
  81693. * Returns a Color3 value containing a yellow color
  81694. * @returns a new Color3 object
  81695. */
  81696. static Yellow(): Color3;
  81697. /**
  81698. * Returns a Color3 value containing a gray color
  81699. * @returns a new Color3 object
  81700. */
  81701. static Gray(): Color3;
  81702. /**
  81703. * Returns a Color3 value containing a teal color
  81704. * @returns a new Color3 object
  81705. */
  81706. static Teal(): Color3;
  81707. /**
  81708. * Returns a Color3 value containing a random color
  81709. * @returns a new Color3 object
  81710. */
  81711. static Random(): Color3;
  81712. }
  81713. /**
  81714. * Class used to hold a RBGA color
  81715. */
  81716. export class Color4 {
  81717. /**
  81718. * Defines the red component (between 0 and 1, default is 0)
  81719. */
  81720. r: number;
  81721. /**
  81722. * Defines the green component (between 0 and 1, default is 0)
  81723. */
  81724. g: number;
  81725. /**
  81726. * Defines the blue component (between 0 and 1, default is 0)
  81727. */
  81728. b: number;
  81729. /**
  81730. * Defines the alpha component (between 0 and 1, default is 1)
  81731. */
  81732. a: number;
  81733. /**
  81734. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81735. * @param r defines the red component (between 0 and 1, default is 0)
  81736. * @param g defines the green component (between 0 and 1, default is 0)
  81737. * @param b defines the blue component (between 0 and 1, default is 0)
  81738. * @param a defines the alpha component (between 0 and 1, default is 1)
  81739. */
  81740. constructor(
  81741. /**
  81742. * Defines the red component (between 0 and 1, default is 0)
  81743. */
  81744. r?: number,
  81745. /**
  81746. * Defines the green component (between 0 and 1, default is 0)
  81747. */
  81748. g?: number,
  81749. /**
  81750. * Defines the blue component (between 0 and 1, default is 0)
  81751. */
  81752. b?: number,
  81753. /**
  81754. * Defines the alpha component (between 0 and 1, default is 1)
  81755. */
  81756. a?: number);
  81757. /**
  81758. * Adds in place the given Color4 values to the current Color4 object
  81759. * @param right defines the second operand
  81760. * @returns the current updated Color4 object
  81761. */
  81762. addInPlace(right: DeepImmutable<Color4>): Color4;
  81763. /**
  81764. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81765. * @returns the new array
  81766. */
  81767. asArray(): number[];
  81768. /**
  81769. * Stores from the starting index in the given array the Color4 successive values
  81770. * @param array defines the array where to store the r,g,b components
  81771. * @param index defines an optional index in the target array to define where to start storing values
  81772. * @returns the current Color4 object
  81773. */
  81774. toArray(array: number[], index?: number): Color4;
  81775. /**
  81776. * Determines equality between Color4 objects
  81777. * @param otherColor defines the second operand
  81778. * @returns true if the rgba values are equal to the given ones
  81779. */
  81780. equals(otherColor: DeepImmutable<Color4>): boolean;
  81781. /**
  81782. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81783. * @param right defines the second operand
  81784. * @returns a new Color4 object
  81785. */
  81786. add(right: DeepImmutable<Color4>): Color4;
  81787. /**
  81788. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81789. * @param right defines the second operand
  81790. * @returns a new Color4 object
  81791. */
  81792. subtract(right: DeepImmutable<Color4>): Color4;
  81793. /**
  81794. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81795. * @param right defines the second operand
  81796. * @param result defines the Color4 object where to store the result
  81797. * @returns the current Color4 object
  81798. */
  81799. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81800. /**
  81801. * Creates a new Color4 with the current Color4 values multiplied by scale
  81802. * @param scale defines the scaling factor to apply
  81803. * @returns a new Color4 object
  81804. */
  81805. scale(scale: number): Color4;
  81806. /**
  81807. * Multiplies the current Color4 values by scale and stores the result in "result"
  81808. * @param scale defines the scaling factor to apply
  81809. * @param result defines the Color4 object where to store the result
  81810. * @returns the current unmodified Color4
  81811. */
  81812. scaleToRef(scale: number, result: Color4): Color4;
  81813. /**
  81814. * Scale the current Color4 values by a factor and add the result to a given Color4
  81815. * @param scale defines the scale factor
  81816. * @param result defines the Color4 object where to store the result
  81817. * @returns the unmodified current Color4
  81818. */
  81819. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81820. /**
  81821. * Clamps the rgb values by the min and max values and stores the result into "result"
  81822. * @param min defines minimum clamping value (default is 0)
  81823. * @param max defines maximum clamping value (default is 1)
  81824. * @param result defines color to store the result into.
  81825. * @returns the cuurent Color4
  81826. */
  81827. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81828. /**
  81829. * Multipy an Color4 value by another and return a new Color4 object
  81830. * @param color defines the Color4 value to multiply by
  81831. * @returns a new Color4 object
  81832. */
  81833. multiply(color: Color4): Color4;
  81834. /**
  81835. * Multipy a Color4 value by another and push the result in a reference value
  81836. * @param color defines the Color4 value to multiply by
  81837. * @param result defines the Color4 to fill the result in
  81838. * @returns the result Color4
  81839. */
  81840. multiplyToRef(color: Color4, result: Color4): Color4;
  81841. /**
  81842. * Creates a string with the Color4 current values
  81843. * @returns the string representation of the Color4 object
  81844. */
  81845. toString(): string;
  81846. /**
  81847. * Returns the string "Color4"
  81848. * @returns "Color4"
  81849. */
  81850. getClassName(): string;
  81851. /**
  81852. * Compute the Color4 hash code
  81853. * @returns an unique number that can be used to hash Color4 objects
  81854. */
  81855. getHashCode(): number;
  81856. /**
  81857. * Creates a new Color4 copied from the current one
  81858. * @returns a new Color4 object
  81859. */
  81860. clone(): Color4;
  81861. /**
  81862. * Copies the given Color4 values into the current one
  81863. * @param source defines the source Color4 object
  81864. * @returns the current updated Color4 object
  81865. */
  81866. copyFrom(source: Color4): Color4;
  81867. /**
  81868. * Copies the given float values into the current one
  81869. * @param r defines the red component to read from
  81870. * @param g defines the green component to read from
  81871. * @param b defines the blue component to read from
  81872. * @param a defines the alpha component to read from
  81873. * @returns the current updated Color4 object
  81874. */
  81875. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81876. /**
  81877. * Copies the given float values into the current one
  81878. * @param r defines the red component to read from
  81879. * @param g defines the green component to read from
  81880. * @param b defines the blue component to read from
  81881. * @param a defines the alpha component to read from
  81882. * @returns the current updated Color4 object
  81883. */
  81884. set(r: number, g: number, b: number, a: number): Color4;
  81885. /**
  81886. * Compute the Color4 hexadecimal code as a string
  81887. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81888. * @returns a string containing the hexadecimal representation of the Color4 object
  81889. */
  81890. toHexString(returnAsColor3?: boolean): string;
  81891. /**
  81892. * Computes a new Color4 converted from the current one to linear space
  81893. * @returns a new Color4 object
  81894. */
  81895. toLinearSpace(): Color4;
  81896. /**
  81897. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81898. * @param convertedColor defines the Color4 object where to store the linear space version
  81899. * @returns the unmodified Color4
  81900. */
  81901. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81902. /**
  81903. * Computes a new Color4 converted from the current one to gamma space
  81904. * @returns a new Color4 object
  81905. */
  81906. toGammaSpace(): Color4;
  81907. /**
  81908. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81909. * @param convertedColor defines the Color4 object where to store the gamma space version
  81910. * @returns the unmodified Color4
  81911. */
  81912. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81913. /**
  81914. * Creates a new Color4 from the string containing valid hexadecimal values
  81915. * @param hex defines a string containing valid hexadecimal values
  81916. * @returns a new Color4 object
  81917. */
  81918. static FromHexString(hex: string): Color4;
  81919. /**
  81920. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81921. * @param left defines the start value
  81922. * @param right defines the end value
  81923. * @param amount defines the gradient factor
  81924. * @returns a new Color4 object
  81925. */
  81926. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81927. /**
  81928. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81929. * @param left defines the start value
  81930. * @param right defines the end value
  81931. * @param amount defines the gradient factor
  81932. * @param result defines the Color4 object where to store data
  81933. */
  81934. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81935. /**
  81936. * Creates a new Color4 from a Color3 and an alpha value
  81937. * @param color3 defines the source Color3 to read from
  81938. * @param alpha defines the alpha component (1.0 by default)
  81939. * @returns a new Color4 object
  81940. */
  81941. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81942. /**
  81943. * Creates a new Color4 from the starting index element of the given array
  81944. * @param array defines the source array to read from
  81945. * @param offset defines the offset in the source array
  81946. * @returns a new Color4 object
  81947. */
  81948. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81949. /**
  81950. * Creates a new Color3 from integer values (< 256)
  81951. * @param r defines the red component to read from (value between 0 and 255)
  81952. * @param g defines the green component to read from (value between 0 and 255)
  81953. * @param b defines the blue component to read from (value between 0 and 255)
  81954. * @param a defines the alpha component to read from (value between 0 and 255)
  81955. * @returns a new Color3 object
  81956. */
  81957. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81958. /**
  81959. * Check the content of a given array and convert it to an array containing RGBA data
  81960. * If the original array was already containing count * 4 values then it is returned directly
  81961. * @param colors defines the array to check
  81962. * @param count defines the number of RGBA data to expect
  81963. * @returns an array containing count * 4 values (RGBA)
  81964. */
  81965. static CheckColors4(colors: number[], count: number): number[];
  81966. }
  81967. /**
  81968. * @hidden
  81969. */
  81970. export class TmpColors {
  81971. static Color3: Color3[];
  81972. static Color4: Color4[];
  81973. }
  81974. }
  81975. declare module BABYLON {
  81976. /**
  81977. * Defines an interface which represents an animation key frame
  81978. */
  81979. export interface IAnimationKey {
  81980. /**
  81981. * Frame of the key frame
  81982. */
  81983. frame: number;
  81984. /**
  81985. * Value at the specifies key frame
  81986. */
  81987. value: any;
  81988. /**
  81989. * The input tangent for the cubic hermite spline
  81990. */
  81991. inTangent?: any;
  81992. /**
  81993. * The output tangent for the cubic hermite spline
  81994. */
  81995. outTangent?: any;
  81996. /**
  81997. * The animation interpolation type
  81998. */
  81999. interpolation?: AnimationKeyInterpolation;
  82000. }
  82001. /**
  82002. * Enum for the animation key frame interpolation type
  82003. */
  82004. export enum AnimationKeyInterpolation {
  82005. /**
  82006. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  82007. */
  82008. STEP = 1
  82009. }
  82010. }
  82011. declare module BABYLON {
  82012. /**
  82013. * Represents the range of an animation
  82014. */
  82015. export class AnimationRange {
  82016. /**The name of the animation range**/
  82017. name: string;
  82018. /**The starting frame of the animation */
  82019. from: number;
  82020. /**The ending frame of the animation*/
  82021. to: number;
  82022. /**
  82023. * Initializes the range of an animation
  82024. * @param name The name of the animation range
  82025. * @param from The starting frame of the animation
  82026. * @param to The ending frame of the animation
  82027. */
  82028. constructor(
  82029. /**The name of the animation range**/
  82030. name: string,
  82031. /**The starting frame of the animation */
  82032. from: number,
  82033. /**The ending frame of the animation*/
  82034. to: number);
  82035. /**
  82036. * Makes a copy of the animation range
  82037. * @returns A copy of the animation range
  82038. */
  82039. clone(): AnimationRange;
  82040. }
  82041. }
  82042. declare module BABYLON {
  82043. /**
  82044. * Composed of a frame, and an action function
  82045. */
  82046. export class AnimationEvent {
  82047. /** The frame for which the event is triggered **/
  82048. frame: number;
  82049. /** The event to perform when triggered **/
  82050. action: (currentFrame: number) => void;
  82051. /** Specifies if the event should be triggered only once**/
  82052. onlyOnce?: boolean | undefined;
  82053. /**
  82054. * Specifies if the animation event is done
  82055. */
  82056. isDone: boolean;
  82057. /**
  82058. * Initializes the animation event
  82059. * @param frame The frame for which the event is triggered
  82060. * @param action The event to perform when triggered
  82061. * @param onlyOnce Specifies if the event should be triggered only once
  82062. */
  82063. constructor(
  82064. /** The frame for which the event is triggered **/
  82065. frame: number,
  82066. /** The event to perform when triggered **/
  82067. action: (currentFrame: number) => void,
  82068. /** Specifies if the event should be triggered only once**/
  82069. onlyOnce?: boolean | undefined);
  82070. /** @hidden */
  82071. _clone(): AnimationEvent;
  82072. }
  82073. }
  82074. declare module BABYLON {
  82075. /**
  82076. * Interface used to define a behavior
  82077. */
  82078. export interface Behavior<T> {
  82079. /** gets or sets behavior's name */
  82080. name: string;
  82081. /**
  82082. * Function called when the behavior needs to be initialized (after attaching it to a target)
  82083. */
  82084. init(): void;
  82085. /**
  82086. * Called when the behavior is attached to a target
  82087. * @param target defines the target where the behavior is attached to
  82088. */
  82089. attach(target: T): void;
  82090. /**
  82091. * Called when the behavior is detached from its target
  82092. */
  82093. detach(): void;
  82094. }
  82095. /**
  82096. * Interface implemented by classes supporting behaviors
  82097. */
  82098. export interface IBehaviorAware<T> {
  82099. /**
  82100. * Attach a behavior
  82101. * @param behavior defines the behavior to attach
  82102. * @returns the current host
  82103. */
  82104. addBehavior(behavior: Behavior<T>): T;
  82105. /**
  82106. * Remove a behavior from the current object
  82107. * @param behavior defines the behavior to detach
  82108. * @returns the current host
  82109. */
  82110. removeBehavior(behavior: Behavior<T>): T;
  82111. /**
  82112. * Gets a behavior using its name to search
  82113. * @param name defines the name to search
  82114. * @returns the behavior or null if not found
  82115. */
  82116. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  82117. }
  82118. }
  82119. declare module BABYLON {
  82120. /**
  82121. * Defines an array and its length.
  82122. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  82123. */
  82124. export interface ISmartArrayLike<T> {
  82125. /**
  82126. * The data of the array.
  82127. */
  82128. data: Array<T>;
  82129. /**
  82130. * The active length of the array.
  82131. */
  82132. length: number;
  82133. }
  82134. /**
  82135. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82136. */
  82137. export class SmartArray<T> implements ISmartArrayLike<T> {
  82138. /**
  82139. * The full set of data from the array.
  82140. */
  82141. data: Array<T>;
  82142. /**
  82143. * The active length of the array.
  82144. */
  82145. length: number;
  82146. protected _id: number;
  82147. /**
  82148. * Instantiates a Smart Array.
  82149. * @param capacity defines the default capacity of the array.
  82150. */
  82151. constructor(capacity: number);
  82152. /**
  82153. * Pushes a value at the end of the active data.
  82154. * @param value defines the object to push in the array.
  82155. */
  82156. push(value: T): void;
  82157. /**
  82158. * Iterates over the active data and apply the lambda to them.
  82159. * @param func defines the action to apply on each value.
  82160. */
  82161. forEach(func: (content: T) => void): void;
  82162. /**
  82163. * Sorts the full sets of data.
  82164. * @param compareFn defines the comparison function to apply.
  82165. */
  82166. sort(compareFn: (a: T, b: T) => number): void;
  82167. /**
  82168. * Resets the active data to an empty array.
  82169. */
  82170. reset(): void;
  82171. /**
  82172. * Releases all the data from the array as well as the array.
  82173. */
  82174. dispose(): void;
  82175. /**
  82176. * Concats the active data with a given array.
  82177. * @param array defines the data to concatenate with.
  82178. */
  82179. concat(array: any): void;
  82180. /**
  82181. * Returns the position of a value in the active data.
  82182. * @param value defines the value to find the index for
  82183. * @returns the index if found in the active data otherwise -1
  82184. */
  82185. indexOf(value: T): number;
  82186. /**
  82187. * Returns whether an element is part of the active data.
  82188. * @param value defines the value to look for
  82189. * @returns true if found in the active data otherwise false
  82190. */
  82191. contains(value: T): boolean;
  82192. private static _GlobalId;
  82193. }
  82194. /**
  82195. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82196. * The data in this array can only be present once
  82197. */
  82198. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82199. private _duplicateId;
  82200. /**
  82201. * Pushes a value at the end of the active data.
  82202. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82203. * @param value defines the object to push in the array.
  82204. */
  82205. push(value: T): void;
  82206. /**
  82207. * Pushes a value at the end of the active data.
  82208. * If the data is already present, it won t be added again
  82209. * @param value defines the object to push in the array.
  82210. * @returns true if added false if it was already present
  82211. */
  82212. pushNoDuplicate(value: T): boolean;
  82213. /**
  82214. * Resets the active data to an empty array.
  82215. */
  82216. reset(): void;
  82217. /**
  82218. * Concats the active data with a given array.
  82219. * This ensures no dupplicate will be present in the result.
  82220. * @param array defines the data to concatenate with.
  82221. */
  82222. concatWithNoDuplicate(array: any): void;
  82223. }
  82224. }
  82225. declare module BABYLON {
  82226. /**
  82227. * @ignore
  82228. * This is a list of all the different input types that are available in the application.
  82229. * Fo instance: ArcRotateCameraGamepadInput...
  82230. */
  82231. export var CameraInputTypes: {};
  82232. /**
  82233. * This is the contract to implement in order to create a new input class.
  82234. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82235. */
  82236. export interface ICameraInput<TCamera extends Camera> {
  82237. /**
  82238. * Defines the camera the input is attached to.
  82239. */
  82240. camera: Nullable<TCamera>;
  82241. /**
  82242. * Gets the class name of the current intput.
  82243. * @returns the class name
  82244. */
  82245. getClassName(): string;
  82246. /**
  82247. * Get the friendly name associated with the input class.
  82248. * @returns the input friendly name
  82249. */
  82250. getSimpleName(): string;
  82251. /**
  82252. * Attach the input controls to a specific dom element to get the input from.
  82253. * @param element Defines the element the controls should be listened from
  82254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82255. */
  82256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82257. /**
  82258. * Detach the current controls from the specified dom element.
  82259. * @param element Defines the element to stop listening the inputs from
  82260. */
  82261. detachControl(element: Nullable<HTMLElement>): void;
  82262. /**
  82263. * Update the current camera state depending on the inputs that have been used this frame.
  82264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82265. */
  82266. checkInputs?: () => void;
  82267. }
  82268. /**
  82269. * Represents a map of input types to input instance or input index to input instance.
  82270. */
  82271. export interface CameraInputsMap<TCamera extends Camera> {
  82272. /**
  82273. * Accessor to the input by input type.
  82274. */
  82275. [name: string]: ICameraInput<TCamera>;
  82276. /**
  82277. * Accessor to the input by input index.
  82278. */
  82279. [idx: number]: ICameraInput<TCamera>;
  82280. }
  82281. /**
  82282. * This represents the input manager used within a camera.
  82283. * It helps dealing with all the different kind of input attached to a camera.
  82284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82285. */
  82286. export class CameraInputsManager<TCamera extends Camera> {
  82287. /**
  82288. * Defines the list of inputs attahed to the camera.
  82289. */
  82290. attached: CameraInputsMap<TCamera>;
  82291. /**
  82292. * Defines the dom element the camera is collecting inputs from.
  82293. * This is null if the controls have not been attached.
  82294. */
  82295. attachedElement: Nullable<HTMLElement>;
  82296. /**
  82297. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82298. */
  82299. noPreventDefault: boolean;
  82300. /**
  82301. * Defined the camera the input manager belongs to.
  82302. */
  82303. camera: TCamera;
  82304. /**
  82305. * Update the current camera state depending on the inputs that have been used this frame.
  82306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82307. */
  82308. checkInputs: () => void;
  82309. /**
  82310. * Instantiate a new Camera Input Manager.
  82311. * @param camera Defines the camera the input manager blongs to
  82312. */
  82313. constructor(camera: TCamera);
  82314. /**
  82315. * Add an input method to a camera
  82316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82317. * @param input camera input method
  82318. */
  82319. add(input: ICameraInput<TCamera>): void;
  82320. /**
  82321. * Remove a specific input method from a camera
  82322. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82323. * @param inputToRemove camera input method
  82324. */
  82325. remove(inputToRemove: ICameraInput<TCamera>): void;
  82326. /**
  82327. * Remove a specific input type from a camera
  82328. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82329. * @param inputType the type of the input to remove
  82330. */
  82331. removeByType(inputType: string): void;
  82332. private _addCheckInputs;
  82333. /**
  82334. * Attach the input controls to the currently attached dom element to listen the events from.
  82335. * @param input Defines the input to attach
  82336. */
  82337. attachInput(input: ICameraInput<TCamera>): void;
  82338. /**
  82339. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82340. * @param element Defines the dom element to collect the events from
  82341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82342. */
  82343. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82344. /**
  82345. * Detach the current manager inputs controls from a specific dom element.
  82346. * @param element Defines the dom element to collect the events from
  82347. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82348. */
  82349. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82350. /**
  82351. * Rebuild the dynamic inputCheck function from the current list of
  82352. * defined inputs in the manager.
  82353. */
  82354. rebuildInputCheck(): void;
  82355. /**
  82356. * Remove all attached input methods from a camera
  82357. */
  82358. clear(): void;
  82359. /**
  82360. * Serialize the current input manager attached to a camera.
  82361. * This ensures than once parsed,
  82362. * the input associated to the camera will be identical to the current ones
  82363. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82364. */
  82365. serialize(serializedCamera: any): void;
  82366. /**
  82367. * Parses an input manager serialized JSON to restore the previous list of inputs
  82368. * and states associated to a camera.
  82369. * @param parsedCamera Defines the JSON to parse
  82370. */
  82371. parse(parsedCamera: any): void;
  82372. }
  82373. }
  82374. declare module BABYLON {
  82375. /**
  82376. * Class used to store data that will be store in GPU memory
  82377. */
  82378. export class Buffer {
  82379. private _engine;
  82380. private _buffer;
  82381. /** @hidden */
  82382. _data: Nullable<DataArray>;
  82383. private _updatable;
  82384. private _instanced;
  82385. private _divisor;
  82386. /**
  82387. * Gets the byte stride.
  82388. */
  82389. readonly byteStride: number;
  82390. /**
  82391. * Constructor
  82392. * @param engine the engine
  82393. * @param data the data to use for this buffer
  82394. * @param updatable whether the data is updatable
  82395. * @param stride the stride (optional)
  82396. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82397. * @param instanced whether the buffer is instanced (optional)
  82398. * @param useBytes set to true if the stride in in bytes (optional)
  82399. * @param divisor sets an optional divisor for instances (1 by default)
  82400. */
  82401. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82402. /**
  82403. * Create a new VertexBuffer based on the current buffer
  82404. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82405. * @param offset defines offset in the buffer (0 by default)
  82406. * @param size defines the size in floats of attributes (position is 3 for instance)
  82407. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82408. * @param instanced defines if the vertex buffer contains indexed data
  82409. * @param useBytes defines if the offset and stride are in bytes *
  82410. * @param divisor sets an optional divisor for instances (1 by default)
  82411. * @returns the new vertex buffer
  82412. */
  82413. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82414. /**
  82415. * Gets a boolean indicating if the Buffer is updatable?
  82416. * @returns true if the buffer is updatable
  82417. */
  82418. isUpdatable(): boolean;
  82419. /**
  82420. * Gets current buffer's data
  82421. * @returns a DataArray or null
  82422. */
  82423. getData(): Nullable<DataArray>;
  82424. /**
  82425. * Gets underlying native buffer
  82426. * @returns underlying native buffer
  82427. */
  82428. getBuffer(): Nullable<DataBuffer>;
  82429. /**
  82430. * Gets the stride in float32 units (i.e. byte stride / 4).
  82431. * May not be an integer if the byte stride is not divisible by 4.
  82432. * @returns the stride in float32 units
  82433. * @deprecated Please use byteStride instead.
  82434. */
  82435. getStrideSize(): number;
  82436. /**
  82437. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82438. * @param data defines the data to store
  82439. */
  82440. create(data?: Nullable<DataArray>): void;
  82441. /** @hidden */
  82442. _rebuild(): void;
  82443. /**
  82444. * Update current buffer data
  82445. * @param data defines the data to store
  82446. */
  82447. update(data: DataArray): void;
  82448. /**
  82449. * Updates the data directly.
  82450. * @param data the new data
  82451. * @param offset the new offset
  82452. * @param vertexCount the vertex count (optional)
  82453. * @param useBytes set to true if the offset is in bytes
  82454. */
  82455. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82456. /**
  82457. * Release all resources
  82458. */
  82459. dispose(): void;
  82460. }
  82461. /**
  82462. * Specialized buffer used to store vertex data
  82463. */
  82464. export class VertexBuffer {
  82465. /** @hidden */
  82466. _buffer: Buffer;
  82467. private _kind;
  82468. private _size;
  82469. private _ownsBuffer;
  82470. private _instanced;
  82471. private _instanceDivisor;
  82472. /**
  82473. * The byte type.
  82474. */
  82475. static readonly BYTE: number;
  82476. /**
  82477. * The unsigned byte type.
  82478. */
  82479. static readonly UNSIGNED_BYTE: number;
  82480. /**
  82481. * The short type.
  82482. */
  82483. static readonly SHORT: number;
  82484. /**
  82485. * The unsigned short type.
  82486. */
  82487. static readonly UNSIGNED_SHORT: number;
  82488. /**
  82489. * The integer type.
  82490. */
  82491. static readonly INT: number;
  82492. /**
  82493. * The unsigned integer type.
  82494. */
  82495. static readonly UNSIGNED_INT: number;
  82496. /**
  82497. * The float type.
  82498. */
  82499. static readonly FLOAT: number;
  82500. /**
  82501. * Gets or sets the instance divisor when in instanced mode
  82502. */
  82503. get instanceDivisor(): number;
  82504. set instanceDivisor(value: number);
  82505. /**
  82506. * Gets the byte stride.
  82507. */
  82508. readonly byteStride: number;
  82509. /**
  82510. * Gets the byte offset.
  82511. */
  82512. readonly byteOffset: number;
  82513. /**
  82514. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82515. */
  82516. readonly normalized: boolean;
  82517. /**
  82518. * Gets the data type of each component in the array.
  82519. */
  82520. readonly type: number;
  82521. /**
  82522. * Constructor
  82523. * @param engine the engine
  82524. * @param data the data to use for this vertex buffer
  82525. * @param kind the vertex buffer kind
  82526. * @param updatable whether the data is updatable
  82527. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82528. * @param stride the stride (optional)
  82529. * @param instanced whether the buffer is instanced (optional)
  82530. * @param offset the offset of the data (optional)
  82531. * @param size the number of components (optional)
  82532. * @param type the type of the component (optional)
  82533. * @param normalized whether the data contains normalized data (optional)
  82534. * @param useBytes set to true if stride and offset are in bytes (optional)
  82535. * @param divisor defines the instance divisor to use (1 by default)
  82536. */
  82537. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  82538. /** @hidden */
  82539. _rebuild(): void;
  82540. /**
  82541. * Returns the kind of the VertexBuffer (string)
  82542. * @returns a string
  82543. */
  82544. getKind(): string;
  82545. /**
  82546. * Gets a boolean indicating if the VertexBuffer is updatable?
  82547. * @returns true if the buffer is updatable
  82548. */
  82549. isUpdatable(): boolean;
  82550. /**
  82551. * Gets current buffer's data
  82552. * @returns a DataArray or null
  82553. */
  82554. getData(): Nullable<DataArray>;
  82555. /**
  82556. * Gets underlying native buffer
  82557. * @returns underlying native buffer
  82558. */
  82559. getBuffer(): Nullable<DataBuffer>;
  82560. /**
  82561. * Gets the stride in float32 units (i.e. byte stride / 4).
  82562. * May not be an integer if the byte stride is not divisible by 4.
  82563. * @returns the stride in float32 units
  82564. * @deprecated Please use byteStride instead.
  82565. */
  82566. getStrideSize(): number;
  82567. /**
  82568. * Returns the offset as a multiple of the type byte length.
  82569. * @returns the offset in bytes
  82570. * @deprecated Please use byteOffset instead.
  82571. */
  82572. getOffset(): number;
  82573. /**
  82574. * Returns the number of components per vertex attribute (integer)
  82575. * @returns the size in float
  82576. */
  82577. getSize(): number;
  82578. /**
  82579. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82580. * @returns true if this buffer is instanced
  82581. */
  82582. getIsInstanced(): boolean;
  82583. /**
  82584. * Returns the instancing divisor, zero for non-instanced (integer).
  82585. * @returns a number
  82586. */
  82587. getInstanceDivisor(): number;
  82588. /**
  82589. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82590. * @param data defines the data to store
  82591. */
  82592. create(data?: DataArray): void;
  82593. /**
  82594. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82595. * This function will create a new buffer if the current one is not updatable
  82596. * @param data defines the data to store
  82597. */
  82598. update(data: DataArray): void;
  82599. /**
  82600. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82601. * Returns the directly updated WebGLBuffer.
  82602. * @param data the new data
  82603. * @param offset the new offset
  82604. * @param useBytes set to true if the offset is in bytes
  82605. */
  82606. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82607. /**
  82608. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82609. */
  82610. dispose(): void;
  82611. /**
  82612. * Enumerates each value of this vertex buffer as numbers.
  82613. * @param count the number of values to enumerate
  82614. * @param callback the callback function called for each value
  82615. */
  82616. forEach(count: number, callback: (value: number, index: number) => void): void;
  82617. /**
  82618. * Positions
  82619. */
  82620. static readonly PositionKind: string;
  82621. /**
  82622. * Normals
  82623. */
  82624. static readonly NormalKind: string;
  82625. /**
  82626. * Tangents
  82627. */
  82628. static readonly TangentKind: string;
  82629. /**
  82630. * Texture coordinates
  82631. */
  82632. static readonly UVKind: string;
  82633. /**
  82634. * Texture coordinates 2
  82635. */
  82636. static readonly UV2Kind: string;
  82637. /**
  82638. * Texture coordinates 3
  82639. */
  82640. static readonly UV3Kind: string;
  82641. /**
  82642. * Texture coordinates 4
  82643. */
  82644. static readonly UV4Kind: string;
  82645. /**
  82646. * Texture coordinates 5
  82647. */
  82648. static readonly UV5Kind: string;
  82649. /**
  82650. * Texture coordinates 6
  82651. */
  82652. static readonly UV6Kind: string;
  82653. /**
  82654. * Colors
  82655. */
  82656. static readonly ColorKind: string;
  82657. /**
  82658. * Matrix indices (for bones)
  82659. */
  82660. static readonly MatricesIndicesKind: string;
  82661. /**
  82662. * Matrix weights (for bones)
  82663. */
  82664. static readonly MatricesWeightsKind: string;
  82665. /**
  82666. * Additional matrix indices (for bones)
  82667. */
  82668. static readonly MatricesIndicesExtraKind: string;
  82669. /**
  82670. * Additional matrix weights (for bones)
  82671. */
  82672. static readonly MatricesWeightsExtraKind: string;
  82673. /**
  82674. * Deduces the stride given a kind.
  82675. * @param kind The kind string to deduce
  82676. * @returns The deduced stride
  82677. */
  82678. static DeduceStride(kind: string): number;
  82679. /**
  82680. * Gets the byte length of the given type.
  82681. * @param type the type
  82682. * @returns the number of bytes
  82683. */
  82684. static GetTypeByteLength(type: number): number;
  82685. /**
  82686. * Enumerates each value of the given parameters as numbers.
  82687. * @param data the data to enumerate
  82688. * @param byteOffset the byte offset of the data
  82689. * @param byteStride the byte stride of the data
  82690. * @param componentCount the number of components per element
  82691. * @param componentType the type of the component
  82692. * @param count the number of values to enumerate
  82693. * @param normalized whether the data is normalized
  82694. * @param callback the callback function called for each value
  82695. */
  82696. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82697. private static _GetFloatValue;
  82698. }
  82699. }
  82700. declare module BABYLON {
  82701. /**
  82702. * @hidden
  82703. */
  82704. export class IntersectionInfo {
  82705. bu: Nullable<number>;
  82706. bv: Nullable<number>;
  82707. distance: number;
  82708. faceId: number;
  82709. subMeshId: number;
  82710. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82711. }
  82712. }
  82713. declare module BABYLON {
  82714. /**
  82715. * Class used to store bounding sphere information
  82716. */
  82717. export class BoundingSphere {
  82718. /**
  82719. * Gets the center of the bounding sphere in local space
  82720. */
  82721. readonly center: Vector3;
  82722. /**
  82723. * Radius of the bounding sphere in local space
  82724. */
  82725. radius: number;
  82726. /**
  82727. * Gets the center of the bounding sphere in world space
  82728. */
  82729. readonly centerWorld: Vector3;
  82730. /**
  82731. * Radius of the bounding sphere in world space
  82732. */
  82733. radiusWorld: number;
  82734. /**
  82735. * Gets the minimum vector in local space
  82736. */
  82737. readonly minimum: Vector3;
  82738. /**
  82739. * Gets the maximum vector in local space
  82740. */
  82741. readonly maximum: Vector3;
  82742. private _worldMatrix;
  82743. private static readonly TmpVector3;
  82744. /**
  82745. * Creates a new bounding sphere
  82746. * @param min defines the minimum vector (in local space)
  82747. * @param max defines the maximum vector (in local space)
  82748. * @param worldMatrix defines the new world matrix
  82749. */
  82750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82751. /**
  82752. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82753. * @param min defines the new minimum vector (in local space)
  82754. * @param max defines the new maximum vector (in local space)
  82755. * @param worldMatrix defines the new world matrix
  82756. */
  82757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82758. /**
  82759. * Scale the current bounding sphere by applying a scale factor
  82760. * @param factor defines the scale factor to apply
  82761. * @returns the current bounding box
  82762. */
  82763. scale(factor: number): BoundingSphere;
  82764. /**
  82765. * Gets the world matrix of the bounding box
  82766. * @returns a matrix
  82767. */
  82768. getWorldMatrix(): DeepImmutable<Matrix>;
  82769. /** @hidden */
  82770. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82771. /**
  82772. * Tests if the bounding sphere is intersecting the frustum planes
  82773. * @param frustumPlanes defines the frustum planes to test
  82774. * @returns true if there is an intersection
  82775. */
  82776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82777. /**
  82778. * Tests if the bounding sphere center is in between the frustum planes.
  82779. * Used for optimistic fast inclusion.
  82780. * @param frustumPlanes defines the frustum planes to test
  82781. * @returns true if the sphere center is in between the frustum planes
  82782. */
  82783. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82784. /**
  82785. * Tests if a point is inside the bounding sphere
  82786. * @param point defines the point to test
  82787. * @returns true if the point is inside the bounding sphere
  82788. */
  82789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82790. /**
  82791. * Checks if two sphere intersct
  82792. * @param sphere0 sphere 0
  82793. * @param sphere1 sphere 1
  82794. * @returns true if the speres intersect
  82795. */
  82796. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82797. }
  82798. }
  82799. declare module BABYLON {
  82800. /**
  82801. * Class used to store bounding box information
  82802. */
  82803. export class BoundingBox implements ICullable {
  82804. /**
  82805. * Gets the 8 vectors representing the bounding box in local space
  82806. */
  82807. readonly vectors: Vector3[];
  82808. /**
  82809. * Gets the center of the bounding box in local space
  82810. */
  82811. readonly center: Vector3;
  82812. /**
  82813. * Gets the center of the bounding box in world space
  82814. */
  82815. readonly centerWorld: Vector3;
  82816. /**
  82817. * Gets the extend size in local space
  82818. */
  82819. readonly extendSize: Vector3;
  82820. /**
  82821. * Gets the extend size in world space
  82822. */
  82823. readonly extendSizeWorld: Vector3;
  82824. /**
  82825. * Gets the OBB (object bounding box) directions
  82826. */
  82827. readonly directions: Vector3[];
  82828. /**
  82829. * Gets the 8 vectors representing the bounding box in world space
  82830. */
  82831. readonly vectorsWorld: Vector3[];
  82832. /**
  82833. * Gets the minimum vector in world space
  82834. */
  82835. readonly minimumWorld: Vector3;
  82836. /**
  82837. * Gets the maximum vector in world space
  82838. */
  82839. readonly maximumWorld: Vector3;
  82840. /**
  82841. * Gets the minimum vector in local space
  82842. */
  82843. readonly minimum: Vector3;
  82844. /**
  82845. * Gets the maximum vector in local space
  82846. */
  82847. readonly maximum: Vector3;
  82848. private _worldMatrix;
  82849. private static readonly TmpVector3;
  82850. /**
  82851. * @hidden
  82852. */
  82853. _tag: number;
  82854. /**
  82855. * Creates a new bounding box
  82856. * @param min defines the minimum vector (in local space)
  82857. * @param max defines the maximum vector (in local space)
  82858. * @param worldMatrix defines the new world matrix
  82859. */
  82860. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82861. /**
  82862. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82863. * @param min defines the new minimum vector (in local space)
  82864. * @param max defines the new maximum vector (in local space)
  82865. * @param worldMatrix defines the new world matrix
  82866. */
  82867. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82868. /**
  82869. * Scale the current bounding box by applying a scale factor
  82870. * @param factor defines the scale factor to apply
  82871. * @returns the current bounding box
  82872. */
  82873. scale(factor: number): BoundingBox;
  82874. /**
  82875. * Gets the world matrix of the bounding box
  82876. * @returns a matrix
  82877. */
  82878. getWorldMatrix(): DeepImmutable<Matrix>;
  82879. /** @hidden */
  82880. _update(world: DeepImmutable<Matrix>): void;
  82881. /**
  82882. * Tests if the bounding box is intersecting the frustum planes
  82883. * @param frustumPlanes defines the frustum planes to test
  82884. * @returns true if there is an intersection
  82885. */
  82886. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82887. /**
  82888. * Tests if the bounding box is entirely inside the frustum planes
  82889. * @param frustumPlanes defines the frustum planes to test
  82890. * @returns true if there is an inclusion
  82891. */
  82892. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82893. /**
  82894. * Tests if a point is inside the bounding box
  82895. * @param point defines the point to test
  82896. * @returns true if the point is inside the bounding box
  82897. */
  82898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82899. /**
  82900. * Tests if the bounding box intersects with a bounding sphere
  82901. * @param sphere defines the sphere to test
  82902. * @returns true if there is an intersection
  82903. */
  82904. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82905. /**
  82906. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82907. * @param min defines the min vector to use
  82908. * @param max defines the max vector to use
  82909. * @returns true if there is an intersection
  82910. */
  82911. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82912. /**
  82913. * Tests if two bounding boxes are intersections
  82914. * @param box0 defines the first box to test
  82915. * @param box1 defines the second box to test
  82916. * @returns true if there is an intersection
  82917. */
  82918. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82919. /**
  82920. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82921. * @param minPoint defines the minimum vector of the bounding box
  82922. * @param maxPoint defines the maximum vector of the bounding box
  82923. * @param sphereCenter defines the sphere center
  82924. * @param sphereRadius defines the sphere radius
  82925. * @returns true if there is an intersection
  82926. */
  82927. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82928. /**
  82929. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82930. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82931. * @param frustumPlanes defines the frustum planes to test
  82932. * @return true if there is an inclusion
  82933. */
  82934. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82935. /**
  82936. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82938. * @param frustumPlanes defines the frustum planes to test
  82939. * @return true if there is an intersection
  82940. */
  82941. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82942. }
  82943. }
  82944. declare module BABYLON {
  82945. /** @hidden */
  82946. export class Collider {
  82947. /** Define if a collision was found */
  82948. collisionFound: boolean;
  82949. /**
  82950. * Define last intersection point in local space
  82951. */
  82952. intersectionPoint: Vector3;
  82953. /**
  82954. * Define last collided mesh
  82955. */
  82956. collidedMesh: Nullable<AbstractMesh>;
  82957. private _collisionPoint;
  82958. private _planeIntersectionPoint;
  82959. private _tempVector;
  82960. private _tempVector2;
  82961. private _tempVector3;
  82962. private _tempVector4;
  82963. private _edge;
  82964. private _baseToVertex;
  82965. private _destinationPoint;
  82966. private _slidePlaneNormal;
  82967. private _displacementVector;
  82968. /** @hidden */
  82969. _radius: Vector3;
  82970. /** @hidden */
  82971. _retry: number;
  82972. private _velocity;
  82973. private _basePoint;
  82974. private _epsilon;
  82975. /** @hidden */
  82976. _velocityWorldLength: number;
  82977. /** @hidden */
  82978. _basePointWorld: Vector3;
  82979. private _velocityWorld;
  82980. private _normalizedVelocity;
  82981. /** @hidden */
  82982. _initialVelocity: Vector3;
  82983. /** @hidden */
  82984. _initialPosition: Vector3;
  82985. private _nearestDistance;
  82986. private _collisionMask;
  82987. get collisionMask(): number;
  82988. set collisionMask(mask: number);
  82989. /**
  82990. * Gets the plane normal used to compute the sliding response (in local space)
  82991. */
  82992. get slidePlaneNormal(): Vector3;
  82993. /** @hidden */
  82994. _initialize(source: Vector3, dir: Vector3, e: number): void;
  82995. /** @hidden */
  82996. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  82997. /** @hidden */
  82998. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  82999. /** @hidden */
  83000. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83001. /** @hidden */
  83002. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83003. /** @hidden */
  83004. _getResponse(pos: Vector3, vel: Vector3): void;
  83005. }
  83006. }
  83007. declare module BABYLON {
  83008. /**
  83009. * Interface for cullable objects
  83010. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  83011. */
  83012. export interface ICullable {
  83013. /**
  83014. * Checks if the object or part of the object is in the frustum
  83015. * @param frustumPlanes Camera near/planes
  83016. * @returns true if the object is in frustum otherwise false
  83017. */
  83018. isInFrustum(frustumPlanes: Plane[]): boolean;
  83019. /**
  83020. * Checks if a cullable object (mesh...) is in the camera frustum
  83021. * Unlike isInFrustum this cheks the full bounding box
  83022. * @param frustumPlanes Camera near/planes
  83023. * @returns true if the object is in frustum otherwise false
  83024. */
  83025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83026. }
  83027. /**
  83028. * Info for a bounding data of a mesh
  83029. */
  83030. export class BoundingInfo implements ICullable {
  83031. /**
  83032. * Bounding box for the mesh
  83033. */
  83034. readonly boundingBox: BoundingBox;
  83035. /**
  83036. * Bounding sphere for the mesh
  83037. */
  83038. readonly boundingSphere: BoundingSphere;
  83039. private _isLocked;
  83040. private static readonly TmpVector3;
  83041. /**
  83042. * Constructs bounding info
  83043. * @param minimum min vector of the bounding box/sphere
  83044. * @param maximum max vector of the bounding box/sphere
  83045. * @param worldMatrix defines the new world matrix
  83046. */
  83047. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83048. /**
  83049. * Recreates the entire bounding info from scratch as if we call the constructor in place
  83050. * @param min defines the new minimum vector (in local space)
  83051. * @param max defines the new maximum vector (in local space)
  83052. * @param worldMatrix defines the new world matrix
  83053. */
  83054. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83055. /**
  83056. * min vector of the bounding box/sphere
  83057. */
  83058. get minimum(): Vector3;
  83059. /**
  83060. * max vector of the bounding box/sphere
  83061. */
  83062. get maximum(): Vector3;
  83063. /**
  83064. * If the info is locked and won't be updated to avoid perf overhead
  83065. */
  83066. get isLocked(): boolean;
  83067. set isLocked(value: boolean);
  83068. /**
  83069. * Updates the bounding sphere and box
  83070. * @param world world matrix to be used to update
  83071. */
  83072. update(world: DeepImmutable<Matrix>): void;
  83073. /**
  83074. * Recreate the bounding info to be centered around a specific point given a specific extend.
  83075. * @param center New center of the bounding info
  83076. * @param extend New extend of the bounding info
  83077. * @returns the current bounding info
  83078. */
  83079. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  83080. /**
  83081. * Scale the current bounding info by applying a scale factor
  83082. * @param factor defines the scale factor to apply
  83083. * @returns the current bounding info
  83084. */
  83085. scale(factor: number): BoundingInfo;
  83086. /**
  83087. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  83088. * @param frustumPlanes defines the frustum to test
  83089. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  83090. * @returns true if the bounding info is in the frustum planes
  83091. */
  83092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  83093. /**
  83094. * Gets the world distance between the min and max points of the bounding box
  83095. */
  83096. get diagonalLength(): number;
  83097. /**
  83098. * Checks if a cullable object (mesh...) is in the camera frustum
  83099. * Unlike isInFrustum this cheks the full bounding box
  83100. * @param frustumPlanes Camera near/planes
  83101. * @returns true if the object is in frustum otherwise false
  83102. */
  83103. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83104. /** @hidden */
  83105. _checkCollision(collider: Collider): boolean;
  83106. /**
  83107. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  83108. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83109. * @param point the point to check intersection with
  83110. * @returns if the point intersects
  83111. */
  83112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83113. /**
  83114. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  83115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83116. * @param boundingInfo the bounding info to check intersection with
  83117. * @param precise if the intersection should be done using OBB
  83118. * @returns if the bounding info intersects
  83119. */
  83120. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  83121. }
  83122. }
  83123. declare module BABYLON {
  83124. /**
  83125. * Extracts minimum and maximum values from a list of indexed positions
  83126. * @param positions defines the positions to use
  83127. * @param indices defines the indices to the positions
  83128. * @param indexStart defines the start index
  83129. * @param indexCount defines the end index
  83130. * @param bias defines bias value to add to the result
  83131. * @return minimum and maximum values
  83132. */
  83133. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  83134. minimum: Vector3;
  83135. maximum: Vector3;
  83136. };
  83137. /**
  83138. * Extracts minimum and maximum values from a list of positions
  83139. * @param positions defines the positions to use
  83140. * @param start defines the start index in the positions array
  83141. * @param count defines the number of positions to handle
  83142. * @param bias defines bias value to add to the result
  83143. * @param stride defines the stride size to use (distance between two positions in the positions array)
  83144. * @return minimum and maximum values
  83145. */
  83146. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  83147. minimum: Vector3;
  83148. maximum: Vector3;
  83149. };
  83150. }
  83151. declare module BABYLON {
  83152. /** @hidden */
  83153. export class WebGLDataBuffer extends DataBuffer {
  83154. private _buffer;
  83155. constructor(resource: WebGLBuffer);
  83156. get underlyingResource(): any;
  83157. }
  83158. }
  83159. declare module BABYLON {
  83160. /** @hidden */
  83161. export class WebGLPipelineContext implements IPipelineContext {
  83162. engine: ThinEngine;
  83163. program: Nullable<WebGLProgram>;
  83164. context?: WebGLRenderingContext;
  83165. vertexShader?: WebGLShader;
  83166. fragmentShader?: WebGLShader;
  83167. isParallelCompiled: boolean;
  83168. onCompiled?: () => void;
  83169. transformFeedback?: WebGLTransformFeedback | null;
  83170. vertexCompilationError: Nullable<string>;
  83171. fragmentCompilationError: Nullable<string>;
  83172. programLinkError: Nullable<string>;
  83173. programValidationError: Nullable<string>;
  83174. get isAsync(): boolean;
  83175. get isReady(): boolean;
  83176. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  83177. _getVertexShaderCode(): string | null;
  83178. _getFragmentShaderCode(): string | null;
  83179. }
  83180. }
  83181. declare module BABYLON {
  83182. interface ThinEngine {
  83183. /**
  83184. * Create an uniform buffer
  83185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83186. * @param elements defines the content of the uniform buffer
  83187. * @returns the webGL uniform buffer
  83188. */
  83189. createUniformBuffer(elements: FloatArray): DataBuffer;
  83190. /**
  83191. * Create a dynamic uniform buffer
  83192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83193. * @param elements defines the content of the uniform buffer
  83194. * @returns the webGL uniform buffer
  83195. */
  83196. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83197. /**
  83198. * Update an existing uniform buffer
  83199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83200. * @param uniformBuffer defines the target uniform buffer
  83201. * @param elements defines the content to update
  83202. * @param offset defines the offset in the uniform buffer where update should start
  83203. * @param count defines the size of the data to update
  83204. */
  83205. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83206. /**
  83207. * Bind an uniform buffer to the current webGL context
  83208. * @param buffer defines the buffer to bind
  83209. */
  83210. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83211. /**
  83212. * Bind a buffer to the current webGL context at a given location
  83213. * @param buffer defines the buffer to bind
  83214. * @param location defines the index where to bind the buffer
  83215. */
  83216. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83217. /**
  83218. * Bind a specific block at a given index in a specific shader program
  83219. * @param pipelineContext defines the pipeline context to use
  83220. * @param blockName defines the block name
  83221. * @param index defines the index where to bind the block
  83222. */
  83223. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83224. }
  83225. }
  83226. declare module BABYLON {
  83227. /**
  83228. * Uniform buffer objects.
  83229. *
  83230. * Handles blocks of uniform on the GPU.
  83231. *
  83232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83233. *
  83234. * For more information, please refer to :
  83235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83236. */
  83237. export class UniformBuffer {
  83238. private _engine;
  83239. private _buffer;
  83240. private _data;
  83241. private _bufferData;
  83242. private _dynamic?;
  83243. private _uniformLocations;
  83244. private _uniformSizes;
  83245. private _uniformLocationPointer;
  83246. private _needSync;
  83247. private _noUBO;
  83248. private _currentEffect;
  83249. /** @hidden */
  83250. _alreadyBound: boolean;
  83251. private static _MAX_UNIFORM_SIZE;
  83252. private static _tempBuffer;
  83253. /**
  83254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83255. * This is dynamic to allow compat with webgl 1 and 2.
  83256. * You will need to pass the name of the uniform as well as the value.
  83257. */
  83258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83259. /**
  83260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83261. * This is dynamic to allow compat with webgl 1 and 2.
  83262. * You will need to pass the name of the uniform as well as the value.
  83263. */
  83264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83265. /**
  83266. * Lambda to Update a single float in a uniform buffer.
  83267. * This is dynamic to allow compat with webgl 1 and 2.
  83268. * You will need to pass the name of the uniform as well as the value.
  83269. */
  83270. updateFloat: (name: string, x: number) => void;
  83271. /**
  83272. * Lambda to Update a vec2 of float in a uniform buffer.
  83273. * This is dynamic to allow compat with webgl 1 and 2.
  83274. * You will need to pass the name of the uniform as well as the value.
  83275. */
  83276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83277. /**
  83278. * Lambda to Update a vec3 of float in a uniform buffer.
  83279. * This is dynamic to allow compat with webgl 1 and 2.
  83280. * You will need to pass the name of the uniform as well as the value.
  83281. */
  83282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83283. /**
  83284. * Lambda to Update a vec4 of float in a uniform buffer.
  83285. * This is dynamic to allow compat with webgl 1 and 2.
  83286. * You will need to pass the name of the uniform as well as the value.
  83287. */
  83288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83289. /**
  83290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83291. * This is dynamic to allow compat with webgl 1 and 2.
  83292. * You will need to pass the name of the uniform as well as the value.
  83293. */
  83294. updateMatrix: (name: string, mat: Matrix) => void;
  83295. /**
  83296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83297. * This is dynamic to allow compat with webgl 1 and 2.
  83298. * You will need to pass the name of the uniform as well as the value.
  83299. */
  83300. updateVector3: (name: string, vector: Vector3) => void;
  83301. /**
  83302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83303. * This is dynamic to allow compat with webgl 1 and 2.
  83304. * You will need to pass the name of the uniform as well as the value.
  83305. */
  83306. updateVector4: (name: string, vector: Vector4) => void;
  83307. /**
  83308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83309. * This is dynamic to allow compat with webgl 1 and 2.
  83310. * You will need to pass the name of the uniform as well as the value.
  83311. */
  83312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83313. /**
  83314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83315. * This is dynamic to allow compat with webgl 1 and 2.
  83316. * You will need to pass the name of the uniform as well as the value.
  83317. */
  83318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83319. /**
  83320. * Instantiates a new Uniform buffer objects.
  83321. *
  83322. * Handles blocks of uniform on the GPU.
  83323. *
  83324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83325. *
  83326. * For more information, please refer to :
  83327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83328. * @param engine Define the engine the buffer is associated with
  83329. * @param data Define the data contained in the buffer
  83330. * @param dynamic Define if the buffer is updatable
  83331. */
  83332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83333. /**
  83334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83335. * or just falling back on setUniformXXX calls.
  83336. */
  83337. get useUbo(): boolean;
  83338. /**
  83339. * Indicates if the WebGL underlying uniform buffer is in sync
  83340. * with the javascript cache data.
  83341. */
  83342. get isSync(): boolean;
  83343. /**
  83344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83345. * Also, a dynamic UniformBuffer will disable cache verification and always
  83346. * update the underlying WebGL uniform buffer to the GPU.
  83347. * @returns if Dynamic, otherwise false
  83348. */
  83349. isDynamic(): boolean;
  83350. /**
  83351. * The data cache on JS side.
  83352. * @returns the underlying data as a float array
  83353. */
  83354. getData(): Float32Array;
  83355. /**
  83356. * The underlying WebGL Uniform buffer.
  83357. * @returns the webgl buffer
  83358. */
  83359. getBuffer(): Nullable<DataBuffer>;
  83360. /**
  83361. * std140 layout specifies how to align data within an UBO structure.
  83362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83363. * for specs.
  83364. */
  83365. private _fillAlignment;
  83366. /**
  83367. * Adds an uniform in the buffer.
  83368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83369. * for the layout to be correct !
  83370. * @param name Name of the uniform, as used in the uniform block in the shader.
  83371. * @param size Data size, or data directly.
  83372. */
  83373. addUniform(name: string, size: number | number[]): void;
  83374. /**
  83375. * Adds a Matrix 4x4 to the uniform buffer.
  83376. * @param name Name of the uniform, as used in the uniform block in the shader.
  83377. * @param mat A 4x4 matrix.
  83378. */
  83379. addMatrix(name: string, mat: Matrix): void;
  83380. /**
  83381. * Adds a vec2 to the uniform buffer.
  83382. * @param name Name of the uniform, as used in the uniform block in the shader.
  83383. * @param x Define the x component value of the vec2
  83384. * @param y Define the y component value of the vec2
  83385. */
  83386. addFloat2(name: string, x: number, y: number): void;
  83387. /**
  83388. * Adds a vec3 to the uniform buffer.
  83389. * @param name Name of the uniform, as used in the uniform block in the shader.
  83390. * @param x Define the x component value of the vec3
  83391. * @param y Define the y component value of the vec3
  83392. * @param z Define the z component value of the vec3
  83393. */
  83394. addFloat3(name: string, x: number, y: number, z: number): void;
  83395. /**
  83396. * Adds a vec3 to the uniform buffer.
  83397. * @param name Name of the uniform, as used in the uniform block in the shader.
  83398. * @param color Define the vec3 from a Color
  83399. */
  83400. addColor3(name: string, color: Color3): void;
  83401. /**
  83402. * Adds a vec4 to the uniform buffer.
  83403. * @param name Name of the uniform, as used in the uniform block in the shader.
  83404. * @param color Define the rgb components from a Color
  83405. * @param alpha Define the a component of the vec4
  83406. */
  83407. addColor4(name: string, color: Color3, alpha: number): void;
  83408. /**
  83409. * Adds a vec3 to the uniform buffer.
  83410. * @param name Name of the uniform, as used in the uniform block in the shader.
  83411. * @param vector Define the vec3 components from a Vector
  83412. */
  83413. addVector3(name: string, vector: Vector3): void;
  83414. /**
  83415. * Adds a Matrix 3x3 to the uniform buffer.
  83416. * @param name Name of the uniform, as used in the uniform block in the shader.
  83417. */
  83418. addMatrix3x3(name: string): void;
  83419. /**
  83420. * Adds a Matrix 2x2 to the uniform buffer.
  83421. * @param name Name of the uniform, as used in the uniform block in the shader.
  83422. */
  83423. addMatrix2x2(name: string): void;
  83424. /**
  83425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83426. */
  83427. create(): void;
  83428. /** @hidden */
  83429. _rebuild(): void;
  83430. /**
  83431. * Updates the WebGL Uniform Buffer on the GPU.
  83432. * If the `dynamic` flag is set to true, no cache comparison is done.
  83433. * Otherwise, the buffer will be updated only if the cache differs.
  83434. */
  83435. update(): void;
  83436. /**
  83437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83439. * @param data Define the flattened data
  83440. * @param size Define the size of the data.
  83441. */
  83442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83443. private _valueCache;
  83444. private _cacheMatrix;
  83445. private _updateMatrix3x3ForUniform;
  83446. private _updateMatrix3x3ForEffect;
  83447. private _updateMatrix2x2ForEffect;
  83448. private _updateMatrix2x2ForUniform;
  83449. private _updateFloatForEffect;
  83450. private _updateFloatForUniform;
  83451. private _updateFloat2ForEffect;
  83452. private _updateFloat2ForUniform;
  83453. private _updateFloat3ForEffect;
  83454. private _updateFloat3ForUniform;
  83455. private _updateFloat4ForEffect;
  83456. private _updateFloat4ForUniform;
  83457. private _updateMatrixForEffect;
  83458. private _updateMatrixForUniform;
  83459. private _updateVector3ForEffect;
  83460. private _updateVector3ForUniform;
  83461. private _updateVector4ForEffect;
  83462. private _updateVector4ForUniform;
  83463. private _updateColor3ForEffect;
  83464. private _updateColor3ForUniform;
  83465. private _updateColor4ForEffect;
  83466. private _updateColor4ForUniform;
  83467. /**
  83468. * Sets a sampler uniform on the effect.
  83469. * @param name Define the name of the sampler.
  83470. * @param texture Define the texture to set in the sampler
  83471. */
  83472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83473. /**
  83474. * Directly updates the value of the uniform in the cache AND on the GPU.
  83475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83476. * @param data Define the flattened data
  83477. */
  83478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83479. /**
  83480. * Binds this uniform buffer to an effect.
  83481. * @param effect Define the effect to bind the buffer to
  83482. * @param name Name of the uniform block in the shader.
  83483. */
  83484. bindToEffect(effect: Effect, name: string): void;
  83485. /**
  83486. * Disposes the uniform buffer.
  83487. */
  83488. dispose(): void;
  83489. }
  83490. }
  83491. declare module BABYLON {
  83492. /**
  83493. * Enum that determines the text-wrapping mode to use.
  83494. */
  83495. export enum InspectableType {
  83496. /**
  83497. * Checkbox for booleans
  83498. */
  83499. Checkbox = 0,
  83500. /**
  83501. * Sliders for numbers
  83502. */
  83503. Slider = 1,
  83504. /**
  83505. * Vector3
  83506. */
  83507. Vector3 = 2,
  83508. /**
  83509. * Quaternions
  83510. */
  83511. Quaternion = 3,
  83512. /**
  83513. * Color3
  83514. */
  83515. Color3 = 4,
  83516. /**
  83517. * String
  83518. */
  83519. String = 5
  83520. }
  83521. /**
  83522. * Interface used to define custom inspectable properties.
  83523. * This interface is used by the inspector to display custom property grids
  83524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83525. */
  83526. export interface IInspectable {
  83527. /**
  83528. * Gets the label to display
  83529. */
  83530. label: string;
  83531. /**
  83532. * Gets the name of the property to edit
  83533. */
  83534. propertyName: string;
  83535. /**
  83536. * Gets the type of the editor to use
  83537. */
  83538. type: InspectableType;
  83539. /**
  83540. * Gets the minimum value of the property when using in "slider" mode
  83541. */
  83542. min?: number;
  83543. /**
  83544. * Gets the maximum value of the property when using in "slider" mode
  83545. */
  83546. max?: number;
  83547. /**
  83548. * Gets the setp to use when using in "slider" mode
  83549. */
  83550. step?: number;
  83551. }
  83552. }
  83553. declare module BABYLON {
  83554. /**
  83555. * Class used to provide helper for timing
  83556. */
  83557. export class TimingTools {
  83558. /**
  83559. * Polyfill for setImmediate
  83560. * @param action defines the action to execute after the current execution block
  83561. */
  83562. static SetImmediate(action: () => void): void;
  83563. }
  83564. }
  83565. declare module BABYLON {
  83566. /**
  83567. * Class used to enable instatition of objects by class name
  83568. */
  83569. export class InstantiationTools {
  83570. /**
  83571. * Use this object to register external classes like custom textures or material
  83572. * to allow the laoders to instantiate them
  83573. */
  83574. static RegisteredExternalClasses: {
  83575. [key: string]: Object;
  83576. };
  83577. /**
  83578. * Tries to instantiate a new object from a given class name
  83579. * @param className defines the class name to instantiate
  83580. * @returns the new object or null if the system was not able to do the instantiation
  83581. */
  83582. static Instantiate(className: string): any;
  83583. }
  83584. }
  83585. declare module BABYLON {
  83586. /**
  83587. * Define options used to create a depth texture
  83588. */
  83589. export class DepthTextureCreationOptions {
  83590. /** Specifies whether or not a stencil should be allocated in the texture */
  83591. generateStencil?: boolean;
  83592. /** Specifies whether or not bilinear filtering is enable on the texture */
  83593. bilinearFiltering?: boolean;
  83594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83595. comparisonFunction?: number;
  83596. /** Specifies if the created texture is a cube texture */
  83597. isCube?: boolean;
  83598. }
  83599. }
  83600. declare module BABYLON {
  83601. interface ThinEngine {
  83602. /**
  83603. * Creates a depth stencil cube texture.
  83604. * This is only available in WebGL 2.
  83605. * @param size The size of face edge in the cube texture.
  83606. * @param options The options defining the cube texture.
  83607. * @returns The cube texture
  83608. */
  83609. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83610. /**
  83611. * Creates a cube texture
  83612. * @param rootUrl defines the url where the files to load is located
  83613. * @param scene defines the current scene
  83614. * @param files defines the list of files to load (1 per face)
  83615. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83616. * @param onLoad defines an optional callback raised when the texture is loaded
  83617. * @param onError defines an optional callback raised if there is an issue to load the texture
  83618. * @param format defines the format of the data
  83619. * @param forcedExtension defines the extension to use to pick the right loader
  83620. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83621. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83622. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83623. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83624. * @returns the cube texture as an InternalTexture
  83625. */
  83626. 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>): InternalTexture;
  83627. /**
  83628. * Creates a cube texture
  83629. * @param rootUrl defines the url where the files to load is located
  83630. * @param scene defines the current scene
  83631. * @param files defines the list of files to load (1 per face)
  83632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83633. * @param onLoad defines an optional callback raised when the texture is loaded
  83634. * @param onError defines an optional callback raised if there is an issue to load the texture
  83635. * @param format defines the format of the data
  83636. * @param forcedExtension defines the extension to use to pick the right loader
  83637. * @returns the cube texture as an InternalTexture
  83638. */
  83639. 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;
  83640. /**
  83641. * Creates a cube texture
  83642. * @param rootUrl defines the url where the files to load is located
  83643. * @param scene defines the current scene
  83644. * @param files defines the list of files to load (1 per face)
  83645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83646. * @param onLoad defines an optional callback raised when the texture is loaded
  83647. * @param onError defines an optional callback raised if there is an issue to load the texture
  83648. * @param format defines the format of the data
  83649. * @param forcedExtension defines the extension to use to pick the right loader
  83650. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83653. * @returns the cube texture as an InternalTexture
  83654. */
  83655. 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;
  83656. /** @hidden */
  83657. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83658. /** @hidden */
  83659. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83660. /** @hidden */
  83661. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83662. /** @hidden */
  83663. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83664. /**
  83665. * @hidden
  83666. */
  83667. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83668. }
  83669. }
  83670. declare module BABYLON {
  83671. /**
  83672. * Class for creating a cube texture
  83673. */
  83674. export class CubeTexture extends BaseTexture {
  83675. private _delayedOnLoad;
  83676. /**
  83677. * Observable triggered once the texture has been loaded.
  83678. */
  83679. onLoadObservable: Observable<CubeTexture>;
  83680. /**
  83681. * The url of the texture
  83682. */
  83683. url: string;
  83684. /**
  83685. * Gets or sets the center of the bounding box associated with the cube texture.
  83686. * It must define where the camera used to render the texture was set
  83687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83688. */
  83689. boundingBoxPosition: Vector3;
  83690. private _boundingBoxSize;
  83691. /**
  83692. * Gets or sets the size of the bounding box associated with the cube texture
  83693. * When defined, the cubemap will switch to local mode
  83694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83695. * @example https://www.babylonjs-playground.com/#RNASML
  83696. */
  83697. set boundingBoxSize(value: Vector3);
  83698. /**
  83699. * Returns the bounding box size
  83700. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83701. */
  83702. get boundingBoxSize(): Vector3;
  83703. protected _rotationY: number;
  83704. /**
  83705. * Sets texture matrix rotation angle around Y axis in radians.
  83706. */
  83707. set rotationY(value: number);
  83708. /**
  83709. * Gets texture matrix rotation angle around Y axis radians.
  83710. */
  83711. get rotationY(): number;
  83712. /**
  83713. * Are mip maps generated for this texture or not.
  83714. */
  83715. get noMipmap(): boolean;
  83716. private _noMipmap;
  83717. private _files;
  83718. protected _forcedExtension: Nullable<string>;
  83719. private _extensions;
  83720. private _textureMatrix;
  83721. private _format;
  83722. private _createPolynomials;
  83723. /** @hidden */
  83724. _prefiltered: boolean;
  83725. /**
  83726. * Creates a cube texture from an array of image urls
  83727. * @param files defines an array of image urls
  83728. * @param scene defines the hosting scene
  83729. * @param noMipmap specifies if mip maps are not used
  83730. * @returns a cube texture
  83731. */
  83732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83733. /**
  83734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83735. * @param url defines the url of the prefiltered texture
  83736. * @param scene defines the scene the texture is attached to
  83737. * @param forcedExtension defines the extension of the file if different from the url
  83738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83739. * @return the prefiltered texture
  83740. */
  83741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83742. /**
  83743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83744. * as prefiltered data.
  83745. * @param rootUrl defines the url of the texture or the root name of the six images
  83746. * @param null defines the scene or engine the texture is attached to
  83747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83748. * @param noMipmap defines if mipmaps should be created or not
  83749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83751. * @param onError defines a callback triggered in case of error during load
  83752. * @param format defines the internal format to use for the texture once loaded
  83753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83758. * @return the cube texture
  83759. */
  83760. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  83761. /**
  83762. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83763. */
  83764. get isPrefiltered(): boolean;
  83765. /**
  83766. * Get the current class name of the texture useful for serialization or dynamic coding.
  83767. * @returns "CubeTexture"
  83768. */
  83769. getClassName(): string;
  83770. /**
  83771. * Update the url (and optional buffer) of this texture if url was null during construction.
  83772. * @param url the url of the texture
  83773. * @param forcedExtension defines the extension to use
  83774. * @param onLoad callback called when the texture is loaded (defaults to null)
  83775. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83776. */
  83777. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83778. /**
  83779. * Delays loading of the cube texture
  83780. * @param forcedExtension defines the extension to use
  83781. */
  83782. delayLoad(forcedExtension?: string): void;
  83783. /**
  83784. * Returns the reflection texture matrix
  83785. * @returns the reflection texture matrix
  83786. */
  83787. getReflectionTextureMatrix(): Matrix;
  83788. /**
  83789. * Sets the reflection texture matrix
  83790. * @param value Reflection texture matrix
  83791. */
  83792. setReflectionTextureMatrix(value: Matrix): void;
  83793. /**
  83794. * Parses text to create a cube texture
  83795. * @param parsedTexture define the serialized text to read from
  83796. * @param scene defines the hosting scene
  83797. * @param rootUrl defines the root url of the cube texture
  83798. * @returns a cube texture
  83799. */
  83800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83801. /**
  83802. * Makes a clone, or deep copy, of the cube texture
  83803. * @returns a new cube texture
  83804. */
  83805. clone(): CubeTexture;
  83806. }
  83807. }
  83808. declare module BABYLON {
  83809. /**
  83810. * Manages the defines for the Material
  83811. */
  83812. export class MaterialDefines {
  83813. /** @hidden */
  83814. protected _keys: string[];
  83815. private _isDirty;
  83816. /** @hidden */
  83817. _renderId: number;
  83818. /** @hidden */
  83819. _areLightsDirty: boolean;
  83820. /** @hidden */
  83821. _areLightsDisposed: boolean;
  83822. /** @hidden */
  83823. _areAttributesDirty: boolean;
  83824. /** @hidden */
  83825. _areTexturesDirty: boolean;
  83826. /** @hidden */
  83827. _areFresnelDirty: boolean;
  83828. /** @hidden */
  83829. _areMiscDirty: boolean;
  83830. /** @hidden */
  83831. _areImageProcessingDirty: boolean;
  83832. /** @hidden */
  83833. _normals: boolean;
  83834. /** @hidden */
  83835. _uvs: boolean;
  83836. /** @hidden */
  83837. _needNormals: boolean;
  83838. /** @hidden */
  83839. _needUVs: boolean;
  83840. [id: string]: any;
  83841. /**
  83842. * Specifies if the material needs to be re-calculated
  83843. */
  83844. get isDirty(): boolean;
  83845. /**
  83846. * Marks the material to indicate that it has been re-calculated
  83847. */
  83848. markAsProcessed(): void;
  83849. /**
  83850. * Marks the material to indicate that it needs to be re-calculated
  83851. */
  83852. markAsUnprocessed(): void;
  83853. /**
  83854. * Marks the material to indicate all of its defines need to be re-calculated
  83855. */
  83856. markAllAsDirty(): void;
  83857. /**
  83858. * Marks the material to indicate that image processing needs to be re-calculated
  83859. */
  83860. markAsImageProcessingDirty(): void;
  83861. /**
  83862. * Marks the material to indicate the lights need to be re-calculated
  83863. * @param disposed Defines whether the light is dirty due to dispose or not
  83864. */
  83865. markAsLightDirty(disposed?: boolean): void;
  83866. /**
  83867. * Marks the attribute state as changed
  83868. */
  83869. markAsAttributesDirty(): void;
  83870. /**
  83871. * Marks the texture state as changed
  83872. */
  83873. markAsTexturesDirty(): void;
  83874. /**
  83875. * Marks the fresnel state as changed
  83876. */
  83877. markAsFresnelDirty(): void;
  83878. /**
  83879. * Marks the misc state as changed
  83880. */
  83881. markAsMiscDirty(): void;
  83882. /**
  83883. * Rebuilds the material defines
  83884. */
  83885. rebuild(): void;
  83886. /**
  83887. * Specifies if two material defines are equal
  83888. * @param other - A material define instance to compare to
  83889. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83890. */
  83891. isEqual(other: MaterialDefines): boolean;
  83892. /**
  83893. * Clones this instance's defines to another instance
  83894. * @param other - material defines to clone values to
  83895. */
  83896. cloneTo(other: MaterialDefines): void;
  83897. /**
  83898. * Resets the material define values
  83899. */
  83900. reset(): void;
  83901. /**
  83902. * Converts the material define values to a string
  83903. * @returns - String of material define information
  83904. */
  83905. toString(): string;
  83906. }
  83907. }
  83908. declare module BABYLON {
  83909. /**
  83910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83912. * 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;
  83913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83914. */
  83915. export class ColorCurves {
  83916. private _dirty;
  83917. private _tempColor;
  83918. private _globalCurve;
  83919. private _highlightsCurve;
  83920. private _midtonesCurve;
  83921. private _shadowsCurve;
  83922. private _positiveCurve;
  83923. private _negativeCurve;
  83924. private _globalHue;
  83925. private _globalDensity;
  83926. private _globalSaturation;
  83927. private _globalExposure;
  83928. /**
  83929. * Gets the global Hue value.
  83930. * 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).
  83931. */
  83932. get globalHue(): number;
  83933. /**
  83934. * Sets the global Hue value.
  83935. * 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).
  83936. */
  83937. set globalHue(value: number);
  83938. /**
  83939. * Gets the global Density value.
  83940. * 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.
  83941. * Values less than zero provide a filter of opposite hue.
  83942. */
  83943. get globalDensity(): number;
  83944. /**
  83945. * Sets the global Density value.
  83946. * 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.
  83947. * Values less than zero provide a filter of opposite hue.
  83948. */
  83949. set globalDensity(value: number);
  83950. /**
  83951. * Gets the global Saturation value.
  83952. * 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.
  83953. */
  83954. get globalSaturation(): number;
  83955. /**
  83956. * Sets the global Saturation value.
  83957. * 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.
  83958. */
  83959. set globalSaturation(value: number);
  83960. /**
  83961. * Gets the global Exposure value.
  83962. * 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.
  83963. */
  83964. get globalExposure(): number;
  83965. /**
  83966. * Sets the global Exposure value.
  83967. * 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.
  83968. */
  83969. set globalExposure(value: number);
  83970. private _highlightsHue;
  83971. private _highlightsDensity;
  83972. private _highlightsSaturation;
  83973. private _highlightsExposure;
  83974. /**
  83975. * Gets the highlights Hue value.
  83976. * 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).
  83977. */
  83978. get highlightsHue(): number;
  83979. /**
  83980. * Sets the highlights Hue value.
  83981. * 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).
  83982. */
  83983. set highlightsHue(value: number);
  83984. /**
  83985. * Gets the highlights Density value.
  83986. * 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.
  83987. * Values less than zero provide a filter of opposite hue.
  83988. */
  83989. get highlightsDensity(): number;
  83990. /**
  83991. * Sets the highlights Density value.
  83992. * 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.
  83993. * Values less than zero provide a filter of opposite hue.
  83994. */
  83995. set highlightsDensity(value: number);
  83996. /**
  83997. * Gets the highlights Saturation value.
  83998. * 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.
  83999. */
  84000. get highlightsSaturation(): number;
  84001. /**
  84002. * Sets the highlights Saturation value.
  84003. * 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.
  84004. */
  84005. set highlightsSaturation(value: number);
  84006. /**
  84007. * Gets the highlights Exposure value.
  84008. * 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.
  84009. */
  84010. get highlightsExposure(): number;
  84011. /**
  84012. * Sets the highlights Exposure value.
  84013. * 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.
  84014. */
  84015. set highlightsExposure(value: number);
  84016. private _midtonesHue;
  84017. private _midtonesDensity;
  84018. private _midtonesSaturation;
  84019. private _midtonesExposure;
  84020. /**
  84021. * Gets the midtones Hue value.
  84022. * 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).
  84023. */
  84024. get midtonesHue(): number;
  84025. /**
  84026. * Sets the midtones Hue value.
  84027. * 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).
  84028. */
  84029. set midtonesHue(value: number);
  84030. /**
  84031. * Gets the midtones Density value.
  84032. * 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.
  84033. * Values less than zero provide a filter of opposite hue.
  84034. */
  84035. get midtonesDensity(): number;
  84036. /**
  84037. * Sets the midtones Density value.
  84038. * 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.
  84039. * Values less than zero provide a filter of opposite hue.
  84040. */
  84041. set midtonesDensity(value: number);
  84042. /**
  84043. * Gets the midtones Saturation value.
  84044. * 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.
  84045. */
  84046. get midtonesSaturation(): number;
  84047. /**
  84048. * Sets the midtones Saturation value.
  84049. * 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.
  84050. */
  84051. set midtonesSaturation(value: number);
  84052. /**
  84053. * Gets the midtones Exposure value.
  84054. * 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.
  84055. */
  84056. get midtonesExposure(): number;
  84057. /**
  84058. * Sets the midtones Exposure value.
  84059. * 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.
  84060. */
  84061. set midtonesExposure(value: number);
  84062. private _shadowsHue;
  84063. private _shadowsDensity;
  84064. private _shadowsSaturation;
  84065. private _shadowsExposure;
  84066. /**
  84067. * Gets the shadows Hue value.
  84068. * 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).
  84069. */
  84070. get shadowsHue(): number;
  84071. /**
  84072. * Sets the shadows Hue value.
  84073. * 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).
  84074. */
  84075. set shadowsHue(value: number);
  84076. /**
  84077. * Gets the shadows Density value.
  84078. * 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.
  84079. * Values less than zero provide a filter of opposite hue.
  84080. */
  84081. get shadowsDensity(): number;
  84082. /**
  84083. * Sets the shadows Density value.
  84084. * 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.
  84085. * Values less than zero provide a filter of opposite hue.
  84086. */
  84087. set shadowsDensity(value: number);
  84088. /**
  84089. * Gets the shadows Saturation value.
  84090. * 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.
  84091. */
  84092. get shadowsSaturation(): number;
  84093. /**
  84094. * Sets the shadows Saturation value.
  84095. * 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.
  84096. */
  84097. set shadowsSaturation(value: number);
  84098. /**
  84099. * Gets the shadows Exposure value.
  84100. * 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.
  84101. */
  84102. get shadowsExposure(): number;
  84103. /**
  84104. * Sets the shadows Exposure value.
  84105. * 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.
  84106. */
  84107. set shadowsExposure(value: number);
  84108. /**
  84109. * Returns the class name
  84110. * @returns The class name
  84111. */
  84112. getClassName(): string;
  84113. /**
  84114. * Binds the color curves to the shader.
  84115. * @param colorCurves The color curve to bind
  84116. * @param effect The effect to bind to
  84117. * @param positiveUniform The positive uniform shader parameter
  84118. * @param neutralUniform The neutral uniform shader parameter
  84119. * @param negativeUniform The negative uniform shader parameter
  84120. */
  84121. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  84122. /**
  84123. * Prepare the list of uniforms associated with the ColorCurves effects.
  84124. * @param uniformsList The list of uniforms used in the effect
  84125. */
  84126. static PrepareUniforms(uniformsList: string[]): void;
  84127. /**
  84128. * Returns color grading data based on a hue, density, saturation and exposure value.
  84129. * @param filterHue The hue of the color filter.
  84130. * @param filterDensity The density of the color filter.
  84131. * @param saturation The saturation.
  84132. * @param exposure The exposure.
  84133. * @param result The result data container.
  84134. */
  84135. private getColorGradingDataToRef;
  84136. /**
  84137. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  84138. * @param value The input slider value in range [-100,100].
  84139. * @returns Adjusted value.
  84140. */
  84141. private static applyColorGradingSliderNonlinear;
  84142. /**
  84143. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  84144. * @param hue The hue (H) input.
  84145. * @param saturation The saturation (S) input.
  84146. * @param brightness The brightness (B) input.
  84147. * @result An RGBA color represented as Vector4.
  84148. */
  84149. private static fromHSBToRef;
  84150. /**
  84151. * Returns a value clamped between min and max
  84152. * @param value The value to clamp
  84153. * @param min The minimum of value
  84154. * @param max The maximum of value
  84155. * @returns The clamped value.
  84156. */
  84157. private static clamp;
  84158. /**
  84159. * Clones the current color curve instance.
  84160. * @return The cloned curves
  84161. */
  84162. clone(): ColorCurves;
  84163. /**
  84164. * Serializes the current color curve instance to a json representation.
  84165. * @return a JSON representation
  84166. */
  84167. serialize(): any;
  84168. /**
  84169. * Parses the color curve from a json representation.
  84170. * @param source the JSON source to parse
  84171. * @return The parsed curves
  84172. */
  84173. static Parse(source: any): ColorCurves;
  84174. }
  84175. }
  84176. declare module BABYLON {
  84177. /**
  84178. * Interface to follow in your material defines to integrate easily the
  84179. * Image proccessing functions.
  84180. * @hidden
  84181. */
  84182. export interface IImageProcessingConfigurationDefines {
  84183. IMAGEPROCESSING: boolean;
  84184. VIGNETTE: boolean;
  84185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84186. VIGNETTEBLENDMODEOPAQUE: boolean;
  84187. TONEMAPPING: boolean;
  84188. TONEMAPPING_ACES: boolean;
  84189. CONTRAST: boolean;
  84190. EXPOSURE: boolean;
  84191. COLORCURVES: boolean;
  84192. COLORGRADING: boolean;
  84193. COLORGRADING3D: boolean;
  84194. SAMPLER3DGREENDEPTH: boolean;
  84195. SAMPLER3DBGRMAP: boolean;
  84196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84197. }
  84198. /**
  84199. * @hidden
  84200. */
  84201. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84202. IMAGEPROCESSING: boolean;
  84203. VIGNETTE: boolean;
  84204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84205. VIGNETTEBLENDMODEOPAQUE: boolean;
  84206. TONEMAPPING: boolean;
  84207. TONEMAPPING_ACES: boolean;
  84208. CONTRAST: boolean;
  84209. COLORCURVES: boolean;
  84210. COLORGRADING: boolean;
  84211. COLORGRADING3D: boolean;
  84212. SAMPLER3DGREENDEPTH: boolean;
  84213. SAMPLER3DBGRMAP: boolean;
  84214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84215. EXPOSURE: boolean;
  84216. constructor();
  84217. }
  84218. /**
  84219. * This groups together the common properties used for image processing either in direct forward pass
  84220. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84221. * or not.
  84222. */
  84223. export class ImageProcessingConfiguration {
  84224. /**
  84225. * Default tone mapping applied in BabylonJS.
  84226. */
  84227. static readonly TONEMAPPING_STANDARD: number;
  84228. /**
  84229. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84230. * to other engines rendering to increase portability.
  84231. */
  84232. static readonly TONEMAPPING_ACES: number;
  84233. /**
  84234. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84235. */
  84236. colorCurves: Nullable<ColorCurves>;
  84237. private _colorCurvesEnabled;
  84238. /**
  84239. * Gets wether the color curves effect is enabled.
  84240. */
  84241. get colorCurvesEnabled(): boolean;
  84242. /**
  84243. * Sets wether the color curves effect is enabled.
  84244. */
  84245. set colorCurvesEnabled(value: boolean);
  84246. private _colorGradingTexture;
  84247. /**
  84248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84249. */
  84250. get colorGradingTexture(): Nullable<BaseTexture>;
  84251. /**
  84252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84253. */
  84254. set colorGradingTexture(value: Nullable<BaseTexture>);
  84255. private _colorGradingEnabled;
  84256. /**
  84257. * Gets wether the color grading effect is enabled.
  84258. */
  84259. get colorGradingEnabled(): boolean;
  84260. /**
  84261. * Sets wether the color grading effect is enabled.
  84262. */
  84263. set colorGradingEnabled(value: boolean);
  84264. private _colorGradingWithGreenDepth;
  84265. /**
  84266. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84267. */
  84268. get colorGradingWithGreenDepth(): boolean;
  84269. /**
  84270. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84271. */
  84272. set colorGradingWithGreenDepth(value: boolean);
  84273. private _colorGradingBGR;
  84274. /**
  84275. * Gets wether the color grading texture contains BGR values.
  84276. */
  84277. get colorGradingBGR(): boolean;
  84278. /**
  84279. * Sets wether the color grading texture contains BGR values.
  84280. */
  84281. set colorGradingBGR(value: boolean);
  84282. /** @hidden */
  84283. _exposure: number;
  84284. /**
  84285. * Gets the Exposure used in the effect.
  84286. */
  84287. get exposure(): number;
  84288. /**
  84289. * Sets the Exposure used in the effect.
  84290. */
  84291. set exposure(value: number);
  84292. private _toneMappingEnabled;
  84293. /**
  84294. * Gets wether the tone mapping effect is enabled.
  84295. */
  84296. get toneMappingEnabled(): boolean;
  84297. /**
  84298. * Sets wether the tone mapping effect is enabled.
  84299. */
  84300. set toneMappingEnabled(value: boolean);
  84301. private _toneMappingType;
  84302. /**
  84303. * Gets the type of tone mapping effect.
  84304. */
  84305. get toneMappingType(): number;
  84306. /**
  84307. * Sets the type of tone mapping effect used in BabylonJS.
  84308. */
  84309. set toneMappingType(value: number);
  84310. protected _contrast: number;
  84311. /**
  84312. * Gets the contrast used in the effect.
  84313. */
  84314. get contrast(): number;
  84315. /**
  84316. * Sets the contrast used in the effect.
  84317. */
  84318. set contrast(value: number);
  84319. /**
  84320. * Vignette stretch size.
  84321. */
  84322. vignetteStretch: number;
  84323. /**
  84324. * Vignette centre X Offset.
  84325. */
  84326. vignetteCentreX: number;
  84327. /**
  84328. * Vignette centre Y Offset.
  84329. */
  84330. vignetteCentreY: number;
  84331. /**
  84332. * Vignette weight or intensity of the vignette effect.
  84333. */
  84334. vignetteWeight: number;
  84335. /**
  84336. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84337. * if vignetteEnabled is set to true.
  84338. */
  84339. vignetteColor: Color4;
  84340. /**
  84341. * Camera field of view used by the Vignette effect.
  84342. */
  84343. vignetteCameraFov: number;
  84344. private _vignetteBlendMode;
  84345. /**
  84346. * Gets the vignette blend mode allowing different kind of effect.
  84347. */
  84348. get vignetteBlendMode(): number;
  84349. /**
  84350. * Sets the vignette blend mode allowing different kind of effect.
  84351. */
  84352. set vignetteBlendMode(value: number);
  84353. private _vignetteEnabled;
  84354. /**
  84355. * Gets wether the vignette effect is enabled.
  84356. */
  84357. get vignetteEnabled(): boolean;
  84358. /**
  84359. * Sets wether the vignette effect is enabled.
  84360. */
  84361. set vignetteEnabled(value: boolean);
  84362. private _applyByPostProcess;
  84363. /**
  84364. * Gets wether the image processing is applied through a post process or not.
  84365. */
  84366. get applyByPostProcess(): boolean;
  84367. /**
  84368. * Sets wether the image processing is applied through a post process or not.
  84369. */
  84370. set applyByPostProcess(value: boolean);
  84371. private _isEnabled;
  84372. /**
  84373. * Gets wether the image processing is enabled or not.
  84374. */
  84375. get isEnabled(): boolean;
  84376. /**
  84377. * Sets wether the image processing is enabled or not.
  84378. */
  84379. set isEnabled(value: boolean);
  84380. /**
  84381. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84382. */
  84383. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84384. /**
  84385. * Method called each time the image processing information changes requires to recompile the effect.
  84386. */
  84387. protected _updateParameters(): void;
  84388. /**
  84389. * Gets the current class name.
  84390. * @return "ImageProcessingConfiguration"
  84391. */
  84392. getClassName(): string;
  84393. /**
  84394. * Prepare the list of uniforms associated with the Image Processing effects.
  84395. * @param uniforms The list of uniforms used in the effect
  84396. * @param defines the list of defines currently in use
  84397. */
  84398. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84399. /**
  84400. * Prepare the list of samplers associated with the Image Processing effects.
  84401. * @param samplersList The list of uniforms used in the effect
  84402. * @param defines the list of defines currently in use
  84403. */
  84404. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84405. /**
  84406. * Prepare the list of defines associated to the shader.
  84407. * @param defines the list of defines to complete
  84408. * @param forPostProcess Define if we are currently in post process mode or not
  84409. */
  84410. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84411. /**
  84412. * Returns true if all the image processing information are ready.
  84413. * @returns True if ready, otherwise, false
  84414. */
  84415. isReady(): boolean;
  84416. /**
  84417. * Binds the image processing to the shader.
  84418. * @param effect The effect to bind to
  84419. * @param overrideAspectRatio Override the aspect ratio of the effect
  84420. */
  84421. bind(effect: Effect, overrideAspectRatio?: number): void;
  84422. /**
  84423. * Clones the current image processing instance.
  84424. * @return The cloned image processing
  84425. */
  84426. clone(): ImageProcessingConfiguration;
  84427. /**
  84428. * Serializes the current image processing instance to a json representation.
  84429. * @return a JSON representation
  84430. */
  84431. serialize(): any;
  84432. /**
  84433. * Parses the image processing from a json representation.
  84434. * @param source the JSON source to parse
  84435. * @return The parsed image processing
  84436. */
  84437. static Parse(source: any): ImageProcessingConfiguration;
  84438. private static _VIGNETTEMODE_MULTIPLY;
  84439. private static _VIGNETTEMODE_OPAQUE;
  84440. /**
  84441. * Used to apply the vignette as a mix with the pixel color.
  84442. */
  84443. static get VIGNETTEMODE_MULTIPLY(): number;
  84444. /**
  84445. * Used to apply the vignette as a replacement of the pixel color.
  84446. */
  84447. static get VIGNETTEMODE_OPAQUE(): number;
  84448. }
  84449. }
  84450. declare module BABYLON {
  84451. /** @hidden */
  84452. export var postprocessVertexShader: {
  84453. name: string;
  84454. shader: string;
  84455. };
  84456. }
  84457. declare module BABYLON {
  84458. interface ThinEngine {
  84459. /**
  84460. * Creates a new render target texture
  84461. * @param size defines the size of the texture
  84462. * @param options defines the options used to create the texture
  84463. * @returns a new render target texture stored in an InternalTexture
  84464. */
  84465. createRenderTargetTexture(size: number | {
  84466. width: number;
  84467. height: number;
  84468. layers?: number;
  84469. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84470. /**
  84471. * Creates a depth stencil texture.
  84472. * This is only available in WebGL 2 or with the depth texture extension available.
  84473. * @param size The size of face edge in the texture.
  84474. * @param options The options defining the texture.
  84475. * @returns The texture
  84476. */
  84477. createDepthStencilTexture(size: number | {
  84478. width: number;
  84479. height: number;
  84480. layers?: number;
  84481. }, options: DepthTextureCreationOptions): InternalTexture;
  84482. /** @hidden */
  84483. _createDepthStencilTexture(size: number | {
  84484. width: number;
  84485. height: number;
  84486. layers?: number;
  84487. }, options: DepthTextureCreationOptions): InternalTexture;
  84488. }
  84489. }
  84490. declare module BABYLON {
  84491. /** Defines supported spaces */
  84492. export enum Space {
  84493. /** Local (object) space */
  84494. LOCAL = 0,
  84495. /** World space */
  84496. WORLD = 1,
  84497. /** Bone space */
  84498. BONE = 2
  84499. }
  84500. /** Defines the 3 main axes */
  84501. export class Axis {
  84502. /** X axis */
  84503. static X: Vector3;
  84504. /** Y axis */
  84505. static Y: Vector3;
  84506. /** Z axis */
  84507. static Z: Vector3;
  84508. }
  84509. }
  84510. declare module BABYLON {
  84511. /**
  84512. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84513. * This is the base of the follow, arc rotate cameras and Free camera
  84514. * @see http://doc.babylonjs.com/features/cameras
  84515. */
  84516. export class TargetCamera extends Camera {
  84517. private static _RigCamTransformMatrix;
  84518. private static _TargetTransformMatrix;
  84519. private static _TargetFocalPoint;
  84520. /**
  84521. * Define the current direction the camera is moving to
  84522. */
  84523. cameraDirection: Vector3;
  84524. /**
  84525. * Define the current rotation the camera is rotating to
  84526. */
  84527. cameraRotation: Vector2;
  84528. /**
  84529. * When set, the up vector of the camera will be updated by the rotation of the camera
  84530. */
  84531. updateUpVectorFromRotation: boolean;
  84532. private _tmpQuaternion;
  84533. /**
  84534. * Define the current rotation of the camera
  84535. */
  84536. rotation: Vector3;
  84537. /**
  84538. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84539. */
  84540. rotationQuaternion: Quaternion;
  84541. /**
  84542. * Define the current speed of the camera
  84543. */
  84544. speed: number;
  84545. /**
  84546. * Add constraint to the camera to prevent it to move freely in all directions and
  84547. * around all axis.
  84548. */
  84549. noRotationConstraint: boolean;
  84550. /**
  84551. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84552. * panning
  84553. */
  84554. invertRotation: boolean;
  84555. /**
  84556. * Speed multiplier for inverse camera panning
  84557. */
  84558. inverseRotationSpeed: number;
  84559. /**
  84560. * Define the current target of the camera as an object or a position.
  84561. */
  84562. lockedTarget: any;
  84563. /** @hidden */
  84564. _currentTarget: Vector3;
  84565. /** @hidden */
  84566. _initialFocalDistance: number;
  84567. /** @hidden */
  84568. _viewMatrix: Matrix;
  84569. /** @hidden */
  84570. _camMatrix: Matrix;
  84571. /** @hidden */
  84572. _cameraTransformMatrix: Matrix;
  84573. /** @hidden */
  84574. _cameraRotationMatrix: Matrix;
  84575. /** @hidden */
  84576. _referencePoint: Vector3;
  84577. /** @hidden */
  84578. _transformedReferencePoint: Vector3;
  84579. protected _globalCurrentTarget: Vector3;
  84580. protected _globalCurrentUpVector: Vector3;
  84581. /** @hidden */
  84582. _reset: () => void;
  84583. private _defaultUp;
  84584. /**
  84585. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84586. * This is the base of the follow, arc rotate cameras and Free camera
  84587. * @see http://doc.babylonjs.com/features/cameras
  84588. * @param name Defines the name of the camera in the scene
  84589. * @param position Defines the start position of the camera in the scene
  84590. * @param scene Defines the scene the camera belongs to
  84591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84592. */
  84593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84594. /**
  84595. * Gets the position in front of the camera at a given distance.
  84596. * @param distance The distance from the camera we want the position to be
  84597. * @returns the position
  84598. */
  84599. getFrontPosition(distance: number): Vector3;
  84600. /** @hidden */
  84601. _getLockedTargetPosition(): Nullable<Vector3>;
  84602. private _storedPosition;
  84603. private _storedRotation;
  84604. private _storedRotationQuaternion;
  84605. /**
  84606. * Store current camera state of the camera (fov, position, rotation, etc..)
  84607. * @returns the camera
  84608. */
  84609. storeState(): Camera;
  84610. /**
  84611. * Restored camera state. You must call storeState() first
  84612. * @returns whether it was successful or not
  84613. * @hidden
  84614. */
  84615. _restoreStateValues(): boolean;
  84616. /** @hidden */
  84617. _initCache(): void;
  84618. /** @hidden */
  84619. _updateCache(ignoreParentClass?: boolean): void;
  84620. /** @hidden */
  84621. _isSynchronizedViewMatrix(): boolean;
  84622. /** @hidden */
  84623. _computeLocalCameraSpeed(): number;
  84624. /**
  84625. * Defines the target the camera should look at.
  84626. * @param target Defines the new target as a Vector or a mesh
  84627. */
  84628. setTarget(target: Vector3): void;
  84629. /**
  84630. * Return the current target position of the camera. This value is expressed in local space.
  84631. * @returns the target position
  84632. */
  84633. getTarget(): Vector3;
  84634. /** @hidden */
  84635. _decideIfNeedsToMove(): boolean;
  84636. /** @hidden */
  84637. _updatePosition(): void;
  84638. /** @hidden */
  84639. _checkInputs(): void;
  84640. protected _updateCameraRotationMatrix(): void;
  84641. /**
  84642. * 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)
  84643. * @returns the current camera
  84644. */
  84645. private _rotateUpVectorWithCameraRotationMatrix;
  84646. private _cachedRotationZ;
  84647. private _cachedQuaternionRotationZ;
  84648. /** @hidden */
  84649. _getViewMatrix(): Matrix;
  84650. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84651. /**
  84652. * @hidden
  84653. */
  84654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84655. /**
  84656. * @hidden
  84657. */
  84658. _updateRigCameras(): void;
  84659. private _getRigCamPositionAndTarget;
  84660. /**
  84661. * Gets the current object class name.
  84662. * @return the class name
  84663. */
  84664. getClassName(): string;
  84665. }
  84666. }
  84667. declare module BABYLON {
  84668. /**
  84669. * Gather the list of keyboard event types as constants.
  84670. */
  84671. export class KeyboardEventTypes {
  84672. /**
  84673. * The keydown event is fired when a key becomes active (pressed).
  84674. */
  84675. static readonly KEYDOWN: number;
  84676. /**
  84677. * The keyup event is fired when a key has been released.
  84678. */
  84679. static readonly KEYUP: number;
  84680. }
  84681. /**
  84682. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84683. */
  84684. export class KeyboardInfo {
  84685. /**
  84686. * Defines the type of event (KeyboardEventTypes)
  84687. */
  84688. type: number;
  84689. /**
  84690. * Defines the related dom event
  84691. */
  84692. event: KeyboardEvent;
  84693. /**
  84694. * Instantiates a new keyboard info.
  84695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84696. * @param type Defines the type of event (KeyboardEventTypes)
  84697. * @param event Defines the related dom event
  84698. */
  84699. constructor(
  84700. /**
  84701. * Defines the type of event (KeyboardEventTypes)
  84702. */
  84703. type: number,
  84704. /**
  84705. * Defines the related dom event
  84706. */
  84707. event: KeyboardEvent);
  84708. }
  84709. /**
  84710. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84711. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84712. */
  84713. export class KeyboardInfoPre extends KeyboardInfo {
  84714. /**
  84715. * Defines the type of event (KeyboardEventTypes)
  84716. */
  84717. type: number;
  84718. /**
  84719. * Defines the related dom event
  84720. */
  84721. event: KeyboardEvent;
  84722. /**
  84723. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84724. */
  84725. skipOnPointerObservable: boolean;
  84726. /**
  84727. * Instantiates a new keyboard pre info.
  84728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84729. * @param type Defines the type of event (KeyboardEventTypes)
  84730. * @param event Defines the related dom event
  84731. */
  84732. constructor(
  84733. /**
  84734. * Defines the type of event (KeyboardEventTypes)
  84735. */
  84736. type: number,
  84737. /**
  84738. * Defines the related dom event
  84739. */
  84740. event: KeyboardEvent);
  84741. }
  84742. }
  84743. declare module BABYLON {
  84744. /**
  84745. * Manage the keyboard inputs to control the movement of a free camera.
  84746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84747. */
  84748. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84749. /**
  84750. * Defines the camera the input is attached to.
  84751. */
  84752. camera: FreeCamera;
  84753. /**
  84754. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84755. */
  84756. keysUp: number[];
  84757. /**
  84758. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84759. */
  84760. keysUpward: number[];
  84761. /**
  84762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84763. */
  84764. keysDown: number[];
  84765. /**
  84766. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84767. */
  84768. keysDownward: number[];
  84769. /**
  84770. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84771. */
  84772. keysLeft: number[];
  84773. /**
  84774. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84775. */
  84776. keysRight: number[];
  84777. private _keys;
  84778. private _onCanvasBlurObserver;
  84779. private _onKeyboardObserver;
  84780. private _engine;
  84781. private _scene;
  84782. /**
  84783. * Attach the input controls to a specific dom element to get the input from.
  84784. * @param element Defines the element the controls should be listened from
  84785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84786. */
  84787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84788. /**
  84789. * Detach the current controls from the specified dom element.
  84790. * @param element Defines the element to stop listening the inputs from
  84791. */
  84792. detachControl(element: Nullable<HTMLElement>): void;
  84793. /**
  84794. * Update the current camera state depending on the inputs that have been used this frame.
  84795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84796. */
  84797. checkInputs(): void;
  84798. /**
  84799. * Gets the class name of the current intput.
  84800. * @returns the class name
  84801. */
  84802. getClassName(): string;
  84803. /** @hidden */
  84804. _onLostFocus(): void;
  84805. /**
  84806. * Get the friendly name associated with the input class.
  84807. * @returns the input friendly name
  84808. */
  84809. getSimpleName(): string;
  84810. }
  84811. }
  84812. declare module BABYLON {
  84813. /**
  84814. * Interface describing all the common properties and methods a shadow light needs to implement.
  84815. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84816. * as well as binding the different shadow properties to the effects.
  84817. */
  84818. export interface IShadowLight extends Light {
  84819. /**
  84820. * The light id in the scene (used in scene.findLighById for instance)
  84821. */
  84822. id: string;
  84823. /**
  84824. * The position the shdow will be casted from.
  84825. */
  84826. position: Vector3;
  84827. /**
  84828. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84829. */
  84830. direction: Vector3;
  84831. /**
  84832. * The transformed position. Position of the light in world space taking parenting in account.
  84833. */
  84834. transformedPosition: Vector3;
  84835. /**
  84836. * The transformed direction. Direction of the light in world space taking parenting in account.
  84837. */
  84838. transformedDirection: Vector3;
  84839. /**
  84840. * The friendly name of the light in the scene.
  84841. */
  84842. name: string;
  84843. /**
  84844. * Defines the shadow projection clipping minimum z value.
  84845. */
  84846. shadowMinZ: number;
  84847. /**
  84848. * Defines the shadow projection clipping maximum z value.
  84849. */
  84850. shadowMaxZ: number;
  84851. /**
  84852. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84853. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84854. */
  84855. computeTransformedInformation(): boolean;
  84856. /**
  84857. * Gets the scene the light belongs to.
  84858. * @returns The scene
  84859. */
  84860. getScene(): Scene;
  84861. /**
  84862. * Callback defining a custom Projection Matrix Builder.
  84863. * This can be used to override the default projection matrix computation.
  84864. */
  84865. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84866. /**
  84867. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84868. * @param matrix The materix to updated with the projection information
  84869. * @param viewMatrix The transform matrix of the light
  84870. * @param renderList The list of mesh to render in the map
  84871. * @returns The current light
  84872. */
  84873. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84874. /**
  84875. * Gets the current depth scale used in ESM.
  84876. * @returns The scale
  84877. */
  84878. getDepthScale(): number;
  84879. /**
  84880. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84881. * @returns true if a cube texture needs to be use
  84882. */
  84883. needCube(): boolean;
  84884. /**
  84885. * Detects if the projection matrix requires to be recomputed this frame.
  84886. * @returns true if it requires to be recomputed otherwise, false.
  84887. */
  84888. needProjectionMatrixCompute(): boolean;
  84889. /**
  84890. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84891. */
  84892. forceProjectionMatrixCompute(): void;
  84893. /**
  84894. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84895. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84896. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84897. */
  84898. getShadowDirection(faceIndex?: number): Vector3;
  84899. /**
  84900. * Gets the minZ used for shadow according to both the scene and the light.
  84901. * @param activeCamera The camera we are returning the min for
  84902. * @returns the depth min z
  84903. */
  84904. getDepthMinZ(activeCamera: Camera): number;
  84905. /**
  84906. * Gets the maxZ used for shadow according to both the scene and the light.
  84907. * @param activeCamera The camera we are returning the max for
  84908. * @returns the depth max z
  84909. */
  84910. getDepthMaxZ(activeCamera: Camera): number;
  84911. }
  84912. /**
  84913. * Base implementation IShadowLight
  84914. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84915. */
  84916. export abstract class ShadowLight extends Light implements IShadowLight {
  84917. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84918. protected _position: Vector3;
  84919. protected _setPosition(value: Vector3): void;
  84920. /**
  84921. * Sets the position the shadow will be casted from. Also use as the light position for both
  84922. * point and spot lights.
  84923. */
  84924. get position(): Vector3;
  84925. /**
  84926. * Sets the position the shadow will be casted from. Also use as the light position for both
  84927. * point and spot lights.
  84928. */
  84929. set position(value: Vector3);
  84930. protected _direction: Vector3;
  84931. protected _setDirection(value: Vector3): void;
  84932. /**
  84933. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84934. * Also use as the light direction on spot and directional lights.
  84935. */
  84936. get direction(): Vector3;
  84937. /**
  84938. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84939. * Also use as the light direction on spot and directional lights.
  84940. */
  84941. set direction(value: Vector3);
  84942. protected _shadowMinZ: number;
  84943. /**
  84944. * Gets the shadow projection clipping minimum z value.
  84945. */
  84946. get shadowMinZ(): number;
  84947. /**
  84948. * Sets the shadow projection clipping minimum z value.
  84949. */
  84950. set shadowMinZ(value: number);
  84951. protected _shadowMaxZ: number;
  84952. /**
  84953. * Sets the shadow projection clipping maximum z value.
  84954. */
  84955. get shadowMaxZ(): number;
  84956. /**
  84957. * Gets the shadow projection clipping maximum z value.
  84958. */
  84959. set shadowMaxZ(value: number);
  84960. /**
  84961. * Callback defining a custom Projection Matrix Builder.
  84962. * This can be used to override the default projection matrix computation.
  84963. */
  84964. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84965. /**
  84966. * The transformed position. Position of the light in world space taking parenting in account.
  84967. */
  84968. transformedPosition: Vector3;
  84969. /**
  84970. * The transformed direction. Direction of the light in world space taking parenting in account.
  84971. */
  84972. transformedDirection: Vector3;
  84973. private _needProjectionMatrixCompute;
  84974. /**
  84975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84977. */
  84978. computeTransformedInformation(): boolean;
  84979. /**
  84980. * Return the depth scale used for the shadow map.
  84981. * @returns the depth scale.
  84982. */
  84983. getDepthScale(): number;
  84984. /**
  84985. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84986. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84987. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84988. */
  84989. getShadowDirection(faceIndex?: number): Vector3;
  84990. /**
  84991. * Returns the ShadowLight absolute position in the World.
  84992. * @returns the position vector in world space
  84993. */
  84994. getAbsolutePosition(): Vector3;
  84995. /**
  84996. * Sets the ShadowLight direction toward the passed target.
  84997. * @param target The point to target in local space
  84998. * @returns the updated ShadowLight direction
  84999. */
  85000. setDirectionToTarget(target: Vector3): Vector3;
  85001. /**
  85002. * Returns the light rotation in euler definition.
  85003. * @returns the x y z rotation in local space.
  85004. */
  85005. getRotation(): Vector3;
  85006. /**
  85007. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85008. * @returns true if a cube texture needs to be use
  85009. */
  85010. needCube(): boolean;
  85011. /**
  85012. * Detects if the projection matrix requires to be recomputed this frame.
  85013. * @returns true if it requires to be recomputed otherwise, false.
  85014. */
  85015. needProjectionMatrixCompute(): boolean;
  85016. /**
  85017. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85018. */
  85019. forceProjectionMatrixCompute(): void;
  85020. /** @hidden */
  85021. _initCache(): void;
  85022. /** @hidden */
  85023. _isSynchronized(): boolean;
  85024. /**
  85025. * Computes the world matrix of the node
  85026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85027. * @returns the world matrix
  85028. */
  85029. computeWorldMatrix(force?: boolean): Matrix;
  85030. /**
  85031. * Gets the minZ used for shadow according to both the scene and the light.
  85032. * @param activeCamera The camera we are returning the min for
  85033. * @returns the depth min z
  85034. */
  85035. getDepthMinZ(activeCamera: Camera): number;
  85036. /**
  85037. * Gets the maxZ used for shadow according to both the scene and the light.
  85038. * @param activeCamera The camera we are returning the max for
  85039. * @returns the depth max z
  85040. */
  85041. getDepthMaxZ(activeCamera: Camera): number;
  85042. /**
  85043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85044. * @param matrix The materix to updated with the projection information
  85045. * @param viewMatrix The transform matrix of the light
  85046. * @param renderList The list of mesh to render in the map
  85047. * @returns The current light
  85048. */
  85049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85050. }
  85051. }
  85052. declare module BABYLON {
  85053. /**
  85054. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85055. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85056. */
  85057. export class EffectFallbacks implements IEffectFallbacks {
  85058. private _defines;
  85059. private _currentRank;
  85060. private _maxRank;
  85061. private _mesh;
  85062. /**
  85063. * Removes the fallback from the bound mesh.
  85064. */
  85065. unBindMesh(): void;
  85066. /**
  85067. * Adds a fallback on the specified property.
  85068. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85069. * @param define The name of the define in the shader
  85070. */
  85071. addFallback(rank: number, define: string): void;
  85072. /**
  85073. * Sets the mesh to use CPU skinning when needing to fallback.
  85074. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85075. * @param mesh The mesh to use the fallbacks.
  85076. */
  85077. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85078. /**
  85079. * Checks to see if more fallbacks are still availible.
  85080. */
  85081. get hasMoreFallbacks(): boolean;
  85082. /**
  85083. * Removes the defines that should be removed when falling back.
  85084. * @param currentDefines defines the current define statements for the shader.
  85085. * @param effect defines the current effect we try to compile
  85086. * @returns The resulting defines with defines of the current rank removed.
  85087. */
  85088. reduce(currentDefines: string, effect: Effect): string;
  85089. }
  85090. }
  85091. declare module BABYLON {
  85092. /**
  85093. * "Static Class" containing the most commonly used helper while dealing with material for
  85094. * rendering purpose.
  85095. *
  85096. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  85097. *
  85098. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  85099. */
  85100. export class MaterialHelper {
  85101. /**
  85102. * Bind the current view position to an effect.
  85103. * @param effect The effect to be bound
  85104. * @param scene The scene the eyes position is used from
  85105. * @param variableName name of the shader variable that will hold the eye position
  85106. */
  85107. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  85108. /**
  85109. * Helps preparing the defines values about the UVs in used in the effect.
  85110. * UVs are shared as much as we can accross channels in the shaders.
  85111. * @param texture The texture we are preparing the UVs for
  85112. * @param defines The defines to update
  85113. * @param key The channel key "diffuse", "specular"... used in the shader
  85114. */
  85115. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  85116. /**
  85117. * Binds a texture matrix value to its corrsponding uniform
  85118. * @param texture The texture to bind the matrix for
  85119. * @param uniformBuffer The uniform buffer receivin the data
  85120. * @param key The channel key "diffuse", "specular"... used in the shader
  85121. */
  85122. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  85123. /**
  85124. * Gets the current status of the fog (should it be enabled?)
  85125. * @param mesh defines the mesh to evaluate for fog support
  85126. * @param scene defines the hosting scene
  85127. * @returns true if fog must be enabled
  85128. */
  85129. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  85130. /**
  85131. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  85132. * @param mesh defines the current mesh
  85133. * @param scene defines the current scene
  85134. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  85135. * @param pointsCloud defines if point cloud rendering has to be turned on
  85136. * @param fogEnabled defines if fog has to be turned on
  85137. * @param alphaTest defines if alpha testing has to be turned on
  85138. * @param defines defines the current list of defines
  85139. */
  85140. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  85141. /**
  85142. * Helper used to prepare the list of defines associated with frame values for shader compilation
  85143. * @param scene defines the current scene
  85144. * @param engine defines the current engine
  85145. * @param defines specifies the list of active defines
  85146. * @param useInstances defines if instances have to be turned on
  85147. * @param useClipPlane defines if clip plane have to be turned on
  85148. */
  85149. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  85150. /**
  85151. * Prepares the defines for bones
  85152. * @param mesh The mesh containing the geometry data we will draw
  85153. * @param defines The defines to update
  85154. */
  85155. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  85156. /**
  85157. * Prepares the defines for morph targets
  85158. * @param mesh The mesh containing the geometry data we will draw
  85159. * @param defines The defines to update
  85160. */
  85161. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  85162. /**
  85163. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  85164. * @param mesh The mesh containing the geometry data we will draw
  85165. * @param defines The defines to update
  85166. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  85167. * @param useBones Precise whether bones should be used or not (override mesh info)
  85168. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  85169. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  85170. * @returns false if defines are considered not dirty and have not been checked
  85171. */
  85172. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  85173. /**
  85174. * Prepares the defines related to multiview
  85175. * @param scene The scene we are intending to draw
  85176. * @param defines The defines to update
  85177. */
  85178. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  85179. /**
  85180. * Prepares the defines related to the light information passed in parameter
  85181. * @param scene The scene we are intending to draw
  85182. * @param mesh The mesh the effect is compiling for
  85183. * @param light The light the effect is compiling for
  85184. * @param lightIndex The index of the light
  85185. * @param defines The defines to update
  85186. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85187. * @param state Defines the current state regarding what is needed (normals, etc...)
  85188. */
  85189. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85190. needNormals: boolean;
  85191. needRebuild: boolean;
  85192. shadowEnabled: boolean;
  85193. specularEnabled: boolean;
  85194. lightmapMode: boolean;
  85195. }): void;
  85196. /**
  85197. * Prepares the defines related to the light information passed in parameter
  85198. * @param scene The scene we are intending to draw
  85199. * @param mesh The mesh the effect is compiling for
  85200. * @param defines The defines to update
  85201. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85202. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85203. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85204. * @returns true if normals will be required for the rest of the effect
  85205. */
  85206. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85207. /**
  85208. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85209. * @param lightIndex defines the light index
  85210. * @param uniformsList The uniform list
  85211. * @param samplersList The sampler list
  85212. * @param projectedLightTexture defines if projected texture must be used
  85213. * @param uniformBuffersList defines an optional list of uniform buffers
  85214. */
  85215. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85216. /**
  85217. * Prepares the uniforms and samplers list to be used in the effect
  85218. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85219. * @param samplersList The sampler list
  85220. * @param defines The defines helping in the list generation
  85221. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85222. */
  85223. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85224. /**
  85225. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85226. * @param defines The defines to update while falling back
  85227. * @param fallbacks The authorized effect fallbacks
  85228. * @param maxSimultaneousLights The maximum number of lights allowed
  85229. * @param rank the current rank of the Effect
  85230. * @returns The newly affected rank
  85231. */
  85232. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85233. private static _TmpMorphInfluencers;
  85234. /**
  85235. * Prepares the list of attributes required for morph targets according to the effect defines.
  85236. * @param attribs The current list of supported attribs
  85237. * @param mesh The mesh to prepare the morph targets attributes for
  85238. * @param influencers The number of influencers
  85239. */
  85240. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85241. /**
  85242. * Prepares the list of attributes required for morph targets according to the effect defines.
  85243. * @param attribs The current list of supported attribs
  85244. * @param mesh The mesh to prepare the morph targets attributes for
  85245. * @param defines The current Defines of the effect
  85246. */
  85247. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85248. /**
  85249. * Prepares the list of attributes required for bones according to the effect defines.
  85250. * @param attribs The current list of supported attribs
  85251. * @param mesh The mesh to prepare the bones attributes for
  85252. * @param defines The current Defines of the effect
  85253. * @param fallbacks The current efffect fallback strategy
  85254. */
  85255. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85256. /**
  85257. * Check and prepare the list of attributes required for instances according to the effect defines.
  85258. * @param attribs The current list of supported attribs
  85259. * @param defines The current MaterialDefines of the effect
  85260. */
  85261. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85262. /**
  85263. * Add the list of attributes required for instances to the attribs array.
  85264. * @param attribs The current list of supported attribs
  85265. */
  85266. static PushAttributesForInstances(attribs: string[]): void;
  85267. /**
  85268. * Binds the light information to the effect.
  85269. * @param light The light containing the generator
  85270. * @param effect The effect we are binding the data to
  85271. * @param lightIndex The light index in the effect used to render
  85272. */
  85273. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85274. /**
  85275. * Binds the lights information from the scene to the effect for the given mesh.
  85276. * @param light Light to bind
  85277. * @param lightIndex Light index
  85278. * @param scene The scene where the light belongs to
  85279. * @param effect The effect we are binding the data to
  85280. * @param useSpecular Defines if specular is supported
  85281. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85282. */
  85283. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85284. /**
  85285. * Binds the lights information from the scene to the effect for the given mesh.
  85286. * @param scene The scene the lights belongs to
  85287. * @param mesh The mesh we are binding the information to render
  85288. * @param effect The effect we are binding the data to
  85289. * @param defines The generated defines for the effect
  85290. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85291. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85292. */
  85293. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85294. private static _tempFogColor;
  85295. /**
  85296. * Binds the fog information from the scene to the effect for the given mesh.
  85297. * @param scene The scene the lights belongs to
  85298. * @param mesh The mesh we are binding the information to render
  85299. * @param effect The effect we are binding the data to
  85300. * @param linearSpace Defines if the fog effect is applied in linear space
  85301. */
  85302. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85303. /**
  85304. * Binds the bones information from the mesh to the effect.
  85305. * @param mesh The mesh we are binding the information to render
  85306. * @param effect The effect we are binding the data to
  85307. */
  85308. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85309. /**
  85310. * Binds the morph targets information from the mesh to the effect.
  85311. * @param abstractMesh The mesh we are binding the information to render
  85312. * @param effect The effect we are binding the data to
  85313. */
  85314. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85315. /**
  85316. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85317. * @param defines The generated defines used in the effect
  85318. * @param effect The effect we are binding the data to
  85319. * @param scene The scene we are willing to render with logarithmic scale for
  85320. */
  85321. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85322. /**
  85323. * Binds the clip plane information from the scene to the effect.
  85324. * @param scene The scene the clip plane information are extracted from
  85325. * @param effect The effect we are binding the data to
  85326. */
  85327. static BindClipPlane(effect: Effect, scene: Scene): void;
  85328. }
  85329. }
  85330. declare module BABYLON {
  85331. /** @hidden */
  85332. export var packingFunctions: {
  85333. name: string;
  85334. shader: string;
  85335. };
  85336. }
  85337. declare module BABYLON {
  85338. /** @hidden */
  85339. export var bayerDitherFunctions: {
  85340. name: string;
  85341. shader: string;
  85342. };
  85343. }
  85344. declare module BABYLON {
  85345. /** @hidden */
  85346. export var shadowMapFragmentDeclaration: {
  85347. name: string;
  85348. shader: string;
  85349. };
  85350. }
  85351. declare module BABYLON {
  85352. /** @hidden */
  85353. export var clipPlaneFragmentDeclaration: {
  85354. name: string;
  85355. shader: string;
  85356. };
  85357. }
  85358. declare module BABYLON {
  85359. /** @hidden */
  85360. export var clipPlaneFragment: {
  85361. name: string;
  85362. shader: string;
  85363. };
  85364. }
  85365. declare module BABYLON {
  85366. /** @hidden */
  85367. export var shadowMapFragment: {
  85368. name: string;
  85369. shader: string;
  85370. };
  85371. }
  85372. declare module BABYLON {
  85373. /** @hidden */
  85374. export var shadowMapPixelShader: {
  85375. name: string;
  85376. shader: string;
  85377. };
  85378. }
  85379. declare module BABYLON {
  85380. /** @hidden */
  85381. export var bonesDeclaration: {
  85382. name: string;
  85383. shader: string;
  85384. };
  85385. }
  85386. declare module BABYLON {
  85387. /** @hidden */
  85388. export var morphTargetsVertexGlobalDeclaration: {
  85389. name: string;
  85390. shader: string;
  85391. };
  85392. }
  85393. declare module BABYLON {
  85394. /** @hidden */
  85395. export var morphTargetsVertexDeclaration: {
  85396. name: string;
  85397. shader: string;
  85398. };
  85399. }
  85400. declare module BABYLON {
  85401. /** @hidden */
  85402. export var instancesDeclaration: {
  85403. name: string;
  85404. shader: string;
  85405. };
  85406. }
  85407. declare module BABYLON {
  85408. /** @hidden */
  85409. export var helperFunctions: {
  85410. name: string;
  85411. shader: string;
  85412. };
  85413. }
  85414. declare module BABYLON {
  85415. /** @hidden */
  85416. export var shadowMapVertexDeclaration: {
  85417. name: string;
  85418. shader: string;
  85419. };
  85420. }
  85421. declare module BABYLON {
  85422. /** @hidden */
  85423. export var clipPlaneVertexDeclaration: {
  85424. name: string;
  85425. shader: string;
  85426. };
  85427. }
  85428. declare module BABYLON {
  85429. /** @hidden */
  85430. export var morphTargetsVertex: {
  85431. name: string;
  85432. shader: string;
  85433. };
  85434. }
  85435. declare module BABYLON {
  85436. /** @hidden */
  85437. export var instancesVertex: {
  85438. name: string;
  85439. shader: string;
  85440. };
  85441. }
  85442. declare module BABYLON {
  85443. /** @hidden */
  85444. export var bonesVertex: {
  85445. name: string;
  85446. shader: string;
  85447. };
  85448. }
  85449. declare module BABYLON {
  85450. /** @hidden */
  85451. export var shadowMapVertexNormalBias: {
  85452. name: string;
  85453. shader: string;
  85454. };
  85455. }
  85456. declare module BABYLON {
  85457. /** @hidden */
  85458. export var shadowMapVertexMetric: {
  85459. name: string;
  85460. shader: string;
  85461. };
  85462. }
  85463. declare module BABYLON {
  85464. /** @hidden */
  85465. export var clipPlaneVertex: {
  85466. name: string;
  85467. shader: string;
  85468. };
  85469. }
  85470. declare module BABYLON {
  85471. /** @hidden */
  85472. export var shadowMapVertexShader: {
  85473. name: string;
  85474. shader: string;
  85475. };
  85476. }
  85477. declare module BABYLON {
  85478. /** @hidden */
  85479. export var depthBoxBlurPixelShader: {
  85480. name: string;
  85481. shader: string;
  85482. };
  85483. }
  85484. declare module BABYLON {
  85485. /** @hidden */
  85486. export var shadowMapFragmentSoftTransparentShadow: {
  85487. name: string;
  85488. shader: string;
  85489. };
  85490. }
  85491. declare module BABYLON {
  85492. /**
  85493. * Class representing a ray with position and direction
  85494. */
  85495. export class Ray {
  85496. /** origin point */
  85497. origin: Vector3;
  85498. /** direction */
  85499. direction: Vector3;
  85500. /** length of the ray */
  85501. length: number;
  85502. private static readonly TmpVector3;
  85503. private _tmpRay;
  85504. /**
  85505. * Creates a new ray
  85506. * @param origin origin point
  85507. * @param direction direction
  85508. * @param length length of the ray
  85509. */
  85510. constructor(
  85511. /** origin point */
  85512. origin: Vector3,
  85513. /** direction */
  85514. direction: Vector3,
  85515. /** length of the ray */
  85516. length?: number);
  85517. /**
  85518. * Checks if the ray intersects a box
  85519. * This does not account for the ray lenght by design to improve perfs.
  85520. * @param minimum bound of the box
  85521. * @param maximum bound of the box
  85522. * @param intersectionTreshold extra extend to be added to the box in all direction
  85523. * @returns if the box was hit
  85524. */
  85525. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85526. /**
  85527. * Checks if the ray intersects a box
  85528. * This does not account for the ray lenght by design to improve perfs.
  85529. * @param box the bounding box to check
  85530. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85531. * @returns if the box was hit
  85532. */
  85533. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85534. /**
  85535. * If the ray hits a sphere
  85536. * @param sphere the bounding sphere to check
  85537. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85538. * @returns true if it hits the sphere
  85539. */
  85540. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85541. /**
  85542. * If the ray hits a triange
  85543. * @param vertex0 triangle vertex
  85544. * @param vertex1 triangle vertex
  85545. * @param vertex2 triangle vertex
  85546. * @returns intersection information if hit
  85547. */
  85548. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85549. /**
  85550. * Checks if ray intersects a plane
  85551. * @param plane the plane to check
  85552. * @returns the distance away it was hit
  85553. */
  85554. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85555. /**
  85556. * Calculate the intercept of a ray on a given axis
  85557. * @param axis to check 'x' | 'y' | 'z'
  85558. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85559. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85560. */
  85561. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85562. /**
  85563. * Checks if ray intersects a mesh
  85564. * @param mesh the mesh to check
  85565. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85566. * @returns picking info of the intersecton
  85567. */
  85568. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85569. /**
  85570. * Checks if ray intersects a mesh
  85571. * @param meshes the meshes to check
  85572. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85573. * @param results array to store result in
  85574. * @returns Array of picking infos
  85575. */
  85576. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85577. private _comparePickingInfo;
  85578. private static smallnum;
  85579. private static rayl;
  85580. /**
  85581. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85582. * @param sega the first point of the segment to test the intersection against
  85583. * @param segb the second point of the segment to test the intersection against
  85584. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85585. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85586. */
  85587. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85588. /**
  85589. * Update the ray from viewport position
  85590. * @param x position
  85591. * @param y y position
  85592. * @param viewportWidth viewport width
  85593. * @param viewportHeight viewport height
  85594. * @param world world matrix
  85595. * @param view view matrix
  85596. * @param projection projection matrix
  85597. * @returns this ray updated
  85598. */
  85599. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85600. /**
  85601. * Creates a ray with origin and direction of 0,0,0
  85602. * @returns the new ray
  85603. */
  85604. static Zero(): Ray;
  85605. /**
  85606. * Creates a new ray from screen space and viewport
  85607. * @param x position
  85608. * @param y y position
  85609. * @param viewportWidth viewport width
  85610. * @param viewportHeight viewport height
  85611. * @param world world matrix
  85612. * @param view view matrix
  85613. * @param projection projection matrix
  85614. * @returns new ray
  85615. */
  85616. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85617. /**
  85618. * 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
  85619. * transformed to the given world matrix.
  85620. * @param origin The origin point
  85621. * @param end The end point
  85622. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85623. * @returns the new ray
  85624. */
  85625. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85626. /**
  85627. * Transforms a ray by a matrix
  85628. * @param ray ray to transform
  85629. * @param matrix matrix to apply
  85630. * @returns the resulting new ray
  85631. */
  85632. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85633. /**
  85634. * Transforms a ray by a matrix
  85635. * @param ray ray to transform
  85636. * @param matrix matrix to apply
  85637. * @param result ray to store result in
  85638. */
  85639. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85640. /**
  85641. * Unproject a ray from screen space to object space
  85642. * @param sourceX defines the screen space x coordinate to use
  85643. * @param sourceY defines the screen space y coordinate to use
  85644. * @param viewportWidth defines the current width of the viewport
  85645. * @param viewportHeight defines the current height of the viewport
  85646. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85647. * @param view defines the view matrix to use
  85648. * @param projection defines the projection matrix to use
  85649. */
  85650. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85651. }
  85652. /**
  85653. * Type used to define predicate used to select faces when a mesh intersection is detected
  85654. */
  85655. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85656. interface Scene {
  85657. /** @hidden */
  85658. _tempPickingRay: Nullable<Ray>;
  85659. /** @hidden */
  85660. _cachedRayForTransform: Ray;
  85661. /** @hidden */
  85662. _pickWithRayInverseMatrix: Matrix;
  85663. /** @hidden */
  85664. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85665. /** @hidden */
  85666. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85667. }
  85668. }
  85669. declare module BABYLON {
  85670. /**
  85671. * Groups all the scene component constants in one place to ease maintenance.
  85672. * @hidden
  85673. */
  85674. export class SceneComponentConstants {
  85675. static readonly NAME_EFFECTLAYER: string;
  85676. static readonly NAME_LAYER: string;
  85677. static readonly NAME_LENSFLARESYSTEM: string;
  85678. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85679. static readonly NAME_PARTICLESYSTEM: string;
  85680. static readonly NAME_GAMEPAD: string;
  85681. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85682. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85683. static readonly NAME_DEPTHRENDERER: string;
  85684. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85685. static readonly NAME_SPRITE: string;
  85686. static readonly NAME_OUTLINERENDERER: string;
  85687. static readonly NAME_PROCEDURALTEXTURE: string;
  85688. static readonly NAME_SHADOWGENERATOR: string;
  85689. static readonly NAME_OCTREE: string;
  85690. static readonly NAME_PHYSICSENGINE: string;
  85691. static readonly NAME_AUDIO: string;
  85692. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85693. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85694. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85695. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85696. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85697. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85698. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85699. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85700. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85701. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85702. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85703. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85704. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85705. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85706. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85707. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85708. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85709. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85710. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85711. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85712. static readonly STEP_AFTERRENDER_AUDIO: number;
  85713. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85714. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85715. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85716. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85717. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85718. static readonly STEP_POINTERMOVE_SPRITE: number;
  85719. static readonly STEP_POINTERDOWN_SPRITE: number;
  85720. static readonly STEP_POINTERUP_SPRITE: number;
  85721. }
  85722. /**
  85723. * This represents a scene component.
  85724. *
  85725. * This is used to decouple the dependency the scene is having on the different workloads like
  85726. * layers, post processes...
  85727. */
  85728. export interface ISceneComponent {
  85729. /**
  85730. * The name of the component. Each component must have a unique name.
  85731. */
  85732. name: string;
  85733. /**
  85734. * The scene the component belongs to.
  85735. */
  85736. scene: Scene;
  85737. /**
  85738. * Register the component to one instance of a scene.
  85739. */
  85740. register(): void;
  85741. /**
  85742. * Rebuilds the elements related to this component in case of
  85743. * context lost for instance.
  85744. */
  85745. rebuild(): void;
  85746. /**
  85747. * Disposes the component and the associated ressources.
  85748. */
  85749. dispose(): void;
  85750. }
  85751. /**
  85752. * This represents a SERIALIZABLE scene component.
  85753. *
  85754. * This extends Scene Component to add Serialization methods on top.
  85755. */
  85756. export interface ISceneSerializableComponent extends ISceneComponent {
  85757. /**
  85758. * Adds all the elements from the container to the scene
  85759. * @param container the container holding the elements
  85760. */
  85761. addFromContainer(container: AbstractScene): void;
  85762. /**
  85763. * Removes all the elements in the container from the scene
  85764. * @param container contains the elements to remove
  85765. * @param dispose if the removed element should be disposed (default: false)
  85766. */
  85767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85768. /**
  85769. * Serializes the component data to the specified json object
  85770. * @param serializationObject The object to serialize to
  85771. */
  85772. serialize(serializationObject: any): void;
  85773. }
  85774. /**
  85775. * Strong typing of a Mesh related stage step action
  85776. */
  85777. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85778. /**
  85779. * Strong typing of a Evaluate Sub Mesh related stage step action
  85780. */
  85781. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85782. /**
  85783. * Strong typing of a Active Mesh related stage step action
  85784. */
  85785. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85786. /**
  85787. * Strong typing of a Camera related stage step action
  85788. */
  85789. export type CameraStageAction = (camera: Camera) => void;
  85790. /**
  85791. * Strong typing of a Camera Frame buffer related stage step action
  85792. */
  85793. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85794. /**
  85795. * Strong typing of a Render Target related stage step action
  85796. */
  85797. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85798. /**
  85799. * Strong typing of a RenderingGroup related stage step action
  85800. */
  85801. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85802. /**
  85803. * Strong typing of a Mesh Render related stage step action
  85804. */
  85805. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85806. /**
  85807. * Strong typing of a simple stage step action
  85808. */
  85809. export type SimpleStageAction = () => void;
  85810. /**
  85811. * Strong typing of a render target action.
  85812. */
  85813. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85814. /**
  85815. * Strong typing of a pointer move action.
  85816. */
  85817. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85818. /**
  85819. * Strong typing of a pointer up/down action.
  85820. */
  85821. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85822. /**
  85823. * Representation of a stage in the scene (Basically a list of ordered steps)
  85824. * @hidden
  85825. */
  85826. export class Stage<T extends Function> extends Array<{
  85827. index: number;
  85828. component: ISceneComponent;
  85829. action: T;
  85830. }> {
  85831. /**
  85832. * Hide ctor from the rest of the world.
  85833. * @param items The items to add.
  85834. */
  85835. private constructor();
  85836. /**
  85837. * Creates a new Stage.
  85838. * @returns A new instance of a Stage
  85839. */
  85840. static Create<T extends Function>(): Stage<T>;
  85841. /**
  85842. * Registers a step in an ordered way in the targeted stage.
  85843. * @param index Defines the position to register the step in
  85844. * @param component Defines the component attached to the step
  85845. * @param action Defines the action to launch during the step
  85846. */
  85847. registerStep(index: number, component: ISceneComponent, action: T): void;
  85848. /**
  85849. * Clears all the steps from the stage.
  85850. */
  85851. clear(): void;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. interface Scene {
  85856. /** @hidden */
  85857. _pointerOverSprite: Nullable<Sprite>;
  85858. /** @hidden */
  85859. _pickedDownSprite: Nullable<Sprite>;
  85860. /** @hidden */
  85861. _tempSpritePickingRay: Nullable<Ray>;
  85862. /**
  85863. * All of the sprite managers added to this scene
  85864. * @see http://doc.babylonjs.com/babylon101/sprites
  85865. */
  85866. spriteManagers: Array<ISpriteManager>;
  85867. /**
  85868. * An event triggered when sprites rendering is about to start
  85869. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85870. */
  85871. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85872. /**
  85873. * An event triggered when sprites rendering is done
  85874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85875. */
  85876. onAfterSpritesRenderingObservable: Observable<Scene>;
  85877. /** @hidden */
  85878. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85879. /** Launch a ray to try to pick a sprite in the scene
  85880. * @param x position on screen
  85881. * @param y position on screen
  85882. * @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
  85883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85884. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85885. * @returns a PickingInfo
  85886. */
  85887. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85888. /** Use the given ray to pick a sprite in the scene
  85889. * @param ray The ray (in world space) to use to pick meshes
  85890. * @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
  85891. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85892. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85893. * @returns a PickingInfo
  85894. */
  85895. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85896. /** @hidden */
  85897. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85898. /** Launch a ray to try to pick sprites in the scene
  85899. * @param x position on screen
  85900. * @param y position on screen
  85901. * @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
  85902. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85903. * @returns a PickingInfo array
  85904. */
  85905. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85906. /** Use the given ray to pick sprites in the scene
  85907. * @param ray The ray (in world space) to use to pick meshes
  85908. * @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
  85909. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85910. * @returns a PickingInfo array
  85911. */
  85912. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85913. /**
  85914. * Force the sprite under the pointer
  85915. * @param sprite defines the sprite to use
  85916. */
  85917. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85918. /**
  85919. * Gets the sprite under the pointer
  85920. * @returns a Sprite or null if no sprite is under the pointer
  85921. */
  85922. getPointerOverSprite(): Nullable<Sprite>;
  85923. }
  85924. /**
  85925. * Defines the sprite scene component responsible to manage sprites
  85926. * in a given scene.
  85927. */
  85928. export class SpriteSceneComponent implements ISceneComponent {
  85929. /**
  85930. * The component name helpfull to identify the component in the list of scene components.
  85931. */
  85932. readonly name: string;
  85933. /**
  85934. * The scene the component belongs to.
  85935. */
  85936. scene: Scene;
  85937. /** @hidden */
  85938. private _spritePredicate;
  85939. /**
  85940. * Creates a new instance of the component for the given scene
  85941. * @param scene Defines the scene to register the component in
  85942. */
  85943. constructor(scene: Scene);
  85944. /**
  85945. * Registers the component in a given scene
  85946. */
  85947. register(): void;
  85948. /**
  85949. * Rebuilds the elements related to this component in case of
  85950. * context lost for instance.
  85951. */
  85952. rebuild(): void;
  85953. /**
  85954. * Disposes the component and the associated ressources.
  85955. */
  85956. dispose(): void;
  85957. private _pickSpriteButKeepRay;
  85958. private _pointerMove;
  85959. private _pointerDown;
  85960. private _pointerUp;
  85961. }
  85962. }
  85963. declare module BABYLON {
  85964. /** @hidden */
  85965. export var fogFragmentDeclaration: {
  85966. name: string;
  85967. shader: string;
  85968. };
  85969. }
  85970. declare module BABYLON {
  85971. /** @hidden */
  85972. export var fogFragment: {
  85973. name: string;
  85974. shader: string;
  85975. };
  85976. }
  85977. declare module BABYLON {
  85978. /** @hidden */
  85979. export var spritesPixelShader: {
  85980. name: string;
  85981. shader: string;
  85982. };
  85983. }
  85984. declare module BABYLON {
  85985. /** @hidden */
  85986. export var fogVertexDeclaration: {
  85987. name: string;
  85988. shader: string;
  85989. };
  85990. }
  85991. declare module BABYLON {
  85992. /** @hidden */
  85993. export var spritesVertexShader: {
  85994. name: string;
  85995. shader: string;
  85996. };
  85997. }
  85998. declare module BABYLON {
  85999. /**
  86000. * Defines the minimum interface to fullfil in order to be a sprite manager.
  86001. */
  86002. export interface ISpriteManager extends IDisposable {
  86003. /**
  86004. * Restricts the camera to viewing objects with the same layerMask.
  86005. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  86006. */
  86007. layerMask: number;
  86008. /**
  86009. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86010. */
  86011. isPickable: boolean;
  86012. /**
  86013. * Specifies the rendering group id for this mesh (0 by default)
  86014. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86015. */
  86016. renderingGroupId: number;
  86017. /**
  86018. * Defines the list of sprites managed by the manager.
  86019. */
  86020. sprites: Array<Sprite>;
  86021. /**
  86022. * Tests the intersection of a sprite with a specific ray.
  86023. * @param ray The ray we are sending to test the collision
  86024. * @param camera The camera space we are sending rays in
  86025. * @param predicate A predicate allowing excluding sprites from the list of object to test
  86026. * @param fastCheck defines if the first intersection will be used (and not the closest)
  86027. * @returns picking info or null.
  86028. */
  86029. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86030. /**
  86031. * Intersects the sprites with a ray
  86032. * @param ray defines the ray to intersect with
  86033. * @param camera defines the current active camera
  86034. * @param predicate defines a predicate used to select candidate sprites
  86035. * @returns null if no hit or a PickingInfo array
  86036. */
  86037. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86038. /**
  86039. * Renders the list of sprites on screen.
  86040. */
  86041. render(): void;
  86042. }
  86043. /**
  86044. * Class used to manage multiple sprites on the same spritesheet
  86045. * @see http://doc.babylonjs.com/babylon101/sprites
  86046. */
  86047. export class SpriteManager implements ISpriteManager {
  86048. /** defines the manager's name */
  86049. name: string;
  86050. /** Gets the list of sprites */
  86051. sprites: Sprite[];
  86052. /** Gets or sets the rendering group id (0 by default) */
  86053. renderingGroupId: number;
  86054. /** Gets or sets camera layer mask */
  86055. layerMask: number;
  86056. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  86057. fogEnabled: boolean;
  86058. /** Gets or sets a boolean indicating if the sprites are pickable */
  86059. isPickable: boolean;
  86060. /** Defines the default width of a cell in the spritesheet */
  86061. cellWidth: number;
  86062. /** Defines the default height of a cell in the spritesheet */
  86063. cellHeight: number;
  86064. /** Associative array from JSON sprite data file */
  86065. private _cellData;
  86066. /** Array of sprite names from JSON sprite data file */
  86067. private _spriteMap;
  86068. /** True when packed cell data from JSON file is ready*/
  86069. private _packedAndReady;
  86070. private _textureContent;
  86071. /**
  86072. * An event triggered when the manager is disposed.
  86073. */
  86074. onDisposeObservable: Observable<SpriteManager>;
  86075. private _onDisposeObserver;
  86076. /**
  86077. * Callback called when the manager is disposed
  86078. */
  86079. set onDispose(callback: () => void);
  86080. private _capacity;
  86081. private _fromPacked;
  86082. private _spriteTexture;
  86083. private _epsilon;
  86084. private _scene;
  86085. private _vertexData;
  86086. private _buffer;
  86087. private _vertexBuffers;
  86088. private _indexBuffer;
  86089. private _effectBase;
  86090. private _effectFog;
  86091. /**
  86092. * Gets or sets the spritesheet texture
  86093. */
  86094. get texture(): Texture;
  86095. set texture(value: Texture);
  86096. private _blendMode;
  86097. /**
  86098. * Blend mode use to render the particle, it can be any of
  86099. * the static Constants.ALPHA_x properties provided in this class.
  86100. * Default value is Constants.ALPHA_COMBINE
  86101. */
  86102. get blendMode(): number;
  86103. set blendMode(blendMode: number);
  86104. /** Disables writing to the depth buffer when rendering the sprites.
  86105. * It can be handy to disable depth writing when using textures without alpha channel
  86106. * and setting some specific blend modes.
  86107. */
  86108. disableDepthWrite: boolean;
  86109. /**
  86110. * Creates a new sprite manager
  86111. * @param name defines the manager's name
  86112. * @param imgUrl defines the sprite sheet url
  86113. * @param capacity defines the maximum allowed number of sprites
  86114. * @param cellSize defines the size of a sprite cell
  86115. * @param scene defines the hosting scene
  86116. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  86117. * @param samplingMode defines the smapling mode to use with spritesheet
  86118. * @param fromPacked set to false; do not alter
  86119. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  86120. */
  86121. constructor(
  86122. /** defines the manager's name */
  86123. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  86124. private _makePacked;
  86125. private _appendSpriteVertex;
  86126. private _checkTextureAlpha;
  86127. /**
  86128. * Intersects the sprites with a ray
  86129. * @param ray defines the ray to intersect with
  86130. * @param camera defines the current active camera
  86131. * @param predicate defines a predicate used to select candidate sprites
  86132. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  86133. * @returns null if no hit or a PickingInfo
  86134. */
  86135. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  86136. /**
  86137. * Intersects the sprites with a ray
  86138. * @param ray defines the ray to intersect with
  86139. * @param camera defines the current active camera
  86140. * @param predicate defines a predicate used to select candidate sprites
  86141. * @returns null if no hit or a PickingInfo array
  86142. */
  86143. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  86144. /**
  86145. * Render all child sprites
  86146. */
  86147. render(): void;
  86148. /**
  86149. * Release associated resources
  86150. */
  86151. dispose(): void;
  86152. }
  86153. }
  86154. declare module BABYLON {
  86155. /** Interface used by value gradients (color, factor, ...) */
  86156. export interface IValueGradient {
  86157. /**
  86158. * Gets or sets the gradient value (between 0 and 1)
  86159. */
  86160. gradient: number;
  86161. }
  86162. /** Class used to store color4 gradient */
  86163. export class ColorGradient implements IValueGradient {
  86164. /**
  86165. * Gets or sets the gradient value (between 0 and 1)
  86166. */
  86167. gradient: number;
  86168. /**
  86169. * Gets or sets first associated color
  86170. */
  86171. color1: Color4;
  86172. /**
  86173. * Gets or sets second associated color
  86174. */
  86175. color2?: Color4 | undefined;
  86176. /**
  86177. * Creates a new color4 gradient
  86178. * @param gradient gets or sets the gradient value (between 0 and 1)
  86179. * @param color1 gets or sets first associated color
  86180. * @param color2 gets or sets first second color
  86181. */
  86182. constructor(
  86183. /**
  86184. * Gets or sets the gradient value (between 0 and 1)
  86185. */
  86186. gradient: number,
  86187. /**
  86188. * Gets or sets first associated color
  86189. */
  86190. color1: Color4,
  86191. /**
  86192. * Gets or sets second associated color
  86193. */
  86194. color2?: Color4 | undefined);
  86195. /**
  86196. * Will get a color picked randomly between color1 and color2.
  86197. * If color2 is undefined then color1 will be used
  86198. * @param result defines the target Color4 to store the result in
  86199. */
  86200. getColorToRef(result: Color4): void;
  86201. }
  86202. /** Class used to store color 3 gradient */
  86203. export class Color3Gradient implements IValueGradient {
  86204. /**
  86205. * Gets or sets the gradient value (between 0 and 1)
  86206. */
  86207. gradient: number;
  86208. /**
  86209. * Gets or sets the associated color
  86210. */
  86211. color: Color3;
  86212. /**
  86213. * Creates a new color3 gradient
  86214. * @param gradient gets or sets the gradient value (between 0 and 1)
  86215. * @param color gets or sets associated color
  86216. */
  86217. constructor(
  86218. /**
  86219. * Gets or sets the gradient value (between 0 and 1)
  86220. */
  86221. gradient: number,
  86222. /**
  86223. * Gets or sets the associated color
  86224. */
  86225. color: Color3);
  86226. }
  86227. /** Class used to store factor gradient */
  86228. export class FactorGradient implements IValueGradient {
  86229. /**
  86230. * Gets or sets the gradient value (between 0 and 1)
  86231. */
  86232. gradient: number;
  86233. /**
  86234. * Gets or sets first associated factor
  86235. */
  86236. factor1: number;
  86237. /**
  86238. * Gets or sets second associated factor
  86239. */
  86240. factor2?: number | undefined;
  86241. /**
  86242. * Creates a new factor gradient
  86243. * @param gradient gets or sets the gradient value (between 0 and 1)
  86244. * @param factor1 gets or sets first associated factor
  86245. * @param factor2 gets or sets second associated factor
  86246. */
  86247. constructor(
  86248. /**
  86249. * Gets or sets the gradient value (between 0 and 1)
  86250. */
  86251. gradient: number,
  86252. /**
  86253. * Gets or sets first associated factor
  86254. */
  86255. factor1: number,
  86256. /**
  86257. * Gets or sets second associated factor
  86258. */
  86259. factor2?: number | undefined);
  86260. /**
  86261. * Will get a number picked randomly between factor1 and factor2.
  86262. * If factor2 is undefined then factor1 will be used
  86263. * @returns the picked number
  86264. */
  86265. getFactor(): number;
  86266. }
  86267. /**
  86268. * Helper used to simplify some generic gradient tasks
  86269. */
  86270. export class GradientHelper {
  86271. /**
  86272. * Gets the current gradient from an array of IValueGradient
  86273. * @param ratio defines the current ratio to get
  86274. * @param gradients defines the array of IValueGradient
  86275. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86276. */
  86277. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86278. }
  86279. }
  86280. declare module BABYLON {
  86281. /**
  86282. * Interface for the size containing width and height
  86283. */
  86284. export interface ISize {
  86285. /**
  86286. * Width
  86287. */
  86288. width: number;
  86289. /**
  86290. * Heighht
  86291. */
  86292. height: number;
  86293. }
  86294. /**
  86295. * Size containing widht and height
  86296. */
  86297. export class Size implements ISize {
  86298. /**
  86299. * Width
  86300. */
  86301. width: number;
  86302. /**
  86303. * Height
  86304. */
  86305. height: number;
  86306. /**
  86307. * Creates a Size object from the given width and height (floats).
  86308. * @param width width of the new size
  86309. * @param height height of the new size
  86310. */
  86311. constructor(width: number, height: number);
  86312. /**
  86313. * Returns a string with the Size width and height
  86314. * @returns a string with the Size width and height
  86315. */
  86316. toString(): string;
  86317. /**
  86318. * "Size"
  86319. * @returns the string "Size"
  86320. */
  86321. getClassName(): string;
  86322. /**
  86323. * Returns the Size hash code.
  86324. * @returns a hash code for a unique width and height
  86325. */
  86326. getHashCode(): number;
  86327. /**
  86328. * Updates the current size from the given one.
  86329. * @param src the given size
  86330. */
  86331. copyFrom(src: Size): void;
  86332. /**
  86333. * Updates in place the current Size from the given floats.
  86334. * @param width width of the new size
  86335. * @param height height of the new size
  86336. * @returns the updated Size.
  86337. */
  86338. copyFromFloats(width: number, height: number): Size;
  86339. /**
  86340. * Updates in place the current Size from the given floats.
  86341. * @param width width to set
  86342. * @param height height to set
  86343. * @returns the updated Size.
  86344. */
  86345. set(width: number, height: number): Size;
  86346. /**
  86347. * Multiplies the width and height by numbers
  86348. * @param w factor to multiple the width by
  86349. * @param h factor to multiple the height by
  86350. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86351. */
  86352. multiplyByFloats(w: number, h: number): Size;
  86353. /**
  86354. * Clones the size
  86355. * @returns a new Size copied from the given one.
  86356. */
  86357. clone(): Size;
  86358. /**
  86359. * True if the current Size and the given one width and height are strictly equal.
  86360. * @param other the other size to compare against
  86361. * @returns True if the current Size and the given one width and height are strictly equal.
  86362. */
  86363. equals(other: Size): boolean;
  86364. /**
  86365. * The surface of the Size : width * height (float).
  86366. */
  86367. get surface(): number;
  86368. /**
  86369. * Create a new size of zero
  86370. * @returns a new Size set to (0.0, 0.0)
  86371. */
  86372. static Zero(): Size;
  86373. /**
  86374. * Sums the width and height of two sizes
  86375. * @param otherSize size to add to this size
  86376. * @returns a new Size set as the addition result of the current Size and the given one.
  86377. */
  86378. add(otherSize: Size): Size;
  86379. /**
  86380. * Subtracts the width and height of two
  86381. * @param otherSize size to subtract to this size
  86382. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86383. */
  86384. subtract(otherSize: Size): Size;
  86385. /**
  86386. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86387. * @param start starting size to lerp between
  86388. * @param end end size to lerp between
  86389. * @param amount amount to lerp between the start and end values
  86390. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86391. */
  86392. static Lerp(start: Size, end: Size, amount: number): Size;
  86393. }
  86394. }
  86395. declare module BABYLON {
  86396. interface ThinEngine {
  86397. /**
  86398. * Creates a dynamic texture
  86399. * @param width defines the width of the texture
  86400. * @param height defines the height of the texture
  86401. * @param generateMipMaps defines if the engine should generate the mip levels
  86402. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86403. * @returns the dynamic texture inside an InternalTexture
  86404. */
  86405. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86406. /**
  86407. * Update the content of a dynamic texture
  86408. * @param texture defines the texture to update
  86409. * @param canvas defines the canvas containing the source
  86410. * @param invertY defines if data must be stored with Y axis inverted
  86411. * @param premulAlpha defines if alpha is stored as premultiplied
  86412. * @param format defines the format of the data
  86413. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86414. */
  86415. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86416. }
  86417. }
  86418. declare module BABYLON {
  86419. /**
  86420. * Helper class used to generate a canvas to manipulate images
  86421. */
  86422. export class CanvasGenerator {
  86423. /**
  86424. * Create a new canvas (or offscreen canvas depending on the context)
  86425. * @param width defines the expected width
  86426. * @param height defines the expected height
  86427. * @return a new canvas or offscreen canvas
  86428. */
  86429. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86430. }
  86431. }
  86432. declare module BABYLON {
  86433. /**
  86434. * A class extending Texture allowing drawing on a texture
  86435. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86436. */
  86437. export class DynamicTexture extends Texture {
  86438. private _generateMipMaps;
  86439. private _canvas;
  86440. private _context;
  86441. /**
  86442. * Creates a DynamicTexture
  86443. * @param name defines the name of the texture
  86444. * @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
  86445. * @param scene defines the scene where you want the texture
  86446. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86447. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86448. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86449. */
  86450. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86451. /**
  86452. * Get the current class name of the texture useful for serialization or dynamic coding.
  86453. * @returns "DynamicTexture"
  86454. */
  86455. getClassName(): string;
  86456. /**
  86457. * Gets the current state of canRescale
  86458. */
  86459. get canRescale(): boolean;
  86460. private _recreate;
  86461. /**
  86462. * Scales the texture
  86463. * @param ratio the scale factor to apply to both width and height
  86464. */
  86465. scale(ratio: number): void;
  86466. /**
  86467. * Resizes the texture
  86468. * @param width the new width
  86469. * @param height the new height
  86470. */
  86471. scaleTo(width: number, height: number): void;
  86472. /**
  86473. * Gets the context of the canvas used by the texture
  86474. * @returns the canvas context of the dynamic texture
  86475. */
  86476. getContext(): CanvasRenderingContext2D;
  86477. /**
  86478. * Clears the texture
  86479. */
  86480. clear(): void;
  86481. /**
  86482. * Updates the texture
  86483. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86484. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86485. */
  86486. update(invertY?: boolean, premulAlpha?: boolean): void;
  86487. /**
  86488. * Draws text onto the texture
  86489. * @param text defines the text to be drawn
  86490. * @param x defines the placement of the text from the left
  86491. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86492. * @param font defines the font to be used with font-style, font-size, font-name
  86493. * @param color defines the color used for the text
  86494. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86495. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86496. * @param update defines whether texture is immediately update (default is true)
  86497. */
  86498. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86499. /**
  86500. * Clones the texture
  86501. * @returns the clone of the texture.
  86502. */
  86503. clone(): DynamicTexture;
  86504. /**
  86505. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86506. * @returns a serialized dynamic texture object
  86507. */
  86508. serialize(): any;
  86509. /** @hidden */
  86510. _rebuild(): void;
  86511. }
  86512. }
  86513. declare module BABYLON {
  86514. interface ThinEngine {
  86515. /**
  86516. * Creates a raw texture
  86517. * @param data defines the data to store in the texture
  86518. * @param width defines the width of the texture
  86519. * @param height defines the height of the texture
  86520. * @param format defines the format of the data
  86521. * @param generateMipMaps defines if the engine should generate the mip levels
  86522. * @param invertY defines if data must be stored with Y axis inverted
  86523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86524. * @param compression defines the compression used (null by default)
  86525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86526. * @returns the raw texture inside an InternalTexture
  86527. */
  86528. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86529. /**
  86530. * Update a raw texture
  86531. * @param texture defines the texture to update
  86532. * @param data defines the data to store in the texture
  86533. * @param format defines the format of the data
  86534. * @param invertY defines if data must be stored with Y axis inverted
  86535. */
  86536. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86537. /**
  86538. * Update a raw texture
  86539. * @param texture defines the texture to update
  86540. * @param data defines the data to store in the texture
  86541. * @param format defines the format of the data
  86542. * @param invertY defines if data must be stored with Y axis inverted
  86543. * @param compression defines the compression used (null by default)
  86544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86545. */
  86546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86547. /**
  86548. * Creates a new raw cube texture
  86549. * @param data defines the array of data to use to create each face
  86550. * @param size defines the size of the textures
  86551. * @param format defines the format of the data
  86552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86553. * @param generateMipMaps defines if the engine should generate the mip levels
  86554. * @param invertY defines if data must be stored with Y axis inverted
  86555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86556. * @param compression defines the compression used (null by default)
  86557. * @returns the cube texture as an InternalTexture
  86558. */
  86559. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86560. /**
  86561. * Update a raw cube texture
  86562. * @param texture defines the texture to udpdate
  86563. * @param data defines the data to store
  86564. * @param format defines the data format
  86565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86566. * @param invertY defines if data must be stored with Y axis inverted
  86567. */
  86568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86569. /**
  86570. * Update a raw cube texture
  86571. * @param texture defines the texture to udpdate
  86572. * @param data defines the data to store
  86573. * @param format defines the data format
  86574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86575. * @param invertY defines if data must be stored with Y axis inverted
  86576. * @param compression defines the compression used (null by default)
  86577. */
  86578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86579. /**
  86580. * Update a raw cube texture
  86581. * @param texture defines the texture to udpdate
  86582. * @param data defines the data to store
  86583. * @param format defines the data format
  86584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86585. * @param invertY defines if data must be stored with Y axis inverted
  86586. * @param compression defines the compression used (null by default)
  86587. * @param level defines which level of the texture to update
  86588. */
  86589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86590. /**
  86591. * Creates a new raw cube texture from a specified url
  86592. * @param url defines the url where the data is located
  86593. * @param scene defines the current scene
  86594. * @param size defines the size of the textures
  86595. * @param format defines the format of the data
  86596. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86597. * @param noMipmap defines if the engine should avoid generating the mip levels
  86598. * @param callback defines a callback used to extract texture data from loaded data
  86599. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86600. * @param onLoad defines a callback called when texture is loaded
  86601. * @param onError defines a callback called if there is an error
  86602. * @returns the cube texture as an InternalTexture
  86603. */
  86604. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  86605. /**
  86606. * Creates a new raw cube texture from a specified url
  86607. * @param url defines the url where the data is located
  86608. * @param scene defines the current scene
  86609. * @param size defines the size of the textures
  86610. * @param format defines the format of the data
  86611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86612. * @param noMipmap defines if the engine should avoid generating the mip levels
  86613. * @param callback defines a callback used to extract texture data from loaded data
  86614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86615. * @param onLoad defines a callback called when texture is loaded
  86616. * @param onError defines a callback called if there is an error
  86617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86618. * @param invertY defines if data must be stored with Y axis inverted
  86619. * @returns the cube texture as an InternalTexture
  86620. */
  86621. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  86622. /**
  86623. * Creates a new raw 3D texture
  86624. * @param data defines the data used to create the texture
  86625. * @param width defines the width of the texture
  86626. * @param height defines the height of the texture
  86627. * @param depth defines the depth of the texture
  86628. * @param format defines the format of the texture
  86629. * @param generateMipMaps defines if the engine must generate mip levels
  86630. * @param invertY defines if data must be stored with Y axis inverted
  86631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86632. * @param compression defines the compressed used (can be null)
  86633. * @param textureType defines the compressed used (can be null)
  86634. * @returns a new raw 3D texture (stored in an InternalTexture)
  86635. */
  86636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86637. /**
  86638. * Update a raw 3D texture
  86639. * @param texture defines the texture to update
  86640. * @param data defines the data to store
  86641. * @param format defines the data format
  86642. * @param invertY defines if data must be stored with Y axis inverted
  86643. */
  86644. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86645. /**
  86646. * Update a raw 3D texture
  86647. * @param texture defines the texture to update
  86648. * @param data defines the data to store
  86649. * @param format defines the data format
  86650. * @param invertY defines if data must be stored with Y axis inverted
  86651. * @param compression defines the used compression (can be null)
  86652. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86653. */
  86654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86655. /**
  86656. * Creates a new raw 2D array texture
  86657. * @param data defines the data used to create the texture
  86658. * @param width defines the width of the texture
  86659. * @param height defines the height of the texture
  86660. * @param depth defines the number of layers of the texture
  86661. * @param format defines the format of the texture
  86662. * @param generateMipMaps defines if the engine must generate mip levels
  86663. * @param invertY defines if data must be stored with Y axis inverted
  86664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86665. * @param compression defines the compressed used (can be null)
  86666. * @param textureType defines the compressed used (can be null)
  86667. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86668. */
  86669. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86670. /**
  86671. * Update a raw 2D array texture
  86672. * @param texture defines the texture to update
  86673. * @param data defines the data to store
  86674. * @param format defines the data format
  86675. * @param invertY defines if data must be stored with Y axis inverted
  86676. */
  86677. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86678. /**
  86679. * Update a raw 2D array texture
  86680. * @param texture defines the texture to update
  86681. * @param data defines the data to store
  86682. * @param format defines the data format
  86683. * @param invertY defines if data must be stored with Y axis inverted
  86684. * @param compression defines the used compression (can be null)
  86685. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86686. */
  86687. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86688. }
  86689. }
  86690. declare module BABYLON {
  86691. /**
  86692. * Raw texture can help creating a texture directly from an array of data.
  86693. * This can be super useful if you either get the data from an uncompressed source or
  86694. * if you wish to create your texture pixel by pixel.
  86695. */
  86696. export class RawTexture extends Texture {
  86697. /**
  86698. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86699. */
  86700. format: number;
  86701. /**
  86702. * Instantiates a new RawTexture.
  86703. * Raw texture can help creating a texture directly from an array of data.
  86704. * This can be super useful if you either get the data from an uncompressed source or
  86705. * if you wish to create your texture pixel by pixel.
  86706. * @param data define the array of data to use to create the texture
  86707. * @param width define the width of the texture
  86708. * @param height define the height of the texture
  86709. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86710. * @param scene define the scene the texture belongs to
  86711. * @param generateMipMaps define whether mip maps should be generated or not
  86712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86714. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86715. */
  86716. constructor(data: ArrayBufferView, width: number, height: number,
  86717. /**
  86718. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86719. */
  86720. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86721. /**
  86722. * Updates the texture underlying data.
  86723. * @param data Define the new data of the texture
  86724. */
  86725. update(data: ArrayBufferView): void;
  86726. /**
  86727. * Creates a luminance texture from some data.
  86728. * @param data Define the texture data
  86729. * @param width Define the width of the texture
  86730. * @param height Define the height of the texture
  86731. * @param scene Define the scene the texture belongs to
  86732. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86735. * @returns the luminance texture
  86736. */
  86737. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86738. /**
  86739. * Creates a luminance alpha texture from some data.
  86740. * @param data Define the texture data
  86741. * @param width Define the width of the texture
  86742. * @param height Define the height of the texture
  86743. * @param scene Define the scene the texture belongs to
  86744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86747. * @returns the luminance alpha texture
  86748. */
  86749. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86750. /**
  86751. * Creates an alpha texture from some data.
  86752. * @param data Define the texture data
  86753. * @param width Define the width of the texture
  86754. * @param height Define the height of the texture
  86755. * @param scene Define the scene the texture belongs to
  86756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86759. * @returns the alpha texture
  86760. */
  86761. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86762. /**
  86763. * Creates a RGB texture from some data.
  86764. * @param data Define the texture data
  86765. * @param width Define the width of the texture
  86766. * @param height Define the height of the texture
  86767. * @param scene Define the scene the texture belongs to
  86768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86771. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86772. * @returns the RGB alpha texture
  86773. */
  86774. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86775. /**
  86776. * Creates a RGBA texture from some data.
  86777. * @param data Define the texture data
  86778. * @param width Define the width of the texture
  86779. * @param height Define the height of the texture
  86780. * @param scene Define the scene the texture belongs to
  86781. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86784. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86785. * @returns the RGBA texture
  86786. */
  86787. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86788. /**
  86789. * Creates a R texture from some data.
  86790. * @param data Define the texture data
  86791. * @param width Define the width of the texture
  86792. * @param height Define the height of the texture
  86793. * @param scene Define the scene the texture belongs to
  86794. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86798. * @returns the R texture
  86799. */
  86800. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. interface AbstractScene {
  86805. /**
  86806. * The list of procedural textures added to the scene
  86807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86808. */
  86809. proceduralTextures: Array<ProceduralTexture>;
  86810. }
  86811. /**
  86812. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86813. * in a given scene.
  86814. */
  86815. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86816. /**
  86817. * The component name helpfull to identify the component in the list of scene components.
  86818. */
  86819. readonly name: string;
  86820. /**
  86821. * The scene the component belongs to.
  86822. */
  86823. scene: Scene;
  86824. /**
  86825. * Creates a new instance of the component for the given scene
  86826. * @param scene Defines the scene to register the component in
  86827. */
  86828. constructor(scene: Scene);
  86829. /**
  86830. * Registers the component in a given scene
  86831. */
  86832. register(): void;
  86833. /**
  86834. * Rebuilds the elements related to this component in case of
  86835. * context lost for instance.
  86836. */
  86837. rebuild(): void;
  86838. /**
  86839. * Disposes the component and the associated ressources.
  86840. */
  86841. dispose(): void;
  86842. private _beforeClear;
  86843. }
  86844. }
  86845. declare module BABYLON {
  86846. interface ThinEngine {
  86847. /**
  86848. * Creates a new render target cube texture
  86849. * @param size defines the size of the texture
  86850. * @param options defines the options used to create the texture
  86851. * @returns a new render target cube texture stored in an InternalTexture
  86852. */
  86853. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86854. }
  86855. }
  86856. declare module BABYLON {
  86857. /** @hidden */
  86858. export var proceduralVertexShader: {
  86859. name: string;
  86860. shader: string;
  86861. };
  86862. }
  86863. declare module BABYLON {
  86864. /**
  86865. * 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.
  86866. * This is the base class of any Procedural texture and contains most of the shareable code.
  86867. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86868. */
  86869. export class ProceduralTexture extends Texture {
  86870. isCube: boolean;
  86871. /**
  86872. * Define if the texture is enabled or not (disabled texture will not render)
  86873. */
  86874. isEnabled: boolean;
  86875. /**
  86876. * Define if the texture must be cleared before rendering (default is true)
  86877. */
  86878. autoClear: boolean;
  86879. /**
  86880. * Callback called when the texture is generated
  86881. */
  86882. onGenerated: () => void;
  86883. /**
  86884. * Event raised when the texture is generated
  86885. */
  86886. onGeneratedObservable: Observable<ProceduralTexture>;
  86887. /** @hidden */
  86888. _generateMipMaps: boolean;
  86889. /** @hidden **/
  86890. _effect: Effect;
  86891. /** @hidden */
  86892. _textures: {
  86893. [key: string]: Texture;
  86894. };
  86895. /** @hidden */
  86896. protected _fallbackTexture: Nullable<Texture>;
  86897. private _size;
  86898. private _currentRefreshId;
  86899. private _frameId;
  86900. private _refreshRate;
  86901. private _vertexBuffers;
  86902. private _indexBuffer;
  86903. private _uniforms;
  86904. private _samplers;
  86905. private _fragment;
  86906. private _floats;
  86907. private _ints;
  86908. private _floatsArrays;
  86909. private _colors3;
  86910. private _colors4;
  86911. private _vectors2;
  86912. private _vectors3;
  86913. private _matrices;
  86914. private _fallbackTextureUsed;
  86915. private _fullEngine;
  86916. private _cachedDefines;
  86917. private _contentUpdateId;
  86918. private _contentData;
  86919. /**
  86920. * Instantiates a new procedural texture.
  86921. * 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.
  86922. * This is the base class of any Procedural texture and contains most of the shareable code.
  86923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86924. * @param name Define the name of the texture
  86925. * @param size Define the size of the texture to create
  86926. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86927. * @param scene Define the scene the texture belongs to
  86928. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86929. * @param generateMipMaps Define if the texture should creates mip maps or not
  86930. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86931. */
  86932. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86933. /**
  86934. * The effect that is created when initializing the post process.
  86935. * @returns The created effect corresponding the the postprocess.
  86936. */
  86937. getEffect(): Effect;
  86938. /**
  86939. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86940. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86941. */
  86942. getContent(): Nullable<ArrayBufferView>;
  86943. private _createIndexBuffer;
  86944. /** @hidden */
  86945. _rebuild(): void;
  86946. /**
  86947. * Resets the texture in order to recreate its associated resources.
  86948. * This can be called in case of context loss
  86949. */
  86950. reset(): void;
  86951. protected _getDefines(): string;
  86952. /**
  86953. * Is the texture ready to be used ? (rendered at least once)
  86954. * @returns true if ready, otherwise, false.
  86955. */
  86956. isReady(): boolean;
  86957. /**
  86958. * Resets the refresh counter of the texture and start bak from scratch.
  86959. * Could be useful to regenerate the texture if it is setup to render only once.
  86960. */
  86961. resetRefreshCounter(): void;
  86962. /**
  86963. * Set the fragment shader to use in order to render the texture.
  86964. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86965. */
  86966. setFragment(fragment: any): void;
  86967. /**
  86968. * Define the refresh rate of the texture or the rendering frequency.
  86969. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86970. */
  86971. get refreshRate(): number;
  86972. set refreshRate(value: number);
  86973. /** @hidden */
  86974. _shouldRender(): boolean;
  86975. /**
  86976. * Get the size the texture is rendering at.
  86977. * @returns the size (texture is always squared)
  86978. */
  86979. getRenderSize(): number;
  86980. /**
  86981. * Resize the texture to new value.
  86982. * @param size Define the new size the texture should have
  86983. * @param generateMipMaps Define whether the new texture should create mip maps
  86984. */
  86985. resize(size: number, generateMipMaps: boolean): void;
  86986. private _checkUniform;
  86987. /**
  86988. * Set a texture in the shader program used to render.
  86989. * @param name Define the name of the uniform samplers as defined in the shader
  86990. * @param texture Define the texture to bind to this sampler
  86991. * @return the texture itself allowing "fluent" like uniform updates
  86992. */
  86993. setTexture(name: string, texture: Texture): ProceduralTexture;
  86994. /**
  86995. * Set a float in the shader.
  86996. * @param name Define the name of the uniform as defined in the shader
  86997. * @param value Define the value to give to the uniform
  86998. * @return the texture itself allowing "fluent" like uniform updates
  86999. */
  87000. setFloat(name: string, value: number): ProceduralTexture;
  87001. /**
  87002. * Set a int in the shader.
  87003. * @param name Define the name of the uniform as defined in the shader
  87004. * @param value Define the value to give to the uniform
  87005. * @return the texture itself allowing "fluent" like uniform updates
  87006. */
  87007. setInt(name: string, value: number): ProceduralTexture;
  87008. /**
  87009. * Set an array of floats in the shader.
  87010. * @param name Define the name of the uniform as defined in the shader
  87011. * @param value Define the value to give to the uniform
  87012. * @return the texture itself allowing "fluent" like uniform updates
  87013. */
  87014. setFloats(name: string, value: number[]): ProceduralTexture;
  87015. /**
  87016. * Set a vec3 in the shader from a Color3.
  87017. * @param name Define the name of the uniform as defined in the shader
  87018. * @param value Define the value to give to the uniform
  87019. * @return the texture itself allowing "fluent" like uniform updates
  87020. */
  87021. setColor3(name: string, value: Color3): ProceduralTexture;
  87022. /**
  87023. * Set a vec4 in the shader from a Color4.
  87024. * @param name Define the name of the uniform as defined in the shader
  87025. * @param value Define the value to give to the uniform
  87026. * @return the texture itself allowing "fluent" like uniform updates
  87027. */
  87028. setColor4(name: string, value: Color4): ProceduralTexture;
  87029. /**
  87030. * Set a vec2 in the shader from a Vector2.
  87031. * @param name Define the name of the uniform as defined in the shader
  87032. * @param value Define the value to give to the uniform
  87033. * @return the texture itself allowing "fluent" like uniform updates
  87034. */
  87035. setVector2(name: string, value: Vector2): ProceduralTexture;
  87036. /**
  87037. * Set a vec3 in the shader from a Vector3.
  87038. * @param name Define the name of the uniform as defined in the shader
  87039. * @param value Define the value to give to the uniform
  87040. * @return the texture itself allowing "fluent" like uniform updates
  87041. */
  87042. setVector3(name: string, value: Vector3): ProceduralTexture;
  87043. /**
  87044. * Set a mat4 in the shader from a MAtrix.
  87045. * @param name Define the name of the uniform as defined in the shader
  87046. * @param value Define the value to give to the uniform
  87047. * @return the texture itself allowing "fluent" like uniform updates
  87048. */
  87049. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87050. /**
  87051. * Render the texture to its associated render target.
  87052. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87053. */
  87054. render(useCameraPostProcess?: boolean): void;
  87055. /**
  87056. * Clone the texture.
  87057. * @returns the cloned texture
  87058. */
  87059. clone(): ProceduralTexture;
  87060. /**
  87061. * Dispose the texture and release its asoociated resources.
  87062. */
  87063. dispose(): void;
  87064. }
  87065. }
  87066. declare module BABYLON {
  87067. /**
  87068. * This represents the base class for particle system in Babylon.
  87069. * 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.
  87070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87071. * @example https://doc.babylonjs.com/babylon101/particles
  87072. */
  87073. export class BaseParticleSystem {
  87074. /**
  87075. * Source color is added to the destination color without alpha affecting the result
  87076. */
  87077. static BLENDMODE_ONEONE: number;
  87078. /**
  87079. * Blend current color and particle color using particle’s alpha
  87080. */
  87081. static BLENDMODE_STANDARD: number;
  87082. /**
  87083. * Add current color and particle color multiplied by particle’s alpha
  87084. */
  87085. static BLENDMODE_ADD: number;
  87086. /**
  87087. * Multiply current color with particle color
  87088. */
  87089. static BLENDMODE_MULTIPLY: number;
  87090. /**
  87091. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87092. */
  87093. static BLENDMODE_MULTIPLYADD: number;
  87094. /**
  87095. * List of animations used by the particle system.
  87096. */
  87097. animations: Animation[];
  87098. /**
  87099. * Gets or sets the unique id of the particle system
  87100. */
  87101. uniqueId: number;
  87102. /**
  87103. * The id of the Particle system.
  87104. */
  87105. id: string;
  87106. /**
  87107. * The friendly name of the Particle system.
  87108. */
  87109. name: string;
  87110. /**
  87111. * Snippet ID if the particle system was created from the snippet server
  87112. */
  87113. snippetId: string;
  87114. /**
  87115. * The rendering group used by the Particle system to chose when to render.
  87116. */
  87117. renderingGroupId: number;
  87118. /**
  87119. * The emitter represents the Mesh or position we are attaching the particle system to.
  87120. */
  87121. emitter: Nullable<AbstractMesh | Vector3>;
  87122. /**
  87123. * The maximum number of particles to emit per frame
  87124. */
  87125. emitRate: number;
  87126. /**
  87127. * If you want to launch only a few particles at once, that can be done, as well.
  87128. */
  87129. manualEmitCount: number;
  87130. /**
  87131. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87132. */
  87133. updateSpeed: number;
  87134. /**
  87135. * The amount of time the particle system is running (depends of the overall update speed).
  87136. */
  87137. targetStopDuration: number;
  87138. /**
  87139. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87140. */
  87141. disposeOnStop: boolean;
  87142. /**
  87143. * Minimum power of emitting particles.
  87144. */
  87145. minEmitPower: number;
  87146. /**
  87147. * Maximum power of emitting particles.
  87148. */
  87149. maxEmitPower: number;
  87150. /**
  87151. * Minimum life time of emitting particles.
  87152. */
  87153. minLifeTime: number;
  87154. /**
  87155. * Maximum life time of emitting particles.
  87156. */
  87157. maxLifeTime: number;
  87158. /**
  87159. * Minimum Size of emitting particles.
  87160. */
  87161. minSize: number;
  87162. /**
  87163. * Maximum Size of emitting particles.
  87164. */
  87165. maxSize: number;
  87166. /**
  87167. * Minimum scale of emitting particles on X axis.
  87168. */
  87169. minScaleX: number;
  87170. /**
  87171. * Maximum scale of emitting particles on X axis.
  87172. */
  87173. maxScaleX: number;
  87174. /**
  87175. * Minimum scale of emitting particles on Y axis.
  87176. */
  87177. minScaleY: number;
  87178. /**
  87179. * Maximum scale of emitting particles on Y axis.
  87180. */
  87181. maxScaleY: number;
  87182. /**
  87183. * Gets or sets the minimal initial rotation in radians.
  87184. */
  87185. minInitialRotation: number;
  87186. /**
  87187. * Gets or sets the maximal initial rotation in radians.
  87188. */
  87189. maxInitialRotation: number;
  87190. /**
  87191. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87192. */
  87193. minAngularSpeed: number;
  87194. /**
  87195. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87196. */
  87197. maxAngularSpeed: number;
  87198. /**
  87199. * The texture used to render each particle. (this can be a spritesheet)
  87200. */
  87201. particleTexture: Nullable<Texture>;
  87202. /**
  87203. * The layer mask we are rendering the particles through.
  87204. */
  87205. layerMask: number;
  87206. /**
  87207. * This can help using your own shader to render the particle system.
  87208. * The according effect will be created
  87209. */
  87210. customShader: any;
  87211. /**
  87212. * By default particle system starts as soon as they are created. This prevents the
  87213. * automatic start to happen and let you decide when to start emitting particles.
  87214. */
  87215. preventAutoStart: boolean;
  87216. private _noiseTexture;
  87217. /**
  87218. * Gets or sets a texture used to add random noise to particle positions
  87219. */
  87220. get noiseTexture(): Nullable<ProceduralTexture>;
  87221. set noiseTexture(value: Nullable<ProceduralTexture>);
  87222. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87223. noiseStrength: Vector3;
  87224. /**
  87225. * Callback triggered when the particle animation is ending.
  87226. */
  87227. onAnimationEnd: Nullable<() => void>;
  87228. /**
  87229. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87230. */
  87231. blendMode: number;
  87232. /**
  87233. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87234. * to override the particles.
  87235. */
  87236. forceDepthWrite: boolean;
  87237. /** 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 */
  87238. preWarmCycles: number;
  87239. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87240. preWarmStepOffset: number;
  87241. /**
  87242. * 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)
  87243. */
  87244. spriteCellChangeSpeed: number;
  87245. /**
  87246. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87247. */
  87248. startSpriteCellID: number;
  87249. /**
  87250. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87251. */
  87252. endSpriteCellID: number;
  87253. /**
  87254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87255. */
  87256. spriteCellWidth: number;
  87257. /**
  87258. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87259. */
  87260. spriteCellHeight: number;
  87261. /**
  87262. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87263. */
  87264. spriteRandomStartCell: boolean;
  87265. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87266. translationPivot: Vector2;
  87267. /** @hidden */
  87268. protected _isAnimationSheetEnabled: boolean;
  87269. /**
  87270. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87271. */
  87272. beginAnimationOnStart: boolean;
  87273. /**
  87274. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87275. */
  87276. beginAnimationFrom: number;
  87277. /**
  87278. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87279. */
  87280. beginAnimationTo: number;
  87281. /**
  87282. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87283. */
  87284. beginAnimationLoop: boolean;
  87285. /**
  87286. * Gets or sets a world offset applied to all particles
  87287. */
  87288. worldOffset: Vector3;
  87289. /**
  87290. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87291. */
  87292. get isAnimationSheetEnabled(): boolean;
  87293. set isAnimationSheetEnabled(value: boolean);
  87294. /**
  87295. * Get hosting scene
  87296. * @returns the scene
  87297. */
  87298. getScene(): Scene;
  87299. /**
  87300. * You can use gravity if you want to give an orientation to your particles.
  87301. */
  87302. gravity: Vector3;
  87303. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87304. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87305. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87306. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87307. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87308. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87309. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87310. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87311. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87312. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87313. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87314. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87315. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87316. /**
  87317. * Defines the delay in milliseconds before starting the system (0 by default)
  87318. */
  87319. startDelay: number;
  87320. /**
  87321. * Gets the current list of drag gradients.
  87322. * You must use addDragGradient and removeDragGradient to udpate this list
  87323. * @returns the list of drag gradients
  87324. */
  87325. getDragGradients(): Nullable<Array<FactorGradient>>;
  87326. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87327. limitVelocityDamping: number;
  87328. /**
  87329. * Gets the current list of limit velocity gradients.
  87330. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87331. * @returns the list of limit velocity gradients
  87332. */
  87333. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87334. /**
  87335. * Gets the current list of color gradients.
  87336. * You must use addColorGradient and removeColorGradient to udpate this list
  87337. * @returns the list of color gradients
  87338. */
  87339. getColorGradients(): Nullable<Array<ColorGradient>>;
  87340. /**
  87341. * Gets the current list of size gradients.
  87342. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87343. * @returns the list of size gradients
  87344. */
  87345. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87346. /**
  87347. * Gets the current list of color remap gradients.
  87348. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87349. * @returns the list of color remap gradients
  87350. */
  87351. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87352. /**
  87353. * Gets the current list of alpha remap gradients.
  87354. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87355. * @returns the list of alpha remap gradients
  87356. */
  87357. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87358. /**
  87359. * Gets the current list of life time gradients.
  87360. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87361. * @returns the list of life time gradients
  87362. */
  87363. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87364. /**
  87365. * Gets the current list of angular speed gradients.
  87366. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87367. * @returns the list of angular speed gradients
  87368. */
  87369. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87370. /**
  87371. * Gets the current list of velocity gradients.
  87372. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87373. * @returns the list of velocity gradients
  87374. */
  87375. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87376. /**
  87377. * Gets the current list of start size gradients.
  87378. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87379. * @returns the list of start size gradients
  87380. */
  87381. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87382. /**
  87383. * Gets the current list of emit rate gradients.
  87384. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87385. * @returns the list of emit rate gradients
  87386. */
  87387. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87388. /**
  87389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87391. */
  87392. get direction1(): Vector3;
  87393. set direction1(value: Vector3);
  87394. /**
  87395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87396. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87397. */
  87398. get direction2(): Vector3;
  87399. set direction2(value: Vector3);
  87400. /**
  87401. * 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.
  87402. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87403. */
  87404. get minEmitBox(): Vector3;
  87405. set minEmitBox(value: Vector3);
  87406. /**
  87407. * 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.
  87408. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87409. */
  87410. get maxEmitBox(): Vector3;
  87411. set maxEmitBox(value: Vector3);
  87412. /**
  87413. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87414. */
  87415. color1: Color4;
  87416. /**
  87417. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87418. */
  87419. color2: Color4;
  87420. /**
  87421. * Color the particle will have at the end of its lifetime
  87422. */
  87423. colorDead: Color4;
  87424. /**
  87425. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87426. */
  87427. textureMask: Color4;
  87428. /**
  87429. * The particle emitter type defines the emitter used by the particle system.
  87430. * It can be for example box, sphere, or cone...
  87431. */
  87432. particleEmitterType: IParticleEmitterType;
  87433. /** @hidden */
  87434. _isSubEmitter: boolean;
  87435. /**
  87436. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87437. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87438. */
  87439. billboardMode: number;
  87440. protected _isBillboardBased: boolean;
  87441. /**
  87442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87443. */
  87444. get isBillboardBased(): boolean;
  87445. set isBillboardBased(value: boolean);
  87446. /**
  87447. * The scene the particle system belongs to.
  87448. */
  87449. protected _scene: Scene;
  87450. /**
  87451. * Local cache of defines for image processing.
  87452. */
  87453. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87454. /**
  87455. * Default configuration related to image processing available in the standard Material.
  87456. */
  87457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87458. /**
  87459. * Gets the image processing configuration used either in this material.
  87460. */
  87461. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87462. /**
  87463. * Sets the Default image processing configuration used either in the this material.
  87464. *
  87465. * If sets to null, the scene one is in use.
  87466. */
  87467. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87468. /**
  87469. * Attaches a new image processing configuration to the Standard Material.
  87470. * @param configuration
  87471. */
  87472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87473. /** @hidden */
  87474. protected _reset(): void;
  87475. /** @hidden */
  87476. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87477. /**
  87478. * Instantiates a particle system.
  87479. * 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.
  87480. * @param name The name of the particle system
  87481. */
  87482. constructor(name: string);
  87483. /**
  87484. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87487. * @returns the emitter
  87488. */
  87489. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87490. /**
  87491. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87492. * @param radius The radius of the hemisphere to emit from
  87493. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87494. * @returns the emitter
  87495. */
  87496. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87497. /**
  87498. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87499. * @param radius The radius of the sphere to emit from
  87500. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87501. * @returns the emitter
  87502. */
  87503. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87504. /**
  87505. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87506. * @param radius The radius of the sphere to emit from
  87507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87509. * @returns the emitter
  87510. */
  87511. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87512. /**
  87513. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87514. * @param radius The radius of the emission cylinder
  87515. * @param height The height of the emission cylinder
  87516. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87517. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87518. * @returns the emitter
  87519. */
  87520. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87521. /**
  87522. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87523. * @param radius The radius of the cylinder to emit from
  87524. * @param height The height of the emission cylinder
  87525. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87528. * @returns the emitter
  87529. */
  87530. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87531. /**
  87532. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87533. * @param radius The radius of the cone to emit from
  87534. * @param angle The base angle of the cone
  87535. * @returns the emitter
  87536. */
  87537. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87538. /**
  87539. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87542. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87543. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87544. * @returns the emitter
  87545. */
  87546. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87547. }
  87548. }
  87549. declare module BABYLON {
  87550. /**
  87551. * Type of sub emitter
  87552. */
  87553. export enum SubEmitterType {
  87554. /**
  87555. * Attached to the particle over it's lifetime
  87556. */
  87557. ATTACHED = 0,
  87558. /**
  87559. * Created when the particle dies
  87560. */
  87561. END = 1
  87562. }
  87563. /**
  87564. * Sub emitter class used to emit particles from an existing particle
  87565. */
  87566. export class SubEmitter {
  87567. /**
  87568. * the particle system to be used by the sub emitter
  87569. */
  87570. particleSystem: ParticleSystem;
  87571. /**
  87572. * Type of the submitter (Default: END)
  87573. */
  87574. type: SubEmitterType;
  87575. /**
  87576. * 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)
  87577. * Note: This only is supported when using an emitter of type Mesh
  87578. */
  87579. inheritDirection: boolean;
  87580. /**
  87581. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87582. */
  87583. inheritedVelocityAmount: number;
  87584. /**
  87585. * Creates a sub emitter
  87586. * @param particleSystem the particle system to be used by the sub emitter
  87587. */
  87588. constructor(
  87589. /**
  87590. * the particle system to be used by the sub emitter
  87591. */
  87592. particleSystem: ParticleSystem);
  87593. /**
  87594. * Clones the sub emitter
  87595. * @returns the cloned sub emitter
  87596. */
  87597. clone(): SubEmitter;
  87598. /**
  87599. * Serialize current object to a JSON object
  87600. * @returns the serialized object
  87601. */
  87602. serialize(): any;
  87603. /** @hidden */
  87604. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87605. /**
  87606. * Creates a new SubEmitter from a serialized JSON version
  87607. * @param serializationObject defines the JSON object to read from
  87608. * @param scene defines the hosting scene
  87609. * @param rootUrl defines the rootUrl for data loading
  87610. * @returns a new SubEmitter
  87611. */
  87612. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87613. /** Release associated resources */
  87614. dispose(): void;
  87615. }
  87616. }
  87617. declare module BABYLON {
  87618. /** @hidden */
  87619. export var imageProcessingDeclaration: {
  87620. name: string;
  87621. shader: string;
  87622. };
  87623. }
  87624. declare module BABYLON {
  87625. /** @hidden */
  87626. export var imageProcessingFunctions: {
  87627. name: string;
  87628. shader: string;
  87629. };
  87630. }
  87631. declare module BABYLON {
  87632. /** @hidden */
  87633. export var particlesPixelShader: {
  87634. name: string;
  87635. shader: string;
  87636. };
  87637. }
  87638. declare module BABYLON {
  87639. /** @hidden */
  87640. export var particlesVertexShader: {
  87641. name: string;
  87642. shader: string;
  87643. };
  87644. }
  87645. declare module BABYLON {
  87646. /**
  87647. * This represents a particle system in Babylon.
  87648. * 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.
  87649. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87650. * @example https://doc.babylonjs.com/babylon101/particles
  87651. */
  87652. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87653. /**
  87654. * Billboard mode will only apply to Y axis
  87655. */
  87656. static readonly BILLBOARDMODE_Y: number;
  87657. /**
  87658. * Billboard mode will apply to all axes
  87659. */
  87660. static readonly BILLBOARDMODE_ALL: number;
  87661. /**
  87662. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87663. */
  87664. static readonly BILLBOARDMODE_STRETCHED: number;
  87665. /**
  87666. * This function can be defined to provide custom update for active particles.
  87667. * This function will be called instead of regular update (age, position, color, etc.).
  87668. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87669. */
  87670. updateFunction: (particles: Particle[]) => void;
  87671. private _emitterWorldMatrix;
  87672. /**
  87673. * This function can be defined to specify initial direction for every new particle.
  87674. * It by default use the emitterType defined function
  87675. */
  87676. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87677. /**
  87678. * This function can be defined to specify initial position for every new particle.
  87679. * It by default use the emitterType defined function
  87680. */
  87681. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87682. /**
  87683. * @hidden
  87684. */
  87685. _inheritedVelocityOffset: Vector3;
  87686. /**
  87687. * An event triggered when the system is disposed
  87688. */
  87689. onDisposeObservable: Observable<ParticleSystem>;
  87690. private _onDisposeObserver;
  87691. /**
  87692. * Sets a callback that will be triggered when the system is disposed
  87693. */
  87694. set onDispose(callback: () => void);
  87695. private _particles;
  87696. private _epsilon;
  87697. private _capacity;
  87698. private _stockParticles;
  87699. private _newPartsExcess;
  87700. private _vertexData;
  87701. private _vertexBuffer;
  87702. private _vertexBuffers;
  87703. private _spriteBuffer;
  87704. private _indexBuffer;
  87705. private _effect;
  87706. private _customEffect;
  87707. private _cachedDefines;
  87708. private _scaledColorStep;
  87709. private _colorDiff;
  87710. private _scaledDirection;
  87711. private _scaledGravity;
  87712. private _currentRenderId;
  87713. private _alive;
  87714. private _useInstancing;
  87715. private _started;
  87716. private _stopped;
  87717. private _actualFrame;
  87718. private _scaledUpdateSpeed;
  87719. private _vertexBufferSize;
  87720. /** @hidden */
  87721. _currentEmitRateGradient: Nullable<FactorGradient>;
  87722. /** @hidden */
  87723. _currentEmitRate1: number;
  87724. /** @hidden */
  87725. _currentEmitRate2: number;
  87726. /** @hidden */
  87727. _currentStartSizeGradient: Nullable<FactorGradient>;
  87728. /** @hidden */
  87729. _currentStartSize1: number;
  87730. /** @hidden */
  87731. _currentStartSize2: number;
  87732. private readonly _rawTextureWidth;
  87733. private _rampGradientsTexture;
  87734. private _useRampGradients;
  87735. /** Gets or sets a boolean indicating that ramp gradients must be used
  87736. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87737. */
  87738. get useRampGradients(): boolean;
  87739. set useRampGradients(value: boolean);
  87740. /**
  87741. * 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.
  87742. * 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: [])
  87743. */
  87744. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87745. private _subEmitters;
  87746. /**
  87747. * @hidden
  87748. * If the particle systems emitter should be disposed when the particle system is disposed
  87749. */
  87750. _disposeEmitterOnDispose: boolean;
  87751. /**
  87752. * The current active Sub-systems, this property is used by the root particle system only.
  87753. */
  87754. activeSubSystems: Array<ParticleSystem>;
  87755. /**
  87756. * Specifies if the particles are updated in emitter local space or world space
  87757. */
  87758. isLocal: boolean;
  87759. private _rootParticleSystem;
  87760. /**
  87761. * Gets the current list of active particles
  87762. */
  87763. get particles(): Particle[];
  87764. /**
  87765. * Gets the number of particles active at the same time.
  87766. * @returns The number of active particles.
  87767. */
  87768. getActiveCount(): number;
  87769. /**
  87770. * Returns the string "ParticleSystem"
  87771. * @returns a string containing the class name
  87772. */
  87773. getClassName(): string;
  87774. /**
  87775. * Gets a boolean indicating that the system is stopping
  87776. * @returns true if the system is currently stopping
  87777. */
  87778. isStopping(): boolean;
  87779. /**
  87780. * Instantiates a particle system.
  87781. * 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.
  87782. * @param name The name of the particle system
  87783. * @param capacity The max number of particles alive at the same time
  87784. * @param scene The scene the particle system belongs to
  87785. * @param customEffect a custom effect used to change the way particles are rendered by default
  87786. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87787. * @param epsilon Offset used to render the particles
  87788. */
  87789. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87790. private _addFactorGradient;
  87791. private _removeFactorGradient;
  87792. /**
  87793. * Adds a new life time gradient
  87794. * @param gradient defines the gradient to use (between 0 and 1)
  87795. * @param factor defines the life time factor to affect to the specified gradient
  87796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87797. * @returns the current particle system
  87798. */
  87799. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87800. /**
  87801. * Remove a specific life time gradient
  87802. * @param gradient defines the gradient to remove
  87803. * @returns the current particle system
  87804. */
  87805. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87806. /**
  87807. * Adds a new size gradient
  87808. * @param gradient defines the gradient to use (between 0 and 1)
  87809. * @param factor defines the size factor to affect to the specified gradient
  87810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87811. * @returns the current particle system
  87812. */
  87813. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87814. /**
  87815. * Remove a specific size gradient
  87816. * @param gradient defines the gradient to remove
  87817. * @returns the current particle system
  87818. */
  87819. removeSizeGradient(gradient: number): IParticleSystem;
  87820. /**
  87821. * Adds a new color remap gradient
  87822. * @param gradient defines the gradient to use (between 0 and 1)
  87823. * @param min defines the color remap minimal range
  87824. * @param max defines the color remap maximal range
  87825. * @returns the current particle system
  87826. */
  87827. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87828. /**
  87829. * Remove a specific color remap gradient
  87830. * @param gradient defines the gradient to remove
  87831. * @returns the current particle system
  87832. */
  87833. removeColorRemapGradient(gradient: number): IParticleSystem;
  87834. /**
  87835. * Adds a new alpha remap gradient
  87836. * @param gradient defines the gradient to use (between 0 and 1)
  87837. * @param min defines the alpha remap minimal range
  87838. * @param max defines the alpha remap maximal range
  87839. * @returns the current particle system
  87840. */
  87841. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87842. /**
  87843. * Remove a specific alpha remap gradient
  87844. * @param gradient defines the gradient to remove
  87845. * @returns the current particle system
  87846. */
  87847. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87848. /**
  87849. * Adds a new angular speed gradient
  87850. * @param gradient defines the gradient to use (between 0 and 1)
  87851. * @param factor defines the angular speed to affect to the specified gradient
  87852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87853. * @returns the current particle system
  87854. */
  87855. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87856. /**
  87857. * Remove a specific angular speed gradient
  87858. * @param gradient defines the gradient to remove
  87859. * @returns the current particle system
  87860. */
  87861. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87862. /**
  87863. * Adds a new velocity gradient
  87864. * @param gradient defines the gradient to use (between 0 and 1)
  87865. * @param factor defines the velocity to affect to the specified gradient
  87866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87867. * @returns the current particle system
  87868. */
  87869. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87870. /**
  87871. * Remove a specific velocity gradient
  87872. * @param gradient defines the gradient to remove
  87873. * @returns the current particle system
  87874. */
  87875. removeVelocityGradient(gradient: number): IParticleSystem;
  87876. /**
  87877. * Adds a new limit velocity gradient
  87878. * @param gradient defines the gradient to use (between 0 and 1)
  87879. * @param factor defines the limit velocity value to affect to the specified gradient
  87880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87881. * @returns the current particle system
  87882. */
  87883. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87884. /**
  87885. * Remove a specific limit velocity gradient
  87886. * @param gradient defines the gradient to remove
  87887. * @returns the current particle system
  87888. */
  87889. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87890. /**
  87891. * Adds a new drag gradient
  87892. * @param gradient defines the gradient to use (between 0 and 1)
  87893. * @param factor defines the drag value to affect to the specified gradient
  87894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87895. * @returns the current particle system
  87896. */
  87897. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87898. /**
  87899. * Remove a specific drag gradient
  87900. * @param gradient defines the gradient to remove
  87901. * @returns the current particle system
  87902. */
  87903. removeDragGradient(gradient: number): IParticleSystem;
  87904. /**
  87905. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87906. * @param gradient defines the gradient to use (between 0 and 1)
  87907. * @param factor defines the emit rate value to affect to the specified gradient
  87908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87909. * @returns the current particle system
  87910. */
  87911. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87912. /**
  87913. * Remove a specific emit rate gradient
  87914. * @param gradient defines the gradient to remove
  87915. * @returns the current particle system
  87916. */
  87917. removeEmitRateGradient(gradient: number): IParticleSystem;
  87918. /**
  87919. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87920. * @param gradient defines the gradient to use (between 0 and 1)
  87921. * @param factor defines the start size value to affect to the specified gradient
  87922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87923. * @returns the current particle system
  87924. */
  87925. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87926. /**
  87927. * Remove a specific start size gradient
  87928. * @param gradient defines the gradient to remove
  87929. * @returns the current particle system
  87930. */
  87931. removeStartSizeGradient(gradient: number): IParticleSystem;
  87932. private _createRampGradientTexture;
  87933. /**
  87934. * Gets the current list of ramp gradients.
  87935. * You must use addRampGradient and removeRampGradient to udpate this list
  87936. * @returns the list of ramp gradients
  87937. */
  87938. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87939. /** Force the system to rebuild all gradients that need to be resync */
  87940. forceRefreshGradients(): void;
  87941. private _syncRampGradientTexture;
  87942. /**
  87943. * Adds a new ramp gradient used to remap particle colors
  87944. * @param gradient defines the gradient to use (between 0 and 1)
  87945. * @param color defines the color to affect to the specified gradient
  87946. * @returns the current particle system
  87947. */
  87948. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87949. /**
  87950. * Remove a specific ramp gradient
  87951. * @param gradient defines the gradient to remove
  87952. * @returns the current particle system
  87953. */
  87954. removeRampGradient(gradient: number): ParticleSystem;
  87955. /**
  87956. * Adds a new color gradient
  87957. * @param gradient defines the gradient to use (between 0 and 1)
  87958. * @param color1 defines the color to affect to the specified gradient
  87959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87960. * @returns this particle system
  87961. */
  87962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87963. /**
  87964. * Remove a specific color gradient
  87965. * @param gradient defines the gradient to remove
  87966. * @returns this particle system
  87967. */
  87968. removeColorGradient(gradient: number): IParticleSystem;
  87969. private _fetchR;
  87970. protected _reset(): void;
  87971. private _resetEffect;
  87972. private _createVertexBuffers;
  87973. private _createIndexBuffer;
  87974. /**
  87975. * Gets the maximum number of particles active at the same time.
  87976. * @returns The max number of active particles.
  87977. */
  87978. getCapacity(): number;
  87979. /**
  87980. * Gets whether there are still active particles in the system.
  87981. * @returns True if it is alive, otherwise false.
  87982. */
  87983. isAlive(): boolean;
  87984. /**
  87985. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87986. * @returns True if it has been started, otherwise false.
  87987. */
  87988. isStarted(): boolean;
  87989. private _prepareSubEmitterInternalArray;
  87990. /**
  87991. * Starts the particle system and begins to emit
  87992. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87993. */
  87994. start(delay?: number): void;
  87995. /**
  87996. * Stops the particle system.
  87997. * @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.
  87998. */
  87999. stop(stopSubEmitters?: boolean): void;
  88000. /**
  88001. * Remove all active particles
  88002. */
  88003. reset(): void;
  88004. /**
  88005. * @hidden (for internal use only)
  88006. */
  88007. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88008. /**
  88009. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88010. * Its lifetime will start back at 0.
  88011. */
  88012. recycleParticle: (particle: Particle) => void;
  88013. private _stopSubEmitters;
  88014. private _createParticle;
  88015. private _removeFromRoot;
  88016. private _emitFromParticle;
  88017. private _update;
  88018. /** @hidden */
  88019. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88020. /** @hidden */
  88021. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88022. /** @hidden */
  88023. private _getEffect;
  88024. /**
  88025. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88026. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88027. */
  88028. animate(preWarmOnly?: boolean): void;
  88029. private _appendParticleVertices;
  88030. /**
  88031. * Rebuilds the particle system.
  88032. */
  88033. rebuild(): void;
  88034. /**
  88035. * Is this system ready to be used/rendered
  88036. * @return true if the system is ready
  88037. */
  88038. isReady(): boolean;
  88039. private _render;
  88040. /**
  88041. * Renders the particle system in its current state.
  88042. * @returns the current number of particles
  88043. */
  88044. render(): number;
  88045. /**
  88046. * Disposes the particle system and free the associated resources
  88047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88048. */
  88049. dispose(disposeTexture?: boolean): void;
  88050. /**
  88051. * Clones the particle system.
  88052. * @param name The name of the cloned object
  88053. * @param newEmitter The new emitter to use
  88054. * @returns the cloned particle system
  88055. */
  88056. clone(name: string, newEmitter: any): ParticleSystem;
  88057. /**
  88058. * Serializes the particle system to a JSON object
  88059. * @param serializeTexture defines if the texture must be serialized as well
  88060. * @returns the JSON object
  88061. */
  88062. serialize(serializeTexture?: boolean): any;
  88063. /** @hidden */
  88064. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  88065. /** @hidden */
  88066. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88067. /**
  88068. * Parses a JSON object to create a particle system.
  88069. * @param parsedParticleSystem The JSON object to parse
  88070. * @param scene The scene to create the particle system in
  88071. * @param rootUrl The root url to use to load external dependencies like texture
  88072. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88073. * @returns the Parsed particle system
  88074. */
  88075. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88076. }
  88077. }
  88078. declare module BABYLON {
  88079. /**
  88080. * A particle represents one of the element emitted by a particle system.
  88081. * This is mainly define by its coordinates, direction, velocity and age.
  88082. */
  88083. export class Particle {
  88084. /**
  88085. * The particle system the particle belongs to.
  88086. */
  88087. particleSystem: ParticleSystem;
  88088. private static _Count;
  88089. /**
  88090. * Unique ID of the particle
  88091. */
  88092. id: number;
  88093. /**
  88094. * The world position of the particle in the scene.
  88095. */
  88096. position: Vector3;
  88097. /**
  88098. * The world direction of the particle in the scene.
  88099. */
  88100. direction: Vector3;
  88101. /**
  88102. * The color of the particle.
  88103. */
  88104. color: Color4;
  88105. /**
  88106. * The color change of the particle per step.
  88107. */
  88108. colorStep: Color4;
  88109. /**
  88110. * Defines how long will the life of the particle be.
  88111. */
  88112. lifeTime: number;
  88113. /**
  88114. * The current age of the particle.
  88115. */
  88116. age: number;
  88117. /**
  88118. * The current size of the particle.
  88119. */
  88120. size: number;
  88121. /**
  88122. * The current scale of the particle.
  88123. */
  88124. scale: Vector2;
  88125. /**
  88126. * The current angle of the particle.
  88127. */
  88128. angle: number;
  88129. /**
  88130. * Defines how fast is the angle changing.
  88131. */
  88132. angularSpeed: number;
  88133. /**
  88134. * Defines the cell index used by the particle to be rendered from a sprite.
  88135. */
  88136. cellIndex: number;
  88137. /**
  88138. * The information required to support color remapping
  88139. */
  88140. remapData: Vector4;
  88141. /** @hidden */
  88142. _randomCellOffset?: number;
  88143. /** @hidden */
  88144. _initialDirection: Nullable<Vector3>;
  88145. /** @hidden */
  88146. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88147. /** @hidden */
  88148. _initialStartSpriteCellID: number;
  88149. /** @hidden */
  88150. _initialEndSpriteCellID: number;
  88151. /** @hidden */
  88152. _currentColorGradient: Nullable<ColorGradient>;
  88153. /** @hidden */
  88154. _currentColor1: Color4;
  88155. /** @hidden */
  88156. _currentColor2: Color4;
  88157. /** @hidden */
  88158. _currentSizeGradient: Nullable<FactorGradient>;
  88159. /** @hidden */
  88160. _currentSize1: number;
  88161. /** @hidden */
  88162. _currentSize2: number;
  88163. /** @hidden */
  88164. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88165. /** @hidden */
  88166. _currentAngularSpeed1: number;
  88167. /** @hidden */
  88168. _currentAngularSpeed2: number;
  88169. /** @hidden */
  88170. _currentVelocityGradient: Nullable<FactorGradient>;
  88171. /** @hidden */
  88172. _currentVelocity1: number;
  88173. /** @hidden */
  88174. _currentVelocity2: number;
  88175. /** @hidden */
  88176. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88177. /** @hidden */
  88178. _currentLimitVelocity1: number;
  88179. /** @hidden */
  88180. _currentLimitVelocity2: number;
  88181. /** @hidden */
  88182. _currentDragGradient: Nullable<FactorGradient>;
  88183. /** @hidden */
  88184. _currentDrag1: number;
  88185. /** @hidden */
  88186. _currentDrag2: number;
  88187. /** @hidden */
  88188. _randomNoiseCoordinates1: Vector3;
  88189. /** @hidden */
  88190. _randomNoiseCoordinates2: Vector3;
  88191. /** @hidden */
  88192. _localPosition?: Vector3;
  88193. /**
  88194. * Creates a new instance Particle
  88195. * @param particleSystem the particle system the particle belongs to
  88196. */
  88197. constructor(
  88198. /**
  88199. * The particle system the particle belongs to.
  88200. */
  88201. particleSystem: ParticleSystem);
  88202. private updateCellInfoFromSystem;
  88203. /**
  88204. * Defines how the sprite cell index is updated for the particle
  88205. */
  88206. updateCellIndex(): void;
  88207. /** @hidden */
  88208. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88209. /** @hidden */
  88210. _inheritParticleInfoToSubEmitters(): void;
  88211. /** @hidden */
  88212. _reset(): void;
  88213. /**
  88214. * Copy the properties of particle to another one.
  88215. * @param other the particle to copy the information to.
  88216. */
  88217. copyTo(other: Particle): void;
  88218. }
  88219. }
  88220. declare module BABYLON {
  88221. /**
  88222. * Particle emitter represents a volume emitting particles.
  88223. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88224. */
  88225. export interface IParticleEmitterType {
  88226. /**
  88227. * Called by the particle System when the direction is computed for the created particle.
  88228. * @param worldMatrix is the world matrix of the particle system
  88229. * @param directionToUpdate is the direction vector to update with the result
  88230. * @param particle is the particle we are computed the direction for
  88231. * @param isLocal defines if the direction should be set in local space
  88232. */
  88233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88234. /**
  88235. * Called by the particle System when the position is computed for the created particle.
  88236. * @param worldMatrix is the world matrix of the particle system
  88237. * @param positionToUpdate is the position vector to update with the result
  88238. * @param particle is the particle we are computed the position for
  88239. * @param isLocal defines if the position should be set in local space
  88240. */
  88241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88242. /**
  88243. * Clones the current emitter and returns a copy of it
  88244. * @returns the new emitter
  88245. */
  88246. clone(): IParticleEmitterType;
  88247. /**
  88248. * Called by the GPUParticleSystem to setup the update shader
  88249. * @param effect defines the update shader
  88250. */
  88251. applyToShader(effect: Effect): void;
  88252. /**
  88253. * Returns a string to use to update the GPU particles update shader
  88254. * @returns the effect defines string
  88255. */
  88256. getEffectDefines(): string;
  88257. /**
  88258. * Returns a string representing the class name
  88259. * @returns a string containing the class name
  88260. */
  88261. getClassName(): string;
  88262. /**
  88263. * Serializes the particle system to a JSON object.
  88264. * @returns the JSON object
  88265. */
  88266. serialize(): any;
  88267. /**
  88268. * Parse properties from a JSON object
  88269. * @param serializationObject defines the JSON object
  88270. * @param scene defines the hosting scene
  88271. */
  88272. parse(serializationObject: any, scene: Scene): void;
  88273. }
  88274. }
  88275. declare module BABYLON {
  88276. /**
  88277. * Particle emitter emitting particles from the inside of a box.
  88278. * It emits the particles randomly between 2 given directions.
  88279. */
  88280. export class BoxParticleEmitter implements IParticleEmitterType {
  88281. /**
  88282. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88283. */
  88284. direction1: Vector3;
  88285. /**
  88286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88287. */
  88288. direction2: Vector3;
  88289. /**
  88290. * 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.
  88291. */
  88292. minEmitBox: Vector3;
  88293. /**
  88294. * 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.
  88295. */
  88296. maxEmitBox: Vector3;
  88297. /**
  88298. * Creates a new instance BoxParticleEmitter
  88299. */
  88300. constructor();
  88301. /**
  88302. * Called by the particle System when the direction is computed for the created particle.
  88303. * @param worldMatrix is the world matrix of the particle system
  88304. * @param directionToUpdate is the direction vector to update with the result
  88305. * @param particle is the particle we are computed the direction for
  88306. * @param isLocal defines if the direction should be set in local space
  88307. */
  88308. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88309. /**
  88310. * Called by the particle System when the position is computed for the created particle.
  88311. * @param worldMatrix is the world matrix of the particle system
  88312. * @param positionToUpdate is the position vector to update with the result
  88313. * @param particle is the particle we are computed the position for
  88314. * @param isLocal defines if the position should be set in local space
  88315. */
  88316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88317. /**
  88318. * Clones the current emitter and returns a copy of it
  88319. * @returns the new emitter
  88320. */
  88321. clone(): BoxParticleEmitter;
  88322. /**
  88323. * Called by the GPUParticleSystem to setup the update shader
  88324. * @param effect defines the update shader
  88325. */
  88326. applyToShader(effect: Effect): void;
  88327. /**
  88328. * Returns a string to use to update the GPU particles update shader
  88329. * @returns a string containng the defines string
  88330. */
  88331. getEffectDefines(): string;
  88332. /**
  88333. * Returns the string "BoxParticleEmitter"
  88334. * @returns a string containing the class name
  88335. */
  88336. getClassName(): string;
  88337. /**
  88338. * Serializes the particle system to a JSON object.
  88339. * @returns the JSON object
  88340. */
  88341. serialize(): any;
  88342. /**
  88343. * Parse properties from a JSON object
  88344. * @param serializationObject defines the JSON object
  88345. */
  88346. parse(serializationObject: any): void;
  88347. }
  88348. }
  88349. declare module BABYLON {
  88350. /**
  88351. * Particle emitter emitting particles from the inside of a cone.
  88352. * It emits the particles alongside the cone volume from the base to the particle.
  88353. * The emission direction might be randomized.
  88354. */
  88355. export class ConeParticleEmitter implements IParticleEmitterType {
  88356. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88357. directionRandomizer: number;
  88358. private _radius;
  88359. private _angle;
  88360. private _height;
  88361. /**
  88362. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88363. */
  88364. radiusRange: number;
  88365. /**
  88366. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88367. */
  88368. heightRange: number;
  88369. /**
  88370. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88371. */
  88372. emitFromSpawnPointOnly: boolean;
  88373. /**
  88374. * Gets or sets the radius of the emission cone
  88375. */
  88376. get radius(): number;
  88377. set radius(value: number);
  88378. /**
  88379. * Gets or sets the angle of the emission cone
  88380. */
  88381. get angle(): number;
  88382. set angle(value: number);
  88383. private _buildHeight;
  88384. /**
  88385. * Creates a new instance ConeParticleEmitter
  88386. * @param radius the radius of the emission cone (1 by default)
  88387. * @param angle the cone base angle (PI by default)
  88388. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88389. */
  88390. constructor(radius?: number, angle?: number,
  88391. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88392. directionRandomizer?: number);
  88393. /**
  88394. * Called by the particle System when the direction is computed for the created particle.
  88395. * @param worldMatrix is the world matrix of the particle system
  88396. * @param directionToUpdate is the direction vector to update with the result
  88397. * @param particle is the particle we are computed the direction for
  88398. * @param isLocal defines if the direction should be set in local space
  88399. */
  88400. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88401. /**
  88402. * Called by the particle System when the position is computed for the created particle.
  88403. * @param worldMatrix is the world matrix of the particle system
  88404. * @param positionToUpdate is the position vector to update with the result
  88405. * @param particle is the particle we are computed the position for
  88406. * @param isLocal defines if the position should be set in local space
  88407. */
  88408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88409. /**
  88410. * Clones the current emitter and returns a copy of it
  88411. * @returns the new emitter
  88412. */
  88413. clone(): ConeParticleEmitter;
  88414. /**
  88415. * Called by the GPUParticleSystem to setup the update shader
  88416. * @param effect defines the update shader
  88417. */
  88418. applyToShader(effect: Effect): void;
  88419. /**
  88420. * Returns a string to use to update the GPU particles update shader
  88421. * @returns a string containng the defines string
  88422. */
  88423. getEffectDefines(): string;
  88424. /**
  88425. * Returns the string "ConeParticleEmitter"
  88426. * @returns a string containing the class name
  88427. */
  88428. getClassName(): string;
  88429. /**
  88430. * Serializes the particle system to a JSON object.
  88431. * @returns the JSON object
  88432. */
  88433. serialize(): any;
  88434. /**
  88435. * Parse properties from a JSON object
  88436. * @param serializationObject defines the JSON object
  88437. */
  88438. parse(serializationObject: any): void;
  88439. }
  88440. }
  88441. declare module BABYLON {
  88442. /**
  88443. * Particle emitter emitting particles from the inside of a cylinder.
  88444. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88445. */
  88446. export class CylinderParticleEmitter implements IParticleEmitterType {
  88447. /**
  88448. * The radius of the emission cylinder.
  88449. */
  88450. radius: number;
  88451. /**
  88452. * The height of the emission cylinder.
  88453. */
  88454. height: number;
  88455. /**
  88456. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88457. */
  88458. radiusRange: number;
  88459. /**
  88460. * How much to randomize the particle direction [0-1].
  88461. */
  88462. directionRandomizer: number;
  88463. /**
  88464. * Creates a new instance CylinderParticleEmitter
  88465. * @param radius the radius of the emission cylinder (1 by default)
  88466. * @param height the height of the emission cylinder (1 by default)
  88467. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88468. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88469. */
  88470. constructor(
  88471. /**
  88472. * The radius of the emission cylinder.
  88473. */
  88474. radius?: number,
  88475. /**
  88476. * The height of the emission cylinder.
  88477. */
  88478. height?: number,
  88479. /**
  88480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88481. */
  88482. radiusRange?: number,
  88483. /**
  88484. * How much to randomize the particle direction [0-1].
  88485. */
  88486. directionRandomizer?: number);
  88487. /**
  88488. * Called by the particle System when the direction is computed for the created particle.
  88489. * @param worldMatrix is the world matrix of the particle system
  88490. * @param directionToUpdate is the direction vector to update with the result
  88491. * @param particle is the particle we are computed the direction for
  88492. * @param isLocal defines if the direction should be set in local space
  88493. */
  88494. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88495. /**
  88496. * Called by the particle System when the position is computed for the created particle.
  88497. * @param worldMatrix is the world matrix of the particle system
  88498. * @param positionToUpdate is the position vector to update with the result
  88499. * @param particle is the particle we are computed the position for
  88500. * @param isLocal defines if the position should be set in local space
  88501. */
  88502. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88503. /**
  88504. * Clones the current emitter and returns a copy of it
  88505. * @returns the new emitter
  88506. */
  88507. clone(): CylinderParticleEmitter;
  88508. /**
  88509. * Called by the GPUParticleSystem to setup the update shader
  88510. * @param effect defines the update shader
  88511. */
  88512. applyToShader(effect: Effect): void;
  88513. /**
  88514. * Returns a string to use to update the GPU particles update shader
  88515. * @returns a string containng the defines string
  88516. */
  88517. getEffectDefines(): string;
  88518. /**
  88519. * Returns the string "CylinderParticleEmitter"
  88520. * @returns a string containing the class name
  88521. */
  88522. getClassName(): string;
  88523. /**
  88524. * Serializes the particle system to a JSON object.
  88525. * @returns the JSON object
  88526. */
  88527. serialize(): any;
  88528. /**
  88529. * Parse properties from a JSON object
  88530. * @param serializationObject defines the JSON object
  88531. */
  88532. parse(serializationObject: any): void;
  88533. }
  88534. /**
  88535. * Particle emitter emitting particles from the inside of a cylinder.
  88536. * It emits the particles randomly between two vectors.
  88537. */
  88538. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88539. /**
  88540. * The min limit of the emission direction.
  88541. */
  88542. direction1: Vector3;
  88543. /**
  88544. * The max limit of the emission direction.
  88545. */
  88546. direction2: Vector3;
  88547. /**
  88548. * Creates a new instance CylinderDirectedParticleEmitter
  88549. * @param radius the radius of the emission cylinder (1 by default)
  88550. * @param height the height of the emission cylinder (1 by default)
  88551. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88552. * @param direction1 the min limit of the emission direction (up vector by default)
  88553. * @param direction2 the max limit of the emission direction (up vector by default)
  88554. */
  88555. constructor(radius?: number, height?: number, radiusRange?: number,
  88556. /**
  88557. * The min limit of the emission direction.
  88558. */
  88559. direction1?: Vector3,
  88560. /**
  88561. * The max limit of the emission direction.
  88562. */
  88563. direction2?: Vector3);
  88564. /**
  88565. * Called by the particle System when the direction is computed for the created particle.
  88566. * @param worldMatrix is the world matrix of the particle system
  88567. * @param directionToUpdate is the direction vector to update with the result
  88568. * @param particle is the particle we are computed the direction for
  88569. */
  88570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88571. /**
  88572. * Clones the current emitter and returns a copy of it
  88573. * @returns the new emitter
  88574. */
  88575. clone(): CylinderDirectedParticleEmitter;
  88576. /**
  88577. * Called by the GPUParticleSystem to setup the update shader
  88578. * @param effect defines the update shader
  88579. */
  88580. applyToShader(effect: Effect): void;
  88581. /**
  88582. * Returns a string to use to update the GPU particles update shader
  88583. * @returns a string containng the defines string
  88584. */
  88585. getEffectDefines(): string;
  88586. /**
  88587. * Returns the string "CylinderDirectedParticleEmitter"
  88588. * @returns a string containing the class name
  88589. */
  88590. getClassName(): string;
  88591. /**
  88592. * Serializes the particle system to a JSON object.
  88593. * @returns the JSON object
  88594. */
  88595. serialize(): any;
  88596. /**
  88597. * Parse properties from a JSON object
  88598. * @param serializationObject defines the JSON object
  88599. */
  88600. parse(serializationObject: any): void;
  88601. }
  88602. }
  88603. declare module BABYLON {
  88604. /**
  88605. * Particle emitter emitting particles from the inside of a hemisphere.
  88606. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88607. */
  88608. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88609. /**
  88610. * The radius of the emission hemisphere.
  88611. */
  88612. radius: number;
  88613. /**
  88614. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88615. */
  88616. radiusRange: number;
  88617. /**
  88618. * How much to randomize the particle direction [0-1].
  88619. */
  88620. directionRandomizer: number;
  88621. /**
  88622. * Creates a new instance HemisphericParticleEmitter
  88623. * @param radius the radius of the emission hemisphere (1 by default)
  88624. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88625. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88626. */
  88627. constructor(
  88628. /**
  88629. * The radius of the emission hemisphere.
  88630. */
  88631. radius?: number,
  88632. /**
  88633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88634. */
  88635. radiusRange?: number,
  88636. /**
  88637. * How much to randomize the particle direction [0-1].
  88638. */
  88639. directionRandomizer?: number);
  88640. /**
  88641. * Called by the particle System when the direction is computed for the created particle.
  88642. * @param worldMatrix is the world matrix of the particle system
  88643. * @param directionToUpdate is the direction vector to update with the result
  88644. * @param particle is the particle we are computed the direction for
  88645. * @param isLocal defines if the direction should be set in local space
  88646. */
  88647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88648. /**
  88649. * Called by the particle System when the position is computed for the created particle.
  88650. * @param worldMatrix is the world matrix of the particle system
  88651. * @param positionToUpdate is the position vector to update with the result
  88652. * @param particle is the particle we are computed the position for
  88653. * @param isLocal defines if the position should be set in local space
  88654. */
  88655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88656. /**
  88657. * Clones the current emitter and returns a copy of it
  88658. * @returns the new emitter
  88659. */
  88660. clone(): HemisphericParticleEmitter;
  88661. /**
  88662. * Called by the GPUParticleSystem to setup the update shader
  88663. * @param effect defines the update shader
  88664. */
  88665. applyToShader(effect: Effect): void;
  88666. /**
  88667. * Returns a string to use to update the GPU particles update shader
  88668. * @returns a string containng the defines string
  88669. */
  88670. getEffectDefines(): string;
  88671. /**
  88672. * Returns the string "HemisphericParticleEmitter"
  88673. * @returns a string containing the class name
  88674. */
  88675. getClassName(): string;
  88676. /**
  88677. * Serializes the particle system to a JSON object.
  88678. * @returns the JSON object
  88679. */
  88680. serialize(): any;
  88681. /**
  88682. * Parse properties from a JSON object
  88683. * @param serializationObject defines the JSON object
  88684. */
  88685. parse(serializationObject: any): void;
  88686. }
  88687. }
  88688. declare module BABYLON {
  88689. /**
  88690. * Particle emitter emitting particles from a point.
  88691. * It emits the particles randomly between 2 given directions.
  88692. */
  88693. export class PointParticleEmitter implements IParticleEmitterType {
  88694. /**
  88695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88696. */
  88697. direction1: Vector3;
  88698. /**
  88699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88700. */
  88701. direction2: Vector3;
  88702. /**
  88703. * Creates a new instance PointParticleEmitter
  88704. */
  88705. constructor();
  88706. /**
  88707. * Called by the particle System when the direction is computed for the created particle.
  88708. * @param worldMatrix is the world matrix of the particle system
  88709. * @param directionToUpdate is the direction vector to update with the result
  88710. * @param particle is the particle we are computed the direction for
  88711. * @param isLocal defines if the direction should be set in local space
  88712. */
  88713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88714. /**
  88715. * Called by the particle System when the position is computed for the created particle.
  88716. * @param worldMatrix is the world matrix of the particle system
  88717. * @param positionToUpdate is the position vector to update with the result
  88718. * @param particle is the particle we are computed the position for
  88719. * @param isLocal defines if the position should be set in local space
  88720. */
  88721. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88722. /**
  88723. * Clones the current emitter and returns a copy of it
  88724. * @returns the new emitter
  88725. */
  88726. clone(): PointParticleEmitter;
  88727. /**
  88728. * Called by the GPUParticleSystem to setup the update shader
  88729. * @param effect defines the update shader
  88730. */
  88731. applyToShader(effect: Effect): void;
  88732. /**
  88733. * Returns a string to use to update the GPU particles update shader
  88734. * @returns a string containng the defines string
  88735. */
  88736. getEffectDefines(): string;
  88737. /**
  88738. * Returns the string "PointParticleEmitter"
  88739. * @returns a string containing the class name
  88740. */
  88741. getClassName(): string;
  88742. /**
  88743. * Serializes the particle system to a JSON object.
  88744. * @returns the JSON object
  88745. */
  88746. serialize(): any;
  88747. /**
  88748. * Parse properties from a JSON object
  88749. * @param serializationObject defines the JSON object
  88750. */
  88751. parse(serializationObject: any): void;
  88752. }
  88753. }
  88754. declare module BABYLON {
  88755. /**
  88756. * Particle emitter emitting particles from the inside of a sphere.
  88757. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88758. */
  88759. export class SphereParticleEmitter implements IParticleEmitterType {
  88760. /**
  88761. * The radius of the emission sphere.
  88762. */
  88763. radius: number;
  88764. /**
  88765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88766. */
  88767. radiusRange: number;
  88768. /**
  88769. * How much to randomize the particle direction [0-1].
  88770. */
  88771. directionRandomizer: number;
  88772. /**
  88773. * Creates a new instance SphereParticleEmitter
  88774. * @param radius the radius of the emission sphere (1 by default)
  88775. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88776. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88777. */
  88778. constructor(
  88779. /**
  88780. * The radius of the emission sphere.
  88781. */
  88782. radius?: number,
  88783. /**
  88784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88785. */
  88786. radiusRange?: number,
  88787. /**
  88788. * How much to randomize the particle direction [0-1].
  88789. */
  88790. directionRandomizer?: number);
  88791. /**
  88792. * Called by the particle System when the direction is computed for the created particle.
  88793. * @param worldMatrix is the world matrix of the particle system
  88794. * @param directionToUpdate is the direction vector to update with the result
  88795. * @param particle is the particle we are computed the direction for
  88796. * @param isLocal defines if the direction should be set in local space
  88797. */
  88798. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88799. /**
  88800. * Called by the particle System when the position is computed for the created particle.
  88801. * @param worldMatrix is the world matrix of the particle system
  88802. * @param positionToUpdate is the position vector to update with the result
  88803. * @param particle is the particle we are computed the position for
  88804. * @param isLocal defines if the position should be set in local space
  88805. */
  88806. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88807. /**
  88808. * Clones the current emitter and returns a copy of it
  88809. * @returns the new emitter
  88810. */
  88811. clone(): SphereParticleEmitter;
  88812. /**
  88813. * Called by the GPUParticleSystem to setup the update shader
  88814. * @param effect defines the update shader
  88815. */
  88816. applyToShader(effect: Effect): void;
  88817. /**
  88818. * Returns a string to use to update the GPU particles update shader
  88819. * @returns a string containng the defines string
  88820. */
  88821. getEffectDefines(): string;
  88822. /**
  88823. * Returns the string "SphereParticleEmitter"
  88824. * @returns a string containing the class name
  88825. */
  88826. getClassName(): string;
  88827. /**
  88828. * Serializes the particle system to a JSON object.
  88829. * @returns the JSON object
  88830. */
  88831. serialize(): any;
  88832. /**
  88833. * Parse properties from a JSON object
  88834. * @param serializationObject defines the JSON object
  88835. */
  88836. parse(serializationObject: any): void;
  88837. }
  88838. /**
  88839. * Particle emitter emitting particles from the inside of a sphere.
  88840. * It emits the particles randomly between two vectors.
  88841. */
  88842. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88843. /**
  88844. * The min limit of the emission direction.
  88845. */
  88846. direction1: Vector3;
  88847. /**
  88848. * The max limit of the emission direction.
  88849. */
  88850. direction2: Vector3;
  88851. /**
  88852. * Creates a new instance SphereDirectedParticleEmitter
  88853. * @param radius the radius of the emission sphere (1 by default)
  88854. * @param direction1 the min limit of the emission direction (up vector by default)
  88855. * @param direction2 the max limit of the emission direction (up vector by default)
  88856. */
  88857. constructor(radius?: number,
  88858. /**
  88859. * The min limit of the emission direction.
  88860. */
  88861. direction1?: Vector3,
  88862. /**
  88863. * The max limit of the emission direction.
  88864. */
  88865. direction2?: Vector3);
  88866. /**
  88867. * Called by the particle System when the direction is computed for the created particle.
  88868. * @param worldMatrix is the world matrix of the particle system
  88869. * @param directionToUpdate is the direction vector to update with the result
  88870. * @param particle is the particle we are computed the direction for
  88871. */
  88872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88873. /**
  88874. * Clones the current emitter and returns a copy of it
  88875. * @returns the new emitter
  88876. */
  88877. clone(): SphereDirectedParticleEmitter;
  88878. /**
  88879. * Called by the GPUParticleSystem to setup the update shader
  88880. * @param effect defines the update shader
  88881. */
  88882. applyToShader(effect: Effect): void;
  88883. /**
  88884. * Returns a string to use to update the GPU particles update shader
  88885. * @returns a string containng the defines string
  88886. */
  88887. getEffectDefines(): string;
  88888. /**
  88889. * Returns the string "SphereDirectedParticleEmitter"
  88890. * @returns a string containing the class name
  88891. */
  88892. getClassName(): string;
  88893. /**
  88894. * Serializes the particle system to a JSON object.
  88895. * @returns the JSON object
  88896. */
  88897. serialize(): any;
  88898. /**
  88899. * Parse properties from a JSON object
  88900. * @param serializationObject defines the JSON object
  88901. */
  88902. parse(serializationObject: any): void;
  88903. }
  88904. }
  88905. declare module BABYLON {
  88906. /**
  88907. * Particle emitter emitting particles from a custom list of positions.
  88908. */
  88909. export class CustomParticleEmitter implements IParticleEmitterType {
  88910. /**
  88911. * Gets or sets the position generator that will create the inital position of each particle.
  88912. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88913. */
  88914. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88915. /**
  88916. * Gets or sets the destination generator that will create the final destination of each particle.
  88917. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88918. */
  88919. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88920. /**
  88921. * Creates a new instance CustomParticleEmitter
  88922. */
  88923. constructor();
  88924. /**
  88925. * Called by the particle System when the direction is computed for the created particle.
  88926. * @param worldMatrix is the world matrix of the particle system
  88927. * @param directionToUpdate is the direction vector to update with the result
  88928. * @param particle is the particle we are computed the direction for
  88929. * @param isLocal defines if the direction should be set in local space
  88930. */
  88931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88932. /**
  88933. * Called by the particle System when the position is computed for the created particle.
  88934. * @param worldMatrix is the world matrix of the particle system
  88935. * @param positionToUpdate is the position vector to update with the result
  88936. * @param particle is the particle we are computed the position for
  88937. * @param isLocal defines if the position should be set in local space
  88938. */
  88939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88940. /**
  88941. * Clones the current emitter and returns a copy of it
  88942. * @returns the new emitter
  88943. */
  88944. clone(): CustomParticleEmitter;
  88945. /**
  88946. * Called by the GPUParticleSystem to setup the update shader
  88947. * @param effect defines the update shader
  88948. */
  88949. applyToShader(effect: Effect): void;
  88950. /**
  88951. * Returns a string to use to update the GPU particles update shader
  88952. * @returns a string containng the defines string
  88953. */
  88954. getEffectDefines(): string;
  88955. /**
  88956. * Returns the string "PointParticleEmitter"
  88957. * @returns a string containing the class name
  88958. */
  88959. getClassName(): string;
  88960. /**
  88961. * Serializes the particle system to a JSON object.
  88962. * @returns the JSON object
  88963. */
  88964. serialize(): any;
  88965. /**
  88966. * Parse properties from a JSON object
  88967. * @param serializationObject defines the JSON object
  88968. */
  88969. parse(serializationObject: any): void;
  88970. }
  88971. }
  88972. declare module BABYLON {
  88973. /**
  88974. * Particle emitter emitting particles from the inside of a box.
  88975. * It emits the particles randomly between 2 given directions.
  88976. */
  88977. export class MeshParticleEmitter implements IParticleEmitterType {
  88978. private _indices;
  88979. private _positions;
  88980. private _normals;
  88981. private _storedNormal;
  88982. private _mesh;
  88983. /**
  88984. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88985. */
  88986. direction1: Vector3;
  88987. /**
  88988. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88989. */
  88990. direction2: Vector3;
  88991. /**
  88992. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  88993. */
  88994. useMeshNormalsForDirection: boolean;
  88995. /** Defines the mesh to use as source */
  88996. get mesh(): Nullable<AbstractMesh>;
  88997. set mesh(value: Nullable<AbstractMesh>);
  88998. /**
  88999. * Creates a new instance MeshParticleEmitter
  89000. * @param mesh defines the mesh to use as source
  89001. */
  89002. constructor(mesh?: Nullable<AbstractMesh>);
  89003. /**
  89004. * Called by the particle System when the direction is computed for the created particle.
  89005. * @param worldMatrix is the world matrix of the particle system
  89006. * @param directionToUpdate is the direction vector to update with the result
  89007. * @param particle is the particle we are computed the direction for
  89008. * @param isLocal defines if the direction should be set in local space
  89009. */
  89010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89011. /**
  89012. * Called by the particle System when the position is computed for the created particle.
  89013. * @param worldMatrix is the world matrix of the particle system
  89014. * @param positionToUpdate is the position vector to update with the result
  89015. * @param particle is the particle we are computed the position for
  89016. * @param isLocal defines if the position should be set in local space
  89017. */
  89018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89019. /**
  89020. * Clones the current emitter and returns a copy of it
  89021. * @returns the new emitter
  89022. */
  89023. clone(): MeshParticleEmitter;
  89024. /**
  89025. * Called by the GPUParticleSystem to setup the update shader
  89026. * @param effect defines the update shader
  89027. */
  89028. applyToShader(effect: Effect): void;
  89029. /**
  89030. * Returns a string to use to update the GPU particles update shader
  89031. * @returns a string containng the defines string
  89032. */
  89033. getEffectDefines(): string;
  89034. /**
  89035. * Returns the string "BoxParticleEmitter"
  89036. * @returns a string containing the class name
  89037. */
  89038. getClassName(): string;
  89039. /**
  89040. * Serializes the particle system to a JSON object.
  89041. * @returns the JSON object
  89042. */
  89043. serialize(): any;
  89044. /**
  89045. * Parse properties from a JSON object
  89046. * @param serializationObject defines the JSON object
  89047. * @param scene defines the hosting scene
  89048. */
  89049. parse(serializationObject: any, scene: Scene): void;
  89050. }
  89051. }
  89052. declare module BABYLON {
  89053. /**
  89054. * Interface representing a particle system in Babylon.js.
  89055. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89056. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89057. */
  89058. export interface IParticleSystem {
  89059. /**
  89060. * List of animations used by the particle system.
  89061. */
  89062. animations: Animation[];
  89063. /**
  89064. * The id of the Particle system.
  89065. */
  89066. id: string;
  89067. /**
  89068. * The name of the Particle system.
  89069. */
  89070. name: string;
  89071. /**
  89072. * The emitter represents the Mesh or position we are attaching the particle system to.
  89073. */
  89074. emitter: Nullable<AbstractMesh | Vector3>;
  89075. /**
  89076. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89077. */
  89078. isBillboardBased: boolean;
  89079. /**
  89080. * The rendering group used by the Particle system to chose when to render.
  89081. */
  89082. renderingGroupId: number;
  89083. /**
  89084. * The layer mask we are rendering the particles through.
  89085. */
  89086. layerMask: number;
  89087. /**
  89088. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89089. */
  89090. updateSpeed: number;
  89091. /**
  89092. * The amount of time the particle system is running (depends of the overall update speed).
  89093. */
  89094. targetStopDuration: number;
  89095. /**
  89096. * The texture used to render each particle. (this can be a spritesheet)
  89097. */
  89098. particleTexture: Nullable<Texture>;
  89099. /**
  89100. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89101. */
  89102. blendMode: number;
  89103. /**
  89104. * Minimum life time of emitting particles.
  89105. */
  89106. minLifeTime: number;
  89107. /**
  89108. * Maximum life time of emitting particles.
  89109. */
  89110. maxLifeTime: number;
  89111. /**
  89112. * Minimum Size of emitting particles.
  89113. */
  89114. minSize: number;
  89115. /**
  89116. * Maximum Size of emitting particles.
  89117. */
  89118. maxSize: number;
  89119. /**
  89120. * Minimum scale of emitting particles on X axis.
  89121. */
  89122. minScaleX: number;
  89123. /**
  89124. * Maximum scale of emitting particles on X axis.
  89125. */
  89126. maxScaleX: number;
  89127. /**
  89128. * Minimum scale of emitting particles on Y axis.
  89129. */
  89130. minScaleY: number;
  89131. /**
  89132. * Maximum scale of emitting particles on Y axis.
  89133. */
  89134. maxScaleY: number;
  89135. /**
  89136. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89137. */
  89138. color1: Color4;
  89139. /**
  89140. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89141. */
  89142. color2: Color4;
  89143. /**
  89144. * Color the particle will have at the end of its lifetime.
  89145. */
  89146. colorDead: Color4;
  89147. /**
  89148. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89149. */
  89150. emitRate: number;
  89151. /**
  89152. * You can use gravity if you want to give an orientation to your particles.
  89153. */
  89154. gravity: Vector3;
  89155. /**
  89156. * Minimum power of emitting particles.
  89157. */
  89158. minEmitPower: number;
  89159. /**
  89160. * Maximum power of emitting particles.
  89161. */
  89162. maxEmitPower: number;
  89163. /**
  89164. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89165. */
  89166. minAngularSpeed: number;
  89167. /**
  89168. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89169. */
  89170. maxAngularSpeed: number;
  89171. /**
  89172. * Gets or sets the minimal initial rotation in radians.
  89173. */
  89174. minInitialRotation: number;
  89175. /**
  89176. * Gets or sets the maximal initial rotation in radians.
  89177. */
  89178. maxInitialRotation: number;
  89179. /**
  89180. * The particle emitter type defines the emitter used by the particle system.
  89181. * It can be for example box, sphere, or cone...
  89182. */
  89183. particleEmitterType: Nullable<IParticleEmitterType>;
  89184. /**
  89185. * Defines the delay in milliseconds before starting the system (0 by default)
  89186. */
  89187. startDelay: number;
  89188. /**
  89189. * 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
  89190. */
  89191. preWarmCycles: number;
  89192. /**
  89193. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89194. */
  89195. preWarmStepOffset: number;
  89196. /**
  89197. * 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)
  89198. */
  89199. spriteCellChangeSpeed: number;
  89200. /**
  89201. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89202. */
  89203. startSpriteCellID: number;
  89204. /**
  89205. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89206. */
  89207. endSpriteCellID: number;
  89208. /**
  89209. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89210. */
  89211. spriteCellWidth: number;
  89212. /**
  89213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89214. */
  89215. spriteCellHeight: number;
  89216. /**
  89217. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89218. */
  89219. spriteRandomStartCell: boolean;
  89220. /**
  89221. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89222. */
  89223. isAnimationSheetEnabled: boolean;
  89224. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89225. translationPivot: Vector2;
  89226. /**
  89227. * Gets or sets a texture used to add random noise to particle positions
  89228. */
  89229. noiseTexture: Nullable<BaseTexture>;
  89230. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89231. noiseStrength: Vector3;
  89232. /**
  89233. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89234. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89235. */
  89236. billboardMode: number;
  89237. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89238. limitVelocityDamping: number;
  89239. /**
  89240. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89241. */
  89242. beginAnimationOnStart: boolean;
  89243. /**
  89244. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89245. */
  89246. beginAnimationFrom: number;
  89247. /**
  89248. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89249. */
  89250. beginAnimationTo: number;
  89251. /**
  89252. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89253. */
  89254. beginAnimationLoop: boolean;
  89255. /**
  89256. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89257. */
  89258. disposeOnStop: boolean;
  89259. /**
  89260. * Specifies if the particles are updated in emitter local space or world space
  89261. */
  89262. isLocal: boolean;
  89263. /** Snippet ID if the particle system was created from the snippet server */
  89264. snippetId: string;
  89265. /**
  89266. * Gets the maximum number of particles active at the same time.
  89267. * @returns The max number of active particles.
  89268. */
  89269. getCapacity(): number;
  89270. /**
  89271. * Gets the number of particles active at the same time.
  89272. * @returns The number of active particles.
  89273. */
  89274. getActiveCount(): number;
  89275. /**
  89276. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89277. * @returns True if it has been started, otherwise false.
  89278. */
  89279. isStarted(): boolean;
  89280. /**
  89281. * Animates the particle system for this frame.
  89282. */
  89283. animate(): void;
  89284. /**
  89285. * Renders the particle system in its current state.
  89286. * @returns the current number of particles
  89287. */
  89288. render(): number;
  89289. /**
  89290. * Dispose the particle system and frees its associated resources.
  89291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89292. */
  89293. dispose(disposeTexture?: boolean): void;
  89294. /**
  89295. * Clones the particle system.
  89296. * @param name The name of the cloned object
  89297. * @param newEmitter The new emitter to use
  89298. * @returns the cloned particle system
  89299. */
  89300. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89301. /**
  89302. * Serializes the particle system to a JSON object
  89303. * @param serializeTexture defines if the texture must be serialized as well
  89304. * @returns the JSON object
  89305. */
  89306. serialize(serializeTexture: boolean): any;
  89307. /**
  89308. * Rebuild the particle system
  89309. */
  89310. rebuild(): void;
  89311. /** Force the system to rebuild all gradients that need to be resync */
  89312. forceRefreshGradients(): void;
  89313. /**
  89314. * Starts the particle system and begins to emit
  89315. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89316. */
  89317. start(delay?: number): void;
  89318. /**
  89319. * Stops the particle system.
  89320. */
  89321. stop(): void;
  89322. /**
  89323. * Remove all active particles
  89324. */
  89325. reset(): void;
  89326. /**
  89327. * Gets a boolean indicating that the system is stopping
  89328. * @returns true if the system is currently stopping
  89329. */
  89330. isStopping(): boolean;
  89331. /**
  89332. * Is this system ready to be used/rendered
  89333. * @return true if the system is ready
  89334. */
  89335. isReady(): boolean;
  89336. /**
  89337. * Returns the string "ParticleSystem"
  89338. * @returns a string containing the class name
  89339. */
  89340. getClassName(): string;
  89341. /**
  89342. * Adds a new color gradient
  89343. * @param gradient defines the gradient to use (between 0 and 1)
  89344. * @param color1 defines the color to affect to the specified gradient
  89345. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89346. * @returns the current particle system
  89347. */
  89348. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89349. /**
  89350. * Remove a specific color gradient
  89351. * @param gradient defines the gradient to remove
  89352. * @returns the current particle system
  89353. */
  89354. removeColorGradient(gradient: number): IParticleSystem;
  89355. /**
  89356. * Adds a new size gradient
  89357. * @param gradient defines the gradient to use (between 0 and 1)
  89358. * @param factor defines the size factor to affect to the specified gradient
  89359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89360. * @returns the current particle system
  89361. */
  89362. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89363. /**
  89364. * Remove a specific size gradient
  89365. * @param gradient defines the gradient to remove
  89366. * @returns the current particle system
  89367. */
  89368. removeSizeGradient(gradient: number): IParticleSystem;
  89369. /**
  89370. * Gets the current list of color gradients.
  89371. * You must use addColorGradient and removeColorGradient to udpate this list
  89372. * @returns the list of color gradients
  89373. */
  89374. getColorGradients(): Nullable<Array<ColorGradient>>;
  89375. /**
  89376. * Gets the current list of size gradients.
  89377. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89378. * @returns the list of size gradients
  89379. */
  89380. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89381. /**
  89382. * Gets the current list of angular speed gradients.
  89383. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89384. * @returns the list of angular speed gradients
  89385. */
  89386. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89387. /**
  89388. * Adds a new angular speed gradient
  89389. * @param gradient defines the gradient to use (between 0 and 1)
  89390. * @param factor defines the angular speed to affect to the specified gradient
  89391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89392. * @returns the current particle system
  89393. */
  89394. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89395. /**
  89396. * Remove a specific angular speed gradient
  89397. * @param gradient defines the gradient to remove
  89398. * @returns the current particle system
  89399. */
  89400. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89401. /**
  89402. * Gets the current list of velocity gradients.
  89403. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89404. * @returns the list of velocity gradients
  89405. */
  89406. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89407. /**
  89408. * Adds a new velocity gradient
  89409. * @param gradient defines the gradient to use (between 0 and 1)
  89410. * @param factor defines the velocity to affect to the specified gradient
  89411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89412. * @returns the current particle system
  89413. */
  89414. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89415. /**
  89416. * Remove a specific velocity gradient
  89417. * @param gradient defines the gradient to remove
  89418. * @returns the current particle system
  89419. */
  89420. removeVelocityGradient(gradient: number): IParticleSystem;
  89421. /**
  89422. * Gets the current list of limit velocity gradients.
  89423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89424. * @returns the list of limit velocity gradients
  89425. */
  89426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89427. /**
  89428. * Adds a new limit velocity gradient
  89429. * @param gradient defines the gradient to use (between 0 and 1)
  89430. * @param factor defines the limit velocity to affect to the specified gradient
  89431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89432. * @returns the current particle system
  89433. */
  89434. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89435. /**
  89436. * Remove a specific limit velocity gradient
  89437. * @param gradient defines the gradient to remove
  89438. * @returns the current particle system
  89439. */
  89440. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89441. /**
  89442. * Adds a new drag gradient
  89443. * @param gradient defines the gradient to use (between 0 and 1)
  89444. * @param factor defines the drag to affect to the specified gradient
  89445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89446. * @returns the current particle system
  89447. */
  89448. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89449. /**
  89450. * Remove a specific drag gradient
  89451. * @param gradient defines the gradient to remove
  89452. * @returns the current particle system
  89453. */
  89454. removeDragGradient(gradient: number): IParticleSystem;
  89455. /**
  89456. * Gets the current list of drag gradients.
  89457. * You must use addDragGradient and removeDragGradient to udpate this list
  89458. * @returns the list of drag gradients
  89459. */
  89460. getDragGradients(): Nullable<Array<FactorGradient>>;
  89461. /**
  89462. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89463. * @param gradient defines the gradient to use (between 0 and 1)
  89464. * @param factor defines the emit rate to affect to the specified gradient
  89465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89466. * @returns the current particle system
  89467. */
  89468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89469. /**
  89470. * Remove a specific emit rate gradient
  89471. * @param gradient defines the gradient to remove
  89472. * @returns the current particle system
  89473. */
  89474. removeEmitRateGradient(gradient: number): IParticleSystem;
  89475. /**
  89476. * Gets the current list of emit rate gradients.
  89477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89478. * @returns the list of emit rate gradients
  89479. */
  89480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89481. /**
  89482. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89483. * @param gradient defines the gradient to use (between 0 and 1)
  89484. * @param factor defines the start size to affect to the specified gradient
  89485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89486. * @returns the current particle system
  89487. */
  89488. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89489. /**
  89490. * Remove a specific start size gradient
  89491. * @param gradient defines the gradient to remove
  89492. * @returns the current particle system
  89493. */
  89494. removeStartSizeGradient(gradient: number): IParticleSystem;
  89495. /**
  89496. * Gets the current list of start size gradients.
  89497. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89498. * @returns the list of start size gradients
  89499. */
  89500. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89501. /**
  89502. * Adds a new life time gradient
  89503. * @param gradient defines the gradient to use (between 0 and 1)
  89504. * @param factor defines the life time factor to affect to the specified gradient
  89505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89506. * @returns the current particle system
  89507. */
  89508. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89509. /**
  89510. * Remove a specific life time gradient
  89511. * @param gradient defines the gradient to remove
  89512. * @returns the current particle system
  89513. */
  89514. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89515. /**
  89516. * Gets the current list of life time gradients.
  89517. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89518. * @returns the list of life time gradients
  89519. */
  89520. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89521. /**
  89522. * Gets the current list of color gradients.
  89523. * You must use addColorGradient and removeColorGradient to udpate this list
  89524. * @returns the list of color gradients
  89525. */
  89526. getColorGradients(): Nullable<Array<ColorGradient>>;
  89527. /**
  89528. * Adds a new ramp gradient used to remap particle colors
  89529. * @param gradient defines the gradient to use (between 0 and 1)
  89530. * @param color defines the color to affect to the specified gradient
  89531. * @returns the current particle system
  89532. */
  89533. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89534. /**
  89535. * Gets the current list of ramp gradients.
  89536. * You must use addRampGradient and removeRampGradient to udpate this list
  89537. * @returns the list of ramp gradients
  89538. */
  89539. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89540. /** Gets or sets a boolean indicating that ramp gradients must be used
  89541. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89542. */
  89543. useRampGradients: boolean;
  89544. /**
  89545. * Adds a new color remap gradient
  89546. * @param gradient defines the gradient to use (between 0 and 1)
  89547. * @param min defines the color remap minimal range
  89548. * @param max defines the color remap maximal range
  89549. * @returns the current particle system
  89550. */
  89551. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89552. /**
  89553. * Gets the current list of color remap gradients.
  89554. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89555. * @returns the list of color remap gradients
  89556. */
  89557. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89558. /**
  89559. * Adds a new alpha remap gradient
  89560. * @param gradient defines the gradient to use (between 0 and 1)
  89561. * @param min defines the alpha remap minimal range
  89562. * @param max defines the alpha remap maximal range
  89563. * @returns the current particle system
  89564. */
  89565. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89566. /**
  89567. * Gets the current list of alpha remap gradients.
  89568. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89569. * @returns the list of alpha remap gradients
  89570. */
  89571. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89572. /**
  89573. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89576. * @returns the emitter
  89577. */
  89578. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89579. /**
  89580. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89581. * @param radius The radius of the hemisphere to emit from
  89582. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89583. * @returns the emitter
  89584. */
  89585. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89586. /**
  89587. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89588. * @param radius The radius of the sphere to emit from
  89589. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89590. * @returns the emitter
  89591. */
  89592. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89593. /**
  89594. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89595. * @param radius The radius of the sphere to emit from
  89596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89598. * @returns the emitter
  89599. */
  89600. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89601. /**
  89602. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89603. * @param radius The radius of the emission cylinder
  89604. * @param height The height of the emission cylinder
  89605. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89606. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89607. * @returns the emitter
  89608. */
  89609. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89610. /**
  89611. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89612. * @param radius The radius of the cylinder to emit from
  89613. * @param height The height of the emission cylinder
  89614. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89617. * @returns the emitter
  89618. */
  89619. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89620. /**
  89621. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89622. * @param radius The radius of the cone to emit from
  89623. * @param angle The base angle of the cone
  89624. * @returns the emitter
  89625. */
  89626. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89627. /**
  89628. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89631. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89632. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89633. * @returns the emitter
  89634. */
  89635. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89636. /**
  89637. * Get hosting scene
  89638. * @returns the scene
  89639. */
  89640. getScene(): Scene;
  89641. }
  89642. }
  89643. declare module BABYLON {
  89644. /**
  89645. * 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.
  89646. * @see https://doc.babylonjs.com/how_to/transformnode
  89647. */
  89648. export class TransformNode extends Node {
  89649. /**
  89650. * Object will not rotate to face the camera
  89651. */
  89652. static BILLBOARDMODE_NONE: number;
  89653. /**
  89654. * Object will rotate to face the camera but only on the x axis
  89655. */
  89656. static BILLBOARDMODE_X: number;
  89657. /**
  89658. * Object will rotate to face the camera but only on the y axis
  89659. */
  89660. static BILLBOARDMODE_Y: number;
  89661. /**
  89662. * Object will rotate to face the camera but only on the z axis
  89663. */
  89664. static BILLBOARDMODE_Z: number;
  89665. /**
  89666. * Object will rotate to face the camera
  89667. */
  89668. static BILLBOARDMODE_ALL: number;
  89669. /**
  89670. * Object will rotate to face the camera's position instead of orientation
  89671. */
  89672. static BILLBOARDMODE_USE_POSITION: number;
  89673. private _forward;
  89674. private _forwardInverted;
  89675. private _up;
  89676. private _right;
  89677. private _rightInverted;
  89678. private _position;
  89679. private _rotation;
  89680. private _rotationQuaternion;
  89681. protected _scaling: Vector3;
  89682. protected _isDirty: boolean;
  89683. private _transformToBoneReferal;
  89684. private _isAbsoluteSynced;
  89685. private _billboardMode;
  89686. /**
  89687. * Gets or sets the billboard mode. Default is 0.
  89688. *
  89689. * | Value | Type | Description |
  89690. * | --- | --- | --- |
  89691. * | 0 | BILLBOARDMODE_NONE | |
  89692. * | 1 | BILLBOARDMODE_X | |
  89693. * | 2 | BILLBOARDMODE_Y | |
  89694. * | 4 | BILLBOARDMODE_Z | |
  89695. * | 7 | BILLBOARDMODE_ALL | |
  89696. *
  89697. */
  89698. get billboardMode(): number;
  89699. set billboardMode(value: number);
  89700. private _preserveParentRotationForBillboard;
  89701. /**
  89702. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89703. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89704. */
  89705. get preserveParentRotationForBillboard(): boolean;
  89706. set preserveParentRotationForBillboard(value: boolean);
  89707. /**
  89708. * 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
  89709. */
  89710. scalingDeterminant: number;
  89711. private _infiniteDistance;
  89712. /**
  89713. * Gets or sets the distance of the object to max, often used by skybox
  89714. */
  89715. get infiniteDistance(): boolean;
  89716. set infiniteDistance(value: boolean);
  89717. /**
  89718. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89719. * By default the system will update normals to compensate
  89720. */
  89721. ignoreNonUniformScaling: boolean;
  89722. /**
  89723. * 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
  89724. */
  89725. reIntegrateRotationIntoRotationQuaternion: boolean;
  89726. /** @hidden */
  89727. _poseMatrix: Nullable<Matrix>;
  89728. /** @hidden */
  89729. _localMatrix: Matrix;
  89730. private _usePivotMatrix;
  89731. private _absolutePosition;
  89732. private _absoluteScaling;
  89733. private _absoluteRotationQuaternion;
  89734. private _pivotMatrix;
  89735. private _pivotMatrixInverse;
  89736. protected _postMultiplyPivotMatrix: boolean;
  89737. protected _isWorldMatrixFrozen: boolean;
  89738. /** @hidden */
  89739. _indexInSceneTransformNodesArray: number;
  89740. /**
  89741. * An event triggered after the world matrix is updated
  89742. */
  89743. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89744. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89745. /**
  89746. * Gets a string identifying the name of the class
  89747. * @returns "TransformNode" string
  89748. */
  89749. getClassName(): string;
  89750. /**
  89751. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89752. */
  89753. get position(): Vector3;
  89754. set position(newPosition: Vector3);
  89755. /**
  89756. * 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)).
  89757. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89758. */
  89759. get rotation(): Vector3;
  89760. set rotation(newRotation: Vector3);
  89761. /**
  89762. * 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)).
  89763. */
  89764. get scaling(): Vector3;
  89765. set scaling(newScaling: Vector3);
  89766. /**
  89767. * 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).
  89768. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89769. */
  89770. get rotationQuaternion(): Nullable<Quaternion>;
  89771. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89772. /**
  89773. * The forward direction of that transform in world space.
  89774. */
  89775. get forward(): Vector3;
  89776. /**
  89777. * The up direction of that transform in world space.
  89778. */
  89779. get up(): Vector3;
  89780. /**
  89781. * The right direction of that transform in world space.
  89782. */
  89783. get right(): Vector3;
  89784. /**
  89785. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89786. * @param matrix the matrix to copy the pose from
  89787. * @returns this TransformNode.
  89788. */
  89789. updatePoseMatrix(matrix: Matrix): TransformNode;
  89790. /**
  89791. * Returns the mesh Pose matrix.
  89792. * @returns the pose matrix
  89793. */
  89794. getPoseMatrix(): Matrix;
  89795. /** @hidden */
  89796. _isSynchronized(): boolean;
  89797. /** @hidden */
  89798. _initCache(): void;
  89799. /**
  89800. * Flag the transform node as dirty (Forcing it to update everything)
  89801. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89802. * @returns this transform node
  89803. */
  89804. markAsDirty(property: string): TransformNode;
  89805. /**
  89806. * Returns the current mesh absolute position.
  89807. * Returns a Vector3.
  89808. */
  89809. get absolutePosition(): Vector3;
  89810. /**
  89811. * Returns the current mesh absolute scaling.
  89812. * Returns a Vector3.
  89813. */
  89814. get absoluteScaling(): Vector3;
  89815. /**
  89816. * Returns the current mesh absolute rotation.
  89817. * Returns a Quaternion.
  89818. */
  89819. get absoluteRotationQuaternion(): Quaternion;
  89820. /**
  89821. * Sets a new matrix to apply before all other transformation
  89822. * @param matrix defines the transform matrix
  89823. * @returns the current TransformNode
  89824. */
  89825. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89826. /**
  89827. * Sets a new pivot matrix to the current node
  89828. * @param matrix defines the new pivot matrix to use
  89829. * @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
  89830. * @returns the current TransformNode
  89831. */
  89832. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89833. /**
  89834. * Returns the mesh pivot matrix.
  89835. * Default : Identity.
  89836. * @returns the matrix
  89837. */
  89838. getPivotMatrix(): Matrix;
  89839. /**
  89840. * Instantiate (when possible) or clone that node with its hierarchy
  89841. * @param newParent defines the new parent to use for the instance (or clone)
  89842. * @param options defines options to configure how copy is done
  89843. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89844. * @returns an instance (or a clone) of the current node with its hiearchy
  89845. */
  89846. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89847. doNotInstantiate: boolean;
  89848. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89849. /**
  89850. * Prevents the World matrix to be computed any longer
  89851. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89852. * @returns the TransformNode.
  89853. */
  89854. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89855. /**
  89856. * Allows back the World matrix computation.
  89857. * @returns the TransformNode.
  89858. */
  89859. unfreezeWorldMatrix(): this;
  89860. /**
  89861. * True if the World matrix has been frozen.
  89862. */
  89863. get isWorldMatrixFrozen(): boolean;
  89864. /**
  89865. * Retuns the mesh absolute position in the World.
  89866. * @returns a Vector3.
  89867. */
  89868. getAbsolutePosition(): Vector3;
  89869. /**
  89870. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89871. * @param absolutePosition the absolute position to set
  89872. * @returns the TransformNode.
  89873. */
  89874. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89875. /**
  89876. * Sets the mesh position in its local space.
  89877. * @param vector3 the position to set in localspace
  89878. * @returns the TransformNode.
  89879. */
  89880. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89881. /**
  89882. * Returns the mesh position in the local space from the current World matrix values.
  89883. * @returns a new Vector3.
  89884. */
  89885. getPositionExpressedInLocalSpace(): Vector3;
  89886. /**
  89887. * Translates the mesh along the passed Vector3 in its local space.
  89888. * @param vector3 the distance to translate in localspace
  89889. * @returns the TransformNode.
  89890. */
  89891. locallyTranslate(vector3: Vector3): TransformNode;
  89892. private static _lookAtVectorCache;
  89893. /**
  89894. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89895. * @param targetPoint the position (must be in same space as current mesh) to look at
  89896. * @param yawCor optional yaw (y-axis) correction in radians
  89897. * @param pitchCor optional pitch (x-axis) correction in radians
  89898. * @param rollCor optional roll (z-axis) correction in radians
  89899. * @param space the choosen space of the target
  89900. * @returns the TransformNode.
  89901. */
  89902. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89903. /**
  89904. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89905. * This Vector3 is expressed in the World space.
  89906. * @param localAxis axis to rotate
  89907. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89908. */
  89909. getDirection(localAxis: Vector3): Vector3;
  89910. /**
  89911. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89912. * localAxis is expressed in the mesh local space.
  89913. * result is computed in the Wordl space from the mesh World matrix.
  89914. * @param localAxis axis to rotate
  89915. * @param result the resulting transformnode
  89916. * @returns this TransformNode.
  89917. */
  89918. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89919. /**
  89920. * Sets this transform node rotation to the given local axis.
  89921. * @param localAxis the axis in local space
  89922. * @param yawCor optional yaw (y-axis) correction in radians
  89923. * @param pitchCor optional pitch (x-axis) correction in radians
  89924. * @param rollCor optional roll (z-axis) correction in radians
  89925. * @returns this TransformNode
  89926. */
  89927. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89928. /**
  89929. * Sets a new pivot point to the current node
  89930. * @param point defines the new pivot point to use
  89931. * @param space defines if the point is in world or local space (local by default)
  89932. * @returns the current TransformNode
  89933. */
  89934. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89935. /**
  89936. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89937. * @returns the pivot point
  89938. */
  89939. getPivotPoint(): Vector3;
  89940. /**
  89941. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89942. * @param result the vector3 to store the result
  89943. * @returns this TransformNode.
  89944. */
  89945. getPivotPointToRef(result: Vector3): TransformNode;
  89946. /**
  89947. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89948. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89949. */
  89950. getAbsolutePivotPoint(): Vector3;
  89951. /**
  89952. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89953. * @param result vector3 to store the result
  89954. * @returns this TransformNode.
  89955. */
  89956. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  89957. /**
  89958. * Defines the passed node as the parent of the current node.
  89959. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89960. * @see https://doc.babylonjs.com/how_to/parenting
  89961. * @param node the node ot set as the parent
  89962. * @returns this TransformNode.
  89963. */
  89964. setParent(node: Nullable<Node>): TransformNode;
  89965. private _nonUniformScaling;
  89966. /**
  89967. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89968. */
  89969. get nonUniformScaling(): boolean;
  89970. /** @hidden */
  89971. _updateNonUniformScalingState(value: boolean): boolean;
  89972. /**
  89973. * Attach the current TransformNode to another TransformNode associated with a bone
  89974. * @param bone Bone affecting the TransformNode
  89975. * @param affectedTransformNode TransformNode associated with the bone
  89976. * @returns this object
  89977. */
  89978. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  89979. /**
  89980. * Detach the transform node if its associated with a bone
  89981. * @returns this object
  89982. */
  89983. detachFromBone(): TransformNode;
  89984. private static _rotationAxisCache;
  89985. /**
  89986. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89987. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89988. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89989. * The passed axis is also normalized.
  89990. * @param axis the axis to rotate around
  89991. * @param amount the amount to rotate in radians
  89992. * @param space Space to rotate in (Default: local)
  89993. * @returns the TransformNode.
  89994. */
  89995. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89996. /**
  89997. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89998. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89999. * The passed axis is also normalized. .
  90000. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90001. * @param point the point to rotate around
  90002. * @param axis the axis to rotate around
  90003. * @param amount the amount to rotate in radians
  90004. * @returns the TransformNode
  90005. */
  90006. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  90007. /**
  90008. * Translates the mesh along the axis vector for the passed distance in the given space.
  90009. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90010. * @param axis the axis to translate in
  90011. * @param distance the distance to translate
  90012. * @param space Space to rotate in (Default: local)
  90013. * @returns the TransformNode.
  90014. */
  90015. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90016. /**
  90017. * Adds a rotation step to the mesh current rotation.
  90018. * x, y, z are Euler angles expressed in radians.
  90019. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90020. * This means this rotation is made in the mesh local space only.
  90021. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90022. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90023. * ```javascript
  90024. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90025. * ```
  90026. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90027. * 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.
  90028. * @param x Rotation to add
  90029. * @param y Rotation to add
  90030. * @param z Rotation to add
  90031. * @returns the TransformNode.
  90032. */
  90033. addRotation(x: number, y: number, z: number): TransformNode;
  90034. /**
  90035. * @hidden
  90036. */
  90037. protected _getEffectiveParent(): Nullable<Node>;
  90038. /**
  90039. * Computes the world matrix of the node
  90040. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90041. * @returns the world matrix
  90042. */
  90043. computeWorldMatrix(force?: boolean): Matrix;
  90044. /**
  90045. * Resets this nodeTransform's local matrix to Matrix.Identity().
  90046. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  90047. */
  90048. resetLocalMatrix(independentOfChildren?: boolean): void;
  90049. protected _afterComputeWorldMatrix(): void;
  90050. /**
  90051. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  90052. * @param func callback function to add
  90053. *
  90054. * @returns the TransformNode.
  90055. */
  90056. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90057. /**
  90058. * Removes a registered callback function.
  90059. * @param func callback function to remove
  90060. * @returns the TransformNode.
  90061. */
  90062. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  90063. /**
  90064. * Gets the position of the current mesh in camera space
  90065. * @param camera defines the camera to use
  90066. * @returns a position
  90067. */
  90068. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  90069. /**
  90070. * Returns the distance from the mesh to the active camera
  90071. * @param camera defines the camera to use
  90072. * @returns the distance
  90073. */
  90074. getDistanceToCamera(camera?: Nullable<Camera>): number;
  90075. /**
  90076. * Clone the current transform node
  90077. * @param name Name of the new clone
  90078. * @param newParent New parent for the clone
  90079. * @param doNotCloneChildren Do not clone children hierarchy
  90080. * @returns the new transform node
  90081. */
  90082. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  90083. /**
  90084. * Serializes the objects information.
  90085. * @param currentSerializationObject defines the object to serialize in
  90086. * @returns the serialized object
  90087. */
  90088. serialize(currentSerializationObject?: any): any;
  90089. /**
  90090. * Returns a new TransformNode object parsed from the source provided.
  90091. * @param parsedTransformNode is the source.
  90092. * @param scene the scne the object belongs to
  90093. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90094. * @returns a new TransformNode object parsed from the source provided.
  90095. */
  90096. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  90097. /**
  90098. * Get all child-transformNodes of this node
  90099. * @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
  90100. * @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
  90101. * @returns an array of TransformNode
  90102. */
  90103. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  90104. /**
  90105. * Releases resources associated with this transform node.
  90106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90108. */
  90109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90110. /**
  90111. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90112. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90113. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90114. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90115. * @returns the current mesh
  90116. */
  90117. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  90118. private _syncAbsoluteScalingAndRotation;
  90119. }
  90120. }
  90121. declare module BABYLON {
  90122. /**
  90123. * Class used to override all child animations of a given target
  90124. */
  90125. export class AnimationPropertiesOverride {
  90126. /**
  90127. * Gets or sets a value indicating if animation blending must be used
  90128. */
  90129. enableBlending: boolean;
  90130. /**
  90131. * Gets or sets the blending speed to use when enableBlending is true
  90132. */
  90133. blendingSpeed: number;
  90134. /**
  90135. * Gets or sets the default loop mode to use
  90136. */
  90137. loopMode: number;
  90138. }
  90139. }
  90140. declare module BABYLON {
  90141. /**
  90142. * Class used to store bone information
  90143. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90144. */
  90145. export class Bone extends Node {
  90146. /**
  90147. * defines the bone name
  90148. */
  90149. name: string;
  90150. private static _tmpVecs;
  90151. private static _tmpQuat;
  90152. private static _tmpMats;
  90153. /**
  90154. * Gets the list of child bones
  90155. */
  90156. children: Bone[];
  90157. /** Gets the animations associated with this bone */
  90158. animations: Animation[];
  90159. /**
  90160. * Gets or sets bone length
  90161. */
  90162. length: number;
  90163. /**
  90164. * @hidden Internal only
  90165. * Set this value to map this bone to a different index in the transform matrices
  90166. * Set this value to -1 to exclude the bone from the transform matrices
  90167. */
  90168. _index: Nullable<number>;
  90169. private _skeleton;
  90170. private _localMatrix;
  90171. private _restPose;
  90172. private _baseMatrix;
  90173. private _absoluteTransform;
  90174. private _invertedAbsoluteTransform;
  90175. private _parent;
  90176. private _scalingDeterminant;
  90177. private _worldTransform;
  90178. private _localScaling;
  90179. private _localRotation;
  90180. private _localPosition;
  90181. private _needToDecompose;
  90182. private _needToCompose;
  90183. /** @hidden */
  90184. _linkedTransformNode: Nullable<TransformNode>;
  90185. /** @hidden */
  90186. _waitingTransformNodeId: Nullable<string>;
  90187. /** @hidden */
  90188. get _matrix(): Matrix;
  90189. /** @hidden */
  90190. set _matrix(value: Matrix);
  90191. /**
  90192. * Create a new bone
  90193. * @param name defines the bone name
  90194. * @param skeleton defines the parent skeleton
  90195. * @param parentBone defines the parent (can be null if the bone is the root)
  90196. * @param localMatrix defines the local matrix
  90197. * @param restPose defines the rest pose matrix
  90198. * @param baseMatrix defines the base matrix
  90199. * @param index defines index of the bone in the hiearchy
  90200. */
  90201. constructor(
  90202. /**
  90203. * defines the bone name
  90204. */
  90205. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90206. /**
  90207. * Gets the current object class name.
  90208. * @return the class name
  90209. */
  90210. getClassName(): string;
  90211. /**
  90212. * Gets the parent skeleton
  90213. * @returns a skeleton
  90214. */
  90215. getSkeleton(): Skeleton;
  90216. /**
  90217. * Gets parent bone
  90218. * @returns a bone or null if the bone is the root of the bone hierarchy
  90219. */
  90220. getParent(): Nullable<Bone>;
  90221. /**
  90222. * Returns an array containing the root bones
  90223. * @returns an array containing the root bones
  90224. */
  90225. getChildren(): Array<Bone>;
  90226. /**
  90227. * Gets the node index in matrix array generated for rendering
  90228. * @returns the node index
  90229. */
  90230. getIndex(): number;
  90231. /**
  90232. * Sets the parent bone
  90233. * @param parent defines the parent (can be null if the bone is the root)
  90234. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90235. */
  90236. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90237. /**
  90238. * Gets the local matrix
  90239. * @returns a matrix
  90240. */
  90241. getLocalMatrix(): Matrix;
  90242. /**
  90243. * Gets the base matrix (initial matrix which remains unchanged)
  90244. * @returns a matrix
  90245. */
  90246. getBaseMatrix(): Matrix;
  90247. /**
  90248. * Gets the rest pose matrix
  90249. * @returns a matrix
  90250. */
  90251. getRestPose(): Matrix;
  90252. /**
  90253. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90254. */
  90255. getWorldMatrix(): Matrix;
  90256. /**
  90257. * Sets the local matrix to rest pose matrix
  90258. */
  90259. returnToRest(): void;
  90260. /**
  90261. * Gets the inverse of the absolute transform matrix.
  90262. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90263. * @returns a matrix
  90264. */
  90265. getInvertedAbsoluteTransform(): Matrix;
  90266. /**
  90267. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90268. * @returns a matrix
  90269. */
  90270. getAbsoluteTransform(): Matrix;
  90271. /**
  90272. * Links with the given transform node.
  90273. * The local matrix of this bone is copied from the transform node every frame.
  90274. * @param transformNode defines the transform node to link to
  90275. */
  90276. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90277. /**
  90278. * Gets the node used to drive the bone's transformation
  90279. * @returns a transform node or null
  90280. */
  90281. getTransformNode(): Nullable<TransformNode>;
  90282. /** Gets or sets current position (in local space) */
  90283. get position(): Vector3;
  90284. set position(newPosition: Vector3);
  90285. /** Gets or sets current rotation (in local space) */
  90286. get rotation(): Vector3;
  90287. set rotation(newRotation: Vector3);
  90288. /** Gets or sets current rotation quaternion (in local space) */
  90289. get rotationQuaternion(): Quaternion;
  90290. set rotationQuaternion(newRotation: Quaternion);
  90291. /** Gets or sets current scaling (in local space) */
  90292. get scaling(): Vector3;
  90293. set scaling(newScaling: Vector3);
  90294. /**
  90295. * Gets the animation properties override
  90296. */
  90297. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90298. private _decompose;
  90299. private _compose;
  90300. /**
  90301. * Update the base and local matrices
  90302. * @param matrix defines the new base or local matrix
  90303. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90304. * @param updateLocalMatrix defines if the local matrix should be updated
  90305. */
  90306. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90307. /** @hidden */
  90308. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90309. /**
  90310. * Flag the bone as dirty (Forcing it to update everything)
  90311. */
  90312. markAsDirty(): void;
  90313. /** @hidden */
  90314. _markAsDirtyAndCompose(): void;
  90315. private _markAsDirtyAndDecompose;
  90316. /**
  90317. * Translate the bone in local or world space
  90318. * @param vec The amount to translate the bone
  90319. * @param space The space that the translation is in
  90320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90321. */
  90322. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90323. /**
  90324. * Set the postion of the bone in local or world space
  90325. * @param position The position to set the bone
  90326. * @param space The space that the position is in
  90327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90328. */
  90329. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90330. /**
  90331. * Set the absolute position of the bone (world space)
  90332. * @param position The position to set the bone
  90333. * @param mesh The mesh that this bone is attached to
  90334. */
  90335. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90336. /**
  90337. * Scale the bone on the x, y and z axes (in local space)
  90338. * @param x The amount to scale the bone on the x axis
  90339. * @param y The amount to scale the bone on the y axis
  90340. * @param z The amount to scale the bone on the z axis
  90341. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90342. */
  90343. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90344. /**
  90345. * Set the bone scaling in local space
  90346. * @param scale defines the scaling vector
  90347. */
  90348. setScale(scale: Vector3): void;
  90349. /**
  90350. * Gets the current scaling in local space
  90351. * @returns the current scaling vector
  90352. */
  90353. getScale(): Vector3;
  90354. /**
  90355. * Gets the current scaling in local space and stores it in a target vector
  90356. * @param result defines the target vector
  90357. */
  90358. getScaleToRef(result: Vector3): void;
  90359. /**
  90360. * Set the yaw, pitch, and roll of the bone in local or world space
  90361. * @param yaw The rotation of the bone on the y axis
  90362. * @param pitch The rotation of the bone on the x axis
  90363. * @param roll The rotation of the bone on the z axis
  90364. * @param space The space that the axes of rotation are in
  90365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90366. */
  90367. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90368. /**
  90369. * Add a rotation to the bone on an axis in local or world space
  90370. * @param axis The axis to rotate the bone on
  90371. * @param amount The amount to rotate the bone
  90372. * @param space The space that the axis is in
  90373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90374. */
  90375. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90376. /**
  90377. * Set the rotation of the bone to a particular axis angle in local or world space
  90378. * @param axis The axis to rotate the bone on
  90379. * @param angle The angle that the bone should be rotated to
  90380. * @param space The space that the axis is in
  90381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90382. */
  90383. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90384. /**
  90385. * Set the euler rotation of the bone in local of world space
  90386. * @param rotation The euler rotation that the bone should be set to
  90387. * @param space The space that the rotation is in
  90388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90389. */
  90390. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90391. /**
  90392. * Set the quaternion rotation of the bone in local of world space
  90393. * @param quat The quaternion rotation that the bone should be set to
  90394. * @param space The space that the rotation is in
  90395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90396. */
  90397. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90398. /**
  90399. * Set the rotation matrix of the bone in local of world space
  90400. * @param rotMat The rotation matrix that the bone should be set to
  90401. * @param space The space that the rotation is in
  90402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90403. */
  90404. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90405. private _rotateWithMatrix;
  90406. private _getNegativeRotationToRef;
  90407. /**
  90408. * Get the position of the bone in local or world space
  90409. * @param space The space that the returned position is in
  90410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90411. * @returns The position of the bone
  90412. */
  90413. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90414. /**
  90415. * Copy the position of the bone to a vector3 in local or world space
  90416. * @param space The space that the returned position is in
  90417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90418. * @param result The vector3 to copy the position to
  90419. */
  90420. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90421. /**
  90422. * Get the absolute position of the bone (world space)
  90423. * @param mesh The mesh that this bone is attached to
  90424. * @returns The absolute position of the bone
  90425. */
  90426. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90427. /**
  90428. * Copy the absolute position of the bone (world space) to the result param
  90429. * @param mesh The mesh that this bone is attached to
  90430. * @param result The vector3 to copy the absolute position to
  90431. */
  90432. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90433. /**
  90434. * Compute the absolute transforms of this bone and its children
  90435. */
  90436. computeAbsoluteTransforms(): void;
  90437. /**
  90438. * Get the world direction from an axis that is in the local space of the bone
  90439. * @param localAxis The local direction that is used to compute the world direction
  90440. * @param mesh The mesh that this bone is attached to
  90441. * @returns The world direction
  90442. */
  90443. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90444. /**
  90445. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90446. * @param localAxis The local direction that is used to compute the world direction
  90447. * @param mesh The mesh that this bone is attached to
  90448. * @param result The vector3 that the world direction will be copied to
  90449. */
  90450. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90451. /**
  90452. * Get the euler rotation of the bone in local or world space
  90453. * @param space The space that the rotation should be in
  90454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90455. * @returns The euler rotation
  90456. */
  90457. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90458. /**
  90459. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90460. * @param space The space that the rotation should be in
  90461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90462. * @param result The vector3 that the rotation should be copied to
  90463. */
  90464. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90465. /**
  90466. * Get the quaternion rotation of the bone in either local or world space
  90467. * @param space The space that the rotation should be in
  90468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90469. * @returns The quaternion rotation
  90470. */
  90471. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90472. /**
  90473. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90474. * @param space The space that the rotation should be in
  90475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90476. * @param result The quaternion that the rotation should be copied to
  90477. */
  90478. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90479. /**
  90480. * Get the rotation matrix of the bone in local or world space
  90481. * @param space The space that the rotation should be in
  90482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90483. * @returns The rotation matrix
  90484. */
  90485. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90486. /**
  90487. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90488. * @param space The space that the rotation should be in
  90489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90490. * @param result The quaternion that the rotation should be copied to
  90491. */
  90492. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90493. /**
  90494. * Get the world position of a point that is in the local space of the bone
  90495. * @param position The local position
  90496. * @param mesh The mesh that this bone is attached to
  90497. * @returns The world position
  90498. */
  90499. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90500. /**
  90501. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90502. * @param position The local position
  90503. * @param mesh The mesh that this bone is attached to
  90504. * @param result The vector3 that the world position should be copied to
  90505. */
  90506. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90507. /**
  90508. * Get the local position of a point that is in world space
  90509. * @param position The world position
  90510. * @param mesh The mesh that this bone is attached to
  90511. * @returns The local position
  90512. */
  90513. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90514. /**
  90515. * Get the local position of a point that is in world space and copy it to the result param
  90516. * @param position The world position
  90517. * @param mesh The mesh that this bone is attached to
  90518. * @param result The vector3 that the local position should be copied to
  90519. */
  90520. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90521. }
  90522. }
  90523. declare module BABYLON {
  90524. /**
  90525. * Defines a runtime animation
  90526. */
  90527. export class RuntimeAnimation {
  90528. private _events;
  90529. /**
  90530. * The current frame of the runtime animation
  90531. */
  90532. private _currentFrame;
  90533. /**
  90534. * The animation used by the runtime animation
  90535. */
  90536. private _animation;
  90537. /**
  90538. * The target of the runtime animation
  90539. */
  90540. private _target;
  90541. /**
  90542. * The initiating animatable
  90543. */
  90544. private _host;
  90545. /**
  90546. * The original value of the runtime animation
  90547. */
  90548. private _originalValue;
  90549. /**
  90550. * The original blend value of the runtime animation
  90551. */
  90552. private _originalBlendValue;
  90553. /**
  90554. * The offsets cache of the runtime animation
  90555. */
  90556. private _offsetsCache;
  90557. /**
  90558. * The high limits cache of the runtime animation
  90559. */
  90560. private _highLimitsCache;
  90561. /**
  90562. * Specifies if the runtime animation has been stopped
  90563. */
  90564. private _stopped;
  90565. /**
  90566. * The blending factor of the runtime animation
  90567. */
  90568. private _blendingFactor;
  90569. /**
  90570. * The BabylonJS scene
  90571. */
  90572. private _scene;
  90573. /**
  90574. * The current value of the runtime animation
  90575. */
  90576. private _currentValue;
  90577. /** @hidden */
  90578. _animationState: _IAnimationState;
  90579. /**
  90580. * The active target of the runtime animation
  90581. */
  90582. private _activeTargets;
  90583. private _currentActiveTarget;
  90584. private _directTarget;
  90585. /**
  90586. * The target path of the runtime animation
  90587. */
  90588. private _targetPath;
  90589. /**
  90590. * The weight of the runtime animation
  90591. */
  90592. private _weight;
  90593. /**
  90594. * The ratio offset of the runtime animation
  90595. */
  90596. private _ratioOffset;
  90597. /**
  90598. * The previous delay of the runtime animation
  90599. */
  90600. private _previousDelay;
  90601. /**
  90602. * The previous ratio of the runtime animation
  90603. */
  90604. private _previousRatio;
  90605. private _enableBlending;
  90606. private _keys;
  90607. private _minFrame;
  90608. private _maxFrame;
  90609. private _minValue;
  90610. private _maxValue;
  90611. private _targetIsArray;
  90612. /**
  90613. * Gets the current frame of the runtime animation
  90614. */
  90615. get currentFrame(): number;
  90616. /**
  90617. * Gets the weight of the runtime animation
  90618. */
  90619. get weight(): number;
  90620. /**
  90621. * Gets the current value of the runtime animation
  90622. */
  90623. get currentValue(): any;
  90624. /**
  90625. * Gets the target path of the runtime animation
  90626. */
  90627. get targetPath(): string;
  90628. /**
  90629. * Gets the actual target of the runtime animation
  90630. */
  90631. get target(): any;
  90632. /**
  90633. * Gets the additive state of the runtime animation
  90634. */
  90635. get isAdditive(): boolean;
  90636. /** @hidden */
  90637. _onLoop: () => void;
  90638. /**
  90639. * Create a new RuntimeAnimation object
  90640. * @param target defines the target of the animation
  90641. * @param animation defines the source animation object
  90642. * @param scene defines the hosting scene
  90643. * @param host defines the initiating Animatable
  90644. */
  90645. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90646. private _preparePath;
  90647. /**
  90648. * Gets the animation from the runtime animation
  90649. */
  90650. get animation(): Animation;
  90651. /**
  90652. * Resets the runtime animation to the beginning
  90653. * @param restoreOriginal defines whether to restore the target property to the original value
  90654. */
  90655. reset(restoreOriginal?: boolean): void;
  90656. /**
  90657. * Specifies if the runtime animation is stopped
  90658. * @returns Boolean specifying if the runtime animation is stopped
  90659. */
  90660. isStopped(): boolean;
  90661. /**
  90662. * Disposes of the runtime animation
  90663. */
  90664. dispose(): void;
  90665. /**
  90666. * Apply the interpolated value to the target
  90667. * @param currentValue defines the value computed by the animation
  90668. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90669. */
  90670. setValue(currentValue: any, weight: number): void;
  90671. private _getOriginalValues;
  90672. private _setValue;
  90673. /**
  90674. * Gets the loop pmode of the runtime animation
  90675. * @returns Loop Mode
  90676. */
  90677. private _getCorrectLoopMode;
  90678. /**
  90679. * Move the current animation to a given frame
  90680. * @param frame defines the frame to move to
  90681. */
  90682. goToFrame(frame: number): void;
  90683. /**
  90684. * @hidden Internal use only
  90685. */
  90686. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90687. /**
  90688. * Execute the current animation
  90689. * @param delay defines the delay to add to the current frame
  90690. * @param from defines the lower bound of the animation range
  90691. * @param to defines the upper bound of the animation range
  90692. * @param loop defines if the current animation must loop
  90693. * @param speedRatio defines the current speed ratio
  90694. * @param weight defines the weight of the animation (default is -1 so no weight)
  90695. * @param onLoop optional callback called when animation loops
  90696. * @returns a boolean indicating if the animation is running
  90697. */
  90698. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90699. }
  90700. }
  90701. declare module BABYLON {
  90702. /**
  90703. * Class used to store an actual running animation
  90704. */
  90705. export class Animatable {
  90706. /** defines the target object */
  90707. target: any;
  90708. /** defines the starting frame number (default is 0) */
  90709. fromFrame: number;
  90710. /** defines the ending frame number (default is 100) */
  90711. toFrame: number;
  90712. /** defines if the animation must loop (default is false) */
  90713. loopAnimation: boolean;
  90714. /** defines a callback to call when animation ends if it is not looping */
  90715. onAnimationEnd?: (() => void) | null | undefined;
  90716. /** defines a callback to call when animation loops */
  90717. onAnimationLoop?: (() => void) | null | undefined;
  90718. /** defines whether the animation should be evaluated additively */
  90719. isAdditive: boolean;
  90720. private _localDelayOffset;
  90721. private _pausedDelay;
  90722. private _runtimeAnimations;
  90723. private _paused;
  90724. private _scene;
  90725. private _speedRatio;
  90726. private _weight;
  90727. private _syncRoot;
  90728. /**
  90729. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90730. * This will only apply for non looping animation (default is true)
  90731. */
  90732. disposeOnEnd: boolean;
  90733. /**
  90734. * Gets a boolean indicating if the animation has started
  90735. */
  90736. animationStarted: boolean;
  90737. /**
  90738. * Observer raised when the animation ends
  90739. */
  90740. onAnimationEndObservable: Observable<Animatable>;
  90741. /**
  90742. * Observer raised when the animation loops
  90743. */
  90744. onAnimationLoopObservable: Observable<Animatable>;
  90745. /**
  90746. * Gets the root Animatable used to synchronize and normalize animations
  90747. */
  90748. get syncRoot(): Nullable<Animatable>;
  90749. /**
  90750. * Gets the current frame of the first RuntimeAnimation
  90751. * Used to synchronize Animatables
  90752. */
  90753. get masterFrame(): number;
  90754. /**
  90755. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90756. */
  90757. get weight(): number;
  90758. set weight(value: number);
  90759. /**
  90760. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90761. */
  90762. get speedRatio(): number;
  90763. set speedRatio(value: number);
  90764. /**
  90765. * Creates a new Animatable
  90766. * @param scene defines the hosting scene
  90767. * @param target defines the target object
  90768. * @param fromFrame defines the starting frame number (default is 0)
  90769. * @param toFrame defines the ending frame number (default is 100)
  90770. * @param loopAnimation defines if the animation must loop (default is false)
  90771. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90772. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90773. * @param animations defines a group of animation to add to the new Animatable
  90774. * @param onAnimationLoop defines a callback to call when animation loops
  90775. * @param isAdditive defines whether the animation should be evaluated additively
  90776. */
  90777. constructor(scene: Scene,
  90778. /** defines the target object */
  90779. target: any,
  90780. /** defines the starting frame number (default is 0) */
  90781. fromFrame?: number,
  90782. /** defines the ending frame number (default is 100) */
  90783. toFrame?: number,
  90784. /** defines if the animation must loop (default is false) */
  90785. loopAnimation?: boolean, speedRatio?: number,
  90786. /** defines a callback to call when animation ends if it is not looping */
  90787. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90788. /** defines a callback to call when animation loops */
  90789. onAnimationLoop?: (() => void) | null | undefined,
  90790. /** defines whether the animation should be evaluated additively */
  90791. isAdditive?: boolean);
  90792. /**
  90793. * Synchronize and normalize current Animatable with a source Animatable
  90794. * This is useful when using animation weights and when animations are not of the same length
  90795. * @param root defines the root Animatable to synchronize with
  90796. * @returns the current Animatable
  90797. */
  90798. syncWith(root: Animatable): Animatable;
  90799. /**
  90800. * Gets the list of runtime animations
  90801. * @returns an array of RuntimeAnimation
  90802. */
  90803. getAnimations(): RuntimeAnimation[];
  90804. /**
  90805. * Adds more animations to the current animatable
  90806. * @param target defines the target of the animations
  90807. * @param animations defines the new animations to add
  90808. */
  90809. appendAnimations(target: any, animations: Animation[]): void;
  90810. /**
  90811. * Gets the source animation for a specific property
  90812. * @param property defines the propertyu to look for
  90813. * @returns null or the source animation for the given property
  90814. */
  90815. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90816. /**
  90817. * Gets the runtime animation for a specific property
  90818. * @param property defines the propertyu to look for
  90819. * @returns null or the runtime animation for the given property
  90820. */
  90821. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90822. /**
  90823. * Resets the animatable to its original state
  90824. */
  90825. reset(): void;
  90826. /**
  90827. * Allows the animatable to blend with current running animations
  90828. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90829. * @param blendingSpeed defines the blending speed to use
  90830. */
  90831. enableBlending(blendingSpeed: number): void;
  90832. /**
  90833. * Disable animation blending
  90834. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90835. */
  90836. disableBlending(): void;
  90837. /**
  90838. * Jump directly to a given frame
  90839. * @param frame defines the frame to jump to
  90840. */
  90841. goToFrame(frame: number): void;
  90842. /**
  90843. * Pause the animation
  90844. */
  90845. pause(): void;
  90846. /**
  90847. * Restart the animation
  90848. */
  90849. restart(): void;
  90850. private _raiseOnAnimationEnd;
  90851. /**
  90852. * Stop and delete the current animation
  90853. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90854. * @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)
  90855. */
  90856. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90857. /**
  90858. * Wait asynchronously for the animation to end
  90859. * @returns a promise which will be fullfilled when the animation ends
  90860. */
  90861. waitAsync(): Promise<Animatable>;
  90862. /** @hidden */
  90863. _animate(delay: number): boolean;
  90864. }
  90865. interface Scene {
  90866. /** @hidden */
  90867. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90868. /** @hidden */
  90869. _processLateAnimationBindingsForMatrices(holder: {
  90870. totalWeight: number;
  90871. totalAdditiveWeight: number;
  90872. animations: RuntimeAnimation[];
  90873. additiveAnimations: RuntimeAnimation[];
  90874. originalValue: Matrix;
  90875. }): any;
  90876. /** @hidden */
  90877. _processLateAnimationBindingsForQuaternions(holder: {
  90878. totalWeight: number;
  90879. totalAdditiveWeight: number;
  90880. animations: RuntimeAnimation[];
  90881. additiveAnimations: RuntimeAnimation[];
  90882. originalValue: Quaternion;
  90883. }, refQuaternion: Quaternion): Quaternion;
  90884. /** @hidden */
  90885. _processLateAnimationBindings(): void;
  90886. /**
  90887. * Will start the animation sequence of a given target
  90888. * @param target defines the target
  90889. * @param from defines from which frame should animation start
  90890. * @param to defines until which frame should animation run.
  90891. * @param weight defines the weight to apply to the animation (1.0 by default)
  90892. * @param loop defines if the animation loops
  90893. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90894. * @param onAnimationEnd defines the function to be executed when the animation ends
  90895. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90896. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90897. * @param onAnimationLoop defines the callback to call when an animation loops
  90898. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90899. * @returns the animatable object created for this animation
  90900. */
  90901. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90902. /**
  90903. * Will start the animation sequence of a given target
  90904. * @param target defines the target
  90905. * @param from defines from which frame should animation start
  90906. * @param to defines until which frame should animation run.
  90907. * @param loop defines if the animation loops
  90908. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90909. * @param onAnimationEnd defines the function to be executed when the animation ends
  90910. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90911. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90912. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90913. * @param onAnimationLoop defines the callback to call when an animation loops
  90914. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90915. * @returns the animatable object created for this animation
  90916. */
  90917. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90918. /**
  90919. * Will start the animation sequence of a given target and its hierarchy
  90920. * @param target defines the target
  90921. * @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.
  90922. * @param from defines from which frame should animation start
  90923. * @param to defines until which frame should animation run.
  90924. * @param loop defines if the animation loops
  90925. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90926. * @param onAnimationEnd defines the function to be executed when the animation ends
  90927. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90928. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90929. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90930. * @param onAnimationLoop defines the callback to call when an animation loops
  90931. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90932. * @returns the list of created animatables
  90933. */
  90934. 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, isAdditive?: boolean): Animatable[];
  90935. /**
  90936. * Begin a new animation on a given node
  90937. * @param target defines the target where the animation will take place
  90938. * @param animations defines the list of animations to start
  90939. * @param from defines the initial value
  90940. * @param to defines the final value
  90941. * @param loop defines if you want animation to loop (off by default)
  90942. * @param speedRatio defines the speed ratio to apply to all animations
  90943. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90944. * @param onAnimationLoop defines the callback to call when an animation loops
  90945. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90946. * @returns the list of created animatables
  90947. */
  90948. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90949. /**
  90950. * Begin a new animation on a given node and its hierarchy
  90951. * @param target defines the root node where the animation will take place
  90952. * @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.
  90953. * @param animations defines the list of animations to start
  90954. * @param from defines the initial value
  90955. * @param to defines the final value
  90956. * @param loop defines if you want animation to loop (off by default)
  90957. * @param speedRatio defines the speed ratio to apply to all animations
  90958. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90959. * @param onAnimationLoop defines the callback to call when an animation loops
  90960. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90961. * @returns the list of animatables created for all nodes
  90962. */
  90963. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90964. /**
  90965. * Gets the animatable associated with a specific target
  90966. * @param target defines the target of the animatable
  90967. * @returns the required animatable if found
  90968. */
  90969. getAnimatableByTarget(target: any): Nullable<Animatable>;
  90970. /**
  90971. * Gets all animatables associated with a given target
  90972. * @param target defines the target to look animatables for
  90973. * @returns an array of Animatables
  90974. */
  90975. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  90976. /**
  90977. * Stops and removes all animations that have been applied to the scene
  90978. */
  90979. stopAllAnimations(): void;
  90980. /**
  90981. * Gets the current delta time used by animation engine
  90982. */
  90983. deltaTime: number;
  90984. }
  90985. interface Bone {
  90986. /**
  90987. * Copy an animation range from another bone
  90988. * @param source defines the source bone
  90989. * @param rangeName defines the range name to copy
  90990. * @param frameOffset defines the frame offset
  90991. * @param rescaleAsRequired defines if rescaling must be applied if required
  90992. * @param skelDimensionsRatio defines the scaling ratio
  90993. * @returns true if operation was successful
  90994. */
  90995. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  90996. }
  90997. }
  90998. declare module BABYLON {
  90999. /**
  91000. * Class used to handle skinning animations
  91001. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91002. */
  91003. export class Skeleton implements IAnimatable {
  91004. /** defines the skeleton name */
  91005. name: string;
  91006. /** defines the skeleton Id */
  91007. id: string;
  91008. /**
  91009. * Defines the list of child bones
  91010. */
  91011. bones: Bone[];
  91012. /**
  91013. * Defines an estimate of the dimension of the skeleton at rest
  91014. */
  91015. dimensionsAtRest: Vector3;
  91016. /**
  91017. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  91018. */
  91019. needInitialSkinMatrix: boolean;
  91020. /**
  91021. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  91022. */
  91023. overrideMesh: Nullable<AbstractMesh>;
  91024. /**
  91025. * Gets the list of animations attached to this skeleton
  91026. */
  91027. animations: Array<Animation>;
  91028. private _scene;
  91029. private _isDirty;
  91030. private _transformMatrices;
  91031. private _transformMatrixTexture;
  91032. private _meshesWithPoseMatrix;
  91033. private _animatables;
  91034. private _identity;
  91035. private _synchronizedWithMesh;
  91036. private _ranges;
  91037. private _lastAbsoluteTransformsUpdateId;
  91038. private _canUseTextureForBones;
  91039. private _uniqueId;
  91040. /** @hidden */
  91041. _numBonesWithLinkedTransformNode: number;
  91042. /** @hidden */
  91043. _hasWaitingData: Nullable<boolean>;
  91044. /**
  91045. * Specifies if the skeleton should be serialized
  91046. */
  91047. doNotSerialize: boolean;
  91048. private _useTextureToStoreBoneMatrices;
  91049. /**
  91050. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  91051. * Please note that this option is not available if the hardware does not support it
  91052. */
  91053. get useTextureToStoreBoneMatrices(): boolean;
  91054. set useTextureToStoreBoneMatrices(value: boolean);
  91055. private _animationPropertiesOverride;
  91056. /**
  91057. * Gets or sets the animation properties override
  91058. */
  91059. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  91060. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  91061. /**
  91062. * List of inspectable custom properties (used by the Inspector)
  91063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91064. */
  91065. inspectableCustomProperties: IInspectable[];
  91066. /**
  91067. * An observable triggered before computing the skeleton's matrices
  91068. */
  91069. onBeforeComputeObservable: Observable<Skeleton>;
  91070. /**
  91071. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  91072. */
  91073. get isUsingTextureForMatrices(): boolean;
  91074. /**
  91075. * Gets the unique ID of this skeleton
  91076. */
  91077. get uniqueId(): number;
  91078. /**
  91079. * Creates a new skeleton
  91080. * @param name defines the skeleton name
  91081. * @param id defines the skeleton Id
  91082. * @param scene defines the hosting scene
  91083. */
  91084. constructor(
  91085. /** defines the skeleton name */
  91086. name: string,
  91087. /** defines the skeleton Id */
  91088. id: string, scene: Scene);
  91089. /**
  91090. * Gets the current object class name.
  91091. * @return the class name
  91092. */
  91093. getClassName(): string;
  91094. /**
  91095. * Returns an array containing the root bones
  91096. * @returns an array containing the root bones
  91097. */
  91098. getChildren(): Array<Bone>;
  91099. /**
  91100. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  91101. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91102. * @returns a Float32Array containing matrices data
  91103. */
  91104. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  91105. /**
  91106. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  91107. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  91108. * @returns a raw texture containing the data
  91109. */
  91110. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  91111. /**
  91112. * Gets the current hosting scene
  91113. * @returns a scene object
  91114. */
  91115. getScene(): Scene;
  91116. /**
  91117. * Gets a string representing the current skeleton data
  91118. * @param fullDetails defines a boolean indicating if we want a verbose version
  91119. * @returns a string representing the current skeleton data
  91120. */
  91121. toString(fullDetails?: boolean): string;
  91122. /**
  91123. * Get bone's index searching by name
  91124. * @param name defines bone's name to search for
  91125. * @return the indice of the bone. Returns -1 if not found
  91126. */
  91127. getBoneIndexByName(name: string): number;
  91128. /**
  91129. * Creater a new animation range
  91130. * @param name defines the name of the range
  91131. * @param from defines the start key
  91132. * @param to defines the end key
  91133. */
  91134. createAnimationRange(name: string, from: number, to: number): void;
  91135. /**
  91136. * Delete a specific animation range
  91137. * @param name defines the name of the range
  91138. * @param deleteFrames defines if frames must be removed as well
  91139. */
  91140. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91141. /**
  91142. * Gets a specific animation range
  91143. * @param name defines the name of the range to look for
  91144. * @returns the requested animation range or null if not found
  91145. */
  91146. getAnimationRange(name: string): Nullable<AnimationRange>;
  91147. /**
  91148. * Gets the list of all animation ranges defined on this skeleton
  91149. * @returns an array
  91150. */
  91151. getAnimationRanges(): Nullable<AnimationRange>[];
  91152. /**
  91153. * Copy animation range from a source skeleton.
  91154. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  91155. * @param source defines the source skeleton
  91156. * @param name defines the name of the range to copy
  91157. * @param rescaleAsRequired defines if rescaling must be applied if required
  91158. * @returns true if operation was successful
  91159. */
  91160. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  91161. /**
  91162. * Forces the skeleton to go to rest pose
  91163. */
  91164. returnToRest(): void;
  91165. private _getHighestAnimationFrame;
  91166. /**
  91167. * Begin a specific animation range
  91168. * @param name defines the name of the range to start
  91169. * @param loop defines if looping must be turned on (false by default)
  91170. * @param speedRatio defines the speed ratio to apply (1 by default)
  91171. * @param onAnimationEnd defines a callback which will be called when animation will end
  91172. * @returns a new animatable
  91173. */
  91174. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91175. /**
  91176. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  91177. * @param skeleton defines the Skeleton containing the animation range to convert
  91178. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  91179. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  91180. * @returns the original skeleton
  91181. */
  91182. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  91183. /** @hidden */
  91184. _markAsDirty(): void;
  91185. /** @hidden */
  91186. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91187. /** @hidden */
  91188. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  91189. private _computeTransformMatrices;
  91190. /**
  91191. * Build all resources required to render a skeleton
  91192. */
  91193. prepare(): void;
  91194. /**
  91195. * Gets the list of animatables currently running for this skeleton
  91196. * @returns an array of animatables
  91197. */
  91198. getAnimatables(): IAnimatable[];
  91199. /**
  91200. * Clone the current skeleton
  91201. * @param name defines the name of the new skeleton
  91202. * @param id defines the id of the new skeleton
  91203. * @returns the new skeleton
  91204. */
  91205. clone(name: string, id?: string): Skeleton;
  91206. /**
  91207. * Enable animation blending for this skeleton
  91208. * @param blendingSpeed defines the blending speed to apply
  91209. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91210. */
  91211. enableBlending(blendingSpeed?: number): void;
  91212. /**
  91213. * Releases all resources associated with the current skeleton
  91214. */
  91215. dispose(): void;
  91216. /**
  91217. * Serialize the skeleton in a JSON object
  91218. * @returns a JSON object
  91219. */
  91220. serialize(): any;
  91221. /**
  91222. * Creates a new skeleton from serialized data
  91223. * @param parsedSkeleton defines the serialized data
  91224. * @param scene defines the hosting scene
  91225. * @returns a new skeleton
  91226. */
  91227. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91228. /**
  91229. * Compute all node absolute transforms
  91230. * @param forceUpdate defines if computation must be done even if cache is up to date
  91231. */
  91232. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91233. /**
  91234. * Gets the root pose matrix
  91235. * @returns a matrix
  91236. */
  91237. getPoseMatrix(): Nullable<Matrix>;
  91238. /**
  91239. * Sorts bones per internal index
  91240. */
  91241. sortBones(): void;
  91242. private _sortBones;
  91243. }
  91244. }
  91245. declare module BABYLON {
  91246. /**
  91247. * Creates an instance based on a source mesh.
  91248. */
  91249. export class InstancedMesh extends AbstractMesh {
  91250. private _sourceMesh;
  91251. private _currentLOD;
  91252. /** @hidden */
  91253. _indexInSourceMeshInstanceArray: number;
  91254. constructor(name: string, source: Mesh);
  91255. /**
  91256. * Returns the string "InstancedMesh".
  91257. */
  91258. getClassName(): string;
  91259. /** Gets the list of lights affecting that mesh */
  91260. get lightSources(): Light[];
  91261. _resyncLightSources(): void;
  91262. _resyncLightSource(light: Light): void;
  91263. _removeLightSource(light: Light, dispose: boolean): void;
  91264. /**
  91265. * If the source mesh receives shadows
  91266. */
  91267. get receiveShadows(): boolean;
  91268. /**
  91269. * The material of the source mesh
  91270. */
  91271. get material(): Nullable<Material>;
  91272. /**
  91273. * Visibility of the source mesh
  91274. */
  91275. get visibility(): number;
  91276. /**
  91277. * Skeleton of the source mesh
  91278. */
  91279. get skeleton(): Nullable<Skeleton>;
  91280. /**
  91281. * Rendering ground id of the source mesh
  91282. */
  91283. get renderingGroupId(): number;
  91284. set renderingGroupId(value: number);
  91285. /**
  91286. * Returns the total number of vertices (integer).
  91287. */
  91288. getTotalVertices(): number;
  91289. /**
  91290. * Returns a positive integer : the total number of indices in this mesh geometry.
  91291. * @returns the numner of indices or zero if the mesh has no geometry.
  91292. */
  91293. getTotalIndices(): number;
  91294. /**
  91295. * The source mesh of the instance
  91296. */
  91297. get sourceMesh(): Mesh;
  91298. /**
  91299. * Is this node ready to be used/rendered
  91300. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91301. * @return {boolean} is it ready
  91302. */
  91303. isReady(completeCheck?: boolean): boolean;
  91304. /**
  91305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91306. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91307. * @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.
  91308. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91309. */
  91310. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91311. /**
  91312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91314. * The `data` are either a numeric array either a Float32Array.
  91315. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91316. * 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).
  91317. * Note that a new underlying VertexBuffer object is created each call.
  91318. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91319. *
  91320. * Possible `kind` values :
  91321. * - VertexBuffer.PositionKind
  91322. * - VertexBuffer.UVKind
  91323. * - VertexBuffer.UV2Kind
  91324. * - VertexBuffer.UV3Kind
  91325. * - VertexBuffer.UV4Kind
  91326. * - VertexBuffer.UV5Kind
  91327. * - VertexBuffer.UV6Kind
  91328. * - VertexBuffer.ColorKind
  91329. * - VertexBuffer.MatricesIndicesKind
  91330. * - VertexBuffer.MatricesIndicesExtraKind
  91331. * - VertexBuffer.MatricesWeightsKind
  91332. * - VertexBuffer.MatricesWeightsExtraKind
  91333. *
  91334. * Returns the Mesh.
  91335. */
  91336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91337. /**
  91338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91339. * If the mesh has no geometry, it is simply returned as it is.
  91340. * The `data` are either a numeric array either a Float32Array.
  91341. * No new underlying VertexBuffer object is created.
  91342. * 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.
  91343. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91344. *
  91345. * Possible `kind` values :
  91346. * - VertexBuffer.PositionKind
  91347. * - VertexBuffer.UVKind
  91348. * - VertexBuffer.UV2Kind
  91349. * - VertexBuffer.UV3Kind
  91350. * - VertexBuffer.UV4Kind
  91351. * - VertexBuffer.UV5Kind
  91352. * - VertexBuffer.UV6Kind
  91353. * - VertexBuffer.ColorKind
  91354. * - VertexBuffer.MatricesIndicesKind
  91355. * - VertexBuffer.MatricesIndicesExtraKind
  91356. * - VertexBuffer.MatricesWeightsKind
  91357. * - VertexBuffer.MatricesWeightsExtraKind
  91358. *
  91359. * Returns the Mesh.
  91360. */
  91361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91362. /**
  91363. * Sets the mesh indices.
  91364. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91366. * This method creates a new index buffer each call.
  91367. * Returns the Mesh.
  91368. */
  91369. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91370. /**
  91371. * Boolean : True if the mesh owns the requested kind of data.
  91372. */
  91373. isVerticesDataPresent(kind: string): boolean;
  91374. /**
  91375. * Returns an array of indices (IndicesArray).
  91376. */
  91377. getIndices(): Nullable<IndicesArray>;
  91378. get _positions(): Nullable<Vector3[]>;
  91379. /**
  91380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91381. * This means the mesh underlying bounding box and sphere are recomputed.
  91382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91383. * @returns the current mesh
  91384. */
  91385. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91386. /** @hidden */
  91387. _preActivate(): InstancedMesh;
  91388. /** @hidden */
  91389. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91390. /** @hidden */
  91391. _postActivate(): void;
  91392. getWorldMatrix(): Matrix;
  91393. get isAnInstance(): boolean;
  91394. /**
  91395. * Returns the current associated LOD AbstractMesh.
  91396. */
  91397. getLOD(camera: Camera): AbstractMesh;
  91398. /** @hidden */
  91399. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91400. /** @hidden */
  91401. _syncSubMeshes(): InstancedMesh;
  91402. /** @hidden */
  91403. _generatePointsArray(): boolean;
  91404. /**
  91405. * Creates a new InstancedMesh from the current mesh.
  91406. * - name (string) : the cloned mesh name
  91407. * - newParent (optional Node) : the optional Node to parent the clone to.
  91408. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91409. *
  91410. * Returns the clone.
  91411. */
  91412. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91413. /**
  91414. * Disposes the InstancedMesh.
  91415. * Returns nothing.
  91416. */
  91417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91418. }
  91419. interface Mesh {
  91420. /**
  91421. * Register a custom buffer that will be instanced
  91422. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91423. * @param kind defines the buffer kind
  91424. * @param stride defines the stride in floats
  91425. */
  91426. registerInstancedBuffer(kind: string, stride: number): void;
  91427. /** @hidden */
  91428. _userInstancedBuffersStorage: {
  91429. data: {
  91430. [key: string]: Float32Array;
  91431. };
  91432. sizes: {
  91433. [key: string]: number;
  91434. };
  91435. vertexBuffers: {
  91436. [key: string]: Nullable<VertexBuffer>;
  91437. };
  91438. strides: {
  91439. [key: string]: number;
  91440. };
  91441. };
  91442. }
  91443. interface AbstractMesh {
  91444. /**
  91445. * Object used to store instanced buffers defined by user
  91446. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91447. */
  91448. instancedBuffers: {
  91449. [key: string]: any;
  91450. };
  91451. }
  91452. }
  91453. declare module BABYLON {
  91454. /**
  91455. * Defines the options associated with the creation of a shader material.
  91456. */
  91457. export interface IShaderMaterialOptions {
  91458. /**
  91459. * Does the material work in alpha blend mode
  91460. */
  91461. needAlphaBlending: boolean;
  91462. /**
  91463. * Does the material work in alpha test mode
  91464. */
  91465. needAlphaTesting: boolean;
  91466. /**
  91467. * The list of attribute names used in the shader
  91468. */
  91469. attributes: string[];
  91470. /**
  91471. * The list of unifrom names used in the shader
  91472. */
  91473. uniforms: string[];
  91474. /**
  91475. * The list of UBO names used in the shader
  91476. */
  91477. uniformBuffers: string[];
  91478. /**
  91479. * The list of sampler names used in the shader
  91480. */
  91481. samplers: string[];
  91482. /**
  91483. * The list of defines used in the shader
  91484. */
  91485. defines: string[];
  91486. }
  91487. /**
  91488. * 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.
  91489. *
  91490. * This returned material effects how the mesh will look based on the code in the shaders.
  91491. *
  91492. * @see http://doc.babylonjs.com/how_to/shader_material
  91493. */
  91494. export class ShaderMaterial extends Material {
  91495. private _shaderPath;
  91496. private _options;
  91497. private _textures;
  91498. private _textureArrays;
  91499. private _floats;
  91500. private _ints;
  91501. private _floatsArrays;
  91502. private _colors3;
  91503. private _colors3Arrays;
  91504. private _colors4;
  91505. private _colors4Arrays;
  91506. private _vectors2;
  91507. private _vectors3;
  91508. private _vectors4;
  91509. private _matrices;
  91510. private _matrixArrays;
  91511. private _matrices3x3;
  91512. private _matrices2x2;
  91513. private _vectors2Arrays;
  91514. private _vectors3Arrays;
  91515. private _vectors4Arrays;
  91516. private _cachedWorldViewMatrix;
  91517. private _cachedWorldViewProjectionMatrix;
  91518. private _renderId;
  91519. private _multiview;
  91520. private _cachedDefines;
  91521. /**
  91522. * Instantiate a new shader material.
  91523. * 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.
  91524. * This returned material effects how the mesh will look based on the code in the shaders.
  91525. * @see http://doc.babylonjs.com/how_to/shader_material
  91526. * @param name Define the name of the material in the scene
  91527. * @param scene Define the scene the material belongs to
  91528. * @param shaderPath Defines the route to the shader code in one of three ways:
  91529. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91530. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91531. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91532. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91533. * @param options Define the options used to create the shader
  91534. */
  91535. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91536. /**
  91537. * Gets the shader path used to define the shader code
  91538. * It can be modified to trigger a new compilation
  91539. */
  91540. get shaderPath(): any;
  91541. /**
  91542. * Sets the shader path used to define the shader code
  91543. * It can be modified to trigger a new compilation
  91544. */
  91545. set shaderPath(shaderPath: any);
  91546. /**
  91547. * Gets the options used to compile the shader.
  91548. * They can be modified to trigger a new compilation
  91549. */
  91550. get options(): IShaderMaterialOptions;
  91551. /**
  91552. * Gets the current class name of the material e.g. "ShaderMaterial"
  91553. * Mainly use in serialization.
  91554. * @returns the class name
  91555. */
  91556. getClassName(): string;
  91557. /**
  91558. * Specifies if the material will require alpha blending
  91559. * @returns a boolean specifying if alpha blending is needed
  91560. */
  91561. needAlphaBlending(): boolean;
  91562. /**
  91563. * Specifies if this material should be rendered in alpha test mode
  91564. * @returns a boolean specifying if an alpha test is needed.
  91565. */
  91566. needAlphaTesting(): boolean;
  91567. private _checkUniform;
  91568. /**
  91569. * Set a texture in the shader.
  91570. * @param name Define the name of the uniform samplers as defined in the shader
  91571. * @param texture Define the texture to bind to this sampler
  91572. * @return the material itself allowing "fluent" like uniform updates
  91573. */
  91574. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91575. /**
  91576. * Set a texture array in the shader.
  91577. * @param name Define the name of the uniform sampler array as defined in the shader
  91578. * @param textures Define the list of textures to bind to this sampler
  91579. * @return the material itself allowing "fluent" like uniform updates
  91580. */
  91581. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91582. /**
  91583. * Set a float in the shader.
  91584. * @param name Define the name of the uniform as defined in the shader
  91585. * @param value Define the value to give to the uniform
  91586. * @return the material itself allowing "fluent" like uniform updates
  91587. */
  91588. setFloat(name: string, value: number): ShaderMaterial;
  91589. /**
  91590. * Set a int in the shader.
  91591. * @param name Define the name of the uniform as defined in the shader
  91592. * @param value Define the value to give to the uniform
  91593. * @return the material itself allowing "fluent" like uniform updates
  91594. */
  91595. setInt(name: string, value: number): ShaderMaterial;
  91596. /**
  91597. * Set an array of floats in the shader.
  91598. * @param name Define the name of the uniform as defined in the shader
  91599. * @param value Define the value to give to the uniform
  91600. * @return the material itself allowing "fluent" like uniform updates
  91601. */
  91602. setFloats(name: string, value: number[]): ShaderMaterial;
  91603. /**
  91604. * Set a vec3 in the shader from a Color3.
  91605. * @param name Define the name of the uniform as defined in the shader
  91606. * @param value Define the value to give to the uniform
  91607. * @return the material itself allowing "fluent" like uniform updates
  91608. */
  91609. setColor3(name: string, value: Color3): ShaderMaterial;
  91610. /**
  91611. * Set a vec3 array in the shader from a Color3 array.
  91612. * @param name Define the name of the uniform as defined in the shader
  91613. * @param value Define the value to give to the uniform
  91614. * @return the material itself allowing "fluent" like uniform updates
  91615. */
  91616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91617. /**
  91618. * Set a vec4 in the shader from a Color4.
  91619. * @param name Define the name of the uniform as defined in the shader
  91620. * @param value Define the value to give to the uniform
  91621. * @return the material itself allowing "fluent" like uniform updates
  91622. */
  91623. setColor4(name: string, value: Color4): ShaderMaterial;
  91624. /**
  91625. * Set a vec4 array in the shader from a Color4 array.
  91626. * @param name Define the name of the uniform as defined in the shader
  91627. * @param value Define the value to give to the uniform
  91628. * @return the material itself allowing "fluent" like uniform updates
  91629. */
  91630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91631. /**
  91632. * Set a vec2 in the shader from a Vector2.
  91633. * @param name Define the name of the uniform as defined in the shader
  91634. * @param value Define the value to give to the uniform
  91635. * @return the material itself allowing "fluent" like uniform updates
  91636. */
  91637. setVector2(name: string, value: Vector2): ShaderMaterial;
  91638. /**
  91639. * Set a vec3 in the shader from a Vector3.
  91640. * @param name Define the name of the uniform as defined in the shader
  91641. * @param value Define the value to give to the uniform
  91642. * @return the material itself allowing "fluent" like uniform updates
  91643. */
  91644. setVector3(name: string, value: Vector3): ShaderMaterial;
  91645. /**
  91646. * Set a vec4 in the shader from a Vector4.
  91647. * @param name Define the name of the uniform as defined in the shader
  91648. * @param value Define the value to give to the uniform
  91649. * @return the material itself allowing "fluent" like uniform updates
  91650. */
  91651. setVector4(name: string, value: Vector4): ShaderMaterial;
  91652. /**
  91653. * Set a mat4 in the shader from a Matrix.
  91654. * @param name Define the name of the uniform as defined in the shader
  91655. * @param value Define the value to give to the uniform
  91656. * @return the material itself allowing "fluent" like uniform updates
  91657. */
  91658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91659. /**
  91660. * Set a float32Array in the shader from a matrix array.
  91661. * @param name Define the name of the uniform as defined in the shader
  91662. * @param value Define the value to give to the uniform
  91663. * @return the material itself allowing "fluent" like uniform updates
  91664. */
  91665. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91666. /**
  91667. * Set a mat3 in the shader from a Float32Array.
  91668. * @param name Define the name of the uniform as defined in the shader
  91669. * @param value Define the value to give to the uniform
  91670. * @return the material itself allowing "fluent" like uniform updates
  91671. */
  91672. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91673. /**
  91674. * Set a mat2 in the shader from a Float32Array.
  91675. * @param name Define the name of the uniform as defined in the shader
  91676. * @param value Define the value to give to the uniform
  91677. * @return the material itself allowing "fluent" like uniform updates
  91678. */
  91679. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91680. /**
  91681. * Set a vec2 array in the shader from a number array.
  91682. * @param name Define the name of the uniform as defined in the shader
  91683. * @param value Define the value to give to the uniform
  91684. * @return the material itself allowing "fluent" like uniform updates
  91685. */
  91686. setArray2(name: string, value: number[]): ShaderMaterial;
  91687. /**
  91688. * Set a vec3 array in the shader from a number array.
  91689. * @param name Define the name of the uniform as defined in the shader
  91690. * @param value Define the value to give to the uniform
  91691. * @return the material itself allowing "fluent" like uniform updates
  91692. */
  91693. setArray3(name: string, value: number[]): ShaderMaterial;
  91694. /**
  91695. * Set a vec4 array in the shader from a number array.
  91696. * @param name Define the name of the uniform as defined in the shader
  91697. * @param value Define the value to give to the uniform
  91698. * @return the material itself allowing "fluent" like uniform updates
  91699. */
  91700. setArray4(name: string, value: number[]): ShaderMaterial;
  91701. private _checkCache;
  91702. /**
  91703. * Specifies that the submesh is ready to be used
  91704. * @param mesh defines the mesh to check
  91705. * @param subMesh defines which submesh to check
  91706. * @param useInstances specifies that instances should be used
  91707. * @returns a boolean indicating that the submesh is ready or not
  91708. */
  91709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91710. /**
  91711. * Checks if the material is ready to render the requested mesh
  91712. * @param mesh Define the mesh to render
  91713. * @param useInstances Define whether or not the material is used with instances
  91714. * @returns true if ready, otherwise false
  91715. */
  91716. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91717. /**
  91718. * Binds the world matrix to the material
  91719. * @param world defines the world transformation matrix
  91720. * @param effectOverride - If provided, use this effect instead of internal effect
  91721. */
  91722. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91723. /**
  91724. * Binds the submesh to this material by preparing the effect and shader to draw
  91725. * @param world defines the world transformation matrix
  91726. * @param mesh defines the mesh containing the submesh
  91727. * @param subMesh defines the submesh to bind the material to
  91728. */
  91729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91730. /**
  91731. * Binds the material to the mesh
  91732. * @param world defines the world transformation matrix
  91733. * @param mesh defines the mesh to bind the material to
  91734. * @param effectOverride - If provided, use this effect instead of internal effect
  91735. */
  91736. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91737. protected _afterBind(mesh?: Mesh): void;
  91738. /**
  91739. * Gets the active textures from the material
  91740. * @returns an array of textures
  91741. */
  91742. getActiveTextures(): BaseTexture[];
  91743. /**
  91744. * Specifies if the material uses a texture
  91745. * @param texture defines the texture to check against the material
  91746. * @returns a boolean specifying if the material uses the texture
  91747. */
  91748. hasTexture(texture: BaseTexture): boolean;
  91749. /**
  91750. * Makes a duplicate of the material, and gives it a new name
  91751. * @param name defines the new name for the duplicated material
  91752. * @returns the cloned material
  91753. */
  91754. clone(name: string): ShaderMaterial;
  91755. /**
  91756. * Disposes the material
  91757. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91758. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91759. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91760. */
  91761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91762. /**
  91763. * Serializes this material in a JSON representation
  91764. * @returns the serialized material object
  91765. */
  91766. serialize(): any;
  91767. /**
  91768. * Creates a shader material from parsed shader material data
  91769. * @param source defines the JSON represnetation of the material
  91770. * @param scene defines the hosting scene
  91771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91772. * @returns a new material
  91773. */
  91774. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91775. }
  91776. }
  91777. declare module BABYLON {
  91778. /** @hidden */
  91779. export var colorPixelShader: {
  91780. name: string;
  91781. shader: string;
  91782. };
  91783. }
  91784. declare module BABYLON {
  91785. /** @hidden */
  91786. export var colorVertexShader: {
  91787. name: string;
  91788. shader: string;
  91789. };
  91790. }
  91791. declare module BABYLON {
  91792. /**
  91793. * Line mesh
  91794. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91795. */
  91796. export class LinesMesh extends Mesh {
  91797. /**
  91798. * If vertex color should be applied to the mesh
  91799. */
  91800. readonly useVertexColor?: boolean | undefined;
  91801. /**
  91802. * If vertex alpha should be applied to the mesh
  91803. */
  91804. readonly useVertexAlpha?: boolean | undefined;
  91805. /**
  91806. * Color of the line (Default: White)
  91807. */
  91808. color: Color3;
  91809. /**
  91810. * Alpha of the line (Default: 1)
  91811. */
  91812. alpha: number;
  91813. /**
  91814. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91815. * This margin is expressed in world space coordinates, so its value may vary.
  91816. * Default value is 0.1
  91817. */
  91818. intersectionThreshold: number;
  91819. private _colorShader;
  91820. private color4;
  91821. /**
  91822. * Creates a new LinesMesh
  91823. * @param name defines the name
  91824. * @param scene defines the hosting scene
  91825. * @param parent defines the parent mesh if any
  91826. * @param source defines the optional source LinesMesh used to clone data from
  91827. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91828. * When false, achieved by calling a clone(), also passing False.
  91829. * This will make creation of children, recursive.
  91830. * @param useVertexColor defines if this LinesMesh supports vertex color
  91831. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91832. */
  91833. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91834. /**
  91835. * If vertex color should be applied to the mesh
  91836. */
  91837. useVertexColor?: boolean | undefined,
  91838. /**
  91839. * If vertex alpha should be applied to the mesh
  91840. */
  91841. useVertexAlpha?: boolean | undefined);
  91842. private _addClipPlaneDefine;
  91843. private _removeClipPlaneDefine;
  91844. isReady(): boolean;
  91845. /**
  91846. * Returns the string "LineMesh"
  91847. */
  91848. getClassName(): string;
  91849. /**
  91850. * @hidden
  91851. */
  91852. get material(): Material;
  91853. /**
  91854. * @hidden
  91855. */
  91856. set material(value: Material);
  91857. /**
  91858. * @hidden
  91859. */
  91860. get checkCollisions(): boolean;
  91861. /** @hidden */
  91862. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91863. /** @hidden */
  91864. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91865. /**
  91866. * Disposes of the line mesh
  91867. * @param doNotRecurse If children should be disposed
  91868. */
  91869. dispose(doNotRecurse?: boolean): void;
  91870. /**
  91871. * Returns a new LineMesh object cloned from the current one.
  91872. */
  91873. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91874. /**
  91875. * Creates a new InstancedLinesMesh object from the mesh model.
  91876. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91877. * @param name defines the name of the new instance
  91878. * @returns a new InstancedLinesMesh
  91879. */
  91880. createInstance(name: string): InstancedLinesMesh;
  91881. }
  91882. /**
  91883. * Creates an instance based on a source LinesMesh
  91884. */
  91885. export class InstancedLinesMesh extends InstancedMesh {
  91886. /**
  91887. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91888. * This margin is expressed in world space coordinates, so its value may vary.
  91889. * Initilized with the intersectionThreshold value of the source LinesMesh
  91890. */
  91891. intersectionThreshold: number;
  91892. constructor(name: string, source: LinesMesh);
  91893. /**
  91894. * Returns the string "InstancedLinesMesh".
  91895. */
  91896. getClassName(): string;
  91897. }
  91898. }
  91899. declare module BABYLON {
  91900. /** @hidden */
  91901. export var linePixelShader: {
  91902. name: string;
  91903. shader: string;
  91904. };
  91905. }
  91906. declare module BABYLON {
  91907. /** @hidden */
  91908. export var lineVertexShader: {
  91909. name: string;
  91910. shader: string;
  91911. };
  91912. }
  91913. declare module BABYLON {
  91914. interface AbstractMesh {
  91915. /**
  91916. * Gets the edgesRenderer associated with the mesh
  91917. */
  91918. edgesRenderer: Nullable<EdgesRenderer>;
  91919. }
  91920. interface LinesMesh {
  91921. /**
  91922. * Enables the edge rendering mode on the mesh.
  91923. * This mode makes the mesh edges visible
  91924. * @param epsilon defines the maximal distance between two angles to detect a face
  91925. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91926. * @returns the currentAbstractMesh
  91927. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91928. */
  91929. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91930. }
  91931. interface InstancedLinesMesh {
  91932. /**
  91933. * Enables the edge rendering mode on the mesh.
  91934. * This mode makes the mesh edges visible
  91935. * @param epsilon defines the maximal distance between two angles to detect a face
  91936. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91937. * @returns the current InstancedLinesMesh
  91938. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91939. */
  91940. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91941. }
  91942. /**
  91943. * Defines the minimum contract an Edges renderer should follow.
  91944. */
  91945. export interface IEdgesRenderer extends IDisposable {
  91946. /**
  91947. * Gets or sets a boolean indicating if the edgesRenderer is active
  91948. */
  91949. isEnabled: boolean;
  91950. /**
  91951. * Renders the edges of the attached mesh,
  91952. */
  91953. render(): void;
  91954. /**
  91955. * Checks wether or not the edges renderer is ready to render.
  91956. * @return true if ready, otherwise false.
  91957. */
  91958. isReady(): boolean;
  91959. }
  91960. /**
  91961. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91962. */
  91963. export class EdgesRenderer implements IEdgesRenderer {
  91964. /**
  91965. * Define the size of the edges with an orthographic camera
  91966. */
  91967. edgesWidthScalerForOrthographic: number;
  91968. /**
  91969. * Define the size of the edges with a perspective camera
  91970. */
  91971. edgesWidthScalerForPerspective: number;
  91972. protected _source: AbstractMesh;
  91973. protected _linesPositions: number[];
  91974. protected _linesNormals: number[];
  91975. protected _linesIndices: number[];
  91976. protected _epsilon: number;
  91977. protected _indicesCount: number;
  91978. protected _lineShader: ShaderMaterial;
  91979. protected _ib: DataBuffer;
  91980. protected _buffers: {
  91981. [key: string]: Nullable<VertexBuffer>;
  91982. };
  91983. protected _checkVerticesInsteadOfIndices: boolean;
  91984. private _meshRebuildObserver;
  91985. private _meshDisposeObserver;
  91986. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91987. isEnabled: boolean;
  91988. /**
  91989. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91990. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91991. * @param source Mesh used to create edges
  91992. * @param epsilon sum of angles in adjacency to check for edge
  91993. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91994. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91995. */
  91996. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91997. protected _prepareRessources(): void;
  91998. /** @hidden */
  91999. _rebuild(): void;
  92000. /**
  92001. * Releases the required resources for the edges renderer
  92002. */
  92003. dispose(): void;
  92004. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92005. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92006. /**
  92007. * Checks if the pair of p0 and p1 is en edge
  92008. * @param faceIndex
  92009. * @param edge
  92010. * @param faceNormals
  92011. * @param p0
  92012. * @param p1
  92013. * @private
  92014. */
  92015. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92016. /**
  92017. * push line into the position, normal and index buffer
  92018. * @protected
  92019. */
  92020. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92021. /**
  92022. * Generates lines edges from adjacencjes
  92023. * @private
  92024. */
  92025. _generateEdgesLines(): void;
  92026. /**
  92027. * Checks wether or not the edges renderer is ready to render.
  92028. * @return true if ready, otherwise false.
  92029. */
  92030. isReady(): boolean;
  92031. /**
  92032. * Renders the edges of the attached mesh,
  92033. */
  92034. render(): void;
  92035. }
  92036. /**
  92037. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92038. */
  92039. export class LineEdgesRenderer extends EdgesRenderer {
  92040. /**
  92041. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92042. * @param source LineMesh used to generate edges
  92043. * @param epsilon not important (specified angle for edge detection)
  92044. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92045. */
  92046. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92047. /**
  92048. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92049. */
  92050. _generateEdgesLines(): void;
  92051. }
  92052. }
  92053. declare module BABYLON {
  92054. /**
  92055. * This represents the object necessary to create a rendering group.
  92056. * This is exclusively used and created by the rendering manager.
  92057. * To modify the behavior, you use the available helpers in your scene or meshes.
  92058. * @hidden
  92059. */
  92060. export class RenderingGroup {
  92061. index: number;
  92062. private static _zeroVector;
  92063. private _scene;
  92064. private _opaqueSubMeshes;
  92065. private _transparentSubMeshes;
  92066. private _alphaTestSubMeshes;
  92067. private _depthOnlySubMeshes;
  92068. private _particleSystems;
  92069. private _spriteManagers;
  92070. private _opaqueSortCompareFn;
  92071. private _alphaTestSortCompareFn;
  92072. private _transparentSortCompareFn;
  92073. private _renderOpaque;
  92074. private _renderAlphaTest;
  92075. private _renderTransparent;
  92076. /** @hidden */
  92077. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92078. onBeforeTransparentRendering: () => void;
  92079. /**
  92080. * Set the opaque sort comparison function.
  92081. * If null the sub meshes will be render in the order they were created
  92082. */
  92083. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92084. /**
  92085. * Set the alpha test sort comparison function.
  92086. * If null the sub meshes will be render in the order they were created
  92087. */
  92088. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92089. /**
  92090. * Set the transparent sort comparison function.
  92091. * If null the sub meshes will be render in the order they were created
  92092. */
  92093. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92094. /**
  92095. * Creates a new rendering group.
  92096. * @param index The rendering group index
  92097. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92098. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92099. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92100. */
  92101. 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>);
  92102. /**
  92103. * Render all the sub meshes contained in the group.
  92104. * @param customRenderFunction Used to override the default render behaviour of the group.
  92105. * @returns true if rendered some submeshes.
  92106. */
  92107. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92108. /**
  92109. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92110. * @param subMeshes The submeshes to render
  92111. */
  92112. private renderOpaqueSorted;
  92113. /**
  92114. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92115. * @param subMeshes The submeshes to render
  92116. */
  92117. private renderAlphaTestSorted;
  92118. /**
  92119. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92120. * @param subMeshes The submeshes to render
  92121. */
  92122. private renderTransparentSorted;
  92123. /**
  92124. * Renders the submeshes in a specified order.
  92125. * @param subMeshes The submeshes to sort before render
  92126. * @param sortCompareFn The comparison function use to sort
  92127. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92128. * @param transparent Specifies to activate blending if true
  92129. */
  92130. private static renderSorted;
  92131. /**
  92132. * Renders the submeshes in the order they were dispatched (no sort applied).
  92133. * @param subMeshes The submeshes to render
  92134. */
  92135. private static renderUnsorted;
  92136. /**
  92137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92138. * are rendered back to front if in the same alpha index.
  92139. *
  92140. * @param a The first submesh
  92141. * @param b The second submesh
  92142. * @returns The result of the comparison
  92143. */
  92144. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92145. /**
  92146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92147. * are rendered back to front.
  92148. *
  92149. * @param a The first submesh
  92150. * @param b The second submesh
  92151. * @returns The result of the comparison
  92152. */
  92153. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92154. /**
  92155. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92156. * are rendered front to back (prevent overdraw).
  92157. *
  92158. * @param a The first submesh
  92159. * @param b The second submesh
  92160. * @returns The result of the comparison
  92161. */
  92162. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92163. /**
  92164. * Resets the different lists of submeshes to prepare a new frame.
  92165. */
  92166. prepare(): void;
  92167. dispose(): void;
  92168. /**
  92169. * Inserts the submesh in its correct queue depending on its material.
  92170. * @param subMesh The submesh to dispatch
  92171. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92172. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92173. */
  92174. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92175. dispatchSprites(spriteManager: ISpriteManager): void;
  92176. dispatchParticles(particleSystem: IParticleSystem): void;
  92177. private _renderParticles;
  92178. private _renderSprites;
  92179. }
  92180. }
  92181. declare module BABYLON {
  92182. /**
  92183. * Interface describing the different options available in the rendering manager
  92184. * regarding Auto Clear between groups.
  92185. */
  92186. export interface IRenderingManagerAutoClearSetup {
  92187. /**
  92188. * Defines whether or not autoclear is enable.
  92189. */
  92190. autoClear: boolean;
  92191. /**
  92192. * Defines whether or not to autoclear the depth buffer.
  92193. */
  92194. depth: boolean;
  92195. /**
  92196. * Defines whether or not to autoclear the stencil buffer.
  92197. */
  92198. stencil: boolean;
  92199. }
  92200. /**
  92201. * This class is used by the onRenderingGroupObservable
  92202. */
  92203. export class RenderingGroupInfo {
  92204. /**
  92205. * The Scene that being rendered
  92206. */
  92207. scene: Scene;
  92208. /**
  92209. * The camera currently used for the rendering pass
  92210. */
  92211. camera: Nullable<Camera>;
  92212. /**
  92213. * The ID of the renderingGroup being processed
  92214. */
  92215. renderingGroupId: number;
  92216. }
  92217. /**
  92218. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92219. * It is enable to manage the different groups as well as the different necessary sort functions.
  92220. * This should not be used directly aside of the few static configurations
  92221. */
  92222. export class RenderingManager {
  92223. /**
  92224. * The max id used for rendering groups (not included)
  92225. */
  92226. static MAX_RENDERINGGROUPS: number;
  92227. /**
  92228. * The min id used for rendering groups (included)
  92229. */
  92230. static MIN_RENDERINGGROUPS: number;
  92231. /**
  92232. * Used to globally prevent autoclearing scenes.
  92233. */
  92234. static AUTOCLEAR: boolean;
  92235. /**
  92236. * @hidden
  92237. */
  92238. _useSceneAutoClearSetup: boolean;
  92239. private _scene;
  92240. private _renderingGroups;
  92241. private _depthStencilBufferAlreadyCleaned;
  92242. private _autoClearDepthStencil;
  92243. private _customOpaqueSortCompareFn;
  92244. private _customAlphaTestSortCompareFn;
  92245. private _customTransparentSortCompareFn;
  92246. private _renderingGroupInfo;
  92247. /**
  92248. * Instantiates a new rendering group for a particular scene
  92249. * @param scene Defines the scene the groups belongs to
  92250. */
  92251. constructor(scene: Scene);
  92252. private _clearDepthStencilBuffer;
  92253. /**
  92254. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92255. * @hidden
  92256. */
  92257. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92258. /**
  92259. * Resets the different information of the group to prepare a new frame
  92260. * @hidden
  92261. */
  92262. reset(): void;
  92263. /**
  92264. * Dispose and release the group and its associated resources.
  92265. * @hidden
  92266. */
  92267. dispose(): void;
  92268. /**
  92269. * Clear the info related to rendering groups preventing retention points during dispose.
  92270. */
  92271. freeRenderingGroups(): void;
  92272. private _prepareRenderingGroup;
  92273. /**
  92274. * Add a sprite manager to the rendering manager in order to render it this frame.
  92275. * @param spriteManager Define the sprite manager to render
  92276. */
  92277. dispatchSprites(spriteManager: ISpriteManager): void;
  92278. /**
  92279. * Add a particle system to the rendering manager in order to render it this frame.
  92280. * @param particleSystem Define the particle system to render
  92281. */
  92282. dispatchParticles(particleSystem: IParticleSystem): void;
  92283. /**
  92284. * Add a submesh to the manager in order to render it this frame
  92285. * @param subMesh The submesh to dispatch
  92286. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92287. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92288. */
  92289. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92290. /**
  92291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92292. * This allowed control for front to back rendering or reversly depending of the special needs.
  92293. *
  92294. * @param renderingGroupId The rendering group id corresponding to its index
  92295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92298. */
  92299. 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;
  92300. /**
  92301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92302. *
  92303. * @param renderingGroupId The rendering group id corresponding to its index
  92304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92307. */
  92308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92309. /**
  92310. * Gets the current auto clear configuration for one rendering group of the rendering
  92311. * manager.
  92312. * @param index the rendering group index to get the information for
  92313. * @returns The auto clear setup for the requested rendering group
  92314. */
  92315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92316. }
  92317. }
  92318. declare module BABYLON {
  92319. /**
  92320. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92321. */
  92322. export interface ICustomShaderOptions {
  92323. /**
  92324. * Gets or sets the custom shader name to use
  92325. */
  92326. shaderName: string;
  92327. /**
  92328. * The list of attribute names used in the shader
  92329. */
  92330. attributes?: string[];
  92331. /**
  92332. * The list of unifrom names used in the shader
  92333. */
  92334. uniforms?: string[];
  92335. /**
  92336. * The list of sampler names used in the shader
  92337. */
  92338. samplers?: string[];
  92339. /**
  92340. * The list of defines used in the shader
  92341. */
  92342. defines?: string[];
  92343. }
  92344. /**
  92345. * Interface to implement to create a shadow generator compatible with BJS.
  92346. */
  92347. export interface IShadowGenerator {
  92348. /**
  92349. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92350. * @returns The render target texture if present otherwise, null
  92351. */
  92352. getShadowMap(): Nullable<RenderTargetTexture>;
  92353. /**
  92354. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92355. * @param subMesh The submesh we want to render in the shadow map
  92356. * @param useInstances Defines wether will draw in the map using instances
  92357. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92358. * @returns true if ready otherwise, false
  92359. */
  92360. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92361. /**
  92362. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92363. * @param defines Defines of the material we want to update
  92364. * @param lightIndex Index of the light in the enabled light list of the material
  92365. */
  92366. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92367. /**
  92368. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92369. * defined in the generator but impacting the effect).
  92370. * It implies the unifroms available on the materials are the standard BJS ones.
  92371. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92372. * @param effect The effect we are binfing the information for
  92373. */
  92374. bindShadowLight(lightIndex: string, effect: Effect): void;
  92375. /**
  92376. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92377. * (eq to shadow prjection matrix * light transform matrix)
  92378. * @returns The transform matrix used to create the shadow map
  92379. */
  92380. getTransformMatrix(): Matrix;
  92381. /**
  92382. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92383. * Cube and 2D textures for instance.
  92384. */
  92385. recreateShadowMap(): void;
  92386. /**
  92387. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92388. * @param onCompiled Callback triggered at the and of the effects compilation
  92389. * @param options Sets of optional options forcing the compilation with different modes
  92390. */
  92391. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92392. useInstances: boolean;
  92393. }>): void;
  92394. /**
  92395. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92396. * @param options Sets of optional options forcing the compilation with different modes
  92397. * @returns A promise that resolves when the compilation completes
  92398. */
  92399. forceCompilationAsync(options?: Partial<{
  92400. useInstances: boolean;
  92401. }>): Promise<void>;
  92402. /**
  92403. * Serializes the shadow generator setup to a json object.
  92404. * @returns The serialized JSON object
  92405. */
  92406. serialize(): any;
  92407. /**
  92408. * Disposes the Shadow map and related Textures and effects.
  92409. */
  92410. dispose(): void;
  92411. }
  92412. /**
  92413. * Default implementation IShadowGenerator.
  92414. * This is the main object responsible of generating shadows in the framework.
  92415. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92416. */
  92417. export class ShadowGenerator implements IShadowGenerator {
  92418. /**
  92419. * Name of the shadow generator class
  92420. */
  92421. static CLASSNAME: string;
  92422. /**
  92423. * Shadow generator mode None: no filtering applied.
  92424. */
  92425. static readonly FILTER_NONE: number;
  92426. /**
  92427. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92428. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92429. */
  92430. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92431. /**
  92432. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92433. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92434. */
  92435. static readonly FILTER_POISSONSAMPLING: number;
  92436. /**
  92437. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92439. */
  92440. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92441. /**
  92442. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92443. * edge artifacts on steep falloff.
  92444. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92445. */
  92446. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92447. /**
  92448. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92449. * edge artifacts on steep falloff.
  92450. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92451. */
  92452. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92453. /**
  92454. * Shadow generator mode PCF: Percentage Closer Filtering
  92455. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92456. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92457. */
  92458. static readonly FILTER_PCF: number;
  92459. /**
  92460. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92461. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92462. * Contact Hardening
  92463. */
  92464. static readonly FILTER_PCSS: number;
  92465. /**
  92466. * Reserved for PCF and PCSS
  92467. * Highest Quality.
  92468. *
  92469. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92470. *
  92471. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92472. */
  92473. static readonly QUALITY_HIGH: number;
  92474. /**
  92475. * Reserved for PCF and PCSS
  92476. * Good tradeoff for quality/perf cross devices
  92477. *
  92478. * Execute PCF on a 3*3 kernel.
  92479. *
  92480. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92481. */
  92482. static readonly QUALITY_MEDIUM: number;
  92483. /**
  92484. * Reserved for PCF and PCSS
  92485. * The lowest quality but the fastest.
  92486. *
  92487. * Execute PCF on a 1*1 kernel.
  92488. *
  92489. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92490. */
  92491. static readonly QUALITY_LOW: number;
  92492. /** Gets or sets the custom shader name to use */
  92493. customShaderOptions: ICustomShaderOptions;
  92494. /**
  92495. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92496. */
  92497. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92498. /**
  92499. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92500. */
  92501. onAfterShadowMapRenderObservable: Observable<Effect>;
  92502. /**
  92503. * Observable triggered before a mesh is rendered in the shadow map.
  92504. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92505. */
  92506. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92507. /**
  92508. * Observable triggered after a mesh is rendered in the shadow map.
  92509. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92510. */
  92511. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92512. protected _bias: number;
  92513. /**
  92514. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92515. */
  92516. get bias(): number;
  92517. /**
  92518. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92519. */
  92520. set bias(bias: number);
  92521. protected _normalBias: number;
  92522. /**
  92523. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92524. */
  92525. get normalBias(): number;
  92526. /**
  92527. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92528. */
  92529. set normalBias(normalBias: number);
  92530. protected _blurBoxOffset: number;
  92531. /**
  92532. * Gets the blur box offset: offset applied during the blur pass.
  92533. * Only useful if useKernelBlur = false
  92534. */
  92535. get blurBoxOffset(): number;
  92536. /**
  92537. * Sets the blur box offset: offset applied during the blur pass.
  92538. * Only useful if useKernelBlur = false
  92539. */
  92540. set blurBoxOffset(value: number);
  92541. protected _blurScale: number;
  92542. /**
  92543. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92544. * 2 means half of the size.
  92545. */
  92546. get blurScale(): number;
  92547. /**
  92548. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92549. * 2 means half of the size.
  92550. */
  92551. set blurScale(value: number);
  92552. protected _blurKernel: number;
  92553. /**
  92554. * Gets the blur kernel: kernel size of the blur pass.
  92555. * Only useful if useKernelBlur = true
  92556. */
  92557. get blurKernel(): number;
  92558. /**
  92559. * Sets the blur kernel: kernel size of the blur pass.
  92560. * Only useful if useKernelBlur = true
  92561. */
  92562. set blurKernel(value: number);
  92563. protected _useKernelBlur: boolean;
  92564. /**
  92565. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92566. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92567. */
  92568. get useKernelBlur(): boolean;
  92569. /**
  92570. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92571. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92572. */
  92573. set useKernelBlur(value: boolean);
  92574. protected _depthScale: number;
  92575. /**
  92576. * Gets the depth scale used in ESM mode.
  92577. */
  92578. get depthScale(): number;
  92579. /**
  92580. * Sets the depth scale used in ESM mode.
  92581. * This can override the scale stored on the light.
  92582. */
  92583. set depthScale(value: number);
  92584. protected _validateFilter(filter: number): number;
  92585. protected _filter: number;
  92586. /**
  92587. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92588. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92589. */
  92590. get filter(): number;
  92591. /**
  92592. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92593. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92594. */
  92595. set filter(value: number);
  92596. /**
  92597. * Gets if the current filter is set to Poisson Sampling.
  92598. */
  92599. get usePoissonSampling(): boolean;
  92600. /**
  92601. * Sets the current filter to Poisson Sampling.
  92602. */
  92603. set usePoissonSampling(value: boolean);
  92604. /**
  92605. * Gets if the current filter is set to ESM.
  92606. */
  92607. get useExponentialShadowMap(): boolean;
  92608. /**
  92609. * Sets the current filter is to ESM.
  92610. */
  92611. set useExponentialShadowMap(value: boolean);
  92612. /**
  92613. * Gets if the current filter is set to filtered ESM.
  92614. */
  92615. get useBlurExponentialShadowMap(): boolean;
  92616. /**
  92617. * Gets if the current filter is set to filtered ESM.
  92618. */
  92619. set useBlurExponentialShadowMap(value: boolean);
  92620. /**
  92621. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92622. * exponential to prevent steep falloff artifacts).
  92623. */
  92624. get useCloseExponentialShadowMap(): boolean;
  92625. /**
  92626. * Sets the current filter to "close ESM" (using the inverse of the
  92627. * exponential to prevent steep falloff artifacts).
  92628. */
  92629. set useCloseExponentialShadowMap(value: boolean);
  92630. /**
  92631. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92632. * exponential to prevent steep falloff artifacts).
  92633. */
  92634. get useBlurCloseExponentialShadowMap(): boolean;
  92635. /**
  92636. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92637. * exponential to prevent steep falloff artifacts).
  92638. */
  92639. set useBlurCloseExponentialShadowMap(value: boolean);
  92640. /**
  92641. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92642. */
  92643. get usePercentageCloserFiltering(): boolean;
  92644. /**
  92645. * Sets the current filter to "PCF" (percentage closer filtering).
  92646. */
  92647. set usePercentageCloserFiltering(value: boolean);
  92648. protected _filteringQuality: number;
  92649. /**
  92650. * Gets the PCF or PCSS Quality.
  92651. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92652. */
  92653. get filteringQuality(): number;
  92654. /**
  92655. * Sets the PCF or PCSS Quality.
  92656. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92657. */
  92658. set filteringQuality(filteringQuality: number);
  92659. /**
  92660. * Gets if the current filter is set to "PCSS" (contact hardening).
  92661. */
  92662. get useContactHardeningShadow(): boolean;
  92663. /**
  92664. * Sets the current filter to "PCSS" (contact hardening).
  92665. */
  92666. set useContactHardeningShadow(value: boolean);
  92667. protected _contactHardeningLightSizeUVRatio: number;
  92668. /**
  92669. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92670. * Using a ratio helps keeping shape stability independently of the map size.
  92671. *
  92672. * It does not account for the light projection as it was having too much
  92673. * instability during the light setup or during light position changes.
  92674. *
  92675. * Only valid if useContactHardeningShadow is true.
  92676. */
  92677. get contactHardeningLightSizeUVRatio(): number;
  92678. /**
  92679. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92680. * Using a ratio helps keeping shape stability independently of the map size.
  92681. *
  92682. * It does not account for the light projection as it was having too much
  92683. * instability during the light setup or during light position changes.
  92684. *
  92685. * Only valid if useContactHardeningShadow is true.
  92686. */
  92687. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92688. protected _darkness: number;
  92689. /** Gets or sets the actual darkness of a shadow */
  92690. get darkness(): number;
  92691. set darkness(value: number);
  92692. /**
  92693. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92694. * 0 means strongest and 1 would means no shadow.
  92695. * @returns the darkness.
  92696. */
  92697. getDarkness(): number;
  92698. /**
  92699. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92700. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92701. * @returns the shadow generator allowing fluent coding.
  92702. */
  92703. setDarkness(darkness: number): ShadowGenerator;
  92704. protected _transparencyShadow: boolean;
  92705. /** Gets or sets the ability to have transparent shadow */
  92706. get transparencyShadow(): boolean;
  92707. set transparencyShadow(value: boolean);
  92708. /**
  92709. * Sets the ability to have transparent shadow (boolean).
  92710. * @param transparent True if transparent else False
  92711. * @returns the shadow generator allowing fluent coding
  92712. */
  92713. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92714. /**
  92715. * Enables or disables shadows with varying strength based on the transparency
  92716. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  92717. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  92718. * mesh.visibility * alphaTexture.a
  92719. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  92720. */
  92721. enableSoftTransparentShadow: boolean;
  92722. protected _shadowMap: Nullable<RenderTargetTexture>;
  92723. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92724. /**
  92725. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92726. * @returns The render target texture if present otherwise, null
  92727. */
  92728. getShadowMap(): Nullable<RenderTargetTexture>;
  92729. /**
  92730. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92731. * @returns The render target texture if the shadow map is present otherwise, null
  92732. */
  92733. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92734. /**
  92735. * Gets the class name of that object
  92736. * @returns "ShadowGenerator"
  92737. */
  92738. getClassName(): string;
  92739. /**
  92740. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92741. * @param mesh Mesh to add
  92742. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92743. * @returns the Shadow Generator itself
  92744. */
  92745. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92746. /**
  92747. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92748. * @param mesh Mesh to remove
  92749. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92750. * @returns the Shadow Generator itself
  92751. */
  92752. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92753. /**
  92754. * Controls the extent to which the shadows fade out at the edge of the frustum
  92755. */
  92756. frustumEdgeFalloff: number;
  92757. protected _light: IShadowLight;
  92758. /**
  92759. * Returns the associated light object.
  92760. * @returns the light generating the shadow
  92761. */
  92762. getLight(): IShadowLight;
  92763. /**
  92764. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92765. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92766. * It might on the other hand introduce peter panning.
  92767. */
  92768. forceBackFacesOnly: boolean;
  92769. protected _scene: Scene;
  92770. protected _lightDirection: Vector3;
  92771. protected _effect: Effect;
  92772. protected _viewMatrix: Matrix;
  92773. protected _projectionMatrix: Matrix;
  92774. protected _transformMatrix: Matrix;
  92775. protected _cachedPosition: Vector3;
  92776. protected _cachedDirection: Vector3;
  92777. protected _cachedDefines: string;
  92778. protected _currentRenderID: number;
  92779. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92780. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92781. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92782. protected _blurPostProcesses: PostProcess[];
  92783. protected _mapSize: number;
  92784. protected _currentFaceIndex: number;
  92785. protected _currentFaceIndexCache: number;
  92786. protected _textureType: number;
  92787. protected _defaultTextureMatrix: Matrix;
  92788. protected _storedUniqueId: Nullable<number>;
  92789. /** @hidden */
  92790. static _SceneComponentInitialization: (scene: Scene) => void;
  92791. /**
  92792. * Creates a ShadowGenerator object.
  92793. * A ShadowGenerator is the required tool to use the shadows.
  92794. * Each light casting shadows needs to use its own ShadowGenerator.
  92795. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92796. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92797. * @param light The light object generating the shadows.
  92798. * @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.
  92799. */
  92800. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92801. protected _initializeGenerator(): void;
  92802. protected _createTargetRenderTexture(): void;
  92803. protected _initializeShadowMap(): void;
  92804. protected _initializeBlurRTTAndPostProcesses(): void;
  92805. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92806. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92807. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  92808. protected _applyFilterValues(): void;
  92809. /**
  92810. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92811. * @param onCompiled Callback triggered at the and of the effects compilation
  92812. * @param options Sets of optional options forcing the compilation with different modes
  92813. */
  92814. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92815. useInstances: boolean;
  92816. }>): void;
  92817. /**
  92818. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92819. * @param options Sets of optional options forcing the compilation with different modes
  92820. * @returns A promise that resolves when the compilation completes
  92821. */
  92822. forceCompilationAsync(options?: Partial<{
  92823. useInstances: boolean;
  92824. }>): Promise<void>;
  92825. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92826. private _prepareShadowDefines;
  92827. /**
  92828. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92829. * @param subMesh The submesh we want to render in the shadow map
  92830. * @param useInstances Defines wether will draw in the map using instances
  92831. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  92832. * @returns true if ready otherwise, false
  92833. */
  92834. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  92835. /**
  92836. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92837. * @param defines Defines of the material we want to update
  92838. * @param lightIndex Index of the light in the enabled light list of the material
  92839. */
  92840. prepareDefines(defines: any, lightIndex: number): void;
  92841. /**
  92842. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92843. * defined in the generator but impacting the effect).
  92844. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92845. * @param effect The effect we are binfing the information for
  92846. */
  92847. bindShadowLight(lightIndex: string, effect: Effect): void;
  92848. /**
  92849. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92850. * (eq to shadow prjection matrix * light transform matrix)
  92851. * @returns The transform matrix used to create the shadow map
  92852. */
  92853. getTransformMatrix(): Matrix;
  92854. /**
  92855. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92856. * Cube and 2D textures for instance.
  92857. */
  92858. recreateShadowMap(): void;
  92859. protected _disposeBlurPostProcesses(): void;
  92860. protected _disposeRTTandPostProcesses(): void;
  92861. /**
  92862. * Disposes the ShadowGenerator.
  92863. * Returns nothing.
  92864. */
  92865. dispose(): void;
  92866. /**
  92867. * Serializes the shadow generator setup to a json object.
  92868. * @returns The serialized JSON object
  92869. */
  92870. serialize(): any;
  92871. /**
  92872. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92873. * @param parsedShadowGenerator The JSON object to parse
  92874. * @param scene The scene to create the shadow map for
  92875. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92876. * @returns The parsed shadow generator
  92877. */
  92878. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92879. }
  92880. }
  92881. declare module BABYLON {
  92882. /**
  92883. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92884. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92885. * 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.
  92886. */
  92887. export abstract class Light extends Node {
  92888. /**
  92889. * Falloff Default: light is falling off following the material specification:
  92890. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92891. */
  92892. static readonly FALLOFF_DEFAULT: number;
  92893. /**
  92894. * Falloff Physical: light is falling off following the inverse squared distance law.
  92895. */
  92896. static readonly FALLOFF_PHYSICAL: number;
  92897. /**
  92898. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92899. * to enhance interoperability with other engines.
  92900. */
  92901. static readonly FALLOFF_GLTF: number;
  92902. /**
  92903. * Falloff Standard: light is falling off like in the standard material
  92904. * to enhance interoperability with other materials.
  92905. */
  92906. static readonly FALLOFF_STANDARD: number;
  92907. /**
  92908. * If every light affecting the material is in this lightmapMode,
  92909. * material.lightmapTexture adds or multiplies
  92910. * (depends on material.useLightmapAsShadowmap)
  92911. * after every other light calculations.
  92912. */
  92913. static readonly LIGHTMAP_DEFAULT: number;
  92914. /**
  92915. * material.lightmapTexture as only diffuse lighting from this light
  92916. * adds only specular lighting from this light
  92917. * adds dynamic shadows
  92918. */
  92919. static readonly LIGHTMAP_SPECULAR: number;
  92920. /**
  92921. * material.lightmapTexture as only lighting
  92922. * no light calculation from this light
  92923. * only adds dynamic shadows from this light
  92924. */
  92925. static readonly LIGHTMAP_SHADOWSONLY: number;
  92926. /**
  92927. * Each light type uses the default quantity according to its type:
  92928. * point/spot lights use luminous intensity
  92929. * directional lights use illuminance
  92930. */
  92931. static readonly INTENSITYMODE_AUTOMATIC: number;
  92932. /**
  92933. * lumen (lm)
  92934. */
  92935. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92936. /**
  92937. * candela (lm/sr)
  92938. */
  92939. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92940. /**
  92941. * lux (lm/m^2)
  92942. */
  92943. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92944. /**
  92945. * nit (cd/m^2)
  92946. */
  92947. static readonly INTENSITYMODE_LUMINANCE: number;
  92948. /**
  92949. * Light type const id of the point light.
  92950. */
  92951. static readonly LIGHTTYPEID_POINTLIGHT: number;
  92952. /**
  92953. * Light type const id of the directional light.
  92954. */
  92955. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  92956. /**
  92957. * Light type const id of the spot light.
  92958. */
  92959. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  92960. /**
  92961. * Light type const id of the hemispheric light.
  92962. */
  92963. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  92964. /**
  92965. * Diffuse gives the basic color to an object.
  92966. */
  92967. diffuse: Color3;
  92968. /**
  92969. * Specular produces a highlight color on an object.
  92970. * Note: This is note affecting PBR materials.
  92971. */
  92972. specular: Color3;
  92973. /**
  92974. * Defines the falloff type for this light. This lets overrriding how punctual light are
  92975. * falling off base on range or angle.
  92976. * This can be set to any values in Light.FALLOFF_x.
  92977. *
  92978. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  92979. * other types of materials.
  92980. */
  92981. falloffType: number;
  92982. /**
  92983. * Strength of the light.
  92984. * Note: By default it is define in the framework own unit.
  92985. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  92986. */
  92987. intensity: number;
  92988. private _range;
  92989. protected _inverseSquaredRange: number;
  92990. /**
  92991. * Defines how far from the source the light is impacting in scene units.
  92992. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92993. */
  92994. get range(): number;
  92995. /**
  92996. * Defines how far from the source the light is impacting in scene units.
  92997. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92998. */
  92999. set range(value: number);
  93000. /**
  93001. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93002. * of light.
  93003. */
  93004. private _photometricScale;
  93005. private _intensityMode;
  93006. /**
  93007. * Gets the photometric scale used to interpret the intensity.
  93008. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93009. */
  93010. get intensityMode(): number;
  93011. /**
  93012. * Sets the photometric scale used to interpret the intensity.
  93013. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93014. */
  93015. set intensityMode(value: number);
  93016. private _radius;
  93017. /**
  93018. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93019. */
  93020. get radius(): number;
  93021. /**
  93022. * sets the light radius used by PBR Materials to simulate soft area lights.
  93023. */
  93024. set radius(value: number);
  93025. private _renderPriority;
  93026. /**
  93027. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93028. * exceeding the number allowed of the materials.
  93029. */
  93030. renderPriority: number;
  93031. private _shadowEnabled;
  93032. /**
  93033. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93034. * the current shadow generator.
  93035. */
  93036. get shadowEnabled(): boolean;
  93037. /**
  93038. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93039. * the current shadow generator.
  93040. */
  93041. set shadowEnabled(value: boolean);
  93042. private _includedOnlyMeshes;
  93043. /**
  93044. * Gets the only meshes impacted by this light.
  93045. */
  93046. get includedOnlyMeshes(): AbstractMesh[];
  93047. /**
  93048. * Sets the only meshes impacted by this light.
  93049. */
  93050. set includedOnlyMeshes(value: AbstractMesh[]);
  93051. private _excludedMeshes;
  93052. /**
  93053. * Gets the meshes not impacted by this light.
  93054. */
  93055. get excludedMeshes(): AbstractMesh[];
  93056. /**
  93057. * Sets the meshes not impacted by this light.
  93058. */
  93059. set excludedMeshes(value: AbstractMesh[]);
  93060. private _excludeWithLayerMask;
  93061. /**
  93062. * Gets the layer id use to find what meshes are not impacted by the light.
  93063. * Inactive if 0
  93064. */
  93065. get excludeWithLayerMask(): number;
  93066. /**
  93067. * Sets the layer id use to find what meshes are not impacted by the light.
  93068. * Inactive if 0
  93069. */
  93070. set excludeWithLayerMask(value: number);
  93071. private _includeOnlyWithLayerMask;
  93072. /**
  93073. * Gets the layer id use to find what meshes are impacted by the light.
  93074. * Inactive if 0
  93075. */
  93076. get includeOnlyWithLayerMask(): number;
  93077. /**
  93078. * Sets the layer id use to find what meshes are impacted by the light.
  93079. * Inactive if 0
  93080. */
  93081. set includeOnlyWithLayerMask(value: number);
  93082. private _lightmapMode;
  93083. /**
  93084. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93085. */
  93086. get lightmapMode(): number;
  93087. /**
  93088. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93089. */
  93090. set lightmapMode(value: number);
  93091. /**
  93092. * Shadow generator associted to the light.
  93093. * @hidden Internal use only.
  93094. */
  93095. _shadowGenerator: Nullable<IShadowGenerator>;
  93096. /**
  93097. * @hidden Internal use only.
  93098. */
  93099. _excludedMeshesIds: string[];
  93100. /**
  93101. * @hidden Internal use only.
  93102. */
  93103. _includedOnlyMeshesIds: string[];
  93104. /**
  93105. * The current light unifom buffer.
  93106. * @hidden Internal use only.
  93107. */
  93108. _uniformBuffer: UniformBuffer;
  93109. /** @hidden */
  93110. _renderId: number;
  93111. /**
  93112. * Creates a Light object in the scene.
  93113. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93114. * @param name The firendly name of the light
  93115. * @param scene The scene the light belongs too
  93116. */
  93117. constructor(name: string, scene: Scene);
  93118. protected abstract _buildUniformLayout(): void;
  93119. /**
  93120. * Sets the passed Effect "effect" with the Light information.
  93121. * @param effect The effect to update
  93122. * @param lightIndex The index of the light in the effect to update
  93123. * @returns The light
  93124. */
  93125. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93126. /**
  93127. * Sets the passed Effect "effect" with the Light textures.
  93128. * @param effect The effect to update
  93129. * @param lightIndex The index of the light in the effect to update
  93130. * @returns The light
  93131. */
  93132. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93133. /**
  93134. * Binds the lights information from the scene to the effect for the given mesh.
  93135. * @param lightIndex Light index
  93136. * @param scene The scene where the light belongs to
  93137. * @param effect The effect we are binding the data to
  93138. * @param useSpecular Defines if specular is supported
  93139. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93140. */
  93141. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93142. /**
  93143. * Sets the passed Effect "effect" with the Light information.
  93144. * @param effect The effect to update
  93145. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93146. * @returns The light
  93147. */
  93148. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93149. /**
  93150. * Returns the string "Light".
  93151. * @returns the class name
  93152. */
  93153. getClassName(): string;
  93154. /** @hidden */
  93155. readonly _isLight: boolean;
  93156. /**
  93157. * Converts the light information to a readable string for debug purpose.
  93158. * @param fullDetails Supports for multiple levels of logging within scene loading
  93159. * @returns the human readable light info
  93160. */
  93161. toString(fullDetails?: boolean): string;
  93162. /** @hidden */
  93163. protected _syncParentEnabledState(): void;
  93164. /**
  93165. * Set the enabled state of this node.
  93166. * @param value - the new enabled state
  93167. */
  93168. setEnabled(value: boolean): void;
  93169. /**
  93170. * Returns the Light associated shadow generator if any.
  93171. * @return the associated shadow generator.
  93172. */
  93173. getShadowGenerator(): Nullable<IShadowGenerator>;
  93174. /**
  93175. * Returns a Vector3, the absolute light position in the World.
  93176. * @returns the world space position of the light
  93177. */
  93178. getAbsolutePosition(): Vector3;
  93179. /**
  93180. * Specifies if the light will affect the passed mesh.
  93181. * @param mesh The mesh to test against the light
  93182. * @return true the mesh is affected otherwise, false.
  93183. */
  93184. canAffectMesh(mesh: AbstractMesh): boolean;
  93185. /**
  93186. * Sort function to order lights for rendering.
  93187. * @param a First Light object to compare to second.
  93188. * @param b Second Light object to compare first.
  93189. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93190. */
  93191. static CompareLightsPriority(a: Light, b: Light): number;
  93192. /**
  93193. * Releases resources associated with this node.
  93194. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93195. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93196. */
  93197. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93198. /**
  93199. * Returns the light type ID (integer).
  93200. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93201. */
  93202. getTypeID(): number;
  93203. /**
  93204. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93205. * @returns the scaled intensity in intensity mode unit
  93206. */
  93207. getScaledIntensity(): number;
  93208. /**
  93209. * Returns a new Light object, named "name", from the current one.
  93210. * @param name The name of the cloned light
  93211. * @returns the new created light
  93212. */
  93213. clone(name: string): Nullable<Light>;
  93214. /**
  93215. * Serializes the current light into a Serialization object.
  93216. * @returns the serialized object.
  93217. */
  93218. serialize(): any;
  93219. /**
  93220. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93221. * This new light is named "name" and added to the passed scene.
  93222. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93223. * @param name The friendly name of the light
  93224. * @param scene The scene the new light will belong to
  93225. * @returns the constructor function
  93226. */
  93227. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93228. /**
  93229. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93230. * @param parsedLight The JSON representation of the light
  93231. * @param scene The scene to create the parsed light in
  93232. * @returns the created light after parsing
  93233. */
  93234. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93235. private _hookArrayForExcluded;
  93236. private _hookArrayForIncludedOnly;
  93237. private _resyncMeshes;
  93238. /**
  93239. * Forces the meshes to update their light related information in their rendering used effects
  93240. * @hidden Internal Use Only
  93241. */
  93242. _markMeshesAsLightDirty(): void;
  93243. /**
  93244. * Recomputes the cached photometric scale if needed.
  93245. */
  93246. private _computePhotometricScale;
  93247. /**
  93248. * Returns the Photometric Scale according to the light type and intensity mode.
  93249. */
  93250. private _getPhotometricScale;
  93251. /**
  93252. * Reorder the light in the scene according to their defined priority.
  93253. * @hidden Internal Use Only
  93254. */
  93255. _reorderLightsInScene(): void;
  93256. /**
  93257. * Prepares the list of defines specific to the light type.
  93258. * @param defines the list of defines
  93259. * @param lightIndex defines the index of the light for the effect
  93260. */
  93261. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93262. }
  93263. }
  93264. declare module BABYLON {
  93265. /**
  93266. * Interface used to define Action
  93267. */
  93268. export interface IAction {
  93269. /**
  93270. * Trigger for the action
  93271. */
  93272. trigger: number;
  93273. /** Options of the trigger */
  93274. triggerOptions: any;
  93275. /**
  93276. * Gets the trigger parameters
  93277. * @returns the trigger parameters
  93278. */
  93279. getTriggerParameter(): any;
  93280. /**
  93281. * Internal only - executes current action event
  93282. * @hidden
  93283. */
  93284. _executeCurrent(evt?: ActionEvent): void;
  93285. /**
  93286. * Serialize placeholder for child classes
  93287. * @param parent of child
  93288. * @returns the serialized object
  93289. */
  93290. serialize(parent: any): any;
  93291. /**
  93292. * Internal only
  93293. * @hidden
  93294. */
  93295. _prepare(): void;
  93296. /**
  93297. * Internal only - manager for action
  93298. * @hidden
  93299. */
  93300. _actionManager: AbstractActionManager;
  93301. /**
  93302. * Adds action to chain of actions, may be a DoNothingAction
  93303. * @param action defines the next action to execute
  93304. * @returns The action passed in
  93305. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93306. */
  93307. then(action: IAction): IAction;
  93308. }
  93309. /**
  93310. * The action to be carried out following a trigger
  93311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93312. */
  93313. export class Action implements IAction {
  93314. /** the trigger, with or without parameters, for the action */
  93315. triggerOptions: any;
  93316. /**
  93317. * Trigger for the action
  93318. */
  93319. trigger: number;
  93320. /**
  93321. * Internal only - manager for action
  93322. * @hidden
  93323. */
  93324. _actionManager: ActionManager;
  93325. private _nextActiveAction;
  93326. private _child;
  93327. private _condition?;
  93328. private _triggerParameter;
  93329. /**
  93330. * An event triggered prior to action being executed.
  93331. */
  93332. onBeforeExecuteObservable: Observable<Action>;
  93333. /**
  93334. * Creates a new Action
  93335. * @param triggerOptions the trigger, with or without parameters, for the action
  93336. * @param condition an optional determinant of action
  93337. */
  93338. constructor(
  93339. /** the trigger, with or without parameters, for the action */
  93340. triggerOptions: any, condition?: Condition);
  93341. /**
  93342. * Internal only
  93343. * @hidden
  93344. */
  93345. _prepare(): void;
  93346. /**
  93347. * Gets the trigger parameters
  93348. * @returns the trigger parameters
  93349. */
  93350. getTriggerParameter(): any;
  93351. /**
  93352. * Internal only - executes current action event
  93353. * @hidden
  93354. */
  93355. _executeCurrent(evt?: ActionEvent): void;
  93356. /**
  93357. * Execute placeholder for child classes
  93358. * @param evt optional action event
  93359. */
  93360. execute(evt?: ActionEvent): void;
  93361. /**
  93362. * Skips to next active action
  93363. */
  93364. skipToNextActiveAction(): void;
  93365. /**
  93366. * Adds action to chain of actions, may be a DoNothingAction
  93367. * @param action defines the next action to execute
  93368. * @returns The action passed in
  93369. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93370. */
  93371. then(action: Action): Action;
  93372. /**
  93373. * Internal only
  93374. * @hidden
  93375. */
  93376. _getProperty(propertyPath: string): string;
  93377. /**
  93378. * Internal only
  93379. * @hidden
  93380. */
  93381. _getEffectiveTarget(target: any, propertyPath: string): any;
  93382. /**
  93383. * Serialize placeholder for child classes
  93384. * @param parent of child
  93385. * @returns the serialized object
  93386. */
  93387. serialize(parent: any): any;
  93388. /**
  93389. * Internal only called by serialize
  93390. * @hidden
  93391. */
  93392. protected _serialize(serializedAction: any, parent?: any): any;
  93393. /**
  93394. * Internal only
  93395. * @hidden
  93396. */
  93397. static _SerializeValueAsString: (value: any) => string;
  93398. /**
  93399. * Internal only
  93400. * @hidden
  93401. */
  93402. static _GetTargetProperty: (target: Node | Scene) => {
  93403. name: string;
  93404. targetType: string;
  93405. value: string;
  93406. };
  93407. }
  93408. }
  93409. declare module BABYLON {
  93410. /**
  93411. * A Condition applied to an Action
  93412. */
  93413. export class Condition {
  93414. /**
  93415. * Internal only - manager for action
  93416. * @hidden
  93417. */
  93418. _actionManager: ActionManager;
  93419. /**
  93420. * Internal only
  93421. * @hidden
  93422. */
  93423. _evaluationId: number;
  93424. /**
  93425. * Internal only
  93426. * @hidden
  93427. */
  93428. _currentResult: boolean;
  93429. /**
  93430. * Creates a new Condition
  93431. * @param actionManager the manager of the action the condition is applied to
  93432. */
  93433. constructor(actionManager: ActionManager);
  93434. /**
  93435. * Check if the current condition is valid
  93436. * @returns a boolean
  93437. */
  93438. isValid(): boolean;
  93439. /**
  93440. * Internal only
  93441. * @hidden
  93442. */
  93443. _getProperty(propertyPath: string): string;
  93444. /**
  93445. * Internal only
  93446. * @hidden
  93447. */
  93448. _getEffectiveTarget(target: any, propertyPath: string): any;
  93449. /**
  93450. * Serialize placeholder for child classes
  93451. * @returns the serialized object
  93452. */
  93453. serialize(): any;
  93454. /**
  93455. * Internal only
  93456. * @hidden
  93457. */
  93458. protected _serialize(serializedCondition: any): any;
  93459. }
  93460. /**
  93461. * Defines specific conditional operators as extensions of Condition
  93462. */
  93463. export class ValueCondition extends Condition {
  93464. /** path to specify the property of the target the conditional operator uses */
  93465. propertyPath: string;
  93466. /** the value compared by the conditional operator against the current value of the property */
  93467. value: any;
  93468. /** the conditional operator, default ValueCondition.IsEqual */
  93469. operator: number;
  93470. /**
  93471. * Internal only
  93472. * @hidden
  93473. */
  93474. private static _IsEqual;
  93475. /**
  93476. * Internal only
  93477. * @hidden
  93478. */
  93479. private static _IsDifferent;
  93480. /**
  93481. * Internal only
  93482. * @hidden
  93483. */
  93484. private static _IsGreater;
  93485. /**
  93486. * Internal only
  93487. * @hidden
  93488. */
  93489. private static _IsLesser;
  93490. /**
  93491. * returns the number for IsEqual
  93492. */
  93493. static get IsEqual(): number;
  93494. /**
  93495. * Returns the number for IsDifferent
  93496. */
  93497. static get IsDifferent(): number;
  93498. /**
  93499. * Returns the number for IsGreater
  93500. */
  93501. static get IsGreater(): number;
  93502. /**
  93503. * Returns the number for IsLesser
  93504. */
  93505. static get IsLesser(): number;
  93506. /**
  93507. * Internal only The action manager for the condition
  93508. * @hidden
  93509. */
  93510. _actionManager: ActionManager;
  93511. /**
  93512. * Internal only
  93513. * @hidden
  93514. */
  93515. private _target;
  93516. /**
  93517. * Internal only
  93518. * @hidden
  93519. */
  93520. private _effectiveTarget;
  93521. /**
  93522. * Internal only
  93523. * @hidden
  93524. */
  93525. private _property;
  93526. /**
  93527. * Creates a new ValueCondition
  93528. * @param actionManager manager for the action the condition applies to
  93529. * @param target for the action
  93530. * @param propertyPath path to specify the property of the target the conditional operator uses
  93531. * @param value the value compared by the conditional operator against the current value of the property
  93532. * @param operator the conditional operator, default ValueCondition.IsEqual
  93533. */
  93534. constructor(actionManager: ActionManager, target: any,
  93535. /** path to specify the property of the target the conditional operator uses */
  93536. propertyPath: string,
  93537. /** the value compared by the conditional operator against the current value of the property */
  93538. value: any,
  93539. /** the conditional operator, default ValueCondition.IsEqual */
  93540. operator?: number);
  93541. /**
  93542. * Compares the given value with the property value for the specified conditional operator
  93543. * @returns the result of the comparison
  93544. */
  93545. isValid(): boolean;
  93546. /**
  93547. * Serialize the ValueCondition into a JSON compatible object
  93548. * @returns serialization object
  93549. */
  93550. serialize(): any;
  93551. /**
  93552. * Gets the name of the conditional operator for the ValueCondition
  93553. * @param operator the conditional operator
  93554. * @returns the name
  93555. */
  93556. static GetOperatorName(operator: number): string;
  93557. }
  93558. /**
  93559. * Defines a predicate condition as an extension of Condition
  93560. */
  93561. export class PredicateCondition extends Condition {
  93562. /** defines the predicate function used to validate the condition */
  93563. predicate: () => boolean;
  93564. /**
  93565. * Internal only - manager for action
  93566. * @hidden
  93567. */
  93568. _actionManager: ActionManager;
  93569. /**
  93570. * Creates a new PredicateCondition
  93571. * @param actionManager manager for the action the condition applies to
  93572. * @param predicate defines the predicate function used to validate the condition
  93573. */
  93574. constructor(actionManager: ActionManager,
  93575. /** defines the predicate function used to validate the condition */
  93576. predicate: () => boolean);
  93577. /**
  93578. * @returns the validity of the predicate condition
  93579. */
  93580. isValid(): boolean;
  93581. }
  93582. /**
  93583. * Defines a state condition as an extension of Condition
  93584. */
  93585. export class StateCondition extends Condition {
  93586. /** Value to compare with target state */
  93587. value: string;
  93588. /**
  93589. * Internal only - manager for action
  93590. * @hidden
  93591. */
  93592. _actionManager: ActionManager;
  93593. /**
  93594. * Internal only
  93595. * @hidden
  93596. */
  93597. private _target;
  93598. /**
  93599. * Creates a new StateCondition
  93600. * @param actionManager manager for the action the condition applies to
  93601. * @param target of the condition
  93602. * @param value to compare with target state
  93603. */
  93604. constructor(actionManager: ActionManager, target: any,
  93605. /** Value to compare with target state */
  93606. value: string);
  93607. /**
  93608. * Gets a boolean indicating if the current condition is met
  93609. * @returns the validity of the state
  93610. */
  93611. isValid(): boolean;
  93612. /**
  93613. * Serialize the StateCondition into a JSON compatible object
  93614. * @returns serialization object
  93615. */
  93616. serialize(): any;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * This defines an action responsible to toggle a boolean once triggered.
  93622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93623. */
  93624. export class SwitchBooleanAction extends Action {
  93625. /**
  93626. * The path to the boolean property in the target object
  93627. */
  93628. propertyPath: string;
  93629. private _target;
  93630. private _effectiveTarget;
  93631. private _property;
  93632. /**
  93633. * Instantiate the action
  93634. * @param triggerOptions defines the trigger options
  93635. * @param target defines the object containing the boolean
  93636. * @param propertyPath defines the path to the boolean property in the target object
  93637. * @param condition defines the trigger related conditions
  93638. */
  93639. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93640. /** @hidden */
  93641. _prepare(): void;
  93642. /**
  93643. * Execute the action toggle the boolean value.
  93644. */
  93645. execute(): void;
  93646. /**
  93647. * Serializes the actions and its related information.
  93648. * @param parent defines the object to serialize in
  93649. * @returns the serialized object
  93650. */
  93651. serialize(parent: any): any;
  93652. }
  93653. /**
  93654. * This defines an action responsible to set a the state field of the target
  93655. * to a desired value once triggered.
  93656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93657. */
  93658. export class SetStateAction extends Action {
  93659. /**
  93660. * The value to store in the state field.
  93661. */
  93662. value: string;
  93663. private _target;
  93664. /**
  93665. * Instantiate the action
  93666. * @param triggerOptions defines the trigger options
  93667. * @param target defines the object containing the state property
  93668. * @param value defines the value to store in the state field
  93669. * @param condition defines the trigger related conditions
  93670. */
  93671. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93672. /**
  93673. * Execute the action and store the value on the target state property.
  93674. */
  93675. execute(): void;
  93676. /**
  93677. * Serializes the actions and its related information.
  93678. * @param parent defines the object to serialize in
  93679. * @returns the serialized object
  93680. */
  93681. serialize(parent: any): any;
  93682. }
  93683. /**
  93684. * This defines an action responsible to set a property of the target
  93685. * to a desired value once triggered.
  93686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93687. */
  93688. export class SetValueAction extends Action {
  93689. /**
  93690. * The path of the property to set in the target.
  93691. */
  93692. propertyPath: string;
  93693. /**
  93694. * The value to set in the property
  93695. */
  93696. value: any;
  93697. private _target;
  93698. private _effectiveTarget;
  93699. private _property;
  93700. /**
  93701. * Instantiate the action
  93702. * @param triggerOptions defines the trigger options
  93703. * @param target defines the object containing the property
  93704. * @param propertyPath defines the path of the property to set in the target
  93705. * @param value defines the value to set in the property
  93706. * @param condition defines the trigger related conditions
  93707. */
  93708. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93709. /** @hidden */
  93710. _prepare(): void;
  93711. /**
  93712. * Execute the action and set the targetted property to the desired value.
  93713. */
  93714. execute(): void;
  93715. /**
  93716. * Serializes the actions and its related information.
  93717. * @param parent defines the object to serialize in
  93718. * @returns the serialized object
  93719. */
  93720. serialize(parent: any): any;
  93721. }
  93722. /**
  93723. * This defines an action responsible to increment the target value
  93724. * to a desired value once triggered.
  93725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93726. */
  93727. export class IncrementValueAction extends Action {
  93728. /**
  93729. * The path of the property to increment in the target.
  93730. */
  93731. propertyPath: string;
  93732. /**
  93733. * The value we should increment the property by.
  93734. */
  93735. value: any;
  93736. private _target;
  93737. private _effectiveTarget;
  93738. private _property;
  93739. /**
  93740. * Instantiate the action
  93741. * @param triggerOptions defines the trigger options
  93742. * @param target defines the object containing the property
  93743. * @param propertyPath defines the path of the property to increment in the target
  93744. * @param value defines the value value we should increment the property by
  93745. * @param condition defines the trigger related conditions
  93746. */
  93747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93748. /** @hidden */
  93749. _prepare(): void;
  93750. /**
  93751. * Execute the action and increment the target of the value amount.
  93752. */
  93753. execute(): void;
  93754. /**
  93755. * Serializes the actions and its related information.
  93756. * @param parent defines the object to serialize in
  93757. * @returns the serialized object
  93758. */
  93759. serialize(parent: any): any;
  93760. }
  93761. /**
  93762. * This defines an action responsible to start an animation once triggered.
  93763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93764. */
  93765. export class PlayAnimationAction extends Action {
  93766. /**
  93767. * Where the animation should start (animation frame)
  93768. */
  93769. from: number;
  93770. /**
  93771. * Where the animation should stop (animation frame)
  93772. */
  93773. to: number;
  93774. /**
  93775. * Define if the animation should loop or stop after the first play.
  93776. */
  93777. loop?: boolean;
  93778. private _target;
  93779. /**
  93780. * Instantiate the action
  93781. * @param triggerOptions defines the trigger options
  93782. * @param target defines the target animation or animation name
  93783. * @param from defines from where the animation should start (animation frame)
  93784. * @param end defines where the animation should stop (animation frame)
  93785. * @param loop defines if the animation should loop or stop after the first play
  93786. * @param condition defines the trigger related conditions
  93787. */
  93788. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93789. /** @hidden */
  93790. _prepare(): void;
  93791. /**
  93792. * Execute the action and play the animation.
  93793. */
  93794. execute(): void;
  93795. /**
  93796. * Serializes the actions and its related information.
  93797. * @param parent defines the object to serialize in
  93798. * @returns the serialized object
  93799. */
  93800. serialize(parent: any): any;
  93801. }
  93802. /**
  93803. * This defines an action responsible to stop an animation once triggered.
  93804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93805. */
  93806. export class StopAnimationAction extends Action {
  93807. private _target;
  93808. /**
  93809. * Instantiate the action
  93810. * @param triggerOptions defines the trigger options
  93811. * @param target defines the target animation or animation name
  93812. * @param condition defines the trigger related conditions
  93813. */
  93814. constructor(triggerOptions: any, target: any, condition?: Condition);
  93815. /** @hidden */
  93816. _prepare(): void;
  93817. /**
  93818. * Execute the action and stop the animation.
  93819. */
  93820. execute(): void;
  93821. /**
  93822. * Serializes the actions and its related information.
  93823. * @param parent defines the object to serialize in
  93824. * @returns the serialized object
  93825. */
  93826. serialize(parent: any): any;
  93827. }
  93828. /**
  93829. * This defines an action responsible that does nothing once triggered.
  93830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93831. */
  93832. export class DoNothingAction extends Action {
  93833. /**
  93834. * Instantiate the action
  93835. * @param triggerOptions defines the trigger options
  93836. * @param condition defines the trigger related conditions
  93837. */
  93838. constructor(triggerOptions?: any, condition?: Condition);
  93839. /**
  93840. * Execute the action and do nothing.
  93841. */
  93842. execute(): void;
  93843. /**
  93844. * Serializes the actions and its related information.
  93845. * @param parent defines the object to serialize in
  93846. * @returns the serialized object
  93847. */
  93848. serialize(parent: any): any;
  93849. }
  93850. /**
  93851. * This defines an action responsible to trigger several actions once triggered.
  93852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93853. */
  93854. export class CombineAction extends Action {
  93855. /**
  93856. * The list of aggregated animations to run.
  93857. */
  93858. children: Action[];
  93859. /**
  93860. * Instantiate the action
  93861. * @param triggerOptions defines the trigger options
  93862. * @param children defines the list of aggregated animations to run
  93863. * @param condition defines the trigger related conditions
  93864. */
  93865. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93866. /** @hidden */
  93867. _prepare(): void;
  93868. /**
  93869. * Execute the action and executes all the aggregated actions.
  93870. */
  93871. execute(evt: ActionEvent): void;
  93872. /**
  93873. * Serializes the actions and its related information.
  93874. * @param parent defines the object to serialize in
  93875. * @returns the serialized object
  93876. */
  93877. serialize(parent: any): any;
  93878. }
  93879. /**
  93880. * This defines an action responsible to run code (external event) once triggered.
  93881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93882. */
  93883. export class ExecuteCodeAction extends Action {
  93884. /**
  93885. * The callback function to run.
  93886. */
  93887. func: (evt: ActionEvent) => void;
  93888. /**
  93889. * Instantiate the action
  93890. * @param triggerOptions defines the trigger options
  93891. * @param func defines the callback function to run
  93892. * @param condition defines the trigger related conditions
  93893. */
  93894. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93895. /**
  93896. * Execute the action and run the attached code.
  93897. */
  93898. execute(evt: ActionEvent): void;
  93899. }
  93900. /**
  93901. * This defines an action responsible to set the parent property of the target once triggered.
  93902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93903. */
  93904. export class SetParentAction extends Action {
  93905. private _parent;
  93906. private _target;
  93907. /**
  93908. * Instantiate the action
  93909. * @param triggerOptions defines the trigger options
  93910. * @param target defines the target containing the parent property
  93911. * @param parent defines from where the animation should start (animation frame)
  93912. * @param condition defines the trigger related conditions
  93913. */
  93914. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93915. /** @hidden */
  93916. _prepare(): void;
  93917. /**
  93918. * Execute the action and set the parent property.
  93919. */
  93920. execute(): void;
  93921. /**
  93922. * Serializes the actions and its related information.
  93923. * @param parent defines the object to serialize in
  93924. * @returns the serialized object
  93925. */
  93926. serialize(parent: any): any;
  93927. }
  93928. }
  93929. declare module BABYLON {
  93930. /**
  93931. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93932. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93934. */
  93935. export class ActionManager extends AbstractActionManager {
  93936. /**
  93937. * Nothing
  93938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93939. */
  93940. static readonly NothingTrigger: number;
  93941. /**
  93942. * On pick
  93943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93944. */
  93945. static readonly OnPickTrigger: number;
  93946. /**
  93947. * On left pick
  93948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93949. */
  93950. static readonly OnLeftPickTrigger: number;
  93951. /**
  93952. * On right pick
  93953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93954. */
  93955. static readonly OnRightPickTrigger: number;
  93956. /**
  93957. * On center pick
  93958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93959. */
  93960. static readonly OnCenterPickTrigger: number;
  93961. /**
  93962. * On pick down
  93963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93964. */
  93965. static readonly OnPickDownTrigger: number;
  93966. /**
  93967. * On double pick
  93968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93969. */
  93970. static readonly OnDoublePickTrigger: number;
  93971. /**
  93972. * On pick up
  93973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93974. */
  93975. static readonly OnPickUpTrigger: number;
  93976. /**
  93977. * On pick out.
  93978. * This trigger will only be raised if you also declared a OnPickDown
  93979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93980. */
  93981. static readonly OnPickOutTrigger: number;
  93982. /**
  93983. * On long press
  93984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93985. */
  93986. static readonly OnLongPressTrigger: number;
  93987. /**
  93988. * On pointer over
  93989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93990. */
  93991. static readonly OnPointerOverTrigger: number;
  93992. /**
  93993. * On pointer out
  93994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93995. */
  93996. static readonly OnPointerOutTrigger: number;
  93997. /**
  93998. * On every frame
  93999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94000. */
  94001. static readonly OnEveryFrameTrigger: number;
  94002. /**
  94003. * On intersection enter
  94004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94005. */
  94006. static readonly OnIntersectionEnterTrigger: number;
  94007. /**
  94008. * On intersection exit
  94009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94010. */
  94011. static readonly OnIntersectionExitTrigger: number;
  94012. /**
  94013. * On key down
  94014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94015. */
  94016. static readonly OnKeyDownTrigger: number;
  94017. /**
  94018. * On key up
  94019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  94020. */
  94021. static readonly OnKeyUpTrigger: number;
  94022. private _scene;
  94023. /**
  94024. * Creates a new action manager
  94025. * @param scene defines the hosting scene
  94026. */
  94027. constructor(scene: Scene);
  94028. /**
  94029. * Releases all associated resources
  94030. */
  94031. dispose(): void;
  94032. /**
  94033. * Gets hosting scene
  94034. * @returns the hosting scene
  94035. */
  94036. getScene(): Scene;
  94037. /**
  94038. * Does this action manager handles actions of any of the given triggers
  94039. * @param triggers defines the triggers to be tested
  94040. * @return a boolean indicating whether one (or more) of the triggers is handled
  94041. */
  94042. hasSpecificTriggers(triggers: number[]): boolean;
  94043. /**
  94044. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94045. * speed.
  94046. * @param triggerA defines the trigger to be tested
  94047. * @param triggerB defines the trigger to be tested
  94048. * @return a boolean indicating whether one (or more) of the triggers is handled
  94049. */
  94050. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94051. /**
  94052. * Does this action manager handles actions of a given trigger
  94053. * @param trigger defines the trigger to be tested
  94054. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94055. * @return whether the trigger is handled
  94056. */
  94057. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94058. /**
  94059. * Does this action manager has pointer triggers
  94060. */
  94061. get hasPointerTriggers(): boolean;
  94062. /**
  94063. * Does this action manager has pick triggers
  94064. */
  94065. get hasPickTriggers(): boolean;
  94066. /**
  94067. * Registers an action to this action manager
  94068. * @param action defines the action to be registered
  94069. * @return the action amended (prepared) after registration
  94070. */
  94071. registerAction(action: IAction): Nullable<IAction>;
  94072. /**
  94073. * Unregisters an action to this action manager
  94074. * @param action defines the action to be unregistered
  94075. * @return a boolean indicating whether the action has been unregistered
  94076. */
  94077. unregisterAction(action: IAction): Boolean;
  94078. /**
  94079. * Process a specific trigger
  94080. * @param trigger defines the trigger to process
  94081. * @param evt defines the event details to be processed
  94082. */
  94083. processTrigger(trigger: number, evt?: IActionEvent): void;
  94084. /** @hidden */
  94085. _getEffectiveTarget(target: any, propertyPath: string): any;
  94086. /** @hidden */
  94087. _getProperty(propertyPath: string): string;
  94088. /**
  94089. * Serialize this manager to a JSON object
  94090. * @param name defines the property name to store this manager
  94091. * @returns a JSON representation of this manager
  94092. */
  94093. serialize(name: string): any;
  94094. /**
  94095. * Creates a new ActionManager from a JSON data
  94096. * @param parsedActions defines the JSON data to read from
  94097. * @param object defines the hosting mesh
  94098. * @param scene defines the hosting scene
  94099. */
  94100. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  94101. /**
  94102. * Get a trigger name by index
  94103. * @param trigger defines the trigger index
  94104. * @returns a trigger name
  94105. */
  94106. static GetTriggerName(trigger: number): string;
  94107. }
  94108. }
  94109. declare module BABYLON {
  94110. /**
  94111. * Class used to represent a sprite
  94112. * @see http://doc.babylonjs.com/babylon101/sprites
  94113. */
  94114. export class Sprite {
  94115. /** defines the name */
  94116. name: string;
  94117. /** Gets or sets the current world position */
  94118. position: Vector3;
  94119. /** Gets or sets the main color */
  94120. color: Color4;
  94121. /** Gets or sets the width */
  94122. width: number;
  94123. /** Gets or sets the height */
  94124. height: number;
  94125. /** Gets or sets rotation angle */
  94126. angle: number;
  94127. /** Gets or sets the cell index in the sprite sheet */
  94128. cellIndex: number;
  94129. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  94130. cellRef: string;
  94131. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  94132. invertU: number;
  94133. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  94134. invertV: number;
  94135. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  94136. disposeWhenFinishedAnimating: boolean;
  94137. /** Gets the list of attached animations */
  94138. animations: Animation[];
  94139. /** Gets or sets a boolean indicating if the sprite can be picked */
  94140. isPickable: boolean;
  94141. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  94142. useAlphaForPicking: boolean;
  94143. /** @hidden */
  94144. _xOffset: number;
  94145. /** @hidden */
  94146. _yOffset: number;
  94147. /** @hidden */
  94148. _xSize: number;
  94149. /** @hidden */
  94150. _ySize: number;
  94151. /**
  94152. * Gets or sets the associated action manager
  94153. */
  94154. actionManager: Nullable<ActionManager>;
  94155. /**
  94156. * An event triggered when the control has been disposed
  94157. */
  94158. onDisposeObservable: Observable<Sprite>;
  94159. private _animationStarted;
  94160. private _loopAnimation;
  94161. private _fromIndex;
  94162. private _toIndex;
  94163. private _delay;
  94164. private _direction;
  94165. private _manager;
  94166. private _time;
  94167. private _onAnimationEnd;
  94168. /**
  94169. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  94170. */
  94171. isVisible: boolean;
  94172. /**
  94173. * Gets or sets the sprite size
  94174. */
  94175. get size(): number;
  94176. set size(value: number);
  94177. /**
  94178. * Creates a new Sprite
  94179. * @param name defines the name
  94180. * @param manager defines the manager
  94181. */
  94182. constructor(
  94183. /** defines the name */
  94184. name: string, manager: ISpriteManager);
  94185. /**
  94186. * Starts an animation
  94187. * @param from defines the initial key
  94188. * @param to defines the end key
  94189. * @param loop defines if the animation must loop
  94190. * @param delay defines the start delay (in ms)
  94191. * @param onAnimationEnd defines a callback to call when animation ends
  94192. */
  94193. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  94194. /** Stops current animation (if any) */
  94195. stopAnimation(): void;
  94196. /** @hidden */
  94197. _animate(deltaTime: number): void;
  94198. /** Release associated resources */
  94199. dispose(): void;
  94200. }
  94201. }
  94202. declare module BABYLON {
  94203. /**
  94204. * Information about the result of picking within a scene
  94205. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  94206. */
  94207. export class PickingInfo {
  94208. /** @hidden */
  94209. _pickingUnavailable: boolean;
  94210. /**
  94211. * If the pick collided with an object
  94212. */
  94213. hit: boolean;
  94214. /**
  94215. * Distance away where the pick collided
  94216. */
  94217. distance: number;
  94218. /**
  94219. * The location of pick collision
  94220. */
  94221. pickedPoint: Nullable<Vector3>;
  94222. /**
  94223. * The mesh corresponding the the pick collision
  94224. */
  94225. pickedMesh: Nullable<AbstractMesh>;
  94226. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94227. bu: number;
  94228. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94229. bv: number;
  94230. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94231. faceId: number;
  94232. /** Id of the the submesh that was picked */
  94233. subMeshId: number;
  94234. /** If a sprite was picked, this will be the sprite the pick collided with */
  94235. pickedSprite: Nullable<Sprite>;
  94236. /**
  94237. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94238. */
  94239. originMesh: Nullable<AbstractMesh>;
  94240. /**
  94241. * The ray that was used to perform the picking.
  94242. */
  94243. ray: Nullable<Ray>;
  94244. /**
  94245. * Gets the normal correspodning to the face the pick collided with
  94246. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94247. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94248. * @returns The normal correspodning to the face the pick collided with
  94249. */
  94250. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94251. /**
  94252. * Gets the texture coordinates of where the pick occured
  94253. * @returns the vector containing the coordnates of the texture
  94254. */
  94255. getTextureCoordinates(): Nullable<Vector2>;
  94256. }
  94257. }
  94258. declare module BABYLON {
  94259. /**
  94260. * Gather the list of pointer event types as constants.
  94261. */
  94262. export class PointerEventTypes {
  94263. /**
  94264. * 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.
  94265. */
  94266. static readonly POINTERDOWN: number;
  94267. /**
  94268. * The pointerup event is fired when a pointer is no longer active.
  94269. */
  94270. static readonly POINTERUP: number;
  94271. /**
  94272. * The pointermove event is fired when a pointer changes coordinates.
  94273. */
  94274. static readonly POINTERMOVE: number;
  94275. /**
  94276. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94277. */
  94278. static readonly POINTERWHEEL: number;
  94279. /**
  94280. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94281. */
  94282. static readonly POINTERPICK: number;
  94283. /**
  94284. * The pointertap event is fired when a the object has been touched and released without drag.
  94285. */
  94286. static readonly POINTERTAP: number;
  94287. /**
  94288. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94289. */
  94290. static readonly POINTERDOUBLETAP: number;
  94291. }
  94292. /**
  94293. * Base class of pointer info types.
  94294. */
  94295. export class PointerInfoBase {
  94296. /**
  94297. * Defines the type of event (PointerEventTypes)
  94298. */
  94299. type: number;
  94300. /**
  94301. * Defines the related dom event
  94302. */
  94303. event: PointerEvent | MouseWheelEvent;
  94304. /**
  94305. * Instantiates the base class of pointers info.
  94306. * @param type Defines the type of event (PointerEventTypes)
  94307. * @param event Defines the related dom event
  94308. */
  94309. constructor(
  94310. /**
  94311. * Defines the type of event (PointerEventTypes)
  94312. */
  94313. type: number,
  94314. /**
  94315. * Defines the related dom event
  94316. */
  94317. event: PointerEvent | MouseWheelEvent);
  94318. }
  94319. /**
  94320. * This class is used to store pointer related info for the onPrePointerObservable event.
  94321. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94322. */
  94323. export class PointerInfoPre extends PointerInfoBase {
  94324. /**
  94325. * Ray from a pointer if availible (eg. 6dof controller)
  94326. */
  94327. ray: Nullable<Ray>;
  94328. /**
  94329. * Defines the local position of the pointer on the canvas.
  94330. */
  94331. localPosition: Vector2;
  94332. /**
  94333. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94334. */
  94335. skipOnPointerObservable: boolean;
  94336. /**
  94337. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94338. * @param type Defines the type of event (PointerEventTypes)
  94339. * @param event Defines the related dom event
  94340. * @param localX Defines the local x coordinates of the pointer when the event occured
  94341. * @param localY Defines the local y coordinates of the pointer when the event occured
  94342. */
  94343. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94344. }
  94345. /**
  94346. * This type contains all the data related to a pointer event in Babylon.js.
  94347. * 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.
  94348. */
  94349. export class PointerInfo extends PointerInfoBase {
  94350. /**
  94351. * Defines the picking info associated to the info (if any)\
  94352. */
  94353. pickInfo: Nullable<PickingInfo>;
  94354. /**
  94355. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94356. * @param type Defines the type of event (PointerEventTypes)
  94357. * @param event Defines the related dom event
  94358. * @param pickInfo Defines the picking info associated to the info (if any)\
  94359. */
  94360. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94361. /**
  94362. * Defines the picking info associated to the info (if any)\
  94363. */
  94364. pickInfo: Nullable<PickingInfo>);
  94365. }
  94366. /**
  94367. * Data relating to a touch event on the screen.
  94368. */
  94369. export interface PointerTouch {
  94370. /**
  94371. * X coordinate of touch.
  94372. */
  94373. x: number;
  94374. /**
  94375. * Y coordinate of touch.
  94376. */
  94377. y: number;
  94378. /**
  94379. * Id of touch. Unique for each finger.
  94380. */
  94381. pointerId: number;
  94382. /**
  94383. * Event type passed from DOM.
  94384. */
  94385. type: any;
  94386. }
  94387. }
  94388. declare module BABYLON {
  94389. /**
  94390. * Manage the mouse inputs to control the movement of a free camera.
  94391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94392. */
  94393. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94394. /**
  94395. * Define if touch is enabled in the mouse input
  94396. */
  94397. touchEnabled: boolean;
  94398. /**
  94399. * Defines the camera the input is attached to.
  94400. */
  94401. camera: FreeCamera;
  94402. /**
  94403. * Defines the buttons associated with the input to handle camera move.
  94404. */
  94405. buttons: number[];
  94406. /**
  94407. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94408. */
  94409. angularSensibility: number;
  94410. private _pointerInput;
  94411. private _onMouseMove;
  94412. private _observer;
  94413. private previousPosition;
  94414. /**
  94415. * Observable for when a pointer move event occurs containing the move offset
  94416. */
  94417. onPointerMovedObservable: Observable<{
  94418. offsetX: number;
  94419. offsetY: number;
  94420. }>;
  94421. /**
  94422. * @hidden
  94423. * If the camera should be rotated automatically based on pointer movement
  94424. */
  94425. _allowCameraRotation: boolean;
  94426. /**
  94427. * Manage the mouse inputs to control the movement of a free camera.
  94428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94429. * @param touchEnabled Defines if touch is enabled or not
  94430. */
  94431. constructor(
  94432. /**
  94433. * Define if touch is enabled in the mouse input
  94434. */
  94435. touchEnabled?: boolean);
  94436. /**
  94437. * Attach the input controls to a specific dom element to get the input from.
  94438. * @param element Defines the element the controls should be listened from
  94439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94440. */
  94441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94442. /**
  94443. * Called on JS contextmenu event.
  94444. * Override this method to provide functionality.
  94445. */
  94446. protected onContextMenu(evt: PointerEvent): void;
  94447. /**
  94448. * Detach the current controls from the specified dom element.
  94449. * @param element Defines the element to stop listening the inputs from
  94450. */
  94451. detachControl(element: Nullable<HTMLElement>): void;
  94452. /**
  94453. * Gets the class name of the current intput.
  94454. * @returns the class name
  94455. */
  94456. getClassName(): string;
  94457. /**
  94458. * Get the friendly name associated with the input class.
  94459. * @returns the input friendly name
  94460. */
  94461. getSimpleName(): string;
  94462. }
  94463. }
  94464. declare module BABYLON {
  94465. /**
  94466. * Manage the touch inputs to control the movement of a free camera.
  94467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94468. */
  94469. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94470. /**
  94471. * Defines the camera the input is attached to.
  94472. */
  94473. camera: FreeCamera;
  94474. /**
  94475. * Defines the touch sensibility for rotation.
  94476. * The higher the faster.
  94477. */
  94478. touchAngularSensibility: number;
  94479. /**
  94480. * Defines the touch sensibility for move.
  94481. * The higher the faster.
  94482. */
  94483. touchMoveSensibility: number;
  94484. private _offsetX;
  94485. private _offsetY;
  94486. private _pointerPressed;
  94487. private _pointerInput;
  94488. private _observer;
  94489. private _onLostFocus;
  94490. /**
  94491. * Attach the input controls to a specific dom element to get the input from.
  94492. * @param element Defines the element the controls should be listened from
  94493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94494. */
  94495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94496. /**
  94497. * Detach the current controls from the specified dom element.
  94498. * @param element Defines the element to stop listening the inputs from
  94499. */
  94500. detachControl(element: Nullable<HTMLElement>): void;
  94501. /**
  94502. * Update the current camera state depending on the inputs that have been used this frame.
  94503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94504. */
  94505. checkInputs(): void;
  94506. /**
  94507. * Gets the class name of the current intput.
  94508. * @returns the class name
  94509. */
  94510. getClassName(): string;
  94511. /**
  94512. * Get the friendly name associated with the input class.
  94513. * @returns the input friendly name
  94514. */
  94515. getSimpleName(): string;
  94516. }
  94517. }
  94518. declare module BABYLON {
  94519. /**
  94520. * Default Inputs manager for the FreeCamera.
  94521. * It groups all the default supported inputs for ease of use.
  94522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94523. */
  94524. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94525. /**
  94526. * @hidden
  94527. */
  94528. _mouseInput: Nullable<FreeCameraMouseInput>;
  94529. /**
  94530. * Instantiates a new FreeCameraInputsManager.
  94531. * @param camera Defines the camera the inputs belong to
  94532. */
  94533. constructor(camera: FreeCamera);
  94534. /**
  94535. * Add keyboard input support to the input manager.
  94536. * @returns the current input manager
  94537. */
  94538. addKeyboard(): FreeCameraInputsManager;
  94539. /**
  94540. * Add mouse input support to the input manager.
  94541. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94542. * @returns the current input manager
  94543. */
  94544. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94545. /**
  94546. * Removes the mouse input support from the manager
  94547. * @returns the current input manager
  94548. */
  94549. removeMouse(): FreeCameraInputsManager;
  94550. /**
  94551. * Add touch input support to the input manager.
  94552. * @returns the current input manager
  94553. */
  94554. addTouch(): FreeCameraInputsManager;
  94555. /**
  94556. * Remove all attached input methods from a camera
  94557. */
  94558. clear(): void;
  94559. }
  94560. }
  94561. declare module BABYLON {
  94562. /**
  94563. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94564. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94565. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94566. */
  94567. export class FreeCamera extends TargetCamera {
  94568. /**
  94569. * Define the collision ellipsoid of the camera.
  94570. * This is helpful to simulate a camera body like the player body around the camera
  94571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94572. */
  94573. ellipsoid: Vector3;
  94574. /**
  94575. * Define an offset for the position of the ellipsoid around the camera.
  94576. * This can be helpful to determine the center of the body near the gravity center of the body
  94577. * instead of its head.
  94578. */
  94579. ellipsoidOffset: Vector3;
  94580. /**
  94581. * Enable or disable collisions of the camera with the rest of the scene objects.
  94582. */
  94583. checkCollisions: boolean;
  94584. /**
  94585. * Enable or disable gravity on the camera.
  94586. */
  94587. applyGravity: boolean;
  94588. /**
  94589. * Define the input manager associated to the camera.
  94590. */
  94591. inputs: FreeCameraInputsManager;
  94592. /**
  94593. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94594. * Higher values reduce sensitivity.
  94595. */
  94596. get angularSensibility(): number;
  94597. /**
  94598. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94599. * Higher values reduce sensitivity.
  94600. */
  94601. set angularSensibility(value: number);
  94602. /**
  94603. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94604. */
  94605. get keysUp(): number[];
  94606. set keysUp(value: number[]);
  94607. /**
  94608. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94609. */
  94610. get keysUpward(): number[];
  94611. set keysUpward(value: number[]);
  94612. /**
  94613. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94614. */
  94615. get keysDown(): number[];
  94616. set keysDown(value: number[]);
  94617. /**
  94618. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94619. */
  94620. get keysDownward(): number[];
  94621. set keysDownward(value: number[]);
  94622. /**
  94623. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94624. */
  94625. get keysLeft(): number[];
  94626. set keysLeft(value: number[]);
  94627. /**
  94628. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94629. */
  94630. get keysRight(): number[];
  94631. set keysRight(value: number[]);
  94632. /**
  94633. * Event raised when the camera collide with a mesh in the scene.
  94634. */
  94635. onCollide: (collidedMesh: AbstractMesh) => void;
  94636. private _collider;
  94637. private _needMoveForGravity;
  94638. private _oldPosition;
  94639. private _diffPosition;
  94640. private _newPosition;
  94641. /** @hidden */
  94642. _localDirection: Vector3;
  94643. /** @hidden */
  94644. _transformedDirection: Vector3;
  94645. /**
  94646. * Instantiates a Free Camera.
  94647. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94648. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94649. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94650. * @param name Define the name of the camera in the scene
  94651. * @param position Define the start position of the camera in the scene
  94652. * @param scene Define the scene the camera belongs to
  94653. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94654. */
  94655. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94656. /**
  94657. * Attached controls to the current camera.
  94658. * @param element Defines the element the controls should be listened from
  94659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94660. */
  94661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94662. /**
  94663. * Detach the current controls from the camera.
  94664. * The camera will stop reacting to inputs.
  94665. * @param element Defines the element to stop listening the inputs from
  94666. */
  94667. detachControl(element: HTMLElement): void;
  94668. private _collisionMask;
  94669. /**
  94670. * Define a collision mask to limit the list of object the camera can collide with
  94671. */
  94672. get collisionMask(): number;
  94673. set collisionMask(mask: number);
  94674. /** @hidden */
  94675. _collideWithWorld(displacement: Vector3): void;
  94676. private _onCollisionPositionChange;
  94677. /** @hidden */
  94678. _checkInputs(): void;
  94679. /** @hidden */
  94680. _decideIfNeedsToMove(): boolean;
  94681. /** @hidden */
  94682. _updatePosition(): void;
  94683. /**
  94684. * Destroy the camera and release the current resources hold by it.
  94685. */
  94686. dispose(): void;
  94687. /**
  94688. * Gets the current object class name.
  94689. * @return the class name
  94690. */
  94691. getClassName(): string;
  94692. }
  94693. }
  94694. declare module BABYLON {
  94695. /**
  94696. * Represents a gamepad control stick position
  94697. */
  94698. export class StickValues {
  94699. /**
  94700. * The x component of the control stick
  94701. */
  94702. x: number;
  94703. /**
  94704. * The y component of the control stick
  94705. */
  94706. y: number;
  94707. /**
  94708. * Initializes the gamepad x and y control stick values
  94709. * @param x The x component of the gamepad control stick value
  94710. * @param y The y component of the gamepad control stick value
  94711. */
  94712. constructor(
  94713. /**
  94714. * The x component of the control stick
  94715. */
  94716. x: number,
  94717. /**
  94718. * The y component of the control stick
  94719. */
  94720. y: number);
  94721. }
  94722. /**
  94723. * An interface which manages callbacks for gamepad button changes
  94724. */
  94725. export interface GamepadButtonChanges {
  94726. /**
  94727. * Called when a gamepad has been changed
  94728. */
  94729. changed: boolean;
  94730. /**
  94731. * Called when a gamepad press event has been triggered
  94732. */
  94733. pressChanged: boolean;
  94734. /**
  94735. * Called when a touch event has been triggered
  94736. */
  94737. touchChanged: boolean;
  94738. /**
  94739. * Called when a value has changed
  94740. */
  94741. valueChanged: boolean;
  94742. }
  94743. /**
  94744. * Represents a gamepad
  94745. */
  94746. export class Gamepad {
  94747. /**
  94748. * The id of the gamepad
  94749. */
  94750. id: string;
  94751. /**
  94752. * The index of the gamepad
  94753. */
  94754. index: number;
  94755. /**
  94756. * The browser gamepad
  94757. */
  94758. browserGamepad: any;
  94759. /**
  94760. * Specifies what type of gamepad this represents
  94761. */
  94762. type: number;
  94763. private _leftStick;
  94764. private _rightStick;
  94765. /** @hidden */
  94766. _isConnected: boolean;
  94767. private _leftStickAxisX;
  94768. private _leftStickAxisY;
  94769. private _rightStickAxisX;
  94770. private _rightStickAxisY;
  94771. /**
  94772. * Triggered when the left control stick has been changed
  94773. */
  94774. private _onleftstickchanged;
  94775. /**
  94776. * Triggered when the right control stick has been changed
  94777. */
  94778. private _onrightstickchanged;
  94779. /**
  94780. * Represents a gamepad controller
  94781. */
  94782. static GAMEPAD: number;
  94783. /**
  94784. * Represents a generic controller
  94785. */
  94786. static GENERIC: number;
  94787. /**
  94788. * Represents an XBox controller
  94789. */
  94790. static XBOX: number;
  94791. /**
  94792. * Represents a pose-enabled controller
  94793. */
  94794. static POSE_ENABLED: number;
  94795. /**
  94796. * Represents an Dual Shock controller
  94797. */
  94798. static DUALSHOCK: number;
  94799. /**
  94800. * Specifies whether the left control stick should be Y-inverted
  94801. */
  94802. protected _invertLeftStickY: boolean;
  94803. /**
  94804. * Specifies if the gamepad has been connected
  94805. */
  94806. get isConnected(): boolean;
  94807. /**
  94808. * Initializes the gamepad
  94809. * @param id The id of the gamepad
  94810. * @param index The index of the gamepad
  94811. * @param browserGamepad The browser gamepad
  94812. * @param leftStickX The x component of the left joystick
  94813. * @param leftStickY The y component of the left joystick
  94814. * @param rightStickX The x component of the right joystick
  94815. * @param rightStickY The y component of the right joystick
  94816. */
  94817. constructor(
  94818. /**
  94819. * The id of the gamepad
  94820. */
  94821. id: string,
  94822. /**
  94823. * The index of the gamepad
  94824. */
  94825. index: number,
  94826. /**
  94827. * The browser gamepad
  94828. */
  94829. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94830. /**
  94831. * Callback triggered when the left joystick has changed
  94832. * @param callback
  94833. */
  94834. onleftstickchanged(callback: (values: StickValues) => void): void;
  94835. /**
  94836. * Callback triggered when the right joystick has changed
  94837. * @param callback
  94838. */
  94839. onrightstickchanged(callback: (values: StickValues) => void): void;
  94840. /**
  94841. * Gets the left joystick
  94842. */
  94843. get leftStick(): StickValues;
  94844. /**
  94845. * Sets the left joystick values
  94846. */
  94847. set leftStick(newValues: StickValues);
  94848. /**
  94849. * Gets the right joystick
  94850. */
  94851. get rightStick(): StickValues;
  94852. /**
  94853. * Sets the right joystick value
  94854. */
  94855. set rightStick(newValues: StickValues);
  94856. /**
  94857. * Updates the gamepad joystick positions
  94858. */
  94859. update(): void;
  94860. /**
  94861. * Disposes the gamepad
  94862. */
  94863. dispose(): void;
  94864. }
  94865. /**
  94866. * Represents a generic gamepad
  94867. */
  94868. export class GenericPad extends Gamepad {
  94869. private _buttons;
  94870. private _onbuttondown;
  94871. private _onbuttonup;
  94872. /**
  94873. * Observable triggered when a button has been pressed
  94874. */
  94875. onButtonDownObservable: Observable<number>;
  94876. /**
  94877. * Observable triggered when a button has been released
  94878. */
  94879. onButtonUpObservable: Observable<number>;
  94880. /**
  94881. * Callback triggered when a button has been pressed
  94882. * @param callback Called when a button has been pressed
  94883. */
  94884. onbuttondown(callback: (buttonPressed: number) => void): void;
  94885. /**
  94886. * Callback triggered when a button has been released
  94887. * @param callback Called when a button has been released
  94888. */
  94889. onbuttonup(callback: (buttonReleased: number) => void): void;
  94890. /**
  94891. * Initializes the generic gamepad
  94892. * @param id The id of the generic gamepad
  94893. * @param index The index of the generic gamepad
  94894. * @param browserGamepad The browser gamepad
  94895. */
  94896. constructor(id: string, index: number, browserGamepad: any);
  94897. private _setButtonValue;
  94898. /**
  94899. * Updates the generic gamepad
  94900. */
  94901. update(): void;
  94902. /**
  94903. * Disposes the generic gamepad
  94904. */
  94905. dispose(): void;
  94906. }
  94907. }
  94908. declare module BABYLON {
  94909. /**
  94910. * Defines the types of pose enabled controllers that are supported
  94911. */
  94912. export enum PoseEnabledControllerType {
  94913. /**
  94914. * HTC Vive
  94915. */
  94916. VIVE = 0,
  94917. /**
  94918. * Oculus Rift
  94919. */
  94920. OCULUS = 1,
  94921. /**
  94922. * Windows mixed reality
  94923. */
  94924. WINDOWS = 2,
  94925. /**
  94926. * Samsung gear VR
  94927. */
  94928. GEAR_VR = 3,
  94929. /**
  94930. * Google Daydream
  94931. */
  94932. DAYDREAM = 4,
  94933. /**
  94934. * Generic
  94935. */
  94936. GENERIC = 5
  94937. }
  94938. /**
  94939. * Defines the MutableGamepadButton interface for the state of a gamepad button
  94940. */
  94941. export interface MutableGamepadButton {
  94942. /**
  94943. * Value of the button/trigger
  94944. */
  94945. value: number;
  94946. /**
  94947. * If the button/trigger is currently touched
  94948. */
  94949. touched: boolean;
  94950. /**
  94951. * If the button/trigger is currently pressed
  94952. */
  94953. pressed: boolean;
  94954. }
  94955. /**
  94956. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  94957. * @hidden
  94958. */
  94959. export interface ExtendedGamepadButton extends GamepadButton {
  94960. /**
  94961. * If the button/trigger is currently pressed
  94962. */
  94963. readonly pressed: boolean;
  94964. /**
  94965. * If the button/trigger is currently touched
  94966. */
  94967. readonly touched: boolean;
  94968. /**
  94969. * Value of the button/trigger
  94970. */
  94971. readonly value: number;
  94972. }
  94973. /** @hidden */
  94974. export interface _GamePadFactory {
  94975. /**
  94976. * Returns whether or not the current gamepad can be created for this type of controller.
  94977. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94978. * @returns true if it can be created, otherwise false
  94979. */
  94980. canCreate(gamepadInfo: any): boolean;
  94981. /**
  94982. * Creates a new instance of the Gamepad.
  94983. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94984. * @returns the new gamepad instance
  94985. */
  94986. create(gamepadInfo: any): Gamepad;
  94987. }
  94988. /**
  94989. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94990. */
  94991. export class PoseEnabledControllerHelper {
  94992. /** @hidden */
  94993. static _ControllerFactories: _GamePadFactory[];
  94994. /** @hidden */
  94995. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  94996. /**
  94997. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94998. * @param vrGamepad the gamepad to initialized
  94999. * @returns a vr controller of the type the gamepad identified as
  95000. */
  95001. static InitiateController(vrGamepad: any): Gamepad;
  95002. }
  95003. /**
  95004. * Defines the PoseEnabledController object that contains state of a vr capable controller
  95005. */
  95006. export class PoseEnabledController extends Gamepad implements PoseControlled {
  95007. /**
  95008. * If the controller is used in a webXR session
  95009. */
  95010. isXR: boolean;
  95011. private _deviceRoomPosition;
  95012. private _deviceRoomRotationQuaternion;
  95013. /**
  95014. * The device position in babylon space
  95015. */
  95016. devicePosition: Vector3;
  95017. /**
  95018. * The device rotation in babylon space
  95019. */
  95020. deviceRotationQuaternion: Quaternion;
  95021. /**
  95022. * The scale factor of the device in babylon space
  95023. */
  95024. deviceScaleFactor: number;
  95025. /**
  95026. * (Likely devicePosition should be used instead) The device position in its room space
  95027. */
  95028. position: Vector3;
  95029. /**
  95030. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  95031. */
  95032. rotationQuaternion: Quaternion;
  95033. /**
  95034. * The type of controller (Eg. Windows mixed reality)
  95035. */
  95036. controllerType: PoseEnabledControllerType;
  95037. protected _calculatedPosition: Vector3;
  95038. private _calculatedRotation;
  95039. /**
  95040. * The raw pose from the device
  95041. */
  95042. rawPose: DevicePose;
  95043. private _trackPosition;
  95044. private _maxRotationDistFromHeadset;
  95045. private _draggedRoomRotation;
  95046. /**
  95047. * @hidden
  95048. */
  95049. _disableTrackPosition(fixedPosition: Vector3): void;
  95050. /**
  95051. * Internal, the mesh attached to the controller
  95052. * @hidden
  95053. */
  95054. _mesh: Nullable<AbstractMesh>;
  95055. private _poseControlledCamera;
  95056. private _leftHandSystemQuaternion;
  95057. /**
  95058. * Internal, matrix used to convert room space to babylon space
  95059. * @hidden
  95060. */
  95061. _deviceToWorld: Matrix;
  95062. /**
  95063. * Node to be used when casting a ray from the controller
  95064. * @hidden
  95065. */
  95066. _pointingPoseNode: Nullable<TransformNode>;
  95067. /**
  95068. * Name of the child mesh that can be used to cast a ray from the controller
  95069. */
  95070. static readonly POINTING_POSE: string;
  95071. /**
  95072. * Creates a new PoseEnabledController from a gamepad
  95073. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  95074. */
  95075. constructor(browserGamepad: any);
  95076. private _workingMatrix;
  95077. /**
  95078. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  95079. */
  95080. update(): void;
  95081. /**
  95082. * Updates only the pose device and mesh without doing any button event checking
  95083. */
  95084. protected _updatePoseAndMesh(): void;
  95085. /**
  95086. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  95087. * @param poseData raw pose fromthe device
  95088. */
  95089. updateFromDevice(poseData: DevicePose): void;
  95090. /**
  95091. * @hidden
  95092. */
  95093. _meshAttachedObservable: Observable<AbstractMesh>;
  95094. /**
  95095. * Attaches a mesh to the controller
  95096. * @param mesh the mesh to be attached
  95097. */
  95098. attachToMesh(mesh: AbstractMesh): void;
  95099. /**
  95100. * Attaches the controllers mesh to a camera
  95101. * @param camera the camera the mesh should be attached to
  95102. */
  95103. attachToPoseControlledCamera(camera: TargetCamera): void;
  95104. /**
  95105. * Disposes of the controller
  95106. */
  95107. dispose(): void;
  95108. /**
  95109. * The mesh that is attached to the controller
  95110. */
  95111. get mesh(): Nullable<AbstractMesh>;
  95112. /**
  95113. * Gets the ray of the controller in the direction the controller is pointing
  95114. * @param length the length the resulting ray should be
  95115. * @returns a ray in the direction the controller is pointing
  95116. */
  95117. getForwardRay(length?: number): Ray;
  95118. }
  95119. }
  95120. declare module BABYLON {
  95121. /**
  95122. * Defines the WebVRController object that represents controllers tracked in 3D space
  95123. */
  95124. export abstract class WebVRController extends PoseEnabledController {
  95125. /**
  95126. * Internal, the default controller model for the controller
  95127. */
  95128. protected _defaultModel: Nullable<AbstractMesh>;
  95129. /**
  95130. * Fired when the trigger state has changed
  95131. */
  95132. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  95133. /**
  95134. * Fired when the main button state has changed
  95135. */
  95136. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95137. /**
  95138. * Fired when the secondary button state has changed
  95139. */
  95140. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  95141. /**
  95142. * Fired when the pad state has changed
  95143. */
  95144. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  95145. /**
  95146. * Fired when controllers stick values have changed
  95147. */
  95148. onPadValuesChangedObservable: Observable<StickValues>;
  95149. /**
  95150. * Array of button availible on the controller
  95151. */
  95152. protected _buttons: Array<MutableGamepadButton>;
  95153. private _onButtonStateChange;
  95154. /**
  95155. * Fired when a controller button's state has changed
  95156. * @param callback the callback containing the button that was modified
  95157. */
  95158. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  95159. /**
  95160. * X and Y axis corresponding to the controllers joystick
  95161. */
  95162. pad: StickValues;
  95163. /**
  95164. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  95165. */
  95166. hand: string;
  95167. /**
  95168. * The default controller model for the controller
  95169. */
  95170. get defaultModel(): Nullable<AbstractMesh>;
  95171. /**
  95172. * Creates a new WebVRController from a gamepad
  95173. * @param vrGamepad the gamepad that the WebVRController should be created from
  95174. */
  95175. constructor(vrGamepad: any);
  95176. /**
  95177. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  95178. */
  95179. update(): void;
  95180. /**
  95181. * Function to be called when a button is modified
  95182. */
  95183. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  95184. /**
  95185. * Loads a mesh and attaches it to the controller
  95186. * @param scene the scene the mesh should be added to
  95187. * @param meshLoaded callback for when the mesh has been loaded
  95188. */
  95189. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  95190. private _setButtonValue;
  95191. private _changes;
  95192. private _checkChanges;
  95193. /**
  95194. * Disposes of th webVRCOntroller
  95195. */
  95196. dispose(): void;
  95197. }
  95198. }
  95199. declare module BABYLON {
  95200. /**
  95201. * The HemisphericLight simulates the ambient environment light,
  95202. * so the passed direction is the light reflection direction, not the incoming direction.
  95203. */
  95204. export class HemisphericLight extends Light {
  95205. /**
  95206. * The groundColor is the light in the opposite direction to the one specified during creation.
  95207. * 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.
  95208. */
  95209. groundColor: Color3;
  95210. /**
  95211. * The light reflection direction, not the incoming direction.
  95212. */
  95213. direction: Vector3;
  95214. /**
  95215. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95216. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95217. * The HemisphericLight can't cast shadows.
  95218. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95219. * @param name The friendly name of the light
  95220. * @param direction The direction of the light reflection
  95221. * @param scene The scene the light belongs to
  95222. */
  95223. constructor(name: string, direction: Vector3, scene: Scene);
  95224. protected _buildUniformLayout(): void;
  95225. /**
  95226. * Returns the string "HemisphericLight".
  95227. * @return The class name
  95228. */
  95229. getClassName(): string;
  95230. /**
  95231. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95232. * Returns the updated direction.
  95233. * @param target The target the direction should point to
  95234. * @return The computed direction
  95235. */
  95236. setDirectionToTarget(target: Vector3): Vector3;
  95237. /**
  95238. * Returns the shadow generator associated to the light.
  95239. * @returns Always null for hemispheric lights because it does not support shadows.
  95240. */
  95241. getShadowGenerator(): Nullable<IShadowGenerator>;
  95242. /**
  95243. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95244. * @param effect The effect to update
  95245. * @param lightIndex The index of the light in the effect to update
  95246. * @returns The hemispheric light
  95247. */
  95248. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95249. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95250. /**
  95251. * Computes the world matrix of the node
  95252. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95253. * @param useWasUpdatedFlag defines a reserved property
  95254. * @returns the world matrix
  95255. */
  95256. computeWorldMatrix(): Matrix;
  95257. /**
  95258. * Returns the integer 3.
  95259. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95260. */
  95261. getTypeID(): number;
  95262. /**
  95263. * Prepares the list of defines specific to the light type.
  95264. * @param defines the list of defines
  95265. * @param lightIndex defines the index of the light for the effect
  95266. */
  95267. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95268. }
  95269. }
  95270. declare module BABYLON {
  95271. /** @hidden */
  95272. export var vrMultiviewToSingleviewPixelShader: {
  95273. name: string;
  95274. shader: string;
  95275. };
  95276. }
  95277. declare module BABYLON {
  95278. /**
  95279. * Renders to multiple views with a single draw call
  95280. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95281. */
  95282. export class MultiviewRenderTarget extends RenderTargetTexture {
  95283. /**
  95284. * Creates a multiview render target
  95285. * @param scene scene used with the render target
  95286. * @param size the size of the render target (used for each view)
  95287. */
  95288. constructor(scene: Scene, size?: number | {
  95289. width: number;
  95290. height: number;
  95291. } | {
  95292. ratio: number;
  95293. });
  95294. /**
  95295. * @hidden
  95296. * @param faceIndex the face index, if its a cube texture
  95297. */
  95298. _bindFrameBuffer(faceIndex?: number): void;
  95299. /**
  95300. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95301. * @returns the view count
  95302. */
  95303. getViewCount(): number;
  95304. }
  95305. }
  95306. declare module BABYLON {
  95307. /**
  95308. * Represents a camera frustum
  95309. */
  95310. export class Frustum {
  95311. /**
  95312. * Gets the planes representing the frustum
  95313. * @param transform matrix to be applied to the returned planes
  95314. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95315. */
  95316. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95317. /**
  95318. * Gets the near frustum plane transformed by the transform matrix
  95319. * @param transform transformation matrix to be applied to the resulting frustum plane
  95320. * @param frustumPlane the resuling frustum plane
  95321. */
  95322. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95323. /**
  95324. * Gets the far frustum plane transformed by the transform matrix
  95325. * @param transform transformation matrix to be applied to the resulting frustum plane
  95326. * @param frustumPlane the resuling frustum plane
  95327. */
  95328. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95329. /**
  95330. * Gets the left frustum plane transformed by the transform matrix
  95331. * @param transform transformation matrix to be applied to the resulting frustum plane
  95332. * @param frustumPlane the resuling frustum plane
  95333. */
  95334. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95335. /**
  95336. * Gets the right frustum plane transformed by the transform matrix
  95337. * @param transform transformation matrix to be applied to the resulting frustum plane
  95338. * @param frustumPlane the resuling frustum plane
  95339. */
  95340. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95341. /**
  95342. * Gets the top frustum plane transformed by the transform matrix
  95343. * @param transform transformation matrix to be applied to the resulting frustum plane
  95344. * @param frustumPlane the resuling frustum plane
  95345. */
  95346. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95347. /**
  95348. * Gets the bottom frustum plane transformed by the transform matrix
  95349. * @param transform transformation matrix to be applied to the resulting frustum plane
  95350. * @param frustumPlane the resuling frustum plane
  95351. */
  95352. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95353. /**
  95354. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95355. * @param transform transformation matrix to be applied to the resulting frustum planes
  95356. * @param frustumPlanes the resuling frustum planes
  95357. */
  95358. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95359. }
  95360. }
  95361. declare module BABYLON {
  95362. interface Engine {
  95363. /**
  95364. * Creates a new multiview render target
  95365. * @param width defines the width of the texture
  95366. * @param height defines the height of the texture
  95367. * @returns the created multiview texture
  95368. */
  95369. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95370. /**
  95371. * Binds a multiview framebuffer to be drawn to
  95372. * @param multiviewTexture texture to bind
  95373. */
  95374. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95375. }
  95376. interface Camera {
  95377. /**
  95378. * @hidden
  95379. * 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)
  95380. */
  95381. _useMultiviewToSingleView: boolean;
  95382. /**
  95383. * @hidden
  95384. * 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)
  95385. */
  95386. _multiviewTexture: Nullable<RenderTargetTexture>;
  95387. /**
  95388. * @hidden
  95389. * ensures the multiview texture of the camera exists and has the specified width/height
  95390. * @param width height to set on the multiview texture
  95391. * @param height width to set on the multiview texture
  95392. */
  95393. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95394. }
  95395. interface Scene {
  95396. /** @hidden */
  95397. _transformMatrixR: Matrix;
  95398. /** @hidden */
  95399. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95400. /** @hidden */
  95401. _createMultiviewUbo(): void;
  95402. /** @hidden */
  95403. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95404. /** @hidden */
  95405. _renderMultiviewToSingleView(camera: Camera): void;
  95406. }
  95407. }
  95408. declare module BABYLON {
  95409. /**
  95410. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95411. * This will not be used for webXR as it supports displaying texture arrays directly
  95412. */
  95413. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95414. /**
  95415. * Initializes a VRMultiviewToSingleview
  95416. * @param name name of the post process
  95417. * @param camera camera to be applied to
  95418. * @param scaleFactor scaling factor to the size of the output texture
  95419. */
  95420. constructor(name: string, camera: Camera, scaleFactor: number);
  95421. }
  95422. }
  95423. declare module BABYLON {
  95424. /**
  95425. * Interface used to define additional presentation attributes
  95426. */
  95427. export interface IVRPresentationAttributes {
  95428. /**
  95429. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95430. */
  95431. highRefreshRate: boolean;
  95432. /**
  95433. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95434. */
  95435. foveationLevel: number;
  95436. }
  95437. interface Engine {
  95438. /** @hidden */
  95439. _vrDisplay: any;
  95440. /** @hidden */
  95441. _vrSupported: boolean;
  95442. /** @hidden */
  95443. _oldSize: Size;
  95444. /** @hidden */
  95445. _oldHardwareScaleFactor: number;
  95446. /** @hidden */
  95447. _vrExclusivePointerMode: boolean;
  95448. /** @hidden */
  95449. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95450. /** @hidden */
  95451. _onVRDisplayPointerRestricted: () => void;
  95452. /** @hidden */
  95453. _onVRDisplayPointerUnrestricted: () => void;
  95454. /** @hidden */
  95455. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95456. /** @hidden */
  95457. _onVrDisplayDisconnect: Nullable<() => void>;
  95458. /** @hidden */
  95459. _onVrDisplayPresentChange: Nullable<() => void>;
  95460. /**
  95461. * Observable signaled when VR display mode changes
  95462. */
  95463. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95464. /**
  95465. * Observable signaled when VR request present is complete
  95466. */
  95467. onVRRequestPresentComplete: Observable<boolean>;
  95468. /**
  95469. * Observable signaled when VR request present starts
  95470. */
  95471. onVRRequestPresentStart: Observable<Engine>;
  95472. /**
  95473. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95474. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95475. */
  95476. isInVRExclusivePointerMode: boolean;
  95477. /**
  95478. * Gets a boolean indicating if a webVR device was detected
  95479. * @returns true if a webVR device was detected
  95480. */
  95481. isVRDevicePresent(): boolean;
  95482. /**
  95483. * Gets the current webVR device
  95484. * @returns the current webVR device (or null)
  95485. */
  95486. getVRDevice(): any;
  95487. /**
  95488. * Initializes a webVR display and starts listening to display change events
  95489. * The onVRDisplayChangedObservable will be notified upon these changes
  95490. * @returns A promise containing a VRDisplay and if vr is supported
  95491. */
  95492. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95493. /** @hidden */
  95494. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95495. /**
  95496. * Gets or sets the presentation attributes used to configure VR rendering
  95497. */
  95498. vrPresentationAttributes?: IVRPresentationAttributes;
  95499. /**
  95500. * Call this function to switch to webVR mode
  95501. * Will do nothing if webVR is not supported or if there is no webVR device
  95502. * @param options the webvr options provided to the camera. mainly used for multiview
  95503. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95504. */
  95505. enableVR(options: WebVROptions): void;
  95506. /** @hidden */
  95507. _onVRFullScreenTriggered(): void;
  95508. }
  95509. }
  95510. declare module BABYLON {
  95511. /**
  95512. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95513. * IMPORTANT!! The data is right-hand data.
  95514. * @export
  95515. * @interface DevicePose
  95516. */
  95517. export interface DevicePose {
  95518. /**
  95519. * The position of the device, values in array are [x,y,z].
  95520. */
  95521. readonly position: Nullable<Float32Array>;
  95522. /**
  95523. * The linearVelocity of the device, values in array are [x,y,z].
  95524. */
  95525. readonly linearVelocity: Nullable<Float32Array>;
  95526. /**
  95527. * The linearAcceleration of the device, values in array are [x,y,z].
  95528. */
  95529. readonly linearAcceleration: Nullable<Float32Array>;
  95530. /**
  95531. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95532. */
  95533. readonly orientation: Nullable<Float32Array>;
  95534. /**
  95535. * The angularVelocity of the device, values in array are [x,y,z].
  95536. */
  95537. readonly angularVelocity: Nullable<Float32Array>;
  95538. /**
  95539. * The angularAcceleration of the device, values in array are [x,y,z].
  95540. */
  95541. readonly angularAcceleration: Nullable<Float32Array>;
  95542. }
  95543. /**
  95544. * Interface representing a pose controlled object in Babylon.
  95545. * A pose controlled object has both regular pose values as well as pose values
  95546. * from an external device such as a VR head mounted display
  95547. */
  95548. export interface PoseControlled {
  95549. /**
  95550. * The position of the object in babylon space.
  95551. */
  95552. position: Vector3;
  95553. /**
  95554. * The rotation quaternion of the object in babylon space.
  95555. */
  95556. rotationQuaternion: Quaternion;
  95557. /**
  95558. * The position of the device in babylon space.
  95559. */
  95560. devicePosition?: Vector3;
  95561. /**
  95562. * The rotation quaternion of the device in babylon space.
  95563. */
  95564. deviceRotationQuaternion: Quaternion;
  95565. /**
  95566. * The raw pose coming from the device.
  95567. */
  95568. rawPose: Nullable<DevicePose>;
  95569. /**
  95570. * The scale of the device to be used when translating from device space to babylon space.
  95571. */
  95572. deviceScaleFactor: number;
  95573. /**
  95574. * Updates the poseControlled values based on the input device pose.
  95575. * @param poseData the pose data to update the object with
  95576. */
  95577. updateFromDevice(poseData: DevicePose): void;
  95578. }
  95579. /**
  95580. * Set of options to customize the webVRCamera
  95581. */
  95582. export interface WebVROptions {
  95583. /**
  95584. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95585. */
  95586. trackPosition?: boolean;
  95587. /**
  95588. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95589. */
  95590. positionScale?: number;
  95591. /**
  95592. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95593. */
  95594. displayName?: string;
  95595. /**
  95596. * Should the native controller meshes be initialized. (default: true)
  95597. */
  95598. controllerMeshes?: boolean;
  95599. /**
  95600. * Creating a default HemiLight only on controllers. (default: true)
  95601. */
  95602. defaultLightingOnControllers?: boolean;
  95603. /**
  95604. * If you don't want to use the default VR button of the helper. (default: false)
  95605. */
  95606. useCustomVRButton?: boolean;
  95607. /**
  95608. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95609. */
  95610. customVRButton?: HTMLButtonElement;
  95611. /**
  95612. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95613. */
  95614. rayLength?: number;
  95615. /**
  95616. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95617. */
  95618. defaultHeight?: number;
  95619. /**
  95620. * If multiview should be used if availible (default: false)
  95621. */
  95622. useMultiview?: boolean;
  95623. }
  95624. /**
  95625. * This represents a WebVR camera.
  95626. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95627. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95628. */
  95629. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95630. private webVROptions;
  95631. /**
  95632. * @hidden
  95633. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95634. */
  95635. _vrDevice: any;
  95636. /**
  95637. * The rawPose of the vrDevice.
  95638. */
  95639. rawPose: Nullable<DevicePose>;
  95640. private _onVREnabled;
  95641. private _specsVersion;
  95642. private _attached;
  95643. private _frameData;
  95644. protected _descendants: Array<Node>;
  95645. private _deviceRoomPosition;
  95646. /** @hidden */
  95647. _deviceRoomRotationQuaternion: Quaternion;
  95648. private _standingMatrix;
  95649. /**
  95650. * Represents device position in babylon space.
  95651. */
  95652. devicePosition: Vector3;
  95653. /**
  95654. * Represents device rotation in babylon space.
  95655. */
  95656. deviceRotationQuaternion: Quaternion;
  95657. /**
  95658. * The scale of the device to be used when translating from device space to babylon space.
  95659. */
  95660. deviceScaleFactor: number;
  95661. private _deviceToWorld;
  95662. private _worldToDevice;
  95663. /**
  95664. * References to the webVR controllers for the vrDevice.
  95665. */
  95666. controllers: Array<WebVRController>;
  95667. /**
  95668. * Emits an event when a controller is attached.
  95669. */
  95670. onControllersAttachedObservable: Observable<WebVRController[]>;
  95671. /**
  95672. * Emits an event when a controller's mesh has been loaded;
  95673. */
  95674. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95675. /**
  95676. * Emits an event when the HMD's pose has been updated.
  95677. */
  95678. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95679. private _poseSet;
  95680. /**
  95681. * If the rig cameras be used as parent instead of this camera.
  95682. */
  95683. rigParenting: boolean;
  95684. private _lightOnControllers;
  95685. private _defaultHeight?;
  95686. /**
  95687. * Instantiates a WebVRFreeCamera.
  95688. * @param name The name of the WebVRFreeCamera
  95689. * @param position The starting anchor position for the camera
  95690. * @param scene The scene the camera belongs to
  95691. * @param webVROptions a set of customizable options for the webVRCamera
  95692. */
  95693. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95694. /**
  95695. * Gets the device distance from the ground in meters.
  95696. * @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.
  95697. */
  95698. deviceDistanceToRoomGround(): number;
  95699. /**
  95700. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95701. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95702. */
  95703. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95704. /**
  95705. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95706. * @returns A promise with a boolean set to if the standing matrix is supported.
  95707. */
  95708. useStandingMatrixAsync(): Promise<boolean>;
  95709. /**
  95710. * Disposes the camera
  95711. */
  95712. dispose(): void;
  95713. /**
  95714. * Gets a vrController by name.
  95715. * @param name The name of the controller to retreive
  95716. * @returns the controller matching the name specified or null if not found
  95717. */
  95718. getControllerByName(name: string): Nullable<WebVRController>;
  95719. private _leftController;
  95720. /**
  95721. * The controller corresponding to the users left hand.
  95722. */
  95723. get leftController(): Nullable<WebVRController>;
  95724. private _rightController;
  95725. /**
  95726. * The controller corresponding to the users right hand.
  95727. */
  95728. get rightController(): Nullable<WebVRController>;
  95729. /**
  95730. * Casts a ray forward from the vrCamera's gaze.
  95731. * @param length Length of the ray (default: 100)
  95732. * @returns the ray corresponding to the gaze
  95733. */
  95734. getForwardRay(length?: number): Ray;
  95735. /**
  95736. * @hidden
  95737. * Updates the camera based on device's frame data
  95738. */
  95739. _checkInputs(): void;
  95740. /**
  95741. * Updates the poseControlled values based on the input device pose.
  95742. * @param poseData Pose coming from the device
  95743. */
  95744. updateFromDevice(poseData: DevicePose): void;
  95745. private _htmlElementAttached;
  95746. private _detachIfAttached;
  95747. /**
  95748. * WebVR's attach control will start broadcasting frames to the device.
  95749. * Note that in certain browsers (chrome for example) this function must be called
  95750. * within a user-interaction callback. Example:
  95751. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95752. *
  95753. * @param element html element to attach the vrDevice to
  95754. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95755. */
  95756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95757. /**
  95758. * Detaches the camera from the html element and disables VR
  95759. *
  95760. * @param element html element to detach from
  95761. */
  95762. detachControl(element: HTMLElement): void;
  95763. /**
  95764. * @returns the name of this class
  95765. */
  95766. getClassName(): string;
  95767. /**
  95768. * Calls resetPose on the vrDisplay
  95769. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95770. */
  95771. resetToCurrentRotation(): void;
  95772. /**
  95773. * @hidden
  95774. * Updates the rig cameras (left and right eye)
  95775. */
  95776. _updateRigCameras(): void;
  95777. private _workingVector;
  95778. private _oneVector;
  95779. private _workingMatrix;
  95780. private updateCacheCalled;
  95781. private _correctPositionIfNotTrackPosition;
  95782. /**
  95783. * @hidden
  95784. * Updates the cached values of the camera
  95785. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95786. */
  95787. _updateCache(ignoreParentClass?: boolean): void;
  95788. /**
  95789. * @hidden
  95790. * Get current device position in babylon world
  95791. */
  95792. _computeDevicePosition(): void;
  95793. /**
  95794. * Updates the current device position and rotation in the babylon world
  95795. */
  95796. update(): void;
  95797. /**
  95798. * @hidden
  95799. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95800. * @returns an identity matrix
  95801. */
  95802. _getViewMatrix(): Matrix;
  95803. private _tmpMatrix;
  95804. /**
  95805. * This function is called by the two RIG cameras.
  95806. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95807. * @hidden
  95808. */
  95809. _getWebVRViewMatrix(): Matrix;
  95810. /** @hidden */
  95811. _getWebVRProjectionMatrix(): Matrix;
  95812. private _onGamepadConnectedObserver;
  95813. private _onGamepadDisconnectedObserver;
  95814. private _updateCacheWhenTrackingDisabledObserver;
  95815. /**
  95816. * Initializes the controllers and their meshes
  95817. */
  95818. initControllers(): void;
  95819. }
  95820. }
  95821. declare module BABYLON {
  95822. /**
  95823. * Size options for a post process
  95824. */
  95825. export type PostProcessOptions = {
  95826. width: number;
  95827. height: number;
  95828. };
  95829. /**
  95830. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95831. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95832. */
  95833. export class PostProcess {
  95834. /** Name of the PostProcess. */
  95835. name: string;
  95836. /**
  95837. * Gets or sets the unique id of the post process
  95838. */
  95839. uniqueId: number;
  95840. /**
  95841. * Width of the texture to apply the post process on
  95842. */
  95843. width: number;
  95844. /**
  95845. * Height of the texture to apply the post process on
  95846. */
  95847. height: number;
  95848. /**
  95849. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95850. * @hidden
  95851. */
  95852. _outputTexture: Nullable<InternalTexture>;
  95853. /**
  95854. * Sampling mode used by the shader
  95855. * See https://doc.babylonjs.com/classes/3.1/texture
  95856. */
  95857. renderTargetSamplingMode: number;
  95858. /**
  95859. * Clear color to use when screen clearing
  95860. */
  95861. clearColor: Color4;
  95862. /**
  95863. * If the buffer needs to be cleared before applying the post process. (default: true)
  95864. * Should be set to false if shader will overwrite all previous pixels.
  95865. */
  95866. autoClear: boolean;
  95867. /**
  95868. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95869. */
  95870. alphaMode: number;
  95871. /**
  95872. * Sets the setAlphaBlendConstants of the babylon engine
  95873. */
  95874. alphaConstants: Color4;
  95875. /**
  95876. * Animations to be used for the post processing
  95877. */
  95878. animations: Animation[];
  95879. /**
  95880. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95881. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95882. */
  95883. enablePixelPerfectMode: boolean;
  95884. /**
  95885. * Force the postprocess to be applied without taking in account viewport
  95886. */
  95887. forceFullscreenViewport: boolean;
  95888. /**
  95889. * List of inspectable custom properties (used by the Inspector)
  95890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95891. */
  95892. inspectableCustomProperties: IInspectable[];
  95893. /**
  95894. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95895. *
  95896. * | Value | Type | Description |
  95897. * | ----- | ----------------------------------- | ----------- |
  95898. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95899. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95900. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95901. *
  95902. */
  95903. scaleMode: number;
  95904. /**
  95905. * Force textures to be a power of two (default: false)
  95906. */
  95907. alwaysForcePOT: boolean;
  95908. private _samples;
  95909. /**
  95910. * Number of sample textures (default: 1)
  95911. */
  95912. get samples(): number;
  95913. set samples(n: number);
  95914. /**
  95915. * Modify the scale of the post process to be the same as the viewport (default: false)
  95916. */
  95917. adaptScaleToCurrentViewport: boolean;
  95918. private _camera;
  95919. private _scene;
  95920. private _engine;
  95921. private _options;
  95922. private _reusable;
  95923. private _textureType;
  95924. private _textureFormat;
  95925. /**
  95926. * Smart array of input and output textures for the post process.
  95927. * @hidden
  95928. */
  95929. _textures: SmartArray<InternalTexture>;
  95930. /**
  95931. * The index in _textures that corresponds to the output texture.
  95932. * @hidden
  95933. */
  95934. _currentRenderTextureInd: number;
  95935. private _effect;
  95936. private _samplers;
  95937. private _fragmentUrl;
  95938. private _vertexUrl;
  95939. private _parameters;
  95940. private _scaleRatio;
  95941. protected _indexParameters: any;
  95942. private _shareOutputWithPostProcess;
  95943. private _texelSize;
  95944. private _forcedOutputTexture;
  95945. /**
  95946. * Returns the fragment url or shader name used in the post process.
  95947. * @returns the fragment url or name in the shader store.
  95948. */
  95949. getEffectName(): string;
  95950. /**
  95951. * An event triggered when the postprocess is activated.
  95952. */
  95953. onActivateObservable: Observable<Camera>;
  95954. private _onActivateObserver;
  95955. /**
  95956. * A function that is added to the onActivateObservable
  95957. */
  95958. set onActivate(callback: Nullable<(camera: Camera) => void>);
  95959. /**
  95960. * An event triggered when the postprocess changes its size.
  95961. */
  95962. onSizeChangedObservable: Observable<PostProcess>;
  95963. private _onSizeChangedObserver;
  95964. /**
  95965. * A function that is added to the onSizeChangedObservable
  95966. */
  95967. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  95968. /**
  95969. * An event triggered when the postprocess applies its effect.
  95970. */
  95971. onApplyObservable: Observable<Effect>;
  95972. private _onApplyObserver;
  95973. /**
  95974. * A function that is added to the onApplyObservable
  95975. */
  95976. set onApply(callback: (effect: Effect) => void);
  95977. /**
  95978. * An event triggered before rendering the postprocess
  95979. */
  95980. onBeforeRenderObservable: Observable<Effect>;
  95981. private _onBeforeRenderObserver;
  95982. /**
  95983. * A function that is added to the onBeforeRenderObservable
  95984. */
  95985. set onBeforeRender(callback: (effect: Effect) => void);
  95986. /**
  95987. * An event triggered after rendering the postprocess
  95988. */
  95989. onAfterRenderObservable: Observable<Effect>;
  95990. private _onAfterRenderObserver;
  95991. /**
  95992. * A function that is added to the onAfterRenderObservable
  95993. */
  95994. set onAfterRender(callback: (efect: Effect) => void);
  95995. /**
  95996. * 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
  95997. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  95998. */
  95999. get inputTexture(): InternalTexture;
  96000. set inputTexture(value: InternalTexture);
  96001. /**
  96002. * Gets the camera which post process is applied to.
  96003. * @returns The camera the post process is applied to.
  96004. */
  96005. getCamera(): Camera;
  96006. /**
  96007. * Gets the texel size of the postprocess.
  96008. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  96009. */
  96010. get texelSize(): Vector2;
  96011. /**
  96012. * Creates a new instance PostProcess
  96013. * @param name The name of the PostProcess.
  96014. * @param fragmentUrl The url of the fragment shader to be used.
  96015. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  96016. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  96017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96018. * @param camera The camera to apply the render pass to.
  96019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96020. * @param engine The engine which the post process will be applied. (default: current engine)
  96021. * @param reusable If the post process can be reused on the same frame. (default: false)
  96022. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  96023. * @param textureType Type of textures used when performing the post process. (default: 0)
  96024. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  96025. * @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
  96026. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  96027. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  96028. */
  96029. constructor(
  96030. /** Name of the PostProcess. */
  96031. 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, textureFormat?: number);
  96032. /**
  96033. * Gets a string idenfifying the name of the class
  96034. * @returns "PostProcess" string
  96035. */
  96036. getClassName(): string;
  96037. /**
  96038. * Gets the engine which this post process belongs to.
  96039. * @returns The engine the post process was enabled with.
  96040. */
  96041. getEngine(): Engine;
  96042. /**
  96043. * The effect that is created when initializing the post process.
  96044. * @returns The created effect corresponding the the postprocess.
  96045. */
  96046. getEffect(): Effect;
  96047. /**
  96048. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  96049. * @param postProcess The post process to share the output with.
  96050. * @returns This post process.
  96051. */
  96052. shareOutputWith(postProcess: PostProcess): PostProcess;
  96053. /**
  96054. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  96055. * This should be called if the post process that shares output with this post process is disabled/disposed.
  96056. */
  96057. useOwnOutput(): void;
  96058. /**
  96059. * Updates the effect with the current post process compile time values and recompiles the shader.
  96060. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96061. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96062. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96063. * @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
  96064. * @param onCompiled Called when the shader has been compiled.
  96065. * @param onError Called if there is an error when compiling a shader.
  96066. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  96067. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  96068. */
  96069. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  96070. /**
  96071. * The post process is reusable if it can be used multiple times within one frame.
  96072. * @returns If the post process is reusable
  96073. */
  96074. isReusable(): boolean;
  96075. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  96076. markTextureDirty(): void;
  96077. /**
  96078. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  96079. * 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.
  96080. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  96081. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  96082. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  96083. * @returns The target texture that was bound to be written to.
  96084. */
  96085. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  96086. /**
  96087. * If the post process is supported.
  96088. */
  96089. get isSupported(): boolean;
  96090. /**
  96091. * The aspect ratio of the output texture.
  96092. */
  96093. get aspectRatio(): number;
  96094. /**
  96095. * Get a value indicating if the post-process is ready to be used
  96096. * @returns true if the post-process is ready (shader is compiled)
  96097. */
  96098. isReady(): boolean;
  96099. /**
  96100. * Binds all textures and uniforms to the shader, this will be run on every pass.
  96101. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  96102. */
  96103. apply(): Nullable<Effect>;
  96104. private _disposeTextures;
  96105. /**
  96106. * Disposes the post process.
  96107. * @param camera The camera to dispose the post process on.
  96108. */
  96109. dispose(camera?: Camera): void;
  96110. }
  96111. }
  96112. declare module BABYLON {
  96113. /** @hidden */
  96114. export var kernelBlurVaryingDeclaration: {
  96115. name: string;
  96116. shader: string;
  96117. };
  96118. }
  96119. declare module BABYLON {
  96120. /** @hidden */
  96121. export var kernelBlurFragment: {
  96122. name: string;
  96123. shader: string;
  96124. };
  96125. }
  96126. declare module BABYLON {
  96127. /** @hidden */
  96128. export var kernelBlurFragment2: {
  96129. name: string;
  96130. shader: string;
  96131. };
  96132. }
  96133. declare module BABYLON {
  96134. /** @hidden */
  96135. export var kernelBlurPixelShader: {
  96136. name: string;
  96137. shader: string;
  96138. };
  96139. }
  96140. declare module BABYLON {
  96141. /** @hidden */
  96142. export var kernelBlurVertex: {
  96143. name: string;
  96144. shader: string;
  96145. };
  96146. }
  96147. declare module BABYLON {
  96148. /** @hidden */
  96149. export var kernelBlurVertexShader: {
  96150. name: string;
  96151. shader: string;
  96152. };
  96153. }
  96154. declare module BABYLON {
  96155. /**
  96156. * The Blur Post Process which blurs an image based on a kernel and direction.
  96157. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  96158. */
  96159. export class BlurPostProcess extends PostProcess {
  96160. /** The direction in which to blur the image. */
  96161. direction: Vector2;
  96162. private blockCompilation;
  96163. protected _kernel: number;
  96164. protected _idealKernel: number;
  96165. protected _packedFloat: boolean;
  96166. private _staticDefines;
  96167. /**
  96168. * Sets the length in pixels of the blur sample region
  96169. */
  96170. set kernel(v: number);
  96171. /**
  96172. * Gets the length in pixels of the blur sample region
  96173. */
  96174. get kernel(): number;
  96175. /**
  96176. * Sets wether or not the blur needs to unpack/repack floats
  96177. */
  96178. set packedFloat(v: boolean);
  96179. /**
  96180. * Gets wether or not the blur is unpacking/repacking floats
  96181. */
  96182. get packedFloat(): boolean;
  96183. /**
  96184. * Creates a new instance BlurPostProcess
  96185. * @param name The name of the effect.
  96186. * @param direction The direction in which to blur the image.
  96187. * @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.
  96188. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  96189. * @param camera The camera to apply the render pass to.
  96190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96191. * @param engine The engine which the post process will be applied. (default: current engine)
  96192. * @param reusable If the post process can be reused on the same frame. (default: false)
  96193. * @param textureType Type of textures used when performing the post process. (default: 0)
  96194. * @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)
  96195. */
  96196. constructor(name: string,
  96197. /** The direction in which to blur the image. */
  96198. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  96199. /**
  96200. * Updates the effect with the current post process compile time values and recompiles the shader.
  96201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  96202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96204. * @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
  96205. * @param onCompiled Called when the shader has been compiled.
  96206. * @param onError Called if there is an error when compiling a shader.
  96207. */
  96208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96209. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96210. /**
  96211. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96212. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96213. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96214. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96215. * The gaps between physical kernels are compensated for in the weighting of the samples
  96216. * @param idealKernel Ideal blur kernel.
  96217. * @return Nearest best kernel.
  96218. */
  96219. protected _nearestBestKernel(idealKernel: number): number;
  96220. /**
  96221. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96222. * @param x The point on the Gaussian distribution to sample.
  96223. * @return the value of the Gaussian function at x.
  96224. */
  96225. protected _gaussianWeight(x: number): number;
  96226. /**
  96227. * Generates a string that can be used as a floating point number in GLSL.
  96228. * @param x Value to print.
  96229. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96230. * @return GLSL float string.
  96231. */
  96232. protected _glslFloat(x: number, decimalFigures?: number): string;
  96233. }
  96234. }
  96235. declare module BABYLON {
  96236. /**
  96237. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96238. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96239. * You can then easily use it as a reflectionTexture on a flat surface.
  96240. * In case the surface is not a plane, please consider relying on reflection probes.
  96241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96242. */
  96243. export class MirrorTexture extends RenderTargetTexture {
  96244. private scene;
  96245. /**
  96246. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96247. * 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.
  96248. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96249. */
  96250. mirrorPlane: Plane;
  96251. /**
  96252. * Define the blur ratio used to blur the reflection if needed.
  96253. */
  96254. set blurRatio(value: number);
  96255. get blurRatio(): number;
  96256. /**
  96257. * Define the adaptive blur kernel used to blur the reflection if needed.
  96258. * This will autocompute the closest best match for the `blurKernel`
  96259. */
  96260. set adaptiveBlurKernel(value: number);
  96261. /**
  96262. * Define the blur kernel used to blur the reflection if needed.
  96263. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96264. */
  96265. set blurKernel(value: number);
  96266. /**
  96267. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96268. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96269. */
  96270. set blurKernelX(value: number);
  96271. get blurKernelX(): number;
  96272. /**
  96273. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96274. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96275. */
  96276. set blurKernelY(value: number);
  96277. get blurKernelY(): number;
  96278. private _autoComputeBlurKernel;
  96279. protected _onRatioRescale(): void;
  96280. private _updateGammaSpace;
  96281. private _imageProcessingConfigChangeObserver;
  96282. private _transformMatrix;
  96283. private _mirrorMatrix;
  96284. private _savedViewMatrix;
  96285. private _blurX;
  96286. private _blurY;
  96287. private _adaptiveBlurKernel;
  96288. private _blurKernelX;
  96289. private _blurKernelY;
  96290. private _blurRatio;
  96291. /**
  96292. * Instantiates a Mirror Texture.
  96293. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96294. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96295. * You can then easily use it as a reflectionTexture on a flat surface.
  96296. * In case the surface is not a plane, please consider relying on reflection probes.
  96297. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96298. * @param name
  96299. * @param size
  96300. * @param scene
  96301. * @param generateMipMaps
  96302. * @param type
  96303. * @param samplingMode
  96304. * @param generateDepthBuffer
  96305. */
  96306. constructor(name: string, size: number | {
  96307. width: number;
  96308. height: number;
  96309. } | {
  96310. ratio: number;
  96311. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96312. private _preparePostProcesses;
  96313. /**
  96314. * Clone the mirror texture.
  96315. * @returns the cloned texture
  96316. */
  96317. clone(): MirrorTexture;
  96318. /**
  96319. * Serialize the texture to a JSON representation you could use in Parse later on
  96320. * @returns the serialized JSON representation
  96321. */
  96322. serialize(): any;
  96323. /**
  96324. * Dispose the texture and release its associated resources.
  96325. */
  96326. dispose(): void;
  96327. }
  96328. }
  96329. declare module BABYLON {
  96330. /**
  96331. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96332. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96333. */
  96334. export class Texture extends BaseTexture {
  96335. /**
  96336. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96337. */
  96338. static SerializeBuffers: boolean;
  96339. /** @hidden */
  96340. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96341. /** @hidden */
  96342. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96343. /** @hidden */
  96344. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96345. /** nearest is mag = nearest and min = nearest and mip = linear */
  96346. static readonly NEAREST_SAMPLINGMODE: number;
  96347. /** nearest is mag = nearest and min = nearest and mip = linear */
  96348. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96349. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96350. static readonly BILINEAR_SAMPLINGMODE: number;
  96351. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96352. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96353. /** Trilinear is mag = linear and min = linear and mip = linear */
  96354. static readonly TRILINEAR_SAMPLINGMODE: number;
  96355. /** Trilinear is mag = linear and min = linear and mip = linear */
  96356. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96357. /** mag = nearest and min = nearest and mip = nearest */
  96358. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96359. /** mag = nearest and min = linear and mip = nearest */
  96360. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96361. /** mag = nearest and min = linear and mip = linear */
  96362. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96363. /** mag = nearest and min = linear and mip = none */
  96364. static readonly NEAREST_LINEAR: number;
  96365. /** mag = nearest and min = nearest and mip = none */
  96366. static readonly NEAREST_NEAREST: number;
  96367. /** mag = linear and min = nearest and mip = nearest */
  96368. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96369. /** mag = linear and min = nearest and mip = linear */
  96370. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96371. /** mag = linear and min = linear and mip = none */
  96372. static readonly LINEAR_LINEAR: number;
  96373. /** mag = linear and min = nearest and mip = none */
  96374. static readonly LINEAR_NEAREST: number;
  96375. /** Explicit coordinates mode */
  96376. static readonly EXPLICIT_MODE: number;
  96377. /** Spherical coordinates mode */
  96378. static readonly SPHERICAL_MODE: number;
  96379. /** Planar coordinates mode */
  96380. static readonly PLANAR_MODE: number;
  96381. /** Cubic coordinates mode */
  96382. static readonly CUBIC_MODE: number;
  96383. /** Projection coordinates mode */
  96384. static readonly PROJECTION_MODE: number;
  96385. /** Inverse Cubic coordinates mode */
  96386. static readonly SKYBOX_MODE: number;
  96387. /** Inverse Cubic coordinates mode */
  96388. static readonly INVCUBIC_MODE: number;
  96389. /** Equirectangular coordinates mode */
  96390. static readonly EQUIRECTANGULAR_MODE: number;
  96391. /** Equirectangular Fixed coordinates mode */
  96392. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96393. /** Equirectangular Fixed Mirrored coordinates mode */
  96394. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96395. /** Texture is not repeating outside of 0..1 UVs */
  96396. static readonly CLAMP_ADDRESSMODE: number;
  96397. /** Texture is repeating outside of 0..1 UVs */
  96398. static readonly WRAP_ADDRESSMODE: number;
  96399. /** Texture is repeating and mirrored */
  96400. static readonly MIRROR_ADDRESSMODE: number;
  96401. /**
  96402. * 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
  96403. */
  96404. static UseSerializedUrlIfAny: boolean;
  96405. /**
  96406. * Define the url of the texture.
  96407. */
  96408. url: Nullable<string>;
  96409. /**
  96410. * Define an offset on the texture to offset the u coordinates of the UVs
  96411. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96412. */
  96413. uOffset: number;
  96414. /**
  96415. * Define an offset on the texture to offset the v coordinates of the UVs
  96416. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96417. */
  96418. vOffset: number;
  96419. /**
  96420. * Define an offset on the texture to scale the u coordinates of the UVs
  96421. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96422. */
  96423. uScale: number;
  96424. /**
  96425. * Define an offset on the texture to scale the v coordinates of the UVs
  96426. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96427. */
  96428. vScale: number;
  96429. /**
  96430. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96431. * @see http://doc.babylonjs.com/how_to/more_materials
  96432. */
  96433. uAng: number;
  96434. /**
  96435. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96436. * @see http://doc.babylonjs.com/how_to/more_materials
  96437. */
  96438. vAng: number;
  96439. /**
  96440. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96441. * @see http://doc.babylonjs.com/how_to/more_materials
  96442. */
  96443. wAng: number;
  96444. /**
  96445. * Defines the center of rotation (U)
  96446. */
  96447. uRotationCenter: number;
  96448. /**
  96449. * Defines the center of rotation (V)
  96450. */
  96451. vRotationCenter: number;
  96452. /**
  96453. * Defines the center of rotation (W)
  96454. */
  96455. wRotationCenter: number;
  96456. /**
  96457. * Are mip maps generated for this texture or not.
  96458. */
  96459. get noMipmap(): boolean;
  96460. /**
  96461. * List of inspectable custom properties (used by the Inspector)
  96462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96463. */
  96464. inspectableCustomProperties: Nullable<IInspectable[]>;
  96465. private _noMipmap;
  96466. /** @hidden */
  96467. _invertY: boolean;
  96468. private _rowGenerationMatrix;
  96469. private _cachedTextureMatrix;
  96470. private _projectionModeMatrix;
  96471. private _t0;
  96472. private _t1;
  96473. private _t2;
  96474. private _cachedUOffset;
  96475. private _cachedVOffset;
  96476. private _cachedUScale;
  96477. private _cachedVScale;
  96478. private _cachedUAng;
  96479. private _cachedVAng;
  96480. private _cachedWAng;
  96481. private _cachedProjectionMatrixId;
  96482. private _cachedCoordinatesMode;
  96483. /** @hidden */
  96484. protected _initialSamplingMode: number;
  96485. /** @hidden */
  96486. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96487. private _deleteBuffer;
  96488. protected _format: Nullable<number>;
  96489. private _delayedOnLoad;
  96490. private _delayedOnError;
  96491. private _mimeType?;
  96492. /**
  96493. * Observable triggered once the texture has been loaded.
  96494. */
  96495. onLoadObservable: Observable<Texture>;
  96496. protected _isBlocking: boolean;
  96497. /**
  96498. * Is the texture preventing material to render while loading.
  96499. * If false, a default texture will be used instead of the loading one during the preparation step.
  96500. */
  96501. set isBlocking(value: boolean);
  96502. get isBlocking(): boolean;
  96503. /**
  96504. * Get the current sampling mode associated with the texture.
  96505. */
  96506. get samplingMode(): number;
  96507. /**
  96508. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96509. */
  96510. get invertY(): boolean;
  96511. /**
  96512. * Instantiates a new texture.
  96513. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96514. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96515. * @param url defines the url of the picture to load as a texture
  96516. * @param sceneOrEngine defines the scene or engine the texture will belong to
  96517. * @param noMipmap defines if the texture will require mip maps or not
  96518. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96519. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96520. * @param onLoad defines a callback triggered when the texture has been loaded
  96521. * @param onError defines a callback triggered when an error occurred during the loading session
  96522. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96523. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96524. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96525. * @param mimeType defines an optional mime type information
  96526. */
  96527. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  96528. /**
  96529. * Update the url (and optional buffer) of this texture if url was null during construction.
  96530. * @param url the url of the texture
  96531. * @param buffer the buffer of the texture (defaults to null)
  96532. * @param onLoad callback called when the texture is loaded (defaults to null)
  96533. */
  96534. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96535. /**
  96536. * Finish the loading sequence of a texture flagged as delayed load.
  96537. * @hidden
  96538. */
  96539. delayLoad(): void;
  96540. private _prepareRowForTextureGeneration;
  96541. /**
  96542. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96543. * @returns the transform matrix of the texture.
  96544. */
  96545. getTextureMatrix(uBase?: number): Matrix;
  96546. /**
  96547. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96548. * @returns The reflection texture transform
  96549. */
  96550. getReflectionTextureMatrix(): Matrix;
  96551. /**
  96552. * Clones the texture.
  96553. * @returns the cloned texture
  96554. */
  96555. clone(): Texture;
  96556. /**
  96557. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96558. * @returns The JSON representation of the texture
  96559. */
  96560. serialize(): any;
  96561. /**
  96562. * Get the current class name of the texture useful for serialization or dynamic coding.
  96563. * @returns "Texture"
  96564. */
  96565. getClassName(): string;
  96566. /**
  96567. * Dispose the texture and release its associated resources.
  96568. */
  96569. dispose(): void;
  96570. /**
  96571. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96572. * @param parsedTexture Define the JSON representation of the texture
  96573. * @param scene Define the scene the parsed texture should be instantiated in
  96574. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96575. * @returns The parsed texture if successful
  96576. */
  96577. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96578. /**
  96579. * Creates a texture from its base 64 representation.
  96580. * @param data Define the base64 payload without the data: prefix
  96581. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96582. * @param scene Define the scene the texture should belong to
  96583. * @param noMipmap Forces the texture to not create mip map information if true
  96584. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96585. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96586. * @param onLoad define a callback triggered when the texture has been loaded
  96587. * @param onError define a callback triggered when an error occurred during the loading session
  96588. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96589. * @returns the created texture
  96590. */
  96591. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96592. /**
  96593. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96594. * @param data Define the base64 payload without the data: prefix
  96595. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96596. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96597. * @param scene Define the scene the texture should belong to
  96598. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96599. * @param noMipmap Forces the texture to not create mip map information if true
  96600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96602. * @param onLoad define a callback triggered when the texture has been loaded
  96603. * @param onError define a callback triggered when an error occurred during the loading session
  96604. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96605. * @returns the created texture
  96606. */
  96607. 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;
  96608. }
  96609. }
  96610. declare module BABYLON {
  96611. /**
  96612. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96613. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96614. */
  96615. export class PostProcessManager {
  96616. private _scene;
  96617. private _indexBuffer;
  96618. private _vertexBuffers;
  96619. /**
  96620. * Creates a new instance PostProcess
  96621. * @param scene The scene that the post process is associated with.
  96622. */
  96623. constructor(scene: Scene);
  96624. private _prepareBuffers;
  96625. private _buildIndexBuffer;
  96626. /**
  96627. * Rebuilds the vertex buffers of the manager.
  96628. * @hidden
  96629. */
  96630. _rebuild(): void;
  96631. /**
  96632. * Prepares a frame to be run through a post process.
  96633. * @param sourceTexture The input texture to the post procesess. (default: null)
  96634. * @param postProcesses An array of post processes to be run. (default: null)
  96635. * @returns True if the post processes were able to be run.
  96636. * @hidden
  96637. */
  96638. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96639. /**
  96640. * Manually render a set of post processes to a texture.
  96641. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96642. * @param postProcesses An array of post processes to be run.
  96643. * @param targetTexture The target texture to render to.
  96644. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96645. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96646. * @param lodLevel defines which lod of the texture to render to
  96647. */
  96648. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96649. /**
  96650. * Finalize the result of the output of the postprocesses.
  96651. * @param doNotPresent If true the result will not be displayed to the screen.
  96652. * @param targetTexture The target texture to render to.
  96653. * @param faceIndex The index of the face to bind the target texture to.
  96654. * @param postProcesses The array of post processes to render.
  96655. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96656. * @hidden
  96657. */
  96658. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96659. /**
  96660. * Disposes of the post process manager.
  96661. */
  96662. dispose(): void;
  96663. }
  96664. }
  96665. declare module BABYLON {
  96666. /**
  96667. * This Helps creating a texture that will be created from a camera in your scene.
  96668. * It is basically a dynamic texture that could be used to create special effects for instance.
  96669. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96670. */
  96671. export class RenderTargetTexture extends Texture {
  96672. isCube: boolean;
  96673. /**
  96674. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96675. */
  96676. static readonly REFRESHRATE_RENDER_ONCE: number;
  96677. /**
  96678. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96679. */
  96680. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96681. /**
  96682. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96683. * the central point of your effect and can save a lot of performances.
  96684. */
  96685. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96686. /**
  96687. * Use this predicate to dynamically define the list of mesh you want to render.
  96688. * If set, the renderList property will be overwritten.
  96689. */
  96690. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96691. private _renderList;
  96692. /**
  96693. * Use this list to define the list of mesh you want to render.
  96694. */
  96695. get renderList(): Nullable<Array<AbstractMesh>>;
  96696. set renderList(value: Nullable<Array<AbstractMesh>>);
  96697. /**
  96698. * Use this function to overload the renderList array at rendering time.
  96699. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96700. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96701. * the cube (if the RTT is a cube, else layerOrFace=0).
  96702. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96703. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96704. * hold dummy elements!
  96705. */
  96706. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96707. private _hookArray;
  96708. /**
  96709. * Define if particles should be rendered in your texture.
  96710. */
  96711. renderParticles: boolean;
  96712. /**
  96713. * Define if sprites should be rendered in your texture.
  96714. */
  96715. renderSprites: boolean;
  96716. /**
  96717. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96718. */
  96719. coordinatesMode: number;
  96720. /**
  96721. * Define the camera used to render the texture.
  96722. */
  96723. activeCamera: Nullable<Camera>;
  96724. /**
  96725. * Override the mesh isReady function with your own one.
  96726. */
  96727. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96728. /**
  96729. * Override the render function of the texture with your own one.
  96730. */
  96731. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96732. /**
  96733. * Define if camera post processes should be use while rendering the texture.
  96734. */
  96735. useCameraPostProcesses: boolean;
  96736. /**
  96737. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96738. */
  96739. ignoreCameraViewport: boolean;
  96740. private _postProcessManager;
  96741. private _postProcesses;
  96742. private _resizeObserver;
  96743. /**
  96744. * An event triggered when the texture is unbind.
  96745. */
  96746. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96747. /**
  96748. * An event triggered when the texture is unbind.
  96749. */
  96750. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96751. private _onAfterUnbindObserver;
  96752. /**
  96753. * Set a after unbind callback in the texture.
  96754. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96755. */
  96756. set onAfterUnbind(callback: () => void);
  96757. /**
  96758. * An event triggered before rendering the texture
  96759. */
  96760. onBeforeRenderObservable: Observable<number>;
  96761. private _onBeforeRenderObserver;
  96762. /**
  96763. * Set a before render callback in the texture.
  96764. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96765. */
  96766. set onBeforeRender(callback: (faceIndex: number) => void);
  96767. /**
  96768. * An event triggered after rendering the texture
  96769. */
  96770. onAfterRenderObservable: Observable<number>;
  96771. private _onAfterRenderObserver;
  96772. /**
  96773. * Set a after render callback in the texture.
  96774. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96775. */
  96776. set onAfterRender(callback: (faceIndex: number) => void);
  96777. /**
  96778. * An event triggered after the texture clear
  96779. */
  96780. onClearObservable: Observable<Engine>;
  96781. private _onClearObserver;
  96782. /**
  96783. * Set a clear callback in the texture.
  96784. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96785. */
  96786. set onClear(callback: (Engine: Engine) => void);
  96787. /**
  96788. * An event triggered when the texture is resized.
  96789. */
  96790. onResizeObservable: Observable<RenderTargetTexture>;
  96791. /**
  96792. * Define the clear color of the Render Target if it should be different from the scene.
  96793. */
  96794. clearColor: Color4;
  96795. protected _size: number | {
  96796. width: number;
  96797. height: number;
  96798. layers?: number;
  96799. };
  96800. protected _initialSizeParameter: number | {
  96801. width: number;
  96802. height: number;
  96803. } | {
  96804. ratio: number;
  96805. };
  96806. protected _sizeRatio: Nullable<number>;
  96807. /** @hidden */
  96808. _generateMipMaps: boolean;
  96809. protected _renderingManager: RenderingManager;
  96810. /** @hidden */
  96811. _waitingRenderList: string[];
  96812. protected _doNotChangeAspectRatio: boolean;
  96813. protected _currentRefreshId: number;
  96814. protected _refreshRate: number;
  96815. protected _textureMatrix: Matrix;
  96816. protected _samples: number;
  96817. protected _renderTargetOptions: RenderTargetCreationOptions;
  96818. /**
  96819. * Gets render target creation options that were used.
  96820. */
  96821. get renderTargetOptions(): RenderTargetCreationOptions;
  96822. protected _onRatioRescale(): void;
  96823. /**
  96824. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96825. * It must define where the camera used to render the texture is set
  96826. */
  96827. boundingBoxPosition: Vector3;
  96828. private _boundingBoxSize;
  96829. /**
  96830. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96831. * When defined, the cubemap will switch to local mode
  96832. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96833. * @example https://www.babylonjs-playground.com/#RNASML
  96834. */
  96835. set boundingBoxSize(value: Vector3);
  96836. get boundingBoxSize(): Vector3;
  96837. /**
  96838. * In case the RTT has been created with a depth texture, get the associated
  96839. * depth texture.
  96840. * Otherwise, return null.
  96841. */
  96842. get depthStencilTexture(): Nullable<InternalTexture>;
  96843. /**
  96844. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96845. * or used a shadow, depth texture...
  96846. * @param name The friendly name of the texture
  96847. * @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)
  96848. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96849. * @param generateMipMaps True if mip maps need to be generated after render.
  96850. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96851. * @param type The type of the buffer in the RTT (int, half float, float...)
  96852. * @param isCube True if a cube texture needs to be created
  96853. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96854. * @param generateDepthBuffer True to generate a depth buffer
  96855. * @param generateStencilBuffer True to generate a stencil buffer
  96856. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96857. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96858. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96859. */
  96860. constructor(name: string, size: number | {
  96861. width: number;
  96862. height: number;
  96863. layers?: number;
  96864. } | {
  96865. ratio: number;
  96866. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96867. /**
  96868. * Creates a depth stencil texture.
  96869. * This is only available in WebGL 2 or with the depth texture extension available.
  96870. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96871. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96872. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96873. */
  96874. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96875. private _processSizeParameter;
  96876. /**
  96877. * Define the number of samples to use in case of MSAA.
  96878. * It defaults to one meaning no MSAA has been enabled.
  96879. */
  96880. get samples(): number;
  96881. set samples(value: number);
  96882. /**
  96883. * Resets the refresh counter of the texture and start bak from scratch.
  96884. * Could be useful to regenerate the texture if it is setup to render only once.
  96885. */
  96886. resetRefreshCounter(): void;
  96887. /**
  96888. * Define the refresh rate of the texture or the rendering frequency.
  96889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96890. */
  96891. get refreshRate(): number;
  96892. set refreshRate(value: number);
  96893. /**
  96894. * Adds a post process to the render target rendering passes.
  96895. * @param postProcess define the post process to add
  96896. */
  96897. addPostProcess(postProcess: PostProcess): void;
  96898. /**
  96899. * Clear all the post processes attached to the render target
  96900. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96901. */
  96902. clearPostProcesses(dispose?: boolean): void;
  96903. /**
  96904. * Remove one of the post process from the list of attached post processes to the texture
  96905. * @param postProcess define the post process to remove from the list
  96906. */
  96907. removePostProcess(postProcess: PostProcess): void;
  96908. /** @hidden */
  96909. _shouldRender(): boolean;
  96910. /**
  96911. * Gets the actual render size of the texture.
  96912. * @returns the width of the render size
  96913. */
  96914. getRenderSize(): number;
  96915. /**
  96916. * Gets the actual render width of the texture.
  96917. * @returns the width of the render size
  96918. */
  96919. getRenderWidth(): number;
  96920. /**
  96921. * Gets the actual render height of the texture.
  96922. * @returns the height of the render size
  96923. */
  96924. getRenderHeight(): number;
  96925. /**
  96926. * Gets the actual number of layers of the texture.
  96927. * @returns the number of layers
  96928. */
  96929. getRenderLayers(): number;
  96930. /**
  96931. * Get if the texture can be rescaled or not.
  96932. */
  96933. get canRescale(): boolean;
  96934. /**
  96935. * Resize the texture using a ratio.
  96936. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96937. */
  96938. scale(ratio: number): void;
  96939. /**
  96940. * Get the texture reflection matrix used to rotate/transform the reflection.
  96941. * @returns the reflection matrix
  96942. */
  96943. getReflectionTextureMatrix(): Matrix;
  96944. /**
  96945. * Resize the texture to a new desired size.
  96946. * Be carrefull as it will recreate all the data in the new texture.
  96947. * @param size Define the new size. It can be:
  96948. * - a number for squared texture,
  96949. * - an object containing { width: number, height: number }
  96950. * - or an object containing a ratio { ratio: number }
  96951. */
  96952. resize(size: number | {
  96953. width: number;
  96954. height: number;
  96955. } | {
  96956. ratio: number;
  96957. }): void;
  96958. private _defaultRenderListPrepared;
  96959. /**
  96960. * Renders all the objects from the render list into the texture.
  96961. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  96962. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  96963. */
  96964. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  96965. private _bestReflectionRenderTargetDimension;
  96966. private _prepareRenderingManager;
  96967. /**
  96968. * @hidden
  96969. * @param faceIndex face index to bind to if this is a cubetexture
  96970. * @param layer defines the index of the texture to bind in the array
  96971. */
  96972. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  96973. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  96974. private renderToTarget;
  96975. /**
  96976. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96977. * This allowed control for front to back rendering or reversly depending of the special needs.
  96978. *
  96979. * @param renderingGroupId The rendering group id corresponding to its index
  96980. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96981. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96982. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96983. */
  96984. 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;
  96985. /**
  96986. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96987. *
  96988. * @param renderingGroupId The rendering group id corresponding to its index
  96989. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96990. */
  96991. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  96992. /**
  96993. * Clones the texture.
  96994. * @returns the cloned texture
  96995. */
  96996. clone(): RenderTargetTexture;
  96997. /**
  96998. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96999. * @returns The JSON representation of the texture
  97000. */
  97001. serialize(): any;
  97002. /**
  97003. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  97004. */
  97005. disposeFramebufferObjects(): void;
  97006. /**
  97007. * Dispose the texture and release its associated resources.
  97008. */
  97009. dispose(): void;
  97010. /** @hidden */
  97011. _rebuild(): void;
  97012. /**
  97013. * Clear the info related to rendering groups preventing retention point in material dispose.
  97014. */
  97015. freeRenderingGroups(): void;
  97016. /**
  97017. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97018. * @returns the view count
  97019. */
  97020. getViewCount(): number;
  97021. }
  97022. }
  97023. declare module BABYLON {
  97024. /**
  97025. * Class used to manipulate GUIDs
  97026. */
  97027. export class GUID {
  97028. /**
  97029. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97030. * Be aware Math.random() could cause collisions, but:
  97031. * "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"
  97032. * @returns a pseudo random id
  97033. */
  97034. static RandomId(): string;
  97035. }
  97036. }
  97037. declare module BABYLON {
  97038. /**
  97039. * Options to be used when creating a shadow depth material
  97040. */
  97041. export interface IIOptionShadowDepthMaterial {
  97042. /** Variables in the vertex shader code that need to have their names remapped.
  97043. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  97044. * "var_name" should be either: worldPos or vNormalW
  97045. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  97046. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  97047. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  97048. */
  97049. remappedVariables?: string[];
  97050. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  97051. standalone?: boolean;
  97052. }
  97053. /**
  97054. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  97055. */
  97056. export class ShadowDepthWrapper {
  97057. private _scene;
  97058. private _options?;
  97059. private _baseMaterial;
  97060. private _onEffectCreatedObserver;
  97061. private _subMeshToEffect;
  97062. private _subMeshToDepthEffect;
  97063. private _meshes;
  97064. /** @hidden */
  97065. _matriceNames: any;
  97066. /** Gets the standalone status of the wrapper */
  97067. get standalone(): boolean;
  97068. /** Gets the base material the wrapper is built upon */
  97069. get baseMaterial(): Material;
  97070. /**
  97071. * Instantiate a new shadow depth wrapper.
  97072. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  97073. * generate the shadow depth map. For more information, please refer to the documentation:
  97074. * https://doc.babylonjs.com/babylon101/shadows
  97075. * @param baseMaterial Material to wrap
  97076. * @param scene Define the scene the material belongs to
  97077. * @param options Options used to create the wrapper
  97078. */
  97079. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  97080. /**
  97081. * Gets the effect to use to generate the depth map
  97082. * @param subMesh subMesh to get the effect for
  97083. * @param shadowGenerator shadow generator to get the effect for
  97084. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  97085. */
  97086. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  97087. /**
  97088. * Specifies that the submesh is ready to be used for depth rendering
  97089. * @param subMesh submesh to check
  97090. * @param defines the list of defines to take into account when checking the effect
  97091. * @param shadowGenerator combined with subMesh, it defines the effect to check
  97092. * @param useInstances specifies that instances should be used
  97093. * @returns a boolean indicating that the submesh is ready or not
  97094. */
  97095. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  97096. /**
  97097. * Disposes the resources
  97098. */
  97099. dispose(): void;
  97100. private _makeEffect;
  97101. }
  97102. }
  97103. declare module BABYLON {
  97104. /**
  97105. * Options for compiling materials.
  97106. */
  97107. export interface IMaterialCompilationOptions {
  97108. /**
  97109. * Defines whether clip planes are enabled.
  97110. */
  97111. clipPlane: boolean;
  97112. /**
  97113. * Defines whether instances are enabled.
  97114. */
  97115. useInstances: boolean;
  97116. }
  97117. /**
  97118. * Base class for the main features of a material in Babylon.js
  97119. */
  97120. export class Material implements IAnimatable {
  97121. /**
  97122. * Returns the triangle fill mode
  97123. */
  97124. static readonly TriangleFillMode: number;
  97125. /**
  97126. * Returns the wireframe mode
  97127. */
  97128. static readonly WireFrameFillMode: number;
  97129. /**
  97130. * Returns the point fill mode
  97131. */
  97132. static readonly PointFillMode: number;
  97133. /**
  97134. * Returns the point list draw mode
  97135. */
  97136. static readonly PointListDrawMode: number;
  97137. /**
  97138. * Returns the line list draw mode
  97139. */
  97140. static readonly LineListDrawMode: number;
  97141. /**
  97142. * Returns the line loop draw mode
  97143. */
  97144. static readonly LineLoopDrawMode: number;
  97145. /**
  97146. * Returns the line strip draw mode
  97147. */
  97148. static readonly LineStripDrawMode: number;
  97149. /**
  97150. * Returns the triangle strip draw mode
  97151. */
  97152. static readonly TriangleStripDrawMode: number;
  97153. /**
  97154. * Returns the triangle fan draw mode
  97155. */
  97156. static readonly TriangleFanDrawMode: number;
  97157. /**
  97158. * Stores the clock-wise side orientation
  97159. */
  97160. static readonly ClockWiseSideOrientation: number;
  97161. /**
  97162. * Stores the counter clock-wise side orientation
  97163. */
  97164. static readonly CounterClockWiseSideOrientation: number;
  97165. /**
  97166. * The dirty texture flag value
  97167. */
  97168. static readonly TextureDirtyFlag: number;
  97169. /**
  97170. * The dirty light flag value
  97171. */
  97172. static readonly LightDirtyFlag: number;
  97173. /**
  97174. * The dirty fresnel flag value
  97175. */
  97176. static readonly FresnelDirtyFlag: number;
  97177. /**
  97178. * The dirty attribute flag value
  97179. */
  97180. static readonly AttributesDirtyFlag: number;
  97181. /**
  97182. * The dirty misc flag value
  97183. */
  97184. static readonly MiscDirtyFlag: number;
  97185. /**
  97186. * The all dirty flag value
  97187. */
  97188. static readonly AllDirtyFlag: number;
  97189. /**
  97190. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  97191. */
  97192. static readonly MATERIAL_OPAQUE: number;
  97193. /**
  97194. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  97195. */
  97196. static readonly MATERIAL_ALPHATEST: number;
  97197. /**
  97198. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97199. */
  97200. static readonly MATERIAL_ALPHABLEND: number;
  97201. /**
  97202. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97203. * They are also discarded below the alpha cutoff threshold to improve performances.
  97204. */
  97205. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  97206. /**
  97207. * Custom callback helping to override the default shader used in the material.
  97208. */
  97209. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  97210. /**
  97211. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97212. */
  97213. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97214. /**
  97215. * The ID of the material
  97216. */
  97217. id: string;
  97218. /**
  97219. * Gets or sets the unique id of the material
  97220. */
  97221. uniqueId: number;
  97222. /**
  97223. * The name of the material
  97224. */
  97225. name: string;
  97226. /**
  97227. * Gets or sets user defined metadata
  97228. */
  97229. metadata: any;
  97230. /**
  97231. * For internal use only. Please do not use.
  97232. */
  97233. reservedDataStore: any;
  97234. /**
  97235. * Specifies if the ready state should be checked on each call
  97236. */
  97237. checkReadyOnEveryCall: boolean;
  97238. /**
  97239. * Specifies if the ready state should be checked once
  97240. */
  97241. checkReadyOnlyOnce: boolean;
  97242. /**
  97243. * The state of the material
  97244. */
  97245. state: string;
  97246. /**
  97247. * The alpha value of the material
  97248. */
  97249. protected _alpha: number;
  97250. /**
  97251. * List of inspectable custom properties (used by the Inspector)
  97252. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97253. */
  97254. inspectableCustomProperties: IInspectable[];
  97255. /**
  97256. * Sets the alpha value of the material
  97257. */
  97258. set alpha(value: number);
  97259. /**
  97260. * Gets the alpha value of the material
  97261. */
  97262. get alpha(): number;
  97263. /**
  97264. * Specifies if back face culling is enabled
  97265. */
  97266. protected _backFaceCulling: boolean;
  97267. /**
  97268. * Sets the back-face culling state
  97269. */
  97270. set backFaceCulling(value: boolean);
  97271. /**
  97272. * Gets the back-face culling state
  97273. */
  97274. get backFaceCulling(): boolean;
  97275. /**
  97276. * Stores the value for side orientation
  97277. */
  97278. sideOrientation: number;
  97279. /**
  97280. * Callback triggered when the material is compiled
  97281. */
  97282. onCompiled: Nullable<(effect: Effect) => void>;
  97283. /**
  97284. * Callback triggered when an error occurs
  97285. */
  97286. onError: Nullable<(effect: Effect, errors: string) => void>;
  97287. /**
  97288. * Callback triggered to get the render target textures
  97289. */
  97290. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97291. /**
  97292. * Gets a boolean indicating that current material needs to register RTT
  97293. */
  97294. get hasRenderTargetTextures(): boolean;
  97295. /**
  97296. * Specifies if the material should be serialized
  97297. */
  97298. doNotSerialize: boolean;
  97299. /**
  97300. * @hidden
  97301. */
  97302. _storeEffectOnSubMeshes: boolean;
  97303. /**
  97304. * Stores the animations for the material
  97305. */
  97306. animations: Nullable<Array<Animation>>;
  97307. /**
  97308. * An event triggered when the material is disposed
  97309. */
  97310. onDisposeObservable: Observable<Material>;
  97311. /**
  97312. * An observer which watches for dispose events
  97313. */
  97314. private _onDisposeObserver;
  97315. private _onUnBindObservable;
  97316. /**
  97317. * Called during a dispose event
  97318. */
  97319. set onDispose(callback: () => void);
  97320. private _onBindObservable;
  97321. /**
  97322. * An event triggered when the material is bound
  97323. */
  97324. get onBindObservable(): Observable<AbstractMesh>;
  97325. /**
  97326. * An observer which watches for bind events
  97327. */
  97328. private _onBindObserver;
  97329. /**
  97330. * Called during a bind event
  97331. */
  97332. set onBind(callback: (Mesh: AbstractMesh) => void);
  97333. /**
  97334. * An event triggered when the material is unbound
  97335. */
  97336. get onUnBindObservable(): Observable<Material>;
  97337. protected _onEffectCreatedObservable: Nullable<Observable<{
  97338. effect: Effect;
  97339. subMesh: Nullable<SubMesh>;
  97340. }>>;
  97341. /**
  97342. * An event triggered when the effect is (re)created
  97343. */
  97344. get onEffectCreatedObservable(): Observable<{
  97345. effect: Effect;
  97346. subMesh: Nullable<SubMesh>;
  97347. }>;
  97348. /**
  97349. * Stores the value of the alpha mode
  97350. */
  97351. private _alphaMode;
  97352. /**
  97353. * Sets the value of the alpha mode.
  97354. *
  97355. * | Value | Type | Description |
  97356. * | --- | --- | --- |
  97357. * | 0 | ALPHA_DISABLE | |
  97358. * | 1 | ALPHA_ADD | |
  97359. * | 2 | ALPHA_COMBINE | |
  97360. * | 3 | ALPHA_SUBTRACT | |
  97361. * | 4 | ALPHA_MULTIPLY | |
  97362. * | 5 | ALPHA_MAXIMIZED | |
  97363. * | 6 | ALPHA_ONEONE | |
  97364. * | 7 | ALPHA_PREMULTIPLIED | |
  97365. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97366. * | 9 | ALPHA_INTERPOLATE | |
  97367. * | 10 | ALPHA_SCREENMODE | |
  97368. *
  97369. */
  97370. set alphaMode(value: number);
  97371. /**
  97372. * Gets the value of the alpha mode
  97373. */
  97374. get alphaMode(): number;
  97375. /**
  97376. * Stores the state of the need depth pre-pass value
  97377. */
  97378. private _needDepthPrePass;
  97379. /**
  97380. * Sets the need depth pre-pass value
  97381. */
  97382. set needDepthPrePass(value: boolean);
  97383. /**
  97384. * Gets the depth pre-pass value
  97385. */
  97386. get needDepthPrePass(): boolean;
  97387. /**
  97388. * Specifies if depth writing should be disabled
  97389. */
  97390. disableDepthWrite: boolean;
  97391. /**
  97392. * Specifies if color writing should be disabled
  97393. */
  97394. disableColorWrite: boolean;
  97395. /**
  97396. * Specifies if depth writing should be forced
  97397. */
  97398. forceDepthWrite: boolean;
  97399. /**
  97400. * Specifies the depth function that should be used. 0 means the default engine function
  97401. */
  97402. depthFunction: number;
  97403. /**
  97404. * Specifies if there should be a separate pass for culling
  97405. */
  97406. separateCullingPass: boolean;
  97407. /**
  97408. * Stores the state specifing if fog should be enabled
  97409. */
  97410. private _fogEnabled;
  97411. /**
  97412. * Sets the state for enabling fog
  97413. */
  97414. set fogEnabled(value: boolean);
  97415. /**
  97416. * Gets the value of the fog enabled state
  97417. */
  97418. get fogEnabled(): boolean;
  97419. /**
  97420. * Stores the size of points
  97421. */
  97422. pointSize: number;
  97423. /**
  97424. * Stores the z offset value
  97425. */
  97426. zOffset: number;
  97427. get wireframe(): boolean;
  97428. /**
  97429. * Sets the state of wireframe mode
  97430. */
  97431. set wireframe(value: boolean);
  97432. /**
  97433. * Gets the value specifying if point clouds are enabled
  97434. */
  97435. get pointsCloud(): boolean;
  97436. /**
  97437. * Sets the state of point cloud mode
  97438. */
  97439. set pointsCloud(value: boolean);
  97440. /**
  97441. * Gets the material fill mode
  97442. */
  97443. get fillMode(): number;
  97444. /**
  97445. * Sets the material fill mode
  97446. */
  97447. set fillMode(value: number);
  97448. /**
  97449. * @hidden
  97450. * Stores the effects for the material
  97451. */
  97452. _effect: Nullable<Effect>;
  97453. /**
  97454. * Specifies if uniform buffers should be used
  97455. */
  97456. private _useUBO;
  97457. /**
  97458. * Stores a reference to the scene
  97459. */
  97460. private _scene;
  97461. /**
  97462. * Stores the fill mode state
  97463. */
  97464. private _fillMode;
  97465. /**
  97466. * Specifies if the depth write state should be cached
  97467. */
  97468. private _cachedDepthWriteState;
  97469. /**
  97470. * Specifies if the color write state should be cached
  97471. */
  97472. private _cachedColorWriteState;
  97473. /**
  97474. * Specifies if the depth function state should be cached
  97475. */
  97476. private _cachedDepthFunctionState;
  97477. /**
  97478. * Stores the uniform buffer
  97479. */
  97480. protected _uniformBuffer: UniformBuffer;
  97481. /** @hidden */
  97482. _indexInSceneMaterialArray: number;
  97483. /** @hidden */
  97484. meshMap: Nullable<{
  97485. [id: string]: AbstractMesh | undefined;
  97486. }>;
  97487. /**
  97488. * Creates a material instance
  97489. * @param name defines the name of the material
  97490. * @param scene defines the scene to reference
  97491. * @param doNotAdd specifies if the material should be added to the scene
  97492. */
  97493. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97494. /**
  97495. * Returns a string representation of the current material
  97496. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97497. * @returns a string with material information
  97498. */
  97499. toString(fullDetails?: boolean): string;
  97500. /**
  97501. * Gets the class name of the material
  97502. * @returns a string with the class name of the material
  97503. */
  97504. getClassName(): string;
  97505. /**
  97506. * Specifies if updates for the material been locked
  97507. */
  97508. get isFrozen(): boolean;
  97509. /**
  97510. * Locks updates for the material
  97511. */
  97512. freeze(): void;
  97513. /**
  97514. * Unlocks updates for the material
  97515. */
  97516. unfreeze(): void;
  97517. /**
  97518. * Specifies if the material is ready to be used
  97519. * @param mesh defines the mesh to check
  97520. * @param useInstances specifies if instances should be used
  97521. * @returns a boolean indicating if the material is ready to be used
  97522. */
  97523. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97524. /**
  97525. * Specifies that the submesh is ready to be used
  97526. * @param mesh defines the mesh to check
  97527. * @param subMesh defines which submesh to check
  97528. * @param useInstances specifies that instances should be used
  97529. * @returns a boolean indicating that the submesh is ready or not
  97530. */
  97531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97532. /**
  97533. * Returns the material effect
  97534. * @returns the effect associated with the material
  97535. */
  97536. getEffect(): Nullable<Effect>;
  97537. /**
  97538. * Returns the current scene
  97539. * @returns a Scene
  97540. */
  97541. getScene(): Scene;
  97542. /**
  97543. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97544. */
  97545. protected _forceAlphaTest: boolean;
  97546. /**
  97547. * The transparency mode of the material.
  97548. */
  97549. protected _transparencyMode: Nullable<number>;
  97550. /**
  97551. * Gets the current transparency mode.
  97552. */
  97553. get transparencyMode(): Nullable<number>;
  97554. /**
  97555. * Sets the transparency mode of the material.
  97556. *
  97557. * | Value | Type | Description |
  97558. * | ----- | ----------------------------------- | ----------- |
  97559. * | 0 | OPAQUE | |
  97560. * | 1 | ALPHATEST | |
  97561. * | 2 | ALPHABLEND | |
  97562. * | 3 | ALPHATESTANDBLEND | |
  97563. *
  97564. */
  97565. set transparencyMode(value: Nullable<number>);
  97566. /**
  97567. * Returns true if alpha blending should be disabled.
  97568. */
  97569. protected get _disableAlphaBlending(): boolean;
  97570. /**
  97571. * Specifies whether or not this material should be rendered in alpha blend mode.
  97572. * @returns a boolean specifying if alpha blending is needed
  97573. */
  97574. needAlphaBlending(): boolean;
  97575. /**
  97576. * Specifies if the mesh will require alpha blending
  97577. * @param mesh defines the mesh to check
  97578. * @returns a boolean specifying if alpha blending is needed for the mesh
  97579. */
  97580. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97581. /**
  97582. * Specifies whether or not this material should be rendered in alpha test mode.
  97583. * @returns a boolean specifying if an alpha test is needed.
  97584. */
  97585. needAlphaTesting(): boolean;
  97586. /**
  97587. * Specifies if material alpha testing should be turned on for the mesh
  97588. * @param mesh defines the mesh to check
  97589. */
  97590. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97591. /**
  97592. * Gets the texture used for the alpha test
  97593. * @returns the texture to use for alpha testing
  97594. */
  97595. getAlphaTestTexture(): Nullable<BaseTexture>;
  97596. /**
  97597. * Marks the material to indicate that it needs to be re-calculated
  97598. */
  97599. markDirty(): void;
  97600. /** @hidden */
  97601. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97602. /**
  97603. * Binds the material to the mesh
  97604. * @param world defines the world transformation matrix
  97605. * @param mesh defines the mesh to bind the material to
  97606. */
  97607. bind(world: Matrix, mesh?: Mesh): void;
  97608. /**
  97609. * Binds the submesh to the material
  97610. * @param world defines the world transformation matrix
  97611. * @param mesh defines the mesh containing the submesh
  97612. * @param subMesh defines the submesh to bind the material to
  97613. */
  97614. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97615. /**
  97616. * Binds the world matrix to the material
  97617. * @param world defines the world transformation matrix
  97618. */
  97619. bindOnlyWorldMatrix(world: Matrix): void;
  97620. /**
  97621. * Binds the scene's uniform buffer to the effect.
  97622. * @param effect defines the effect to bind to the scene uniform buffer
  97623. * @param sceneUbo defines the uniform buffer storing scene data
  97624. */
  97625. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97626. /**
  97627. * Binds the view matrix to the effect
  97628. * @param effect defines the effect to bind the view matrix to
  97629. */
  97630. bindView(effect: Effect): void;
  97631. /**
  97632. * Binds the view projection matrix to the effect
  97633. * @param effect defines the effect to bind the view projection matrix to
  97634. */
  97635. bindViewProjection(effect: Effect): void;
  97636. /**
  97637. * Processes to execute after binding the material to a mesh
  97638. * @param mesh defines the rendered mesh
  97639. */
  97640. protected _afterBind(mesh?: Mesh): void;
  97641. /**
  97642. * Unbinds the material from the mesh
  97643. */
  97644. unbind(): void;
  97645. /**
  97646. * Gets the active textures from the material
  97647. * @returns an array of textures
  97648. */
  97649. getActiveTextures(): BaseTexture[];
  97650. /**
  97651. * Specifies if the material uses a texture
  97652. * @param texture defines the texture to check against the material
  97653. * @returns a boolean specifying if the material uses the texture
  97654. */
  97655. hasTexture(texture: BaseTexture): boolean;
  97656. /**
  97657. * Makes a duplicate of the material, and gives it a new name
  97658. * @param name defines the new name for the duplicated material
  97659. * @returns the cloned material
  97660. */
  97661. clone(name: string): Nullable<Material>;
  97662. /**
  97663. * Gets the meshes bound to the material
  97664. * @returns an array of meshes bound to the material
  97665. */
  97666. getBindedMeshes(): AbstractMesh[];
  97667. /**
  97668. * Force shader compilation
  97669. * @param mesh defines the mesh associated with this material
  97670. * @param onCompiled defines a function to execute once the material is compiled
  97671. * @param options defines the options to configure the compilation
  97672. * @param onError defines a function to execute if the material fails compiling
  97673. */
  97674. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97675. /**
  97676. * Force shader compilation
  97677. * @param mesh defines the mesh that will use this material
  97678. * @param options defines additional options for compiling the shaders
  97679. * @returns a promise that resolves when the compilation completes
  97680. */
  97681. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97682. private static readonly _AllDirtyCallBack;
  97683. private static readonly _ImageProcessingDirtyCallBack;
  97684. private static readonly _TextureDirtyCallBack;
  97685. private static readonly _FresnelDirtyCallBack;
  97686. private static readonly _MiscDirtyCallBack;
  97687. private static readonly _LightsDirtyCallBack;
  97688. private static readonly _AttributeDirtyCallBack;
  97689. private static _FresnelAndMiscDirtyCallBack;
  97690. private static _TextureAndMiscDirtyCallBack;
  97691. private static readonly _DirtyCallbackArray;
  97692. private static readonly _RunDirtyCallBacks;
  97693. /**
  97694. * Marks a define in the material to indicate that it needs to be re-computed
  97695. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97696. */
  97697. markAsDirty(flag: number): void;
  97698. /**
  97699. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97700. * @param func defines a function which checks material defines against the submeshes
  97701. */
  97702. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97703. /**
  97704. * Indicates that we need to re-calculated for all submeshes
  97705. */
  97706. protected _markAllSubMeshesAsAllDirty(): void;
  97707. /**
  97708. * Indicates that image processing needs to be re-calculated for all submeshes
  97709. */
  97710. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97711. /**
  97712. * Indicates that textures need to be re-calculated for all submeshes
  97713. */
  97714. protected _markAllSubMeshesAsTexturesDirty(): void;
  97715. /**
  97716. * Indicates that fresnel needs to be re-calculated for all submeshes
  97717. */
  97718. protected _markAllSubMeshesAsFresnelDirty(): void;
  97719. /**
  97720. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97721. */
  97722. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97723. /**
  97724. * Indicates that lights need to be re-calculated for all submeshes
  97725. */
  97726. protected _markAllSubMeshesAsLightsDirty(): void;
  97727. /**
  97728. * Indicates that attributes need to be re-calculated for all submeshes
  97729. */
  97730. protected _markAllSubMeshesAsAttributesDirty(): void;
  97731. /**
  97732. * Indicates that misc needs to be re-calculated for all submeshes
  97733. */
  97734. protected _markAllSubMeshesAsMiscDirty(): void;
  97735. /**
  97736. * Indicates that textures and misc need to be re-calculated for all submeshes
  97737. */
  97738. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97739. /**
  97740. * Disposes the material
  97741. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97742. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97743. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97744. */
  97745. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97746. /** @hidden */
  97747. private releaseVertexArrayObject;
  97748. /**
  97749. * Serializes this material
  97750. * @returns the serialized material object
  97751. */
  97752. serialize(): any;
  97753. /**
  97754. * Creates a material from parsed material data
  97755. * @param parsedMaterial defines parsed material data
  97756. * @param scene defines the hosting scene
  97757. * @param rootUrl defines the root URL to use to load textures
  97758. * @returns a new material
  97759. */
  97760. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97761. }
  97762. }
  97763. declare module BABYLON {
  97764. /**
  97765. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97766. * separate meshes. This can be use to improve performances.
  97767. * @see http://doc.babylonjs.com/how_to/multi_materials
  97768. */
  97769. export class MultiMaterial extends Material {
  97770. private _subMaterials;
  97771. /**
  97772. * Gets or Sets the list of Materials used within the multi material.
  97773. * They need to be ordered according to the submeshes order in the associated mesh
  97774. */
  97775. get subMaterials(): Nullable<Material>[];
  97776. set subMaterials(value: Nullable<Material>[]);
  97777. /**
  97778. * Function used to align with Node.getChildren()
  97779. * @returns the list of Materials used within the multi material
  97780. */
  97781. getChildren(): Nullable<Material>[];
  97782. /**
  97783. * Instantiates a new Multi Material
  97784. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97785. * separate meshes. This can be use to improve performances.
  97786. * @see http://doc.babylonjs.com/how_to/multi_materials
  97787. * @param name Define the name in the scene
  97788. * @param scene Define the scene the material belongs to
  97789. */
  97790. constructor(name: string, scene: Scene);
  97791. private _hookArray;
  97792. /**
  97793. * Get one of the submaterial by its index in the submaterials array
  97794. * @param index The index to look the sub material at
  97795. * @returns The Material if the index has been defined
  97796. */
  97797. getSubMaterial(index: number): Nullable<Material>;
  97798. /**
  97799. * Get the list of active textures for the whole sub materials list.
  97800. * @returns All the textures that will be used during the rendering
  97801. */
  97802. getActiveTextures(): BaseTexture[];
  97803. /**
  97804. * Gets the current class name of the material e.g. "MultiMaterial"
  97805. * Mainly use in serialization.
  97806. * @returns the class name
  97807. */
  97808. getClassName(): string;
  97809. /**
  97810. * Checks if the material is ready to render the requested sub mesh
  97811. * @param mesh Define the mesh the submesh belongs to
  97812. * @param subMesh Define the sub mesh to look readyness for
  97813. * @param useInstances Define whether or not the material is used with instances
  97814. * @returns true if ready, otherwise false
  97815. */
  97816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97817. /**
  97818. * Clones the current material and its related sub materials
  97819. * @param name Define the name of the newly cloned material
  97820. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97821. * @returns the cloned material
  97822. */
  97823. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97824. /**
  97825. * Serializes the materials into a JSON representation.
  97826. * @returns the JSON representation
  97827. */
  97828. serialize(): any;
  97829. /**
  97830. * Dispose the material and release its associated resources
  97831. * @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)
  97832. * @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)
  97833. * @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)
  97834. */
  97835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97836. /**
  97837. * Creates a MultiMaterial from parsed MultiMaterial data.
  97838. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97839. * @param scene defines the hosting scene
  97840. * @returns a new MultiMaterial
  97841. */
  97842. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97843. }
  97844. }
  97845. declare module BABYLON {
  97846. /**
  97847. * Base class for submeshes
  97848. */
  97849. export class BaseSubMesh {
  97850. /** @hidden */
  97851. _materialDefines: Nullable<MaterialDefines>;
  97852. /** @hidden */
  97853. _materialEffect: Nullable<Effect>;
  97854. /** @hidden */
  97855. _effectOverride: Nullable<Effect>;
  97856. /**
  97857. * Gets material defines used by the effect associated to the sub mesh
  97858. */
  97859. get materialDefines(): Nullable<MaterialDefines>;
  97860. /**
  97861. * Sets material defines used by the effect associated to the sub mesh
  97862. */
  97863. set materialDefines(defines: Nullable<MaterialDefines>);
  97864. /**
  97865. * Gets associated effect
  97866. */
  97867. get effect(): Nullable<Effect>;
  97868. /**
  97869. * Sets associated effect (effect used to render this submesh)
  97870. * @param effect defines the effect to associate with
  97871. * @param defines defines the set of defines used to compile this effect
  97872. */
  97873. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97874. }
  97875. /**
  97876. * Defines a subdivision inside a mesh
  97877. */
  97878. export class SubMesh extends BaseSubMesh implements ICullable {
  97879. /** the material index to use */
  97880. materialIndex: number;
  97881. /** vertex index start */
  97882. verticesStart: number;
  97883. /** vertices count */
  97884. verticesCount: number;
  97885. /** index start */
  97886. indexStart: number;
  97887. /** indices count */
  97888. indexCount: number;
  97889. /** @hidden */
  97890. _linesIndexCount: number;
  97891. private _mesh;
  97892. private _renderingMesh;
  97893. private _boundingInfo;
  97894. private _linesIndexBuffer;
  97895. /** @hidden */
  97896. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97897. /** @hidden */
  97898. _trianglePlanes: Plane[];
  97899. /** @hidden */
  97900. _lastColliderTransformMatrix: Nullable<Matrix>;
  97901. /** @hidden */
  97902. _renderId: number;
  97903. /** @hidden */
  97904. _alphaIndex: number;
  97905. /** @hidden */
  97906. _distanceToCamera: number;
  97907. /** @hidden */
  97908. _id: number;
  97909. private _currentMaterial;
  97910. /**
  97911. * Add a new submesh to a mesh
  97912. * @param materialIndex defines the material index to use
  97913. * @param verticesStart defines vertex index start
  97914. * @param verticesCount defines vertices count
  97915. * @param indexStart defines index start
  97916. * @param indexCount defines indices count
  97917. * @param mesh defines the parent mesh
  97918. * @param renderingMesh defines an optional rendering mesh
  97919. * @param createBoundingBox defines if bounding box should be created for this submesh
  97920. * @returns the new submesh
  97921. */
  97922. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97923. /**
  97924. * Creates a new submesh
  97925. * @param materialIndex defines the material index to use
  97926. * @param verticesStart defines vertex index start
  97927. * @param verticesCount defines vertices count
  97928. * @param indexStart defines index start
  97929. * @param indexCount defines indices count
  97930. * @param mesh defines the parent mesh
  97931. * @param renderingMesh defines an optional rendering mesh
  97932. * @param createBoundingBox defines if bounding box should be created for this submesh
  97933. */
  97934. constructor(
  97935. /** the material index to use */
  97936. materialIndex: number,
  97937. /** vertex index start */
  97938. verticesStart: number,
  97939. /** vertices count */
  97940. verticesCount: number,
  97941. /** index start */
  97942. indexStart: number,
  97943. /** indices count */
  97944. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  97945. /**
  97946. * Returns true if this submesh covers the entire parent mesh
  97947. * @ignorenaming
  97948. */
  97949. get IsGlobal(): boolean;
  97950. /**
  97951. * Returns the submesh BoudingInfo object
  97952. * @returns current bounding info (or mesh's one if the submesh is global)
  97953. */
  97954. getBoundingInfo(): BoundingInfo;
  97955. /**
  97956. * Sets the submesh BoundingInfo
  97957. * @param boundingInfo defines the new bounding info to use
  97958. * @returns the SubMesh
  97959. */
  97960. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  97961. /**
  97962. * Returns the mesh of the current submesh
  97963. * @return the parent mesh
  97964. */
  97965. getMesh(): AbstractMesh;
  97966. /**
  97967. * Returns the rendering mesh of the submesh
  97968. * @returns the rendering mesh (could be different from parent mesh)
  97969. */
  97970. getRenderingMesh(): Mesh;
  97971. /**
  97972. * Returns the submesh material
  97973. * @returns null or the current material
  97974. */
  97975. getMaterial(): Nullable<Material>;
  97976. /**
  97977. * Sets a new updated BoundingInfo object to the submesh
  97978. * @param data defines an optional position array to use to determine the bounding info
  97979. * @returns the SubMesh
  97980. */
  97981. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  97982. /** @hidden */
  97983. _checkCollision(collider: Collider): boolean;
  97984. /**
  97985. * Updates the submesh BoundingInfo
  97986. * @param world defines the world matrix to use to update the bounding info
  97987. * @returns the submesh
  97988. */
  97989. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  97990. /**
  97991. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  97992. * @param frustumPlanes defines the frustum planes
  97993. * @returns true if the submesh is intersecting with the frustum
  97994. */
  97995. isInFrustum(frustumPlanes: Plane[]): boolean;
  97996. /**
  97997. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  97998. * @param frustumPlanes defines the frustum planes
  97999. * @returns true if the submesh is inside the frustum
  98000. */
  98001. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98002. /**
  98003. * Renders the submesh
  98004. * @param enableAlphaMode defines if alpha needs to be used
  98005. * @returns the submesh
  98006. */
  98007. render(enableAlphaMode: boolean): SubMesh;
  98008. /**
  98009. * @hidden
  98010. */
  98011. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  98012. /**
  98013. * Checks if the submesh intersects with a ray
  98014. * @param ray defines the ray to test
  98015. * @returns true is the passed ray intersects the submesh bounding box
  98016. */
  98017. canIntersects(ray: Ray): boolean;
  98018. /**
  98019. * Intersects current submesh with a ray
  98020. * @param ray defines the ray to test
  98021. * @param positions defines mesh's positions array
  98022. * @param indices defines mesh's indices array
  98023. * @param fastCheck defines if the first intersection will be used (and not the closest)
  98024. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98025. * @returns intersection info or null if no intersection
  98026. */
  98027. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  98028. /** @hidden */
  98029. private _intersectLines;
  98030. /** @hidden */
  98031. private _intersectUnIndexedLines;
  98032. /** @hidden */
  98033. private _intersectTriangles;
  98034. /** @hidden */
  98035. private _intersectUnIndexedTriangles;
  98036. /** @hidden */
  98037. _rebuild(): void;
  98038. /**
  98039. * Creates a new submesh from the passed mesh
  98040. * @param newMesh defines the new hosting mesh
  98041. * @param newRenderingMesh defines an optional rendering mesh
  98042. * @returns the new submesh
  98043. */
  98044. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  98045. /**
  98046. * Release associated resources
  98047. */
  98048. dispose(): void;
  98049. /**
  98050. * Gets the class name
  98051. * @returns the string "SubMesh".
  98052. */
  98053. getClassName(): string;
  98054. /**
  98055. * Creates a new submesh from indices data
  98056. * @param materialIndex the index of the main mesh material
  98057. * @param startIndex the index where to start the copy in the mesh indices array
  98058. * @param indexCount the number of indices to copy then from the startIndex
  98059. * @param mesh the main mesh to create the submesh from
  98060. * @param renderingMesh the optional rendering mesh
  98061. * @returns a new submesh
  98062. */
  98063. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  98064. }
  98065. }
  98066. declare module BABYLON {
  98067. /**
  98068. * Class used to represent data loading progression
  98069. */
  98070. export class SceneLoaderFlags {
  98071. private static _ForceFullSceneLoadingForIncremental;
  98072. private static _ShowLoadingScreen;
  98073. private static _CleanBoneMatrixWeights;
  98074. private static _loggingLevel;
  98075. /**
  98076. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98077. */
  98078. static get ForceFullSceneLoadingForIncremental(): boolean;
  98079. static set ForceFullSceneLoadingForIncremental(value: boolean);
  98080. /**
  98081. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98082. */
  98083. static get ShowLoadingScreen(): boolean;
  98084. static set ShowLoadingScreen(value: boolean);
  98085. /**
  98086. * Defines the current logging level (while loading the scene)
  98087. * @ignorenaming
  98088. */
  98089. static get loggingLevel(): number;
  98090. static set loggingLevel(value: number);
  98091. /**
  98092. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98093. */
  98094. static get CleanBoneMatrixWeights(): boolean;
  98095. static set CleanBoneMatrixWeights(value: boolean);
  98096. }
  98097. }
  98098. declare module BABYLON {
  98099. /**
  98100. * Class used to store geometry data (vertex buffers + index buffer)
  98101. */
  98102. export class Geometry implements IGetSetVerticesData {
  98103. /**
  98104. * Gets or sets the ID of the geometry
  98105. */
  98106. id: string;
  98107. /**
  98108. * Gets or sets the unique ID of the geometry
  98109. */
  98110. uniqueId: number;
  98111. /**
  98112. * Gets the delay loading state of the geometry (none by default which means not delayed)
  98113. */
  98114. delayLoadState: number;
  98115. /**
  98116. * Gets the file containing the data to load when running in delay load state
  98117. */
  98118. delayLoadingFile: Nullable<string>;
  98119. /**
  98120. * Callback called when the geometry is updated
  98121. */
  98122. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  98123. private _scene;
  98124. private _engine;
  98125. private _meshes;
  98126. private _totalVertices;
  98127. /** @hidden */
  98128. _indices: IndicesArray;
  98129. /** @hidden */
  98130. _vertexBuffers: {
  98131. [key: string]: VertexBuffer;
  98132. };
  98133. private _isDisposed;
  98134. private _extend;
  98135. private _boundingBias;
  98136. /** @hidden */
  98137. _delayInfo: Array<string>;
  98138. private _indexBuffer;
  98139. private _indexBufferIsUpdatable;
  98140. /** @hidden */
  98141. _boundingInfo: Nullable<BoundingInfo>;
  98142. /** @hidden */
  98143. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  98144. /** @hidden */
  98145. _softwareSkinningFrameId: number;
  98146. private _vertexArrayObjects;
  98147. private _updatable;
  98148. /** @hidden */
  98149. _positions: Nullable<Vector3[]>;
  98150. /**
  98151. * 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
  98152. */
  98153. get boundingBias(): Vector2;
  98154. /**
  98155. * 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
  98156. */
  98157. set boundingBias(value: Vector2);
  98158. /**
  98159. * Static function used to attach a new empty geometry to a mesh
  98160. * @param mesh defines the mesh to attach the geometry to
  98161. * @returns the new Geometry
  98162. */
  98163. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  98164. /** Get the list of meshes using this geometry */
  98165. get meshes(): Mesh[];
  98166. /**
  98167. * Creates a new geometry
  98168. * @param id defines the unique ID
  98169. * @param scene defines the hosting scene
  98170. * @param vertexData defines the VertexData used to get geometry data
  98171. * @param updatable defines if geometry must be updatable (false by default)
  98172. * @param mesh defines the mesh that will be associated with the geometry
  98173. */
  98174. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  98175. /**
  98176. * Gets the current extend of the geometry
  98177. */
  98178. get extend(): {
  98179. minimum: Vector3;
  98180. maximum: Vector3;
  98181. };
  98182. /**
  98183. * Gets the hosting scene
  98184. * @returns the hosting Scene
  98185. */
  98186. getScene(): Scene;
  98187. /**
  98188. * Gets the hosting engine
  98189. * @returns the hosting Engine
  98190. */
  98191. getEngine(): Engine;
  98192. /**
  98193. * Defines if the geometry is ready to use
  98194. * @returns true if the geometry is ready to be used
  98195. */
  98196. isReady(): boolean;
  98197. /**
  98198. * Gets a value indicating that the geometry should not be serialized
  98199. */
  98200. get doNotSerialize(): boolean;
  98201. /** @hidden */
  98202. _rebuild(): void;
  98203. /**
  98204. * Affects all geometry data in one call
  98205. * @param vertexData defines the geometry data
  98206. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  98207. */
  98208. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  98209. /**
  98210. * Set specific vertex data
  98211. * @param kind defines the data kind (Position, normal, etc...)
  98212. * @param data defines the vertex data to use
  98213. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98214. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98215. */
  98216. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98217. /**
  98218. * Removes a specific vertex data
  98219. * @param kind defines the data kind (Position, normal, etc...)
  98220. */
  98221. removeVerticesData(kind: string): void;
  98222. /**
  98223. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98224. * @param buffer defines the vertex buffer to use
  98225. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98226. */
  98227. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98228. /**
  98229. * Update a specific vertex buffer
  98230. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98231. * It will do nothing if the buffer is not updatable
  98232. * @param kind defines the data kind (Position, normal, etc...)
  98233. * @param data defines the data to use
  98234. * @param offset defines the offset in the target buffer where to store the data
  98235. * @param useBytes set to true if the offset is in bytes
  98236. */
  98237. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98238. /**
  98239. * Update a specific vertex buffer
  98240. * This function will create a new buffer if the current one is not updatable
  98241. * @param kind defines the data kind (Position, normal, etc...)
  98242. * @param data defines the data to use
  98243. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98244. */
  98245. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98246. private _updateBoundingInfo;
  98247. /** @hidden */
  98248. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98249. /**
  98250. * Gets total number of vertices
  98251. * @returns the total number of vertices
  98252. */
  98253. getTotalVertices(): number;
  98254. /**
  98255. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98256. * @param kind defines the data kind (Position, normal, etc...)
  98257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98259. * @returns a float array containing vertex data
  98260. */
  98261. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98262. /**
  98263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98264. * @param kind defines the data kind (Position, normal, etc...)
  98265. * @returns true if the vertex buffer with the specified kind is updatable
  98266. */
  98267. isVertexBufferUpdatable(kind: string): boolean;
  98268. /**
  98269. * Gets a specific vertex buffer
  98270. * @param kind defines the data kind (Position, normal, etc...)
  98271. * @returns a VertexBuffer
  98272. */
  98273. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98274. /**
  98275. * Returns all vertex buffers
  98276. * @return an object holding all vertex buffers indexed by kind
  98277. */
  98278. getVertexBuffers(): Nullable<{
  98279. [key: string]: VertexBuffer;
  98280. }>;
  98281. /**
  98282. * Gets a boolean indicating if specific vertex buffer is present
  98283. * @param kind defines the data kind (Position, normal, etc...)
  98284. * @returns true if data is present
  98285. */
  98286. isVerticesDataPresent(kind: string): boolean;
  98287. /**
  98288. * Gets a list of all attached data kinds (Position, normal, etc...)
  98289. * @returns a list of string containing all kinds
  98290. */
  98291. getVerticesDataKinds(): string[];
  98292. /**
  98293. * Update index buffer
  98294. * @param indices defines the indices to store in the index buffer
  98295. * @param offset defines the offset in the target buffer where to store the data
  98296. * @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)
  98297. */
  98298. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98299. /**
  98300. * Creates a new index buffer
  98301. * @param indices defines the indices to store in the index buffer
  98302. * @param totalVertices defines the total number of vertices (could be null)
  98303. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98304. */
  98305. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98306. /**
  98307. * Return the total number of indices
  98308. * @returns the total number of indices
  98309. */
  98310. getTotalIndices(): number;
  98311. /**
  98312. * Gets the index buffer array
  98313. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98314. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98315. * @returns the index buffer array
  98316. */
  98317. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98318. /**
  98319. * Gets the index buffer
  98320. * @return the index buffer
  98321. */
  98322. getIndexBuffer(): Nullable<DataBuffer>;
  98323. /** @hidden */
  98324. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98325. /**
  98326. * Release the associated resources for a specific mesh
  98327. * @param mesh defines the source mesh
  98328. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98329. */
  98330. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98331. /**
  98332. * Apply current geometry to a given mesh
  98333. * @param mesh defines the mesh to apply geometry to
  98334. */
  98335. applyToMesh(mesh: Mesh): void;
  98336. private _updateExtend;
  98337. private _applyToMesh;
  98338. private notifyUpdate;
  98339. /**
  98340. * Load the geometry if it was flagged as delay loaded
  98341. * @param scene defines the hosting scene
  98342. * @param onLoaded defines a callback called when the geometry is loaded
  98343. */
  98344. load(scene: Scene, onLoaded?: () => void): void;
  98345. private _queueLoad;
  98346. /**
  98347. * Invert the geometry to move from a right handed system to a left handed one.
  98348. */
  98349. toLeftHanded(): void;
  98350. /** @hidden */
  98351. _resetPointsArrayCache(): void;
  98352. /** @hidden */
  98353. _generatePointsArray(): boolean;
  98354. /**
  98355. * Gets a value indicating if the geometry is disposed
  98356. * @returns true if the geometry was disposed
  98357. */
  98358. isDisposed(): boolean;
  98359. private _disposeVertexArrayObjects;
  98360. /**
  98361. * Free all associated resources
  98362. */
  98363. dispose(): void;
  98364. /**
  98365. * Clone the current geometry into a new geometry
  98366. * @param id defines the unique ID of the new geometry
  98367. * @returns a new geometry object
  98368. */
  98369. copy(id: string): Geometry;
  98370. /**
  98371. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98372. * @return a JSON representation of the current geometry data (without the vertices data)
  98373. */
  98374. serialize(): any;
  98375. private toNumberArray;
  98376. /**
  98377. * Serialize all vertices data into a JSON oject
  98378. * @returns a JSON representation of the current geometry data
  98379. */
  98380. serializeVerticeData(): any;
  98381. /**
  98382. * Extracts a clone of a mesh geometry
  98383. * @param mesh defines the source mesh
  98384. * @param id defines the unique ID of the new geometry object
  98385. * @returns the new geometry object
  98386. */
  98387. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98388. /**
  98389. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98390. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98391. * Be aware Math.random() could cause collisions, but:
  98392. * "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"
  98393. * @returns a string containing a new GUID
  98394. */
  98395. static RandomId(): string;
  98396. /** @hidden */
  98397. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98398. private static _CleanMatricesWeights;
  98399. /**
  98400. * Create a new geometry from persisted data (Using .babylon file format)
  98401. * @param parsedVertexData defines the persisted data
  98402. * @param scene defines the hosting scene
  98403. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98404. * @returns the new geometry object
  98405. */
  98406. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98407. }
  98408. }
  98409. declare module BABYLON {
  98410. /**
  98411. * Define an interface for all classes that will get and set the data on vertices
  98412. */
  98413. export interface IGetSetVerticesData {
  98414. /**
  98415. * Gets a boolean indicating if specific vertex data is present
  98416. * @param kind defines the vertex data kind to use
  98417. * @returns true is data kind is present
  98418. */
  98419. isVerticesDataPresent(kind: string): boolean;
  98420. /**
  98421. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98422. * @param kind defines the data kind (Position, normal, etc...)
  98423. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98424. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98425. * @returns a float array containing vertex data
  98426. */
  98427. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98428. /**
  98429. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98430. * @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.
  98431. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98432. * @returns the indices array or an empty array if the mesh has no geometry
  98433. */
  98434. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98435. /**
  98436. * Set specific vertex data
  98437. * @param kind defines the data kind (Position, normal, etc...)
  98438. * @param data defines the vertex data to use
  98439. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98440. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98441. */
  98442. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98443. /**
  98444. * Update a specific associated vertex buffer
  98445. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98446. * - VertexBuffer.PositionKind
  98447. * - VertexBuffer.UVKind
  98448. * - VertexBuffer.UV2Kind
  98449. * - VertexBuffer.UV3Kind
  98450. * - VertexBuffer.UV4Kind
  98451. * - VertexBuffer.UV5Kind
  98452. * - VertexBuffer.UV6Kind
  98453. * - VertexBuffer.ColorKind
  98454. * - VertexBuffer.MatricesIndicesKind
  98455. * - VertexBuffer.MatricesIndicesExtraKind
  98456. * - VertexBuffer.MatricesWeightsKind
  98457. * - VertexBuffer.MatricesWeightsExtraKind
  98458. * @param data defines the data source
  98459. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98460. * @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)
  98461. */
  98462. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98463. /**
  98464. * Creates a new index buffer
  98465. * @param indices defines the indices to store in the index buffer
  98466. * @param totalVertices defines the total number of vertices (could be null)
  98467. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98468. */
  98469. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98470. }
  98471. /**
  98472. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98473. */
  98474. export class VertexData {
  98475. /**
  98476. * Mesh side orientation : usually the external or front surface
  98477. */
  98478. static readonly FRONTSIDE: number;
  98479. /**
  98480. * Mesh side orientation : usually the internal or back surface
  98481. */
  98482. static readonly BACKSIDE: number;
  98483. /**
  98484. * Mesh side orientation : both internal and external or front and back surfaces
  98485. */
  98486. static readonly DOUBLESIDE: number;
  98487. /**
  98488. * Mesh side orientation : by default, `FRONTSIDE`
  98489. */
  98490. static readonly DEFAULTSIDE: number;
  98491. /**
  98492. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98493. */
  98494. positions: Nullable<FloatArray>;
  98495. /**
  98496. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98497. */
  98498. normals: Nullable<FloatArray>;
  98499. /**
  98500. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98501. */
  98502. tangents: Nullable<FloatArray>;
  98503. /**
  98504. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98505. */
  98506. uvs: Nullable<FloatArray>;
  98507. /**
  98508. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98509. */
  98510. uvs2: Nullable<FloatArray>;
  98511. /**
  98512. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98513. */
  98514. uvs3: Nullable<FloatArray>;
  98515. /**
  98516. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98517. */
  98518. uvs4: Nullable<FloatArray>;
  98519. /**
  98520. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98521. */
  98522. uvs5: Nullable<FloatArray>;
  98523. /**
  98524. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98525. */
  98526. uvs6: Nullable<FloatArray>;
  98527. /**
  98528. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98529. */
  98530. colors: Nullable<FloatArray>;
  98531. /**
  98532. * 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).
  98533. */
  98534. matricesIndices: Nullable<FloatArray>;
  98535. /**
  98536. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98537. */
  98538. matricesWeights: Nullable<FloatArray>;
  98539. /**
  98540. * An array extending the number of possible indices
  98541. */
  98542. matricesIndicesExtra: Nullable<FloatArray>;
  98543. /**
  98544. * An array extending the number of possible weights when the number of indices is extended
  98545. */
  98546. matricesWeightsExtra: Nullable<FloatArray>;
  98547. /**
  98548. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98549. */
  98550. indices: Nullable<IndicesArray>;
  98551. /**
  98552. * Uses the passed data array to set the set the values for the specified kind of data
  98553. * @param data a linear array of floating numbers
  98554. * @param kind the type of data that is being set, eg positions, colors etc
  98555. */
  98556. set(data: FloatArray, kind: string): void;
  98557. /**
  98558. * Associates the vertexData to the passed Mesh.
  98559. * Sets it as updatable or not (default `false`)
  98560. * @param mesh the mesh the vertexData is applied to
  98561. * @param updatable when used and having the value true allows new data to update the vertexData
  98562. * @returns the VertexData
  98563. */
  98564. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98565. /**
  98566. * Associates the vertexData to the passed Geometry.
  98567. * Sets it as updatable or not (default `false`)
  98568. * @param geometry the geometry the vertexData is applied to
  98569. * @param updatable when used and having the value true allows new data to update the vertexData
  98570. * @returns VertexData
  98571. */
  98572. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98573. /**
  98574. * Updates the associated mesh
  98575. * @param mesh the mesh to be updated
  98576. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98577. * @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
  98578. * @returns VertexData
  98579. */
  98580. updateMesh(mesh: Mesh): VertexData;
  98581. /**
  98582. * Updates the associated geometry
  98583. * @param geometry the geometry to be updated
  98584. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98585. * @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
  98586. * @returns VertexData.
  98587. */
  98588. updateGeometry(geometry: Geometry): VertexData;
  98589. private _applyTo;
  98590. private _update;
  98591. /**
  98592. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98593. * @param matrix the transforming matrix
  98594. * @returns the VertexData
  98595. */
  98596. transform(matrix: Matrix): VertexData;
  98597. /**
  98598. * Merges the passed VertexData into the current one
  98599. * @param other the VertexData to be merged into the current one
  98600. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98601. * @returns the modified VertexData
  98602. */
  98603. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98604. private _mergeElement;
  98605. private _validate;
  98606. /**
  98607. * Serializes the VertexData
  98608. * @returns a serialized object
  98609. */
  98610. serialize(): any;
  98611. /**
  98612. * Extracts the vertexData from a mesh
  98613. * @param mesh the mesh from which to extract the VertexData
  98614. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98615. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98616. * @returns the object VertexData associated to the passed mesh
  98617. */
  98618. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98619. /**
  98620. * Extracts the vertexData from the geometry
  98621. * @param geometry the geometry from which to extract the VertexData
  98622. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98623. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98624. * @returns the object VertexData associated to the passed mesh
  98625. */
  98626. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98627. private static _ExtractFrom;
  98628. /**
  98629. * Creates the VertexData for a Ribbon
  98630. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98631. * * pathArray array of paths, each of which an array of successive Vector3
  98632. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98633. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98634. * * 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
  98635. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98636. * * 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)
  98637. * * 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)
  98638. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98639. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98640. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98641. * @returns the VertexData of the ribbon
  98642. */
  98643. static CreateRibbon(options: {
  98644. pathArray: Vector3[][];
  98645. closeArray?: boolean;
  98646. closePath?: boolean;
  98647. offset?: number;
  98648. sideOrientation?: number;
  98649. frontUVs?: Vector4;
  98650. backUVs?: Vector4;
  98651. invertUV?: boolean;
  98652. uvs?: Vector2[];
  98653. colors?: Color4[];
  98654. }): VertexData;
  98655. /**
  98656. * Creates the VertexData for a box
  98657. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98658. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98659. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98660. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98661. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98662. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98663. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98665. * * 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)
  98666. * * 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)
  98667. * @returns the VertexData of the box
  98668. */
  98669. static CreateBox(options: {
  98670. size?: number;
  98671. width?: number;
  98672. height?: number;
  98673. depth?: number;
  98674. faceUV?: Vector4[];
  98675. faceColors?: Color4[];
  98676. sideOrientation?: number;
  98677. frontUVs?: Vector4;
  98678. backUVs?: Vector4;
  98679. }): VertexData;
  98680. /**
  98681. * Creates the VertexData for a tiled box
  98682. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98683. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98684. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98685. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98687. * @returns the VertexData of the box
  98688. */
  98689. static CreateTiledBox(options: {
  98690. pattern?: number;
  98691. width?: number;
  98692. height?: number;
  98693. depth?: number;
  98694. tileSize?: number;
  98695. tileWidth?: number;
  98696. tileHeight?: number;
  98697. alignHorizontal?: number;
  98698. alignVertical?: number;
  98699. faceUV?: Vector4[];
  98700. faceColors?: Color4[];
  98701. sideOrientation?: number;
  98702. }): VertexData;
  98703. /**
  98704. * Creates the VertexData for a tiled plane
  98705. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98706. * * pattern a limited pattern arrangement depending on the number
  98707. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98708. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98709. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98711. * * 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)
  98712. * * 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)
  98713. * @returns the VertexData of the tiled plane
  98714. */
  98715. static CreateTiledPlane(options: {
  98716. pattern?: number;
  98717. tileSize?: number;
  98718. tileWidth?: number;
  98719. tileHeight?: number;
  98720. size?: number;
  98721. width?: number;
  98722. height?: number;
  98723. alignHorizontal?: number;
  98724. alignVertical?: number;
  98725. sideOrientation?: number;
  98726. frontUVs?: Vector4;
  98727. backUVs?: Vector4;
  98728. }): VertexData;
  98729. /**
  98730. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98731. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98732. * * segments sets the number of horizontal strips optional, default 32
  98733. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98734. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98735. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98736. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98737. * * 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
  98738. * * 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
  98739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98740. * * 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)
  98741. * * 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)
  98742. * @returns the VertexData of the ellipsoid
  98743. */
  98744. static CreateSphere(options: {
  98745. segments?: number;
  98746. diameter?: number;
  98747. diameterX?: number;
  98748. diameterY?: number;
  98749. diameterZ?: number;
  98750. arc?: number;
  98751. slice?: number;
  98752. sideOrientation?: number;
  98753. frontUVs?: Vector4;
  98754. backUVs?: Vector4;
  98755. }): VertexData;
  98756. /**
  98757. * Creates the VertexData for a cylinder, cone or prism
  98758. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98759. * * height sets the height (y direction) of the cylinder, optional, default 2
  98760. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98761. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98762. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98763. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98764. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98765. * * 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
  98766. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98767. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98768. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98769. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98771. * * 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)
  98772. * * 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)
  98773. * @returns the VertexData of the cylinder, cone or prism
  98774. */
  98775. static CreateCylinder(options: {
  98776. height?: number;
  98777. diameterTop?: number;
  98778. diameterBottom?: number;
  98779. diameter?: number;
  98780. tessellation?: number;
  98781. subdivisions?: number;
  98782. arc?: number;
  98783. faceColors?: Color4[];
  98784. faceUV?: Vector4[];
  98785. hasRings?: boolean;
  98786. enclose?: boolean;
  98787. sideOrientation?: number;
  98788. frontUVs?: Vector4;
  98789. backUVs?: Vector4;
  98790. }): VertexData;
  98791. /**
  98792. * Creates the VertexData for a torus
  98793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98794. * * diameter the diameter of the torus, optional default 1
  98795. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98796. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98798. * * 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)
  98799. * * 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)
  98800. * @returns the VertexData of the torus
  98801. */
  98802. static CreateTorus(options: {
  98803. diameter?: number;
  98804. thickness?: number;
  98805. tessellation?: number;
  98806. sideOrientation?: number;
  98807. frontUVs?: Vector4;
  98808. backUVs?: Vector4;
  98809. }): VertexData;
  98810. /**
  98811. * Creates the VertexData of the LineSystem
  98812. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98813. * - lines an array of lines, each line being an array of successive Vector3
  98814. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98815. * @returns the VertexData of the LineSystem
  98816. */
  98817. static CreateLineSystem(options: {
  98818. lines: Vector3[][];
  98819. colors?: Nullable<Color4[][]>;
  98820. }): VertexData;
  98821. /**
  98822. * Create the VertexData for a DashedLines
  98823. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98824. * - points an array successive Vector3
  98825. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98826. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98827. * - dashNb the intended total number of dashes, optional, default 200
  98828. * @returns the VertexData for the DashedLines
  98829. */
  98830. static CreateDashedLines(options: {
  98831. points: Vector3[];
  98832. dashSize?: number;
  98833. gapSize?: number;
  98834. dashNb?: number;
  98835. }): VertexData;
  98836. /**
  98837. * Creates the VertexData for a Ground
  98838. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98839. * - width the width (x direction) of the ground, optional, default 1
  98840. * - height the height (z direction) of the ground, optional, default 1
  98841. * - subdivisions the number of subdivisions per side, optional, default 1
  98842. * @returns the VertexData of the Ground
  98843. */
  98844. static CreateGround(options: {
  98845. width?: number;
  98846. height?: number;
  98847. subdivisions?: number;
  98848. subdivisionsX?: number;
  98849. subdivisionsY?: number;
  98850. }): VertexData;
  98851. /**
  98852. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98853. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98854. * * xmin the ground minimum X coordinate, optional, default -1
  98855. * * zmin the ground minimum Z coordinate, optional, default -1
  98856. * * xmax the ground maximum X coordinate, optional, default 1
  98857. * * zmax the ground maximum Z coordinate, optional, default 1
  98858. * * 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}
  98859. * * 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}
  98860. * @returns the VertexData of the TiledGround
  98861. */
  98862. static CreateTiledGround(options: {
  98863. xmin: number;
  98864. zmin: number;
  98865. xmax: number;
  98866. zmax: number;
  98867. subdivisions?: {
  98868. w: number;
  98869. h: number;
  98870. };
  98871. precision?: {
  98872. w: number;
  98873. h: number;
  98874. };
  98875. }): VertexData;
  98876. /**
  98877. * Creates the VertexData of the Ground designed from a heightmap
  98878. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98879. * * width the width (x direction) of the ground
  98880. * * height the height (z direction) of the ground
  98881. * * subdivisions the number of subdivisions per side
  98882. * * minHeight the minimum altitude on the ground, optional, default 0
  98883. * * maxHeight the maximum altitude on the ground, optional default 1
  98884. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98885. * * buffer the array holding the image color data
  98886. * * bufferWidth the width of image
  98887. * * bufferHeight the height of image
  98888. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98889. * @returns the VertexData of the Ground designed from a heightmap
  98890. */
  98891. static CreateGroundFromHeightMap(options: {
  98892. width: number;
  98893. height: number;
  98894. subdivisions: number;
  98895. minHeight: number;
  98896. maxHeight: number;
  98897. colorFilter: Color3;
  98898. buffer: Uint8Array;
  98899. bufferWidth: number;
  98900. bufferHeight: number;
  98901. alphaFilter: number;
  98902. }): VertexData;
  98903. /**
  98904. * Creates the VertexData for a Plane
  98905. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98906. * * size sets the width and height of the plane to the value of size, optional default 1
  98907. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98908. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98910. * * 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)
  98911. * * 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)
  98912. * @returns the VertexData of the box
  98913. */
  98914. static CreatePlane(options: {
  98915. size?: number;
  98916. width?: number;
  98917. height?: number;
  98918. sideOrientation?: number;
  98919. frontUVs?: Vector4;
  98920. backUVs?: Vector4;
  98921. }): VertexData;
  98922. /**
  98923. * Creates the VertexData of the Disc or regular Polygon
  98924. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98925. * * radius the radius of the disc, optional default 0.5
  98926. * * tessellation the number of polygon sides, optional, default 64
  98927. * * 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
  98928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98929. * * 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)
  98930. * * 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)
  98931. * @returns the VertexData of the box
  98932. */
  98933. static CreateDisc(options: {
  98934. radius?: number;
  98935. tessellation?: number;
  98936. arc?: number;
  98937. sideOrientation?: number;
  98938. frontUVs?: Vector4;
  98939. backUVs?: Vector4;
  98940. }): VertexData;
  98941. /**
  98942. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  98943. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  98944. * @param polygon a mesh built from polygonTriangulation.build()
  98945. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98946. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98947. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98948. * @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)
  98949. * @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)
  98950. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  98951. * @returns the VertexData of the Polygon
  98952. */
  98953. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  98954. /**
  98955. * Creates the VertexData of the IcoSphere
  98956. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  98957. * * radius the radius of the IcoSphere, optional default 1
  98958. * * radiusX allows stretching in the x direction, optional, default radius
  98959. * * radiusY allows stretching in the y direction, optional, default radius
  98960. * * radiusZ allows stretching in the z direction, optional, default radius
  98961. * * flat when true creates a flat shaded mesh, optional, default true
  98962. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98964. * * 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)
  98965. * * 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)
  98966. * @returns the VertexData of the IcoSphere
  98967. */
  98968. static CreateIcoSphere(options: {
  98969. radius?: number;
  98970. radiusX?: number;
  98971. radiusY?: number;
  98972. radiusZ?: number;
  98973. flat?: boolean;
  98974. subdivisions?: number;
  98975. sideOrientation?: number;
  98976. frontUVs?: Vector4;
  98977. backUVs?: Vector4;
  98978. }): VertexData;
  98979. /**
  98980. * Creates the VertexData for a Polyhedron
  98981. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  98982. * * type provided types are:
  98983. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  98984. * * 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)
  98985. * * size the size of the IcoSphere, optional default 1
  98986. * * sizeX allows stretching in the x direction, optional, default size
  98987. * * sizeY allows stretching in the y direction, optional, default size
  98988. * * sizeZ allows stretching in the z direction, optional, default size
  98989. * * 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
  98990. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98991. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98992. * * flat when true creates a flat shaded mesh, optional, default true
  98993. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98994. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98995. * * 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)
  98996. * * 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)
  98997. * @returns the VertexData of the Polyhedron
  98998. */
  98999. static CreatePolyhedron(options: {
  99000. type?: number;
  99001. size?: number;
  99002. sizeX?: number;
  99003. sizeY?: number;
  99004. sizeZ?: number;
  99005. custom?: any;
  99006. faceUV?: Vector4[];
  99007. faceColors?: Color4[];
  99008. flat?: boolean;
  99009. sideOrientation?: number;
  99010. frontUVs?: Vector4;
  99011. backUVs?: Vector4;
  99012. }): VertexData;
  99013. /**
  99014. * Creates the VertexData for a TorusKnot
  99015. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  99016. * * radius the radius of the torus knot, optional, default 2
  99017. * * tube the thickness of the tube, optional, default 0.5
  99018. * * radialSegments the number of sides on each tube segments, optional, default 32
  99019. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  99020. * * p the number of windings around the z axis, optional, default 2
  99021. * * q the number of windings around the x axis, optional, default 3
  99022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99023. * * 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)
  99024. * * 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)
  99025. * @returns the VertexData of the Torus Knot
  99026. */
  99027. static CreateTorusKnot(options: {
  99028. radius?: number;
  99029. tube?: number;
  99030. radialSegments?: number;
  99031. tubularSegments?: number;
  99032. p?: number;
  99033. q?: number;
  99034. sideOrientation?: number;
  99035. frontUVs?: Vector4;
  99036. backUVs?: Vector4;
  99037. }): VertexData;
  99038. /**
  99039. * Compute normals for given positions and indices
  99040. * @param positions an array of vertex positions, [...., x, y, z, ......]
  99041. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  99042. * @param normals an array of vertex normals, [...., x, y, z, ......]
  99043. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  99044. * * facetNormals : optional array of facet normals (vector3)
  99045. * * facetPositions : optional array of facet positions (vector3)
  99046. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  99047. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  99048. * * bInfo : optional bounding info, required for facetPartitioning computation
  99049. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  99050. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  99051. * * useRightHandedSystem: optional boolean to for right handed system computation
  99052. * * depthSort : optional boolean to enable the facet depth sort computation
  99053. * * distanceTo : optional Vector3 to compute the facet depth from this location
  99054. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  99055. */
  99056. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  99057. facetNormals?: any;
  99058. facetPositions?: any;
  99059. facetPartitioning?: any;
  99060. ratio?: number;
  99061. bInfo?: any;
  99062. bbSize?: Vector3;
  99063. subDiv?: any;
  99064. useRightHandedSystem?: boolean;
  99065. depthSort?: boolean;
  99066. distanceTo?: Vector3;
  99067. depthSortedFacets?: any;
  99068. }): void;
  99069. /** @hidden */
  99070. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  99071. /**
  99072. * Applies VertexData created from the imported parameters to the geometry
  99073. * @param parsedVertexData the parsed data from an imported file
  99074. * @param geometry the geometry to apply the VertexData to
  99075. */
  99076. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  99077. }
  99078. }
  99079. declare module BABYLON {
  99080. /**
  99081. * Defines a target to use with MorphTargetManager
  99082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99083. */
  99084. export class MorphTarget implements IAnimatable {
  99085. /** defines the name of the target */
  99086. name: string;
  99087. /**
  99088. * Gets or sets the list of animations
  99089. */
  99090. animations: Animation[];
  99091. private _scene;
  99092. private _positions;
  99093. private _normals;
  99094. private _tangents;
  99095. private _uvs;
  99096. private _influence;
  99097. private _uniqueId;
  99098. /**
  99099. * Observable raised when the influence changes
  99100. */
  99101. onInfluenceChanged: Observable<boolean>;
  99102. /** @hidden */
  99103. _onDataLayoutChanged: Observable<void>;
  99104. /**
  99105. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99106. */
  99107. get influence(): number;
  99108. set influence(influence: number);
  99109. /**
  99110. * Gets or sets the id of the morph Target
  99111. */
  99112. id: string;
  99113. private _animationPropertiesOverride;
  99114. /**
  99115. * Gets or sets the animation properties override
  99116. */
  99117. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99118. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99119. /**
  99120. * Creates a new MorphTarget
  99121. * @param name defines the name of the target
  99122. * @param influence defines the influence to use
  99123. * @param scene defines the scene the morphtarget belongs to
  99124. */
  99125. constructor(
  99126. /** defines the name of the target */
  99127. name: string, influence?: number, scene?: Nullable<Scene>);
  99128. /**
  99129. * Gets the unique ID of this manager
  99130. */
  99131. get uniqueId(): number;
  99132. /**
  99133. * Gets a boolean defining if the target contains position data
  99134. */
  99135. get hasPositions(): boolean;
  99136. /**
  99137. * Gets a boolean defining if the target contains normal data
  99138. */
  99139. get hasNormals(): boolean;
  99140. /**
  99141. * Gets a boolean defining if the target contains tangent data
  99142. */
  99143. get hasTangents(): boolean;
  99144. /**
  99145. * Gets a boolean defining if the target contains texture coordinates data
  99146. */
  99147. get hasUVs(): boolean;
  99148. /**
  99149. * Affects position data to this target
  99150. * @param data defines the position data to use
  99151. */
  99152. setPositions(data: Nullable<FloatArray>): void;
  99153. /**
  99154. * Gets the position data stored in this target
  99155. * @returns a FloatArray containing the position data (or null if not present)
  99156. */
  99157. getPositions(): Nullable<FloatArray>;
  99158. /**
  99159. * Affects normal data to this target
  99160. * @param data defines the normal data to use
  99161. */
  99162. setNormals(data: Nullable<FloatArray>): void;
  99163. /**
  99164. * Gets the normal data stored in this target
  99165. * @returns a FloatArray containing the normal data (or null if not present)
  99166. */
  99167. getNormals(): Nullable<FloatArray>;
  99168. /**
  99169. * Affects tangent data to this target
  99170. * @param data defines the tangent data to use
  99171. */
  99172. setTangents(data: Nullable<FloatArray>): void;
  99173. /**
  99174. * Gets the tangent data stored in this target
  99175. * @returns a FloatArray containing the tangent data (or null if not present)
  99176. */
  99177. getTangents(): Nullable<FloatArray>;
  99178. /**
  99179. * Affects texture coordinates data to this target
  99180. * @param data defines the texture coordinates data to use
  99181. */
  99182. setUVs(data: Nullable<FloatArray>): void;
  99183. /**
  99184. * Gets the texture coordinates data stored in this target
  99185. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  99186. */
  99187. getUVs(): Nullable<FloatArray>;
  99188. /**
  99189. * Clone the current target
  99190. * @returns a new MorphTarget
  99191. */
  99192. clone(): MorphTarget;
  99193. /**
  99194. * Serializes the current target into a Serialization object
  99195. * @returns the serialized object
  99196. */
  99197. serialize(): any;
  99198. /**
  99199. * Returns the string "MorphTarget"
  99200. * @returns "MorphTarget"
  99201. */
  99202. getClassName(): string;
  99203. /**
  99204. * Creates a new target from serialized data
  99205. * @param serializationObject defines the serialized data to use
  99206. * @returns a new MorphTarget
  99207. */
  99208. static Parse(serializationObject: any): MorphTarget;
  99209. /**
  99210. * Creates a MorphTarget from mesh data
  99211. * @param mesh defines the source mesh
  99212. * @param name defines the name to use for the new target
  99213. * @param influence defines the influence to attach to the target
  99214. * @returns a new MorphTarget
  99215. */
  99216. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99217. }
  99218. }
  99219. declare module BABYLON {
  99220. /**
  99221. * This class is used to deform meshes using morphing between different targets
  99222. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99223. */
  99224. export class MorphTargetManager {
  99225. private _targets;
  99226. private _targetInfluenceChangedObservers;
  99227. private _targetDataLayoutChangedObservers;
  99228. private _activeTargets;
  99229. private _scene;
  99230. private _influences;
  99231. private _supportsNormals;
  99232. private _supportsTangents;
  99233. private _supportsUVs;
  99234. private _vertexCount;
  99235. private _uniqueId;
  99236. private _tempInfluences;
  99237. /**
  99238. * Gets or sets a boolean indicating if normals must be morphed
  99239. */
  99240. enableNormalMorphing: boolean;
  99241. /**
  99242. * Gets or sets a boolean indicating if tangents must be morphed
  99243. */
  99244. enableTangentMorphing: boolean;
  99245. /**
  99246. * Gets or sets a boolean indicating if UV must be morphed
  99247. */
  99248. enableUVMorphing: boolean;
  99249. /**
  99250. * Creates a new MorphTargetManager
  99251. * @param scene defines the current scene
  99252. */
  99253. constructor(scene?: Nullable<Scene>);
  99254. /**
  99255. * Gets the unique ID of this manager
  99256. */
  99257. get uniqueId(): number;
  99258. /**
  99259. * Gets the number of vertices handled by this manager
  99260. */
  99261. get vertexCount(): number;
  99262. /**
  99263. * Gets a boolean indicating if this manager supports morphing of normals
  99264. */
  99265. get supportsNormals(): boolean;
  99266. /**
  99267. * Gets a boolean indicating if this manager supports morphing of tangents
  99268. */
  99269. get supportsTangents(): boolean;
  99270. /**
  99271. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99272. */
  99273. get supportsUVs(): boolean;
  99274. /**
  99275. * Gets the number of targets stored in this manager
  99276. */
  99277. get numTargets(): number;
  99278. /**
  99279. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99280. */
  99281. get numInfluencers(): number;
  99282. /**
  99283. * Gets the list of influences (one per target)
  99284. */
  99285. get influences(): Float32Array;
  99286. /**
  99287. * Gets the active target at specified index. An active target is a target with an influence > 0
  99288. * @param index defines the index to check
  99289. * @returns the requested target
  99290. */
  99291. getActiveTarget(index: number): MorphTarget;
  99292. /**
  99293. * Gets the target at specified index
  99294. * @param index defines the index to check
  99295. * @returns the requested target
  99296. */
  99297. getTarget(index: number): MorphTarget;
  99298. /**
  99299. * Add a new target to this manager
  99300. * @param target defines the target to add
  99301. */
  99302. addTarget(target: MorphTarget): void;
  99303. /**
  99304. * Removes a target from the manager
  99305. * @param target defines the target to remove
  99306. */
  99307. removeTarget(target: MorphTarget): void;
  99308. /**
  99309. * Clone the current manager
  99310. * @returns a new MorphTargetManager
  99311. */
  99312. clone(): MorphTargetManager;
  99313. /**
  99314. * Serializes the current manager into a Serialization object
  99315. * @returns the serialized object
  99316. */
  99317. serialize(): any;
  99318. private _syncActiveTargets;
  99319. /**
  99320. * Syncrhonize the targets with all the meshes using this morph target manager
  99321. */
  99322. synchronize(): void;
  99323. /**
  99324. * Creates a new MorphTargetManager from serialized data
  99325. * @param serializationObject defines the serialized data
  99326. * @param scene defines the hosting scene
  99327. * @returns the new MorphTargetManager
  99328. */
  99329. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. /**
  99334. * Class used to represent a specific level of detail of a mesh
  99335. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99336. */
  99337. export class MeshLODLevel {
  99338. /** Defines the distance where this level should start being displayed */
  99339. distance: number;
  99340. /** Defines the mesh to use to render this level */
  99341. mesh: Nullable<Mesh>;
  99342. /**
  99343. * Creates a new LOD level
  99344. * @param distance defines the distance where this level should star being displayed
  99345. * @param mesh defines the mesh to use to render this level
  99346. */
  99347. constructor(
  99348. /** Defines the distance where this level should start being displayed */
  99349. distance: number,
  99350. /** Defines the mesh to use to render this level */
  99351. mesh: Nullable<Mesh>);
  99352. }
  99353. }
  99354. declare module BABYLON {
  99355. /**
  99356. * Mesh representing the gorund
  99357. */
  99358. export class GroundMesh extends Mesh {
  99359. /** If octree should be generated */
  99360. generateOctree: boolean;
  99361. private _heightQuads;
  99362. /** @hidden */
  99363. _subdivisionsX: number;
  99364. /** @hidden */
  99365. _subdivisionsY: number;
  99366. /** @hidden */
  99367. _width: number;
  99368. /** @hidden */
  99369. _height: number;
  99370. /** @hidden */
  99371. _minX: number;
  99372. /** @hidden */
  99373. _maxX: number;
  99374. /** @hidden */
  99375. _minZ: number;
  99376. /** @hidden */
  99377. _maxZ: number;
  99378. constructor(name: string, scene: Scene);
  99379. /**
  99380. * "GroundMesh"
  99381. * @returns "GroundMesh"
  99382. */
  99383. getClassName(): string;
  99384. /**
  99385. * The minimum of x and y subdivisions
  99386. */
  99387. get subdivisions(): number;
  99388. /**
  99389. * X subdivisions
  99390. */
  99391. get subdivisionsX(): number;
  99392. /**
  99393. * Y subdivisions
  99394. */
  99395. get subdivisionsY(): number;
  99396. /**
  99397. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99398. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99399. * @param chunksCount the number of subdivisions for x and y
  99400. * @param octreeBlocksSize (Default: 32)
  99401. */
  99402. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99403. /**
  99404. * Returns a height (y) value in the Worl system :
  99405. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99406. * @param x x coordinate
  99407. * @param z z coordinate
  99408. * @returns the ground y position if (x, z) are outside the ground surface.
  99409. */
  99410. getHeightAtCoordinates(x: number, z: number): number;
  99411. /**
  99412. * Returns a normalized vector (Vector3) orthogonal to the ground
  99413. * at the ground coordinates (x, z) expressed in the World system.
  99414. * @param x x coordinate
  99415. * @param z z coordinate
  99416. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99417. */
  99418. getNormalAtCoordinates(x: number, z: number): Vector3;
  99419. /**
  99420. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99421. * at the ground coordinates (x, z) expressed in the World system.
  99422. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99423. * @param x x coordinate
  99424. * @param z z coordinate
  99425. * @param ref vector to store the result
  99426. * @returns the GroundMesh.
  99427. */
  99428. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99429. /**
  99430. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99431. * if the ground has been updated.
  99432. * This can be used in the render loop.
  99433. * @returns the GroundMesh.
  99434. */
  99435. updateCoordinateHeights(): GroundMesh;
  99436. private _getFacetAt;
  99437. private _initHeightQuads;
  99438. private _computeHeightQuads;
  99439. /**
  99440. * Serializes this ground mesh
  99441. * @param serializationObject object to write serialization to
  99442. */
  99443. serialize(serializationObject: any): void;
  99444. /**
  99445. * Parses a serialized ground mesh
  99446. * @param parsedMesh the serialized mesh
  99447. * @param scene the scene to create the ground mesh in
  99448. * @returns the created ground mesh
  99449. */
  99450. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99451. }
  99452. }
  99453. declare module BABYLON {
  99454. /**
  99455. * Interface for Physics-Joint data
  99456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99457. */
  99458. export interface PhysicsJointData {
  99459. /**
  99460. * The main pivot of the joint
  99461. */
  99462. mainPivot?: Vector3;
  99463. /**
  99464. * The connected pivot of the joint
  99465. */
  99466. connectedPivot?: Vector3;
  99467. /**
  99468. * The main axis of the joint
  99469. */
  99470. mainAxis?: Vector3;
  99471. /**
  99472. * The connected axis of the joint
  99473. */
  99474. connectedAxis?: Vector3;
  99475. /**
  99476. * The collision of the joint
  99477. */
  99478. collision?: boolean;
  99479. /**
  99480. * Native Oimo/Cannon/Energy data
  99481. */
  99482. nativeParams?: any;
  99483. }
  99484. /**
  99485. * This is a holder class for the physics joint created by the physics plugin
  99486. * It holds a set of functions to control the underlying joint
  99487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99488. */
  99489. export class PhysicsJoint {
  99490. /**
  99491. * The type of the physics joint
  99492. */
  99493. type: number;
  99494. /**
  99495. * The data for the physics joint
  99496. */
  99497. jointData: PhysicsJointData;
  99498. private _physicsJoint;
  99499. protected _physicsPlugin: IPhysicsEnginePlugin;
  99500. /**
  99501. * Initializes the physics joint
  99502. * @param type The type of the physics joint
  99503. * @param jointData The data for the physics joint
  99504. */
  99505. constructor(
  99506. /**
  99507. * The type of the physics joint
  99508. */
  99509. type: number,
  99510. /**
  99511. * The data for the physics joint
  99512. */
  99513. jointData: PhysicsJointData);
  99514. /**
  99515. * Gets the physics joint
  99516. */
  99517. get physicsJoint(): any;
  99518. /**
  99519. * Sets the physics joint
  99520. */
  99521. set physicsJoint(newJoint: any);
  99522. /**
  99523. * Sets the physics plugin
  99524. */
  99525. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99526. /**
  99527. * Execute a function that is physics-plugin specific.
  99528. * @param {Function} func the function that will be executed.
  99529. * It accepts two parameters: the physics world and the physics joint
  99530. */
  99531. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99532. /**
  99533. * Distance-Joint type
  99534. */
  99535. static DistanceJoint: number;
  99536. /**
  99537. * Hinge-Joint type
  99538. */
  99539. static HingeJoint: number;
  99540. /**
  99541. * Ball-and-Socket joint type
  99542. */
  99543. static BallAndSocketJoint: number;
  99544. /**
  99545. * Wheel-Joint type
  99546. */
  99547. static WheelJoint: number;
  99548. /**
  99549. * Slider-Joint type
  99550. */
  99551. static SliderJoint: number;
  99552. /**
  99553. * Prismatic-Joint type
  99554. */
  99555. static PrismaticJoint: number;
  99556. /**
  99557. * Universal-Joint type
  99558. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99559. */
  99560. static UniversalJoint: number;
  99561. /**
  99562. * Hinge-Joint 2 type
  99563. */
  99564. static Hinge2Joint: number;
  99565. /**
  99566. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99567. */
  99568. static PointToPointJoint: number;
  99569. /**
  99570. * Spring-Joint type
  99571. */
  99572. static SpringJoint: number;
  99573. /**
  99574. * Lock-Joint type
  99575. */
  99576. static LockJoint: number;
  99577. }
  99578. /**
  99579. * A class representing a physics distance joint
  99580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99581. */
  99582. export class DistanceJoint extends PhysicsJoint {
  99583. /**
  99584. *
  99585. * @param jointData The data for the Distance-Joint
  99586. */
  99587. constructor(jointData: DistanceJointData);
  99588. /**
  99589. * Update the predefined distance.
  99590. * @param maxDistance The maximum preferred distance
  99591. * @param minDistance The minimum preferred distance
  99592. */
  99593. updateDistance(maxDistance: number, minDistance?: number): void;
  99594. }
  99595. /**
  99596. * Represents a Motor-Enabled Joint
  99597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99598. */
  99599. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99600. /**
  99601. * Initializes the Motor-Enabled Joint
  99602. * @param type The type of the joint
  99603. * @param jointData The physica joint data for the joint
  99604. */
  99605. constructor(type: number, jointData: PhysicsJointData);
  99606. /**
  99607. * Set the motor values.
  99608. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99609. * @param force the force to apply
  99610. * @param maxForce max force for this motor.
  99611. */
  99612. setMotor(force?: number, maxForce?: number): void;
  99613. /**
  99614. * Set the motor's limits.
  99615. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99616. * @param upperLimit The upper limit of the motor
  99617. * @param lowerLimit The lower limit of the motor
  99618. */
  99619. setLimit(upperLimit: number, lowerLimit?: number): void;
  99620. }
  99621. /**
  99622. * This class represents a single physics Hinge-Joint
  99623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99624. */
  99625. export class HingeJoint extends MotorEnabledJoint {
  99626. /**
  99627. * Initializes the Hinge-Joint
  99628. * @param jointData The joint data for the Hinge-Joint
  99629. */
  99630. constructor(jointData: PhysicsJointData);
  99631. /**
  99632. * Set the motor values.
  99633. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99634. * @param {number} force the force to apply
  99635. * @param {number} maxForce max force for this motor.
  99636. */
  99637. setMotor(force?: number, maxForce?: number): void;
  99638. /**
  99639. * Set the motor's limits.
  99640. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99641. * @param upperLimit The upper limit of the motor
  99642. * @param lowerLimit The lower limit of the motor
  99643. */
  99644. setLimit(upperLimit: number, lowerLimit?: number): void;
  99645. }
  99646. /**
  99647. * This class represents a dual hinge physics joint (same as wheel joint)
  99648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99649. */
  99650. export class Hinge2Joint extends MotorEnabledJoint {
  99651. /**
  99652. * Initializes the Hinge2-Joint
  99653. * @param jointData The joint data for the Hinge2-Joint
  99654. */
  99655. constructor(jointData: PhysicsJointData);
  99656. /**
  99657. * Set the motor values.
  99658. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99659. * @param {number} targetSpeed the speed the motor is to reach
  99660. * @param {number} maxForce max force for this motor.
  99661. * @param {motorIndex} the motor's index, 0 or 1.
  99662. */
  99663. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99664. /**
  99665. * Set the motor limits.
  99666. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99667. * @param {number} upperLimit the upper limit
  99668. * @param {number} lowerLimit lower limit
  99669. * @param {motorIndex} the motor's index, 0 or 1.
  99670. */
  99671. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99672. }
  99673. /**
  99674. * Interface for a motor enabled joint
  99675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99676. */
  99677. export interface IMotorEnabledJoint {
  99678. /**
  99679. * Physics joint
  99680. */
  99681. physicsJoint: any;
  99682. /**
  99683. * Sets the motor of the motor-enabled joint
  99684. * @param force The force of the motor
  99685. * @param maxForce The maximum force of the motor
  99686. * @param motorIndex The index of the motor
  99687. */
  99688. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99689. /**
  99690. * Sets the limit of the motor
  99691. * @param upperLimit The upper limit of the motor
  99692. * @param lowerLimit The lower limit of the motor
  99693. * @param motorIndex The index of the motor
  99694. */
  99695. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99696. }
  99697. /**
  99698. * Joint data for a Distance-Joint
  99699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99700. */
  99701. export interface DistanceJointData extends PhysicsJointData {
  99702. /**
  99703. * Max distance the 2 joint objects can be apart
  99704. */
  99705. maxDistance: number;
  99706. }
  99707. /**
  99708. * Joint data from a spring joint
  99709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99710. */
  99711. export interface SpringJointData extends PhysicsJointData {
  99712. /**
  99713. * Length of the spring
  99714. */
  99715. length: number;
  99716. /**
  99717. * Stiffness of the spring
  99718. */
  99719. stiffness: number;
  99720. /**
  99721. * Damping of the spring
  99722. */
  99723. damping: number;
  99724. /** this callback will be called when applying the force to the impostors. */
  99725. forceApplicationCallback: () => void;
  99726. }
  99727. }
  99728. declare module BABYLON {
  99729. /**
  99730. * Holds the data for the raycast result
  99731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99732. */
  99733. export class PhysicsRaycastResult {
  99734. private _hasHit;
  99735. private _hitDistance;
  99736. private _hitNormalWorld;
  99737. private _hitPointWorld;
  99738. private _rayFromWorld;
  99739. private _rayToWorld;
  99740. /**
  99741. * Gets if there was a hit
  99742. */
  99743. get hasHit(): boolean;
  99744. /**
  99745. * Gets the distance from the hit
  99746. */
  99747. get hitDistance(): number;
  99748. /**
  99749. * Gets the hit normal/direction in the world
  99750. */
  99751. get hitNormalWorld(): Vector3;
  99752. /**
  99753. * Gets the hit point in the world
  99754. */
  99755. get hitPointWorld(): Vector3;
  99756. /**
  99757. * Gets the ray "start point" of the ray in the world
  99758. */
  99759. get rayFromWorld(): Vector3;
  99760. /**
  99761. * Gets the ray "end point" of the ray in the world
  99762. */
  99763. get rayToWorld(): Vector3;
  99764. /**
  99765. * Sets the hit data (normal & point in world space)
  99766. * @param hitNormalWorld defines the normal in world space
  99767. * @param hitPointWorld defines the point in world space
  99768. */
  99769. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99770. /**
  99771. * Sets the distance from the start point to the hit point
  99772. * @param distance
  99773. */
  99774. setHitDistance(distance: number): void;
  99775. /**
  99776. * Calculates the distance manually
  99777. */
  99778. calculateHitDistance(): void;
  99779. /**
  99780. * Resets all the values to default
  99781. * @param from The from point on world space
  99782. * @param to The to point on world space
  99783. */
  99784. reset(from?: Vector3, to?: Vector3): void;
  99785. }
  99786. /**
  99787. * Interface for the size containing width and height
  99788. */
  99789. interface IXYZ {
  99790. /**
  99791. * X
  99792. */
  99793. x: number;
  99794. /**
  99795. * Y
  99796. */
  99797. y: number;
  99798. /**
  99799. * Z
  99800. */
  99801. z: number;
  99802. }
  99803. }
  99804. declare module BABYLON {
  99805. /**
  99806. * Interface used to describe a physics joint
  99807. */
  99808. export interface PhysicsImpostorJoint {
  99809. /** Defines the main impostor to which the joint is linked */
  99810. mainImpostor: PhysicsImpostor;
  99811. /** Defines the impostor that is connected to the main impostor using this joint */
  99812. connectedImpostor: PhysicsImpostor;
  99813. /** Defines the joint itself */
  99814. joint: PhysicsJoint;
  99815. }
  99816. /** @hidden */
  99817. export interface IPhysicsEnginePlugin {
  99818. world: any;
  99819. name: string;
  99820. setGravity(gravity: Vector3): void;
  99821. setTimeStep(timeStep: number): void;
  99822. getTimeStep(): number;
  99823. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99824. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99825. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99826. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99827. removePhysicsBody(impostor: PhysicsImpostor): void;
  99828. generateJoint(joint: PhysicsImpostorJoint): void;
  99829. removeJoint(joint: PhysicsImpostorJoint): void;
  99830. isSupported(): boolean;
  99831. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99832. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99833. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99834. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99836. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99838. getBodyMass(impostor: PhysicsImpostor): number;
  99839. getBodyFriction(impostor: PhysicsImpostor): number;
  99840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99841. getBodyRestitution(impostor: PhysicsImpostor): number;
  99842. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99843. getBodyPressure?(impostor: PhysicsImpostor): number;
  99844. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99845. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99846. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99847. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99848. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99849. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99850. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99851. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99852. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99853. sleepBody(impostor: PhysicsImpostor): void;
  99854. wakeUpBody(impostor: PhysicsImpostor): void;
  99855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99856. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99857. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99858. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99859. getRadius(impostor: PhysicsImpostor): number;
  99860. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99861. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99862. dispose(): void;
  99863. }
  99864. /**
  99865. * Interface used to define a physics engine
  99866. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99867. */
  99868. export interface IPhysicsEngine {
  99869. /**
  99870. * Gets the gravity vector used by the simulation
  99871. */
  99872. gravity: Vector3;
  99873. /**
  99874. * Sets the gravity vector used by the simulation
  99875. * @param gravity defines the gravity vector to use
  99876. */
  99877. setGravity(gravity: Vector3): void;
  99878. /**
  99879. * Set the time step of the physics engine.
  99880. * Default is 1/60.
  99881. * To slow it down, enter 1/600 for example.
  99882. * To speed it up, 1/30
  99883. * @param newTimeStep the new timestep to apply to this world.
  99884. */
  99885. setTimeStep(newTimeStep: number): void;
  99886. /**
  99887. * Get the time step of the physics engine.
  99888. * @returns the current time step
  99889. */
  99890. getTimeStep(): number;
  99891. /**
  99892. * Set the sub time step of the physics engine.
  99893. * Default is 0 meaning there is no sub steps
  99894. * To increase physics resolution precision, set a small value (like 1 ms)
  99895. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99896. */
  99897. setSubTimeStep(subTimeStep: number): void;
  99898. /**
  99899. * Get the sub time step of the physics engine.
  99900. * @returns the current sub time step
  99901. */
  99902. getSubTimeStep(): number;
  99903. /**
  99904. * Release all resources
  99905. */
  99906. dispose(): void;
  99907. /**
  99908. * Gets the name of the current physics plugin
  99909. * @returns the name of the plugin
  99910. */
  99911. getPhysicsPluginName(): string;
  99912. /**
  99913. * Adding a new impostor for the impostor tracking.
  99914. * This will be done by the impostor itself.
  99915. * @param impostor the impostor to add
  99916. */
  99917. addImpostor(impostor: PhysicsImpostor): void;
  99918. /**
  99919. * Remove an impostor from the engine.
  99920. * This impostor and its mesh will not longer be updated by the physics engine.
  99921. * @param impostor the impostor to remove
  99922. */
  99923. removeImpostor(impostor: PhysicsImpostor): void;
  99924. /**
  99925. * Add a joint to the physics engine
  99926. * @param mainImpostor defines the main impostor to which the joint is added.
  99927. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99928. * @param joint defines the joint that will connect both impostors.
  99929. */
  99930. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99931. /**
  99932. * Removes a joint from the simulation
  99933. * @param mainImpostor defines the impostor used with the joint
  99934. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99935. * @param joint defines the joint to remove
  99936. */
  99937. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99938. /**
  99939. * Gets the current plugin used to run the simulation
  99940. * @returns current plugin
  99941. */
  99942. getPhysicsPlugin(): IPhysicsEnginePlugin;
  99943. /**
  99944. * Gets the list of physic impostors
  99945. * @returns an array of PhysicsImpostor
  99946. */
  99947. getImpostors(): Array<PhysicsImpostor>;
  99948. /**
  99949. * Gets the impostor for a physics enabled object
  99950. * @param object defines the object impersonated by the impostor
  99951. * @returns the PhysicsImpostor or null if not found
  99952. */
  99953. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99954. /**
  99955. * Gets the impostor for a physics body object
  99956. * @param body defines physics body used by the impostor
  99957. * @returns the PhysicsImpostor or null if not found
  99958. */
  99959. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  99960. /**
  99961. * Does a raycast in the physics world
  99962. * @param from when should the ray start?
  99963. * @param to when should the ray end?
  99964. * @returns PhysicsRaycastResult
  99965. */
  99966. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99967. /**
  99968. * Called by the scene. No need to call it.
  99969. * @param delta defines the timespam between frames
  99970. */
  99971. _step(delta: number): void;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * The interface for the physics imposter parameters
  99977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99978. */
  99979. export interface PhysicsImpostorParameters {
  99980. /**
  99981. * The mass of the physics imposter
  99982. */
  99983. mass: number;
  99984. /**
  99985. * The friction of the physics imposter
  99986. */
  99987. friction?: number;
  99988. /**
  99989. * The coefficient of restitution of the physics imposter
  99990. */
  99991. restitution?: number;
  99992. /**
  99993. * The native options of the physics imposter
  99994. */
  99995. nativeOptions?: any;
  99996. /**
  99997. * Specifies if the parent should be ignored
  99998. */
  99999. ignoreParent?: boolean;
  100000. /**
  100001. * Specifies if bi-directional transformations should be disabled
  100002. */
  100003. disableBidirectionalTransformation?: boolean;
  100004. /**
  100005. * The pressure inside the physics imposter, soft object only
  100006. */
  100007. pressure?: number;
  100008. /**
  100009. * The stiffness the physics imposter, soft object only
  100010. */
  100011. stiffness?: number;
  100012. /**
  100013. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  100014. */
  100015. velocityIterations?: number;
  100016. /**
  100017. * The number of iterations used in maintaining consistent vertex positions, soft object only
  100018. */
  100019. positionIterations?: number;
  100020. /**
  100021. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  100022. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  100023. * Add to fix multiple points
  100024. */
  100025. fixedPoints?: number;
  100026. /**
  100027. * The collision margin around a soft object
  100028. */
  100029. margin?: number;
  100030. /**
  100031. * The collision margin around a soft object
  100032. */
  100033. damping?: number;
  100034. /**
  100035. * The path for a rope based on an extrusion
  100036. */
  100037. path?: any;
  100038. /**
  100039. * The shape of an extrusion used for a rope based on an extrusion
  100040. */
  100041. shape?: any;
  100042. }
  100043. /**
  100044. * Interface for a physics-enabled object
  100045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100046. */
  100047. export interface IPhysicsEnabledObject {
  100048. /**
  100049. * The position of the physics-enabled object
  100050. */
  100051. position: Vector3;
  100052. /**
  100053. * The rotation of the physics-enabled object
  100054. */
  100055. rotationQuaternion: Nullable<Quaternion>;
  100056. /**
  100057. * The scale of the physics-enabled object
  100058. */
  100059. scaling: Vector3;
  100060. /**
  100061. * The rotation of the physics-enabled object
  100062. */
  100063. rotation?: Vector3;
  100064. /**
  100065. * The parent of the physics-enabled object
  100066. */
  100067. parent?: any;
  100068. /**
  100069. * The bounding info of the physics-enabled object
  100070. * @returns The bounding info of the physics-enabled object
  100071. */
  100072. getBoundingInfo(): BoundingInfo;
  100073. /**
  100074. * Computes the world matrix
  100075. * @param force Specifies if the world matrix should be computed by force
  100076. * @returns A world matrix
  100077. */
  100078. computeWorldMatrix(force: boolean): Matrix;
  100079. /**
  100080. * Gets the world matrix
  100081. * @returns A world matrix
  100082. */
  100083. getWorldMatrix?(): Matrix;
  100084. /**
  100085. * Gets the child meshes
  100086. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  100087. * @returns An array of abstract meshes
  100088. */
  100089. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  100090. /**
  100091. * Gets the vertex data
  100092. * @param kind The type of vertex data
  100093. * @returns A nullable array of numbers, or a float32 array
  100094. */
  100095. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  100096. /**
  100097. * Gets the indices from the mesh
  100098. * @returns A nullable array of index arrays
  100099. */
  100100. getIndices?(): Nullable<IndicesArray>;
  100101. /**
  100102. * Gets the scene from the mesh
  100103. * @returns the indices array or null
  100104. */
  100105. getScene?(): Scene;
  100106. /**
  100107. * Gets the absolute position from the mesh
  100108. * @returns the absolute position
  100109. */
  100110. getAbsolutePosition(): Vector3;
  100111. /**
  100112. * Gets the absolute pivot point from the mesh
  100113. * @returns the absolute pivot point
  100114. */
  100115. getAbsolutePivotPoint(): Vector3;
  100116. /**
  100117. * Rotates the mesh
  100118. * @param axis The axis of rotation
  100119. * @param amount The amount of rotation
  100120. * @param space The space of the rotation
  100121. * @returns The rotation transform node
  100122. */
  100123. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  100124. /**
  100125. * Translates the mesh
  100126. * @param axis The axis of translation
  100127. * @param distance The distance of translation
  100128. * @param space The space of the translation
  100129. * @returns The transform node
  100130. */
  100131. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  100132. /**
  100133. * Sets the absolute position of the mesh
  100134. * @param absolutePosition The absolute position of the mesh
  100135. * @returns The transform node
  100136. */
  100137. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  100138. /**
  100139. * Gets the class name of the mesh
  100140. * @returns The class name
  100141. */
  100142. getClassName(): string;
  100143. }
  100144. /**
  100145. * Represents a physics imposter
  100146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  100147. */
  100148. export class PhysicsImpostor {
  100149. /**
  100150. * The physics-enabled object used as the physics imposter
  100151. */
  100152. object: IPhysicsEnabledObject;
  100153. /**
  100154. * The type of the physics imposter
  100155. */
  100156. type: number;
  100157. private _options;
  100158. private _scene?;
  100159. /**
  100160. * The default object size of the imposter
  100161. */
  100162. static DEFAULT_OBJECT_SIZE: Vector3;
  100163. /**
  100164. * The identity quaternion of the imposter
  100165. */
  100166. static IDENTITY_QUATERNION: Quaternion;
  100167. /** @hidden */
  100168. _pluginData: any;
  100169. private _physicsEngine;
  100170. private _physicsBody;
  100171. private _bodyUpdateRequired;
  100172. private _onBeforePhysicsStepCallbacks;
  100173. private _onAfterPhysicsStepCallbacks;
  100174. /** @hidden */
  100175. _onPhysicsCollideCallbacks: Array<{
  100176. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  100177. otherImpostors: Array<PhysicsImpostor>;
  100178. }>;
  100179. private _deltaPosition;
  100180. private _deltaRotation;
  100181. private _deltaRotationConjugated;
  100182. /** @hidden */
  100183. _isFromLine: boolean;
  100184. private _parent;
  100185. private _isDisposed;
  100186. private static _tmpVecs;
  100187. private static _tmpQuat;
  100188. /**
  100189. * Specifies if the physics imposter is disposed
  100190. */
  100191. get isDisposed(): boolean;
  100192. /**
  100193. * Gets the mass of the physics imposter
  100194. */
  100195. get mass(): number;
  100196. set mass(value: number);
  100197. /**
  100198. * Gets the coefficient of friction
  100199. */
  100200. get friction(): number;
  100201. /**
  100202. * Sets the coefficient of friction
  100203. */
  100204. set friction(value: number);
  100205. /**
  100206. * Gets the coefficient of restitution
  100207. */
  100208. get restitution(): number;
  100209. /**
  100210. * Sets the coefficient of restitution
  100211. */
  100212. set restitution(value: number);
  100213. /**
  100214. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100215. */
  100216. get pressure(): number;
  100217. /**
  100218. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100219. */
  100220. set pressure(value: number);
  100221. /**
  100222. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100223. */
  100224. get stiffness(): number;
  100225. /**
  100226. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100227. */
  100228. set stiffness(value: number);
  100229. /**
  100230. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100231. */
  100232. get velocityIterations(): number;
  100233. /**
  100234. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100235. */
  100236. set velocityIterations(value: number);
  100237. /**
  100238. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100239. */
  100240. get positionIterations(): number;
  100241. /**
  100242. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100243. */
  100244. set positionIterations(value: number);
  100245. /**
  100246. * The unique id of the physics imposter
  100247. * set by the physics engine when adding this impostor to the array
  100248. */
  100249. uniqueId: number;
  100250. /**
  100251. * @hidden
  100252. */
  100253. soft: boolean;
  100254. /**
  100255. * @hidden
  100256. */
  100257. segments: number;
  100258. private _joints;
  100259. /**
  100260. * Initializes the physics imposter
  100261. * @param object The physics-enabled object used as the physics imposter
  100262. * @param type The type of the physics imposter
  100263. * @param _options The options for the physics imposter
  100264. * @param _scene The Babylon scene
  100265. */
  100266. constructor(
  100267. /**
  100268. * The physics-enabled object used as the physics imposter
  100269. */
  100270. object: IPhysicsEnabledObject,
  100271. /**
  100272. * The type of the physics imposter
  100273. */
  100274. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100275. /**
  100276. * This function will completly initialize this impostor.
  100277. * It will create a new body - but only if this mesh has no parent.
  100278. * If it has, this impostor will not be used other than to define the impostor
  100279. * of the child mesh.
  100280. * @hidden
  100281. */
  100282. _init(): void;
  100283. private _getPhysicsParent;
  100284. /**
  100285. * Should a new body be generated.
  100286. * @returns boolean specifying if body initialization is required
  100287. */
  100288. isBodyInitRequired(): boolean;
  100289. /**
  100290. * Sets the updated scaling
  100291. * @param updated Specifies if the scaling is updated
  100292. */
  100293. setScalingUpdated(): void;
  100294. /**
  100295. * Force a regeneration of this or the parent's impostor's body.
  100296. * Use under cautious - This will remove all joints already implemented.
  100297. */
  100298. forceUpdate(): void;
  100299. /**
  100300. * Gets the body that holds this impostor. Either its own, or its parent.
  100301. */
  100302. get physicsBody(): any;
  100303. /**
  100304. * Get the parent of the physics imposter
  100305. * @returns Physics imposter or null
  100306. */
  100307. get parent(): Nullable<PhysicsImpostor>;
  100308. /**
  100309. * Sets the parent of the physics imposter
  100310. */
  100311. set parent(value: Nullable<PhysicsImpostor>);
  100312. /**
  100313. * Set the physics body. Used mainly by the physics engine/plugin
  100314. */
  100315. set physicsBody(physicsBody: any);
  100316. /**
  100317. * Resets the update flags
  100318. */
  100319. resetUpdateFlags(): void;
  100320. /**
  100321. * Gets the object extend size
  100322. * @returns the object extend size
  100323. */
  100324. getObjectExtendSize(): Vector3;
  100325. /**
  100326. * Gets the object center
  100327. * @returns The object center
  100328. */
  100329. getObjectCenter(): Vector3;
  100330. /**
  100331. * Get a specific parameter from the options parameters
  100332. * @param paramName The object parameter name
  100333. * @returns The object parameter
  100334. */
  100335. getParam(paramName: string): any;
  100336. /**
  100337. * Sets a specific parameter in the options given to the physics plugin
  100338. * @param paramName The parameter name
  100339. * @param value The value of the parameter
  100340. */
  100341. setParam(paramName: string, value: number): void;
  100342. /**
  100343. * Specifically change the body's mass option. Won't recreate the physics body object
  100344. * @param mass The mass of the physics imposter
  100345. */
  100346. setMass(mass: number): void;
  100347. /**
  100348. * Gets the linear velocity
  100349. * @returns linear velocity or null
  100350. */
  100351. getLinearVelocity(): Nullable<Vector3>;
  100352. /**
  100353. * Sets the linear velocity
  100354. * @param velocity linear velocity or null
  100355. */
  100356. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100357. /**
  100358. * Gets the angular velocity
  100359. * @returns angular velocity or null
  100360. */
  100361. getAngularVelocity(): Nullable<Vector3>;
  100362. /**
  100363. * Sets the angular velocity
  100364. * @param velocity The velocity or null
  100365. */
  100366. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100367. /**
  100368. * Execute a function with the physics plugin native code
  100369. * Provide a function the will have two variables - the world object and the physics body object
  100370. * @param func The function to execute with the physics plugin native code
  100371. */
  100372. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100373. /**
  100374. * Register a function that will be executed before the physics world is stepping forward
  100375. * @param func The function to execute before the physics world is stepped forward
  100376. */
  100377. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100378. /**
  100379. * Unregister a function that will be executed before the physics world is stepping forward
  100380. * @param func The function to execute before the physics world is stepped forward
  100381. */
  100382. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100383. /**
  100384. * Register a function that will be executed after the physics step
  100385. * @param func The function to execute after physics step
  100386. */
  100387. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100388. /**
  100389. * Unregisters a function that will be executed after the physics step
  100390. * @param func The function to execute after physics step
  100391. */
  100392. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100393. /**
  100394. * register a function that will be executed when this impostor collides against a different body
  100395. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100396. * @param func Callback that is executed on collision
  100397. */
  100398. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100399. /**
  100400. * Unregisters the physics imposter on contact
  100401. * @param collideAgainst The physics object to collide against
  100402. * @param func Callback to execute on collision
  100403. */
  100404. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100405. private _tmpQuat;
  100406. private _tmpQuat2;
  100407. /**
  100408. * Get the parent rotation
  100409. * @returns The parent rotation
  100410. */
  100411. getParentsRotation(): Quaternion;
  100412. /**
  100413. * this function is executed by the physics engine.
  100414. */
  100415. beforeStep: () => void;
  100416. /**
  100417. * this function is executed by the physics engine
  100418. */
  100419. afterStep: () => void;
  100420. /**
  100421. * Legacy collision detection event support
  100422. */
  100423. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100424. /**
  100425. * event and body object due to cannon's event-based architecture.
  100426. */
  100427. onCollide: (e: {
  100428. body: any;
  100429. }) => void;
  100430. /**
  100431. * Apply a force
  100432. * @param force The force to apply
  100433. * @param contactPoint The contact point for the force
  100434. * @returns The physics imposter
  100435. */
  100436. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100437. /**
  100438. * Apply an impulse
  100439. * @param force The impulse force
  100440. * @param contactPoint The contact point for the impulse force
  100441. * @returns The physics imposter
  100442. */
  100443. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100444. /**
  100445. * A help function to create a joint
  100446. * @param otherImpostor A physics imposter used to create a joint
  100447. * @param jointType The type of joint
  100448. * @param jointData The data for the joint
  100449. * @returns The physics imposter
  100450. */
  100451. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100452. /**
  100453. * Add a joint to this impostor with a different impostor
  100454. * @param otherImpostor A physics imposter used to add a joint
  100455. * @param joint The joint to add
  100456. * @returns The physics imposter
  100457. */
  100458. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100459. /**
  100460. * Add an anchor to a cloth impostor
  100461. * @param otherImpostor rigid impostor to anchor to
  100462. * @param width ratio across width from 0 to 1
  100463. * @param height ratio up height from 0 to 1
  100464. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100465. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100466. * @returns impostor the soft imposter
  100467. */
  100468. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100469. /**
  100470. * Add a hook to a rope impostor
  100471. * @param otherImpostor rigid impostor to anchor to
  100472. * @param length ratio across rope from 0 to 1
  100473. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100474. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100475. * @returns impostor the rope imposter
  100476. */
  100477. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100478. /**
  100479. * Will keep this body still, in a sleep mode.
  100480. * @returns the physics imposter
  100481. */
  100482. sleep(): PhysicsImpostor;
  100483. /**
  100484. * Wake the body up.
  100485. * @returns The physics imposter
  100486. */
  100487. wakeUp(): PhysicsImpostor;
  100488. /**
  100489. * Clones the physics imposter
  100490. * @param newObject The physics imposter clones to this physics-enabled object
  100491. * @returns A nullable physics imposter
  100492. */
  100493. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100494. /**
  100495. * Disposes the physics imposter
  100496. */
  100497. dispose(): void;
  100498. /**
  100499. * Sets the delta position
  100500. * @param position The delta position amount
  100501. */
  100502. setDeltaPosition(position: Vector3): void;
  100503. /**
  100504. * Sets the delta rotation
  100505. * @param rotation The delta rotation amount
  100506. */
  100507. setDeltaRotation(rotation: Quaternion): void;
  100508. /**
  100509. * Gets the box size of the physics imposter and stores the result in the input parameter
  100510. * @param result Stores the box size
  100511. * @returns The physics imposter
  100512. */
  100513. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100514. /**
  100515. * Gets the radius of the physics imposter
  100516. * @returns Radius of the physics imposter
  100517. */
  100518. getRadius(): number;
  100519. /**
  100520. * Sync a bone with this impostor
  100521. * @param bone The bone to sync to the impostor.
  100522. * @param boneMesh The mesh that the bone is influencing.
  100523. * @param jointPivot The pivot of the joint / bone in local space.
  100524. * @param distToJoint Optional distance from the impostor to the joint.
  100525. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100526. */
  100527. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100528. /**
  100529. * Sync impostor to a bone
  100530. * @param bone The bone that the impostor will be synced to.
  100531. * @param boneMesh The mesh that the bone is influencing.
  100532. * @param jointPivot The pivot of the joint / bone in local space.
  100533. * @param distToJoint Optional distance from the impostor to the joint.
  100534. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100535. * @param boneAxis Optional vector3 axis the bone is aligned with
  100536. */
  100537. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100538. /**
  100539. * No-Imposter type
  100540. */
  100541. static NoImpostor: number;
  100542. /**
  100543. * Sphere-Imposter type
  100544. */
  100545. static SphereImpostor: number;
  100546. /**
  100547. * Box-Imposter type
  100548. */
  100549. static BoxImpostor: number;
  100550. /**
  100551. * Plane-Imposter type
  100552. */
  100553. static PlaneImpostor: number;
  100554. /**
  100555. * Mesh-imposter type
  100556. */
  100557. static MeshImpostor: number;
  100558. /**
  100559. * Capsule-Impostor type (Ammo.js plugin only)
  100560. */
  100561. static CapsuleImpostor: number;
  100562. /**
  100563. * Cylinder-Imposter type
  100564. */
  100565. static CylinderImpostor: number;
  100566. /**
  100567. * Particle-Imposter type
  100568. */
  100569. static ParticleImpostor: number;
  100570. /**
  100571. * Heightmap-Imposter type
  100572. */
  100573. static HeightmapImpostor: number;
  100574. /**
  100575. * ConvexHull-Impostor type (Ammo.js plugin only)
  100576. */
  100577. static ConvexHullImpostor: number;
  100578. /**
  100579. * Custom-Imposter type (Ammo.js plugin only)
  100580. */
  100581. static CustomImpostor: number;
  100582. /**
  100583. * Rope-Imposter type
  100584. */
  100585. static RopeImpostor: number;
  100586. /**
  100587. * Cloth-Imposter type
  100588. */
  100589. static ClothImpostor: number;
  100590. /**
  100591. * Softbody-Imposter type
  100592. */
  100593. static SoftbodyImpostor: number;
  100594. }
  100595. }
  100596. declare module BABYLON {
  100597. /**
  100598. * @hidden
  100599. **/
  100600. export class _CreationDataStorage {
  100601. closePath?: boolean;
  100602. closeArray?: boolean;
  100603. idx: number[];
  100604. dashSize: number;
  100605. gapSize: number;
  100606. path3D: Path3D;
  100607. pathArray: Vector3[][];
  100608. arc: number;
  100609. radius: number;
  100610. cap: number;
  100611. tessellation: number;
  100612. }
  100613. /**
  100614. * @hidden
  100615. **/
  100616. class _InstanceDataStorage {
  100617. visibleInstances: any;
  100618. batchCache: _InstancesBatch;
  100619. instancesBufferSize: number;
  100620. instancesBuffer: Nullable<Buffer>;
  100621. instancesData: Float32Array;
  100622. overridenInstanceCount: number;
  100623. isFrozen: boolean;
  100624. previousBatch: Nullable<_InstancesBatch>;
  100625. hardwareInstancedRendering: boolean;
  100626. sideOrientation: number;
  100627. manualUpdate: boolean;
  100628. }
  100629. /**
  100630. * @hidden
  100631. **/
  100632. export class _InstancesBatch {
  100633. mustReturn: boolean;
  100634. visibleInstances: Nullable<InstancedMesh[]>[];
  100635. renderSelf: boolean[];
  100636. hardwareInstancedRendering: boolean[];
  100637. }
  100638. /**
  100639. * Class used to represent renderable models
  100640. */
  100641. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100642. /**
  100643. * Mesh side orientation : usually the external or front surface
  100644. */
  100645. static readonly FRONTSIDE: number;
  100646. /**
  100647. * Mesh side orientation : usually the internal or back surface
  100648. */
  100649. static readonly BACKSIDE: number;
  100650. /**
  100651. * Mesh side orientation : both internal and external or front and back surfaces
  100652. */
  100653. static readonly DOUBLESIDE: number;
  100654. /**
  100655. * Mesh side orientation : by default, `FRONTSIDE`
  100656. */
  100657. static readonly DEFAULTSIDE: number;
  100658. /**
  100659. * Mesh cap setting : no cap
  100660. */
  100661. static readonly NO_CAP: number;
  100662. /**
  100663. * Mesh cap setting : one cap at the beginning of the mesh
  100664. */
  100665. static readonly CAP_START: number;
  100666. /**
  100667. * Mesh cap setting : one cap at the end of the mesh
  100668. */
  100669. static readonly CAP_END: number;
  100670. /**
  100671. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100672. */
  100673. static readonly CAP_ALL: number;
  100674. /**
  100675. * Mesh pattern setting : no flip or rotate
  100676. */
  100677. static readonly NO_FLIP: number;
  100678. /**
  100679. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100680. */
  100681. static readonly FLIP_TILE: number;
  100682. /**
  100683. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100684. */
  100685. static readonly ROTATE_TILE: number;
  100686. /**
  100687. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100688. */
  100689. static readonly FLIP_ROW: number;
  100690. /**
  100691. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100692. */
  100693. static readonly ROTATE_ROW: number;
  100694. /**
  100695. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100696. */
  100697. static readonly FLIP_N_ROTATE_TILE: number;
  100698. /**
  100699. * Mesh pattern setting : rotate pattern and rotate
  100700. */
  100701. static readonly FLIP_N_ROTATE_ROW: number;
  100702. /**
  100703. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100704. */
  100705. static readonly CENTER: number;
  100706. /**
  100707. * Mesh tile positioning : part tiles on left
  100708. */
  100709. static readonly LEFT: number;
  100710. /**
  100711. * Mesh tile positioning : part tiles on right
  100712. */
  100713. static readonly RIGHT: number;
  100714. /**
  100715. * Mesh tile positioning : part tiles on top
  100716. */
  100717. static readonly TOP: number;
  100718. /**
  100719. * Mesh tile positioning : part tiles on bottom
  100720. */
  100721. static readonly BOTTOM: number;
  100722. /**
  100723. * Gets the default side orientation.
  100724. * @param orientation the orientation to value to attempt to get
  100725. * @returns the default orientation
  100726. * @hidden
  100727. */
  100728. static _GetDefaultSideOrientation(orientation?: number): number;
  100729. private _internalMeshDataInfo;
  100730. /**
  100731. * An event triggered before rendering the mesh
  100732. */
  100733. get onBeforeRenderObservable(): Observable<Mesh>;
  100734. /**
  100735. * An event triggered before binding the mesh
  100736. */
  100737. get onBeforeBindObservable(): Observable<Mesh>;
  100738. /**
  100739. * An event triggered after rendering the mesh
  100740. */
  100741. get onAfterRenderObservable(): Observable<Mesh>;
  100742. /**
  100743. * An event triggered before drawing the mesh
  100744. */
  100745. get onBeforeDrawObservable(): Observable<Mesh>;
  100746. private _onBeforeDrawObserver;
  100747. /**
  100748. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100749. */
  100750. set onBeforeDraw(callback: () => void);
  100751. get hasInstances(): boolean;
  100752. /**
  100753. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100754. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100755. */
  100756. delayLoadState: number;
  100757. /**
  100758. * Gets the list of instances created from this mesh
  100759. * it is not supposed to be modified manually.
  100760. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100761. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100762. */
  100763. instances: InstancedMesh[];
  100764. /**
  100765. * Gets the file containing delay loading data for this mesh
  100766. */
  100767. delayLoadingFile: string;
  100768. /** @hidden */
  100769. _binaryInfo: any;
  100770. /**
  100771. * User defined function used to change how LOD level selection is done
  100772. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100773. */
  100774. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100775. /**
  100776. * Gets or sets the morph target manager
  100777. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100778. */
  100779. get morphTargetManager(): Nullable<MorphTargetManager>;
  100780. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100781. /** @hidden */
  100782. _creationDataStorage: Nullable<_CreationDataStorage>;
  100783. /** @hidden */
  100784. _geometry: Nullable<Geometry>;
  100785. /** @hidden */
  100786. _delayInfo: Array<string>;
  100787. /** @hidden */
  100788. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100789. /** @hidden */
  100790. _instanceDataStorage: _InstanceDataStorage;
  100791. private _effectiveMaterial;
  100792. /** @hidden */
  100793. _shouldGenerateFlatShading: boolean;
  100794. /** @hidden */
  100795. _originalBuilderSideOrientation: number;
  100796. /**
  100797. * Use this property to change the original side orientation defined at construction time
  100798. */
  100799. overrideMaterialSideOrientation: Nullable<number>;
  100800. /**
  100801. * Gets the source mesh (the one used to clone this one from)
  100802. */
  100803. get source(): Nullable<Mesh>;
  100804. /**
  100805. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100806. */
  100807. get isUnIndexed(): boolean;
  100808. set isUnIndexed(value: boolean);
  100809. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100810. get worldMatrixInstancedBuffer(): Float32Array;
  100811. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100812. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100813. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100814. /**
  100815. * @constructor
  100816. * @param name The value used by scene.getMeshByName() to do a lookup.
  100817. * @param scene The scene to add this mesh to.
  100818. * @param parent The parent of this mesh, if it has one
  100819. * @param source An optional Mesh from which geometry is shared, cloned.
  100820. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100821. * When false, achieved by calling a clone(), also passing False.
  100822. * This will make creation of children, recursive.
  100823. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100824. */
  100825. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100826. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100827. doNotInstantiate: boolean;
  100828. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100829. /**
  100830. * Gets the class name
  100831. * @returns the string "Mesh".
  100832. */
  100833. getClassName(): string;
  100834. /** @hidden */
  100835. get _isMesh(): boolean;
  100836. /**
  100837. * Returns a description of this mesh
  100838. * @param fullDetails define if full details about this mesh must be used
  100839. * @returns a descriptive string representing this mesh
  100840. */
  100841. toString(fullDetails?: boolean): string;
  100842. /** @hidden */
  100843. _unBindEffect(): void;
  100844. /**
  100845. * Gets a boolean indicating if this mesh has LOD
  100846. */
  100847. get hasLODLevels(): boolean;
  100848. /**
  100849. * Gets the list of MeshLODLevel associated with the current mesh
  100850. * @returns an array of MeshLODLevel
  100851. */
  100852. getLODLevels(): MeshLODLevel[];
  100853. private _sortLODLevels;
  100854. /**
  100855. * Add a mesh as LOD level triggered at the given distance.
  100856. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100857. * @param distance The distance from the center of the object to show this level
  100858. * @param mesh The mesh to be added as LOD level (can be null)
  100859. * @return This mesh (for chaining)
  100860. */
  100861. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100862. /**
  100863. * Returns the LOD level mesh at the passed distance or null if not found.
  100864. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100865. * @param distance The distance from the center of the object to show this level
  100866. * @returns a Mesh or `null`
  100867. */
  100868. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100869. /**
  100870. * Remove a mesh from the LOD array
  100871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100872. * @param mesh defines the mesh to be removed
  100873. * @return This mesh (for chaining)
  100874. */
  100875. removeLODLevel(mesh: Mesh): Mesh;
  100876. /**
  100877. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100878. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100879. * @param camera defines the camera to use to compute distance
  100880. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100881. * @return This mesh (for chaining)
  100882. */
  100883. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100884. /**
  100885. * Gets the mesh internal Geometry object
  100886. */
  100887. get geometry(): Nullable<Geometry>;
  100888. /**
  100889. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100890. * @returns the total number of vertices
  100891. */
  100892. getTotalVertices(): number;
  100893. /**
  100894. * Returns the content of an associated vertex buffer
  100895. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100896. * - VertexBuffer.PositionKind
  100897. * - VertexBuffer.UVKind
  100898. * - VertexBuffer.UV2Kind
  100899. * - VertexBuffer.UV3Kind
  100900. * - VertexBuffer.UV4Kind
  100901. * - VertexBuffer.UV5Kind
  100902. * - VertexBuffer.UV6Kind
  100903. * - VertexBuffer.ColorKind
  100904. * - VertexBuffer.MatricesIndicesKind
  100905. * - VertexBuffer.MatricesIndicesExtraKind
  100906. * - VertexBuffer.MatricesWeightsKind
  100907. * - VertexBuffer.MatricesWeightsExtraKind
  100908. * @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
  100909. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100910. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100911. */
  100912. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100913. /**
  100914. * Returns the mesh VertexBuffer object from the requested `kind`
  100915. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100916. * - VertexBuffer.PositionKind
  100917. * - VertexBuffer.NormalKind
  100918. * - VertexBuffer.UVKind
  100919. * - VertexBuffer.UV2Kind
  100920. * - VertexBuffer.UV3Kind
  100921. * - VertexBuffer.UV4Kind
  100922. * - VertexBuffer.UV5Kind
  100923. * - VertexBuffer.UV6Kind
  100924. * - VertexBuffer.ColorKind
  100925. * - VertexBuffer.MatricesIndicesKind
  100926. * - VertexBuffer.MatricesIndicesExtraKind
  100927. * - VertexBuffer.MatricesWeightsKind
  100928. * - VertexBuffer.MatricesWeightsExtraKind
  100929. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100930. */
  100931. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100932. /**
  100933. * Tests if a specific vertex buffer is associated with this mesh
  100934. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100935. * - VertexBuffer.PositionKind
  100936. * - VertexBuffer.NormalKind
  100937. * - VertexBuffer.UVKind
  100938. * - VertexBuffer.UV2Kind
  100939. * - VertexBuffer.UV3Kind
  100940. * - VertexBuffer.UV4Kind
  100941. * - VertexBuffer.UV5Kind
  100942. * - VertexBuffer.UV6Kind
  100943. * - VertexBuffer.ColorKind
  100944. * - VertexBuffer.MatricesIndicesKind
  100945. * - VertexBuffer.MatricesIndicesExtraKind
  100946. * - VertexBuffer.MatricesWeightsKind
  100947. * - VertexBuffer.MatricesWeightsExtraKind
  100948. * @returns a boolean
  100949. */
  100950. isVerticesDataPresent(kind: string): boolean;
  100951. /**
  100952. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  100953. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100954. * - VertexBuffer.PositionKind
  100955. * - VertexBuffer.UVKind
  100956. * - VertexBuffer.UV2Kind
  100957. * - VertexBuffer.UV3Kind
  100958. * - VertexBuffer.UV4Kind
  100959. * - VertexBuffer.UV5Kind
  100960. * - VertexBuffer.UV6Kind
  100961. * - VertexBuffer.ColorKind
  100962. * - VertexBuffer.MatricesIndicesKind
  100963. * - VertexBuffer.MatricesIndicesExtraKind
  100964. * - VertexBuffer.MatricesWeightsKind
  100965. * - VertexBuffer.MatricesWeightsExtraKind
  100966. * @returns a boolean
  100967. */
  100968. isVertexBufferUpdatable(kind: string): boolean;
  100969. /**
  100970. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  100971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100972. * - VertexBuffer.PositionKind
  100973. * - VertexBuffer.NormalKind
  100974. * - VertexBuffer.UVKind
  100975. * - VertexBuffer.UV2Kind
  100976. * - VertexBuffer.UV3Kind
  100977. * - VertexBuffer.UV4Kind
  100978. * - VertexBuffer.UV5Kind
  100979. * - VertexBuffer.UV6Kind
  100980. * - VertexBuffer.ColorKind
  100981. * - VertexBuffer.MatricesIndicesKind
  100982. * - VertexBuffer.MatricesIndicesExtraKind
  100983. * - VertexBuffer.MatricesWeightsKind
  100984. * - VertexBuffer.MatricesWeightsExtraKind
  100985. * @returns an array of strings
  100986. */
  100987. getVerticesDataKinds(): string[];
  100988. /**
  100989. * Returns a positive integer : the total number of indices in this mesh geometry.
  100990. * @returns the numner of indices or zero if the mesh has no geometry.
  100991. */
  100992. getTotalIndices(): number;
  100993. /**
  100994. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  100995. * @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.
  100996. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  100997. * @returns the indices array or an empty array if the mesh has no geometry
  100998. */
  100999. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101000. get isBlocked(): boolean;
  101001. /**
  101002. * Determine if the current mesh is ready to be rendered
  101003. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101004. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  101005. * @returns true if all associated assets are ready (material, textures, shaders)
  101006. */
  101007. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  101008. /**
  101009. * 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.
  101010. */
  101011. get areNormalsFrozen(): boolean;
  101012. /**
  101013. * 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.
  101014. * @returns the current mesh
  101015. */
  101016. freezeNormals(): Mesh;
  101017. /**
  101018. * 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
  101019. * @returns the current mesh
  101020. */
  101021. unfreezeNormals(): Mesh;
  101022. /**
  101023. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  101024. */
  101025. set overridenInstanceCount(count: number);
  101026. /** @hidden */
  101027. _preActivate(): Mesh;
  101028. /** @hidden */
  101029. _preActivateForIntermediateRendering(renderId: number): Mesh;
  101030. /** @hidden */
  101031. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  101032. /**
  101033. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101034. * This means the mesh underlying bounding box and sphere are recomputed.
  101035. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101036. * @returns the current mesh
  101037. */
  101038. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  101039. /** @hidden */
  101040. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  101041. /**
  101042. * This function will subdivide the mesh into multiple submeshes
  101043. * @param count defines the expected number of submeshes
  101044. */
  101045. subdivide(count: number): void;
  101046. /**
  101047. * Copy a FloatArray into a specific associated vertex buffer
  101048. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101049. * - VertexBuffer.PositionKind
  101050. * - VertexBuffer.UVKind
  101051. * - VertexBuffer.UV2Kind
  101052. * - VertexBuffer.UV3Kind
  101053. * - VertexBuffer.UV4Kind
  101054. * - VertexBuffer.UV5Kind
  101055. * - VertexBuffer.UV6Kind
  101056. * - VertexBuffer.ColorKind
  101057. * - VertexBuffer.MatricesIndicesKind
  101058. * - VertexBuffer.MatricesIndicesExtraKind
  101059. * - VertexBuffer.MatricesWeightsKind
  101060. * - VertexBuffer.MatricesWeightsExtraKind
  101061. * @param data defines the data source
  101062. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101063. * @param stride defines the data stride size (can be null)
  101064. * @returns the current mesh
  101065. */
  101066. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101067. /**
  101068. * Delete a vertex buffer associated with this mesh
  101069. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  101070. * - VertexBuffer.PositionKind
  101071. * - VertexBuffer.UVKind
  101072. * - VertexBuffer.UV2Kind
  101073. * - VertexBuffer.UV3Kind
  101074. * - VertexBuffer.UV4Kind
  101075. * - VertexBuffer.UV5Kind
  101076. * - VertexBuffer.UV6Kind
  101077. * - VertexBuffer.ColorKind
  101078. * - VertexBuffer.MatricesIndicesKind
  101079. * - VertexBuffer.MatricesIndicesExtraKind
  101080. * - VertexBuffer.MatricesWeightsKind
  101081. * - VertexBuffer.MatricesWeightsExtraKind
  101082. */
  101083. removeVerticesData(kind: string): void;
  101084. /**
  101085. * Flags an associated vertex buffer as updatable
  101086. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  101087. * - VertexBuffer.PositionKind
  101088. * - VertexBuffer.UVKind
  101089. * - VertexBuffer.UV2Kind
  101090. * - VertexBuffer.UV3Kind
  101091. * - VertexBuffer.UV4Kind
  101092. * - VertexBuffer.UV5Kind
  101093. * - VertexBuffer.UV6Kind
  101094. * - VertexBuffer.ColorKind
  101095. * - VertexBuffer.MatricesIndicesKind
  101096. * - VertexBuffer.MatricesIndicesExtraKind
  101097. * - VertexBuffer.MatricesWeightsKind
  101098. * - VertexBuffer.MatricesWeightsExtraKind
  101099. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  101100. */
  101101. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  101102. /**
  101103. * Sets the mesh global Vertex Buffer
  101104. * @param buffer defines the buffer to use
  101105. * @returns the current mesh
  101106. */
  101107. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  101108. /**
  101109. * Update a specific associated vertex buffer
  101110. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101111. * - VertexBuffer.PositionKind
  101112. * - VertexBuffer.UVKind
  101113. * - VertexBuffer.UV2Kind
  101114. * - VertexBuffer.UV3Kind
  101115. * - VertexBuffer.UV4Kind
  101116. * - VertexBuffer.UV5Kind
  101117. * - VertexBuffer.UV6Kind
  101118. * - VertexBuffer.ColorKind
  101119. * - VertexBuffer.MatricesIndicesKind
  101120. * - VertexBuffer.MatricesIndicesExtraKind
  101121. * - VertexBuffer.MatricesWeightsKind
  101122. * - VertexBuffer.MatricesWeightsExtraKind
  101123. * @param data defines the data source
  101124. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101125. * @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)
  101126. * @returns the current mesh
  101127. */
  101128. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101129. /**
  101130. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  101131. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  101132. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  101133. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  101134. * @returns the current mesh
  101135. */
  101136. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  101137. /**
  101138. * Creates a un-shared specific occurence of the geometry for the mesh.
  101139. * @returns the current mesh
  101140. */
  101141. makeGeometryUnique(): Mesh;
  101142. /**
  101143. * Set the index buffer of this mesh
  101144. * @param indices defines the source data
  101145. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  101146. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  101147. * @returns the current mesh
  101148. */
  101149. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  101150. /**
  101151. * Update the current index buffer
  101152. * @param indices defines the source data
  101153. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101154. * @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)
  101155. * @returns the current mesh
  101156. */
  101157. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101158. /**
  101159. * Invert the geometry to move from a right handed system to a left handed one.
  101160. * @returns the current mesh
  101161. */
  101162. toLeftHanded(): Mesh;
  101163. /** @hidden */
  101164. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  101165. /** @hidden */
  101166. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  101167. /**
  101168. * Registers for this mesh a javascript function called just before the rendering process
  101169. * @param func defines the function to call before rendering this mesh
  101170. * @returns the current mesh
  101171. */
  101172. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101173. /**
  101174. * Disposes a previously registered javascript function called before the rendering
  101175. * @param func defines the function to remove
  101176. * @returns the current mesh
  101177. */
  101178. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  101179. /**
  101180. * Registers for this mesh a javascript function called just after the rendering is complete
  101181. * @param func defines the function to call after rendering this mesh
  101182. * @returns the current mesh
  101183. */
  101184. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101185. /**
  101186. * Disposes a previously registered javascript function called after the rendering.
  101187. * @param func defines the function to remove
  101188. * @returns the current mesh
  101189. */
  101190. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  101191. /** @hidden */
  101192. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  101193. /** @hidden */
  101194. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  101195. /** @hidden */
  101196. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  101197. /** @hidden */
  101198. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  101199. /** @hidden */
  101200. _rebuild(): void;
  101201. /** @hidden */
  101202. _freeze(): void;
  101203. /** @hidden */
  101204. _unFreeze(): void;
  101205. /**
  101206. * 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
  101207. * @param subMesh defines the subMesh to render
  101208. * @param enableAlphaMode defines if alpha mode can be changed
  101209. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  101210. * @returns the current mesh
  101211. */
  101212. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101213. private _onBeforeDraw;
  101214. /**
  101215. * Renormalize the mesh and patch it up if there are no weights
  101216. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101217. * However in the case of zero weights then we set just a single influence to 1.
  101218. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101219. */
  101220. cleanMatrixWeights(): void;
  101221. private normalizeSkinFourWeights;
  101222. private normalizeSkinWeightsAndExtra;
  101223. /**
  101224. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101225. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101226. * the user know there was an issue with importing the mesh
  101227. * @returns a validation object with skinned, valid and report string
  101228. */
  101229. validateSkinning(): {
  101230. skinned: boolean;
  101231. valid: boolean;
  101232. report: string;
  101233. };
  101234. /** @hidden */
  101235. _checkDelayState(): Mesh;
  101236. private _queueLoad;
  101237. /**
  101238. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101239. * A mesh is in the frustum if its bounding box intersects the frustum
  101240. * @param frustumPlanes defines the frustum to test
  101241. * @returns true if the mesh is in the frustum planes
  101242. */
  101243. isInFrustum(frustumPlanes: Plane[]): boolean;
  101244. /**
  101245. * Sets the mesh material by the material or multiMaterial `id` property
  101246. * @param id is a string identifying the material or the multiMaterial
  101247. * @returns the current mesh
  101248. */
  101249. setMaterialByID(id: string): Mesh;
  101250. /**
  101251. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101252. * @returns an array of IAnimatable
  101253. */
  101254. getAnimatables(): IAnimatable[];
  101255. /**
  101256. * Modifies the mesh geometry according to the passed transformation matrix.
  101257. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101258. * The mesh normals are modified using the same transformation.
  101259. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101260. * @param transform defines the transform matrix to use
  101261. * @see http://doc.babylonjs.com/resources/baking_transformations
  101262. * @returns the current mesh
  101263. */
  101264. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101265. /**
  101266. * Modifies the mesh geometry according to its own current World Matrix.
  101267. * The mesh World Matrix is then reset.
  101268. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101269. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101270. * @see http://doc.babylonjs.com/resources/baking_transformations
  101271. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101272. * @returns the current mesh
  101273. */
  101274. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101275. /** @hidden */
  101276. get _positions(): Nullable<Vector3[]>;
  101277. /** @hidden */
  101278. _resetPointsArrayCache(): Mesh;
  101279. /** @hidden */
  101280. _generatePointsArray(): boolean;
  101281. /**
  101282. * Returns a new Mesh object generated from the current mesh properties.
  101283. * This method must not get confused with createInstance()
  101284. * @param name is a string, the name given to the new mesh
  101285. * @param newParent can be any Node object (default `null`)
  101286. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101287. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101288. * @returns a new mesh
  101289. */
  101290. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101291. /**
  101292. * Releases resources associated with this mesh.
  101293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101295. */
  101296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101297. /** @hidden */
  101298. _disposeInstanceSpecificData(): void;
  101299. /**
  101300. * Modifies the mesh geometry according to a displacement map.
  101301. * 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.
  101302. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101303. * @param url is a string, the URL from the image file is to be downloaded.
  101304. * @param minHeight is the lower limit of the displacement.
  101305. * @param maxHeight is the upper limit of the displacement.
  101306. * @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.
  101307. * @param uvOffset is an optional vector2 used to offset UV.
  101308. * @param uvScale is an optional vector2 used to scale UV.
  101309. * @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.
  101310. * @returns the Mesh.
  101311. */
  101312. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101313. /**
  101314. * Modifies the mesh geometry according to a displacementMap buffer.
  101315. * 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.
  101316. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101317. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101318. * @param heightMapWidth is the width of the buffer image.
  101319. * @param heightMapHeight is the height of the buffer image.
  101320. * @param minHeight is the lower limit of the displacement.
  101321. * @param maxHeight is the upper limit of the displacement.
  101322. * @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.
  101323. * @param uvOffset is an optional vector2 used to offset UV.
  101324. * @param uvScale is an optional vector2 used to scale UV.
  101325. * @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.
  101326. * @returns the Mesh.
  101327. */
  101328. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101329. /**
  101330. * Modify the mesh to get a flat shading rendering.
  101331. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101332. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101333. * @returns current mesh
  101334. */
  101335. convertToFlatShadedMesh(): Mesh;
  101336. /**
  101337. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101338. * In other words, more vertices, no more indices and a single bigger VBO.
  101339. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101340. * @returns current mesh
  101341. */
  101342. convertToUnIndexedMesh(): Mesh;
  101343. /**
  101344. * Inverses facet orientations.
  101345. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101346. * @param flipNormals will also inverts the normals
  101347. * @returns current mesh
  101348. */
  101349. flipFaces(flipNormals?: boolean): Mesh;
  101350. /**
  101351. * Increase the number of facets and hence vertices in a mesh
  101352. * Vertex normals are interpolated from existing vertex normals
  101353. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101354. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101355. */
  101356. increaseVertices(numberPerEdge: number): void;
  101357. /**
  101358. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101359. * This will undo any application of covertToFlatShadedMesh
  101360. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101361. */
  101362. forceSharedVertices(): void;
  101363. /** @hidden */
  101364. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101365. /** @hidden */
  101366. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101367. /**
  101368. * Creates a new InstancedMesh object from the mesh model.
  101369. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101370. * @param name defines the name of the new instance
  101371. * @returns a new InstancedMesh
  101372. */
  101373. createInstance(name: string): InstancedMesh;
  101374. /**
  101375. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101376. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101377. * @returns the current mesh
  101378. */
  101379. synchronizeInstances(): Mesh;
  101380. /**
  101381. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101382. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101383. * This should be used together with the simplification to avoid disappearing triangles.
  101384. * @param successCallback an optional success callback to be called after the optimization finished.
  101385. * @returns the current mesh
  101386. */
  101387. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101388. /**
  101389. * Serialize current mesh
  101390. * @param serializationObject defines the object which will receive the serialization data
  101391. */
  101392. serialize(serializationObject: any): void;
  101393. /** @hidden */
  101394. _syncGeometryWithMorphTargetManager(): void;
  101395. /** @hidden */
  101396. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101397. /**
  101398. * Returns a new Mesh object parsed from the source provided.
  101399. * @param parsedMesh is the source
  101400. * @param scene defines the hosting scene
  101401. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101402. * @returns a new Mesh
  101403. */
  101404. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101405. /**
  101406. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101407. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101408. * @param name defines the name of the mesh to create
  101409. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101410. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101411. * @param closePath creates a seam between the first and the last points of each path of the path array
  101412. * @param offset is taken in account only if the `pathArray` is containing a single path
  101413. * @param scene defines the hosting scene
  101414. * @param updatable defines if the mesh must be flagged as updatable
  101415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101416. * @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)
  101417. * @returns a new Mesh
  101418. */
  101419. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101420. /**
  101421. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101422. * @param name defines the name of the mesh to create
  101423. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101424. * @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
  101425. * @param scene defines the hosting scene
  101426. * @param updatable defines if the mesh must be flagged as updatable
  101427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101428. * @returns a new Mesh
  101429. */
  101430. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101431. /**
  101432. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101433. * @param name defines the name of the mesh to create
  101434. * @param size sets the size (float) of each box side (default 1)
  101435. * @param scene defines the hosting scene
  101436. * @param updatable defines if the mesh must be flagged as updatable
  101437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101438. * @returns a new Mesh
  101439. */
  101440. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101441. /**
  101442. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101443. * @param name defines the name of the mesh to create
  101444. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101445. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101446. * @param scene defines the hosting scene
  101447. * @param updatable defines if the mesh must be flagged as updatable
  101448. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101449. * @returns a new Mesh
  101450. */
  101451. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101452. /**
  101453. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101454. * @param name defines the name of the mesh to create
  101455. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101456. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101457. * @param scene defines the hosting scene
  101458. * @returns a new Mesh
  101459. */
  101460. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101461. /**
  101462. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101463. * @param name defines the name of the mesh to create
  101464. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101465. * @param diameterTop set the top cap diameter (floats, default 1)
  101466. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101467. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101468. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101469. * @param scene defines the hosting scene
  101470. * @param updatable defines if the mesh must be flagged as updatable
  101471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101472. * @returns a new Mesh
  101473. */
  101474. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101475. /**
  101476. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101477. * @param name defines the name of the mesh to create
  101478. * @param diameter sets the diameter size (float) of the torus (default 1)
  101479. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101480. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101481. * @param scene defines the hosting scene
  101482. * @param updatable defines if the mesh must be flagged as updatable
  101483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101484. * @returns a new Mesh
  101485. */
  101486. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101487. /**
  101488. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101489. * @param name defines the name of the mesh to create
  101490. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101491. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101492. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101493. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101494. * @param p the number of windings on X axis (positive integers, default 2)
  101495. * @param q the number of windings on Y axis (positive integers, default 3)
  101496. * @param scene defines the hosting scene
  101497. * @param updatable defines if the mesh must be flagged as updatable
  101498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101499. * @returns a new Mesh
  101500. */
  101501. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101502. /**
  101503. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101504. * @param name defines the name of the mesh to create
  101505. * @param points is an array successive Vector3
  101506. * @param scene defines the hosting scene
  101507. * @param updatable defines if the mesh must be flagged as updatable
  101508. * @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).
  101509. * @returns a new Mesh
  101510. */
  101511. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101512. /**
  101513. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101514. * @param name defines the name of the mesh to create
  101515. * @param points is an array successive Vector3
  101516. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101517. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101518. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101519. * @param scene defines the hosting scene
  101520. * @param updatable defines if the mesh must be flagged as updatable
  101521. * @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)
  101522. * @returns a new Mesh
  101523. */
  101524. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101525. /**
  101526. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101527. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101528. * 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.
  101529. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101530. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101531. * Remember you can only change the shape positions, not their number when updating a polygon.
  101532. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101533. * @param name defines the name of the mesh to create
  101534. * @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
  101535. * @param scene defines the hosting scene
  101536. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101537. * @param updatable defines if the mesh must be flagged as updatable
  101538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101539. * @param earcutInjection can be used to inject your own earcut reference
  101540. * @returns a new Mesh
  101541. */
  101542. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101543. /**
  101544. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101545. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101546. * @param name defines the name of the mesh to create
  101547. * @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
  101548. * @param depth defines the height of extrusion
  101549. * @param scene defines the hosting scene
  101550. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101551. * @param updatable defines if the mesh must be flagged as updatable
  101552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101553. * @param earcutInjection can be used to inject your own earcut reference
  101554. * @returns a new Mesh
  101555. */
  101556. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101557. /**
  101558. * Creates an extruded shape mesh.
  101559. * 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
  101560. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101561. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101562. * @param name defines the name of the mesh to create
  101563. * @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
  101564. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101565. * @param scale is the value to scale the shape
  101566. * @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
  101567. * @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
  101568. * @param scene defines the hosting scene
  101569. * @param updatable defines if the mesh must be flagged as updatable
  101570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101571. * @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)
  101572. * @returns a new Mesh
  101573. */
  101574. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101575. /**
  101576. * Creates an custom extruded shape mesh.
  101577. * The custom extrusion is a parametric shape.
  101578. * It has no predefined shape. Its final shape will depend on the input parameters.
  101579. * Please consider using the same method from the MeshBuilder class instead
  101580. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101581. * @param name defines the name of the mesh to create
  101582. * @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
  101583. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101584. * @param scaleFunction is a custom Javascript function called on each path point
  101585. * @param rotationFunction is a custom Javascript function called on each path point
  101586. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101587. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101588. * @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
  101589. * @param scene defines the hosting scene
  101590. * @param updatable defines if the mesh must be flagged as updatable
  101591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101592. * @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)
  101593. * @returns a new Mesh
  101594. */
  101595. 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;
  101596. /**
  101597. * Creates lathe mesh.
  101598. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101599. * Please consider using the same method from the MeshBuilder class instead
  101600. * @param name defines the name of the mesh to create
  101601. * @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
  101602. * @param radius is the radius value of the lathe
  101603. * @param tessellation is the side number of the lathe.
  101604. * @param scene defines the hosting scene
  101605. * @param updatable defines if the mesh must be flagged as updatable
  101606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101607. * @returns a new Mesh
  101608. */
  101609. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101610. /**
  101611. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101612. * @param name defines the name of the mesh to create
  101613. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101614. * @param scene defines the hosting scene
  101615. * @param updatable defines if the mesh must be flagged as updatable
  101616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101617. * @returns a new Mesh
  101618. */
  101619. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101620. /**
  101621. * Creates a ground mesh.
  101622. * Please consider using the same method from the MeshBuilder class instead
  101623. * @param name defines the name of the mesh to create
  101624. * @param width set the width of the ground
  101625. * @param height set the height of the ground
  101626. * @param subdivisions sets the number of subdivisions per side
  101627. * @param scene defines the hosting scene
  101628. * @param updatable defines if the mesh must be flagged as updatable
  101629. * @returns a new Mesh
  101630. */
  101631. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101632. /**
  101633. * Creates a tiled ground mesh.
  101634. * Please consider using the same method from the MeshBuilder class instead
  101635. * @param name defines the name of the mesh to create
  101636. * @param xmin set the ground minimum X coordinate
  101637. * @param zmin set the ground minimum Y coordinate
  101638. * @param xmax set the ground maximum X coordinate
  101639. * @param zmax set the ground maximum Z coordinate
  101640. * @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
  101641. * @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
  101642. * @param scene defines the hosting scene
  101643. * @param updatable defines if the mesh must be flagged as updatable
  101644. * @returns a new Mesh
  101645. */
  101646. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101647. w: number;
  101648. h: number;
  101649. }, precision: {
  101650. w: number;
  101651. h: number;
  101652. }, scene: Scene, updatable?: boolean): Mesh;
  101653. /**
  101654. * Creates a ground mesh from a height map.
  101655. * Please consider using the same method from the MeshBuilder class instead
  101656. * @see http://doc.babylonjs.com/babylon101/height_map
  101657. * @param name defines the name of the mesh to create
  101658. * @param url sets the URL of the height map image resource
  101659. * @param width set the ground width size
  101660. * @param height set the ground height size
  101661. * @param subdivisions sets the number of subdivision per side
  101662. * @param minHeight is the minimum altitude on the ground
  101663. * @param maxHeight is the maximum altitude on the ground
  101664. * @param scene defines the hosting scene
  101665. * @param updatable defines if the mesh must be flagged as updatable
  101666. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101667. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101668. * @returns a new Mesh
  101669. */
  101670. 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;
  101671. /**
  101672. * Creates a tube mesh.
  101673. * The tube is a parametric shape.
  101674. * It has no predefined shape. Its final shape will depend on the input parameters.
  101675. * Please consider using the same method from the MeshBuilder class instead
  101676. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101677. * @param name defines the name of the mesh to create
  101678. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101679. * @param radius sets the tube radius size
  101680. * @param tessellation is the number of sides on the tubular surface
  101681. * @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
  101682. * @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
  101683. * @param scene defines the hosting scene
  101684. * @param updatable defines if the mesh must be flagged as updatable
  101685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101686. * @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)
  101687. * @returns a new Mesh
  101688. */
  101689. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101690. (i: number, distance: number): number;
  101691. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101692. /**
  101693. * Creates a polyhedron mesh.
  101694. * Please consider using the same method from the MeshBuilder class instead.
  101695. * * 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
  101696. * * The parameter `size` (positive float, default 1) sets the polygon size
  101697. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101698. * * 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`
  101699. * * 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
  101700. * * 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)`)
  101701. * * 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
  101702. * * 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
  101703. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101704. * * If you create a double-sided mesh, you can choose what parts of 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
  101705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101706. * @param name defines the name of the mesh to create
  101707. * @param options defines the options used to create the mesh
  101708. * @param scene defines the hosting scene
  101709. * @returns a new Mesh
  101710. */
  101711. static CreatePolyhedron(name: string, options: {
  101712. type?: number;
  101713. size?: number;
  101714. sizeX?: number;
  101715. sizeY?: number;
  101716. sizeZ?: number;
  101717. custom?: any;
  101718. faceUV?: Vector4[];
  101719. faceColors?: Color4[];
  101720. updatable?: boolean;
  101721. sideOrientation?: number;
  101722. }, scene: Scene): Mesh;
  101723. /**
  101724. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101725. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101726. * * 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`)
  101727. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101728. * * 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
  101729. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101730. * * If you create a double-sided mesh, you can choose what parts of 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
  101731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101732. * @param name defines the name of the mesh
  101733. * @param options defines the options used to create the mesh
  101734. * @param scene defines the hosting scene
  101735. * @returns a new Mesh
  101736. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101737. */
  101738. static CreateIcoSphere(name: string, options: {
  101739. radius?: number;
  101740. flat?: boolean;
  101741. subdivisions?: number;
  101742. sideOrientation?: number;
  101743. updatable?: boolean;
  101744. }, scene: Scene): Mesh;
  101745. /**
  101746. * Creates a decal mesh.
  101747. * Please consider using the same method from the MeshBuilder class instead.
  101748. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101749. * @param name defines the name of the mesh
  101750. * @param sourceMesh defines the mesh receiving the decal
  101751. * @param position sets the position of the decal in world coordinates
  101752. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101753. * @param size sets the decal scaling
  101754. * @param angle sets the angle to rotate the decal
  101755. * @returns a new Mesh
  101756. */
  101757. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101758. /**
  101759. * Prepare internal position array for software CPU skinning
  101760. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101761. */
  101762. setPositionsForCPUSkinning(): Float32Array;
  101763. /**
  101764. * Prepare internal normal array for software CPU skinning
  101765. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101766. */
  101767. setNormalsForCPUSkinning(): Float32Array;
  101768. /**
  101769. * Updates the vertex buffer by applying transformation from the bones
  101770. * @param skeleton defines the skeleton to apply to current mesh
  101771. * @returns the current mesh
  101772. */
  101773. applySkeleton(skeleton: Skeleton): Mesh;
  101774. /**
  101775. * 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
  101776. * @param meshes defines the list of meshes to scan
  101777. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101778. */
  101779. static MinMax(meshes: AbstractMesh[]): {
  101780. min: Vector3;
  101781. max: Vector3;
  101782. };
  101783. /**
  101784. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101785. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101786. * @returns a vector3
  101787. */
  101788. static Center(meshesOrMinMaxVector: {
  101789. min: Vector3;
  101790. max: Vector3;
  101791. } | AbstractMesh[]): Vector3;
  101792. /**
  101793. * Merge the array of meshes into a single mesh for performance reasons.
  101794. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101795. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101796. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101797. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101798. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101799. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101800. * @returns a new mesh
  101801. */
  101802. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101803. /** @hidden */
  101804. addInstance(instance: InstancedMesh): void;
  101805. /** @hidden */
  101806. removeInstance(instance: InstancedMesh): void;
  101807. }
  101808. }
  101809. declare module BABYLON {
  101810. /**
  101811. * This is the base class of all the camera used in the application.
  101812. * @see http://doc.babylonjs.com/features/cameras
  101813. */
  101814. export class Camera extends Node {
  101815. /** @hidden */
  101816. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101817. /**
  101818. * This is the default projection mode used by the cameras.
  101819. * It helps recreating a feeling of perspective and better appreciate depth.
  101820. * This is the best way to simulate real life cameras.
  101821. */
  101822. static readonly PERSPECTIVE_CAMERA: number;
  101823. /**
  101824. * This helps creating camera with an orthographic mode.
  101825. * 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.
  101826. */
  101827. static readonly ORTHOGRAPHIC_CAMERA: number;
  101828. /**
  101829. * This is the default FOV mode for perspective cameras.
  101830. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101831. */
  101832. static readonly FOVMODE_VERTICAL_FIXED: number;
  101833. /**
  101834. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101835. */
  101836. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101837. /**
  101838. * This specifies ther is no need for a camera rig.
  101839. * Basically only one eye is rendered corresponding to the camera.
  101840. */
  101841. static readonly RIG_MODE_NONE: number;
  101842. /**
  101843. * Simulates a camera Rig with one blue eye and one red eye.
  101844. * This can be use with 3d blue and red glasses.
  101845. */
  101846. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101847. /**
  101848. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101849. */
  101850. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101851. /**
  101852. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101853. */
  101854. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101855. /**
  101856. * Defines that both eyes of the camera will be rendered over under each other.
  101857. */
  101858. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101859. /**
  101860. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101861. */
  101862. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101863. /**
  101864. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101865. */
  101866. static readonly RIG_MODE_VR: number;
  101867. /**
  101868. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101869. */
  101870. static readonly RIG_MODE_WEBVR: number;
  101871. /**
  101872. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101873. */
  101874. static readonly RIG_MODE_CUSTOM: number;
  101875. /**
  101876. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101877. */
  101878. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101879. /**
  101880. * Define the input manager associated with the camera.
  101881. */
  101882. inputs: CameraInputsManager<Camera>;
  101883. /** @hidden */
  101884. _position: Vector3;
  101885. /**
  101886. * Define the current local position of the camera in the scene
  101887. */
  101888. get position(): Vector3;
  101889. set position(newPosition: Vector3);
  101890. /**
  101891. * The vector the camera should consider as up.
  101892. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101893. */
  101894. upVector: Vector3;
  101895. /**
  101896. * Define the current limit on the left side for an orthographic camera
  101897. * In scene unit
  101898. */
  101899. orthoLeft: Nullable<number>;
  101900. /**
  101901. * Define the current limit on the right side for an orthographic camera
  101902. * In scene unit
  101903. */
  101904. orthoRight: Nullable<number>;
  101905. /**
  101906. * Define the current limit on the bottom side for an orthographic camera
  101907. * In scene unit
  101908. */
  101909. orthoBottom: Nullable<number>;
  101910. /**
  101911. * Define the current limit on the top side for an orthographic camera
  101912. * In scene unit
  101913. */
  101914. orthoTop: Nullable<number>;
  101915. /**
  101916. * Field Of View is set in Radians. (default is 0.8)
  101917. */
  101918. fov: number;
  101919. /**
  101920. * Define the minimum distance the camera can see from.
  101921. * This is important to note that the depth buffer are not infinite and the closer it starts
  101922. * the more your scene might encounter depth fighting issue.
  101923. */
  101924. minZ: number;
  101925. /**
  101926. * Define the maximum distance the camera can see to.
  101927. * This is important to note that the depth buffer are not infinite and the further it end
  101928. * the more your scene might encounter depth fighting issue.
  101929. */
  101930. maxZ: number;
  101931. /**
  101932. * Define the default inertia of the camera.
  101933. * This helps giving a smooth feeling to the camera movement.
  101934. */
  101935. inertia: number;
  101936. /**
  101937. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  101938. */
  101939. mode: number;
  101940. /**
  101941. * Define whether the camera is intermediate.
  101942. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  101943. */
  101944. isIntermediate: boolean;
  101945. /**
  101946. * Define the viewport of the camera.
  101947. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  101948. */
  101949. viewport: Viewport;
  101950. /**
  101951. * Restricts the camera to viewing objects with the same layerMask.
  101952. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  101953. */
  101954. layerMask: number;
  101955. /**
  101956. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  101957. */
  101958. fovMode: number;
  101959. /**
  101960. * Rig mode of the camera.
  101961. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  101962. * This is normally controlled byt the camera themselves as internal use.
  101963. */
  101964. cameraRigMode: number;
  101965. /**
  101966. * Defines the distance between both "eyes" in case of a RIG
  101967. */
  101968. interaxialDistance: number;
  101969. /**
  101970. * Defines if stereoscopic rendering is done side by side or over under.
  101971. */
  101972. isStereoscopicSideBySide: boolean;
  101973. /**
  101974. * 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
  101975. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  101976. * else in the scene. (Eg. security camera)
  101977. *
  101978. * 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)
  101979. */
  101980. customRenderTargets: RenderTargetTexture[];
  101981. /**
  101982. * When set, the camera will render to this render target instead of the default canvas
  101983. *
  101984. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  101985. */
  101986. outputRenderTarget: Nullable<RenderTargetTexture>;
  101987. /**
  101988. * Observable triggered when the camera view matrix has changed.
  101989. */
  101990. onViewMatrixChangedObservable: Observable<Camera>;
  101991. /**
  101992. * Observable triggered when the camera Projection matrix has changed.
  101993. */
  101994. onProjectionMatrixChangedObservable: Observable<Camera>;
  101995. /**
  101996. * Observable triggered when the inputs have been processed.
  101997. */
  101998. onAfterCheckInputsObservable: Observable<Camera>;
  101999. /**
  102000. * Observable triggered when reset has been called and applied to the camera.
  102001. */
  102002. onRestoreStateObservable: Observable<Camera>;
  102003. /**
  102004. * Is this camera a part of a rig system?
  102005. */
  102006. isRigCamera: boolean;
  102007. /**
  102008. * If isRigCamera set to true this will be set with the parent camera.
  102009. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  102010. */
  102011. rigParent?: Camera;
  102012. /** @hidden */
  102013. _cameraRigParams: any;
  102014. /** @hidden */
  102015. _rigCameras: Camera[];
  102016. /** @hidden */
  102017. _rigPostProcess: Nullable<PostProcess>;
  102018. protected _webvrViewMatrix: Matrix;
  102019. /** @hidden */
  102020. _skipRendering: boolean;
  102021. /** @hidden */
  102022. _projectionMatrix: Matrix;
  102023. /** @hidden */
  102024. _postProcesses: Nullable<PostProcess>[];
  102025. /** @hidden */
  102026. _activeMeshes: SmartArray<AbstractMesh>;
  102027. protected _globalPosition: Vector3;
  102028. /** @hidden */
  102029. _computedViewMatrix: Matrix;
  102030. private _doNotComputeProjectionMatrix;
  102031. private _transformMatrix;
  102032. private _frustumPlanes;
  102033. private _refreshFrustumPlanes;
  102034. private _storedFov;
  102035. private _stateStored;
  102036. /**
  102037. * Instantiates a new camera object.
  102038. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  102039. * @see http://doc.babylonjs.com/features/cameras
  102040. * @param name Defines the name of the camera in the scene
  102041. * @param position Defines the position of the camera
  102042. * @param scene Defines the scene the camera belongs too
  102043. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  102044. */
  102045. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102046. /**
  102047. * Store current camera state (fov, position, etc..)
  102048. * @returns the camera
  102049. */
  102050. storeState(): Camera;
  102051. /**
  102052. * Restores the camera state values if it has been stored. You must call storeState() first
  102053. */
  102054. protected _restoreStateValues(): boolean;
  102055. /**
  102056. * Restored camera state. You must call storeState() first.
  102057. * @returns true if restored and false otherwise
  102058. */
  102059. restoreState(): boolean;
  102060. /**
  102061. * Gets the class name of the camera.
  102062. * @returns the class name
  102063. */
  102064. getClassName(): string;
  102065. /** @hidden */
  102066. readonly _isCamera: boolean;
  102067. /**
  102068. * Gets a string representation of the camera useful for debug purpose.
  102069. * @param fullDetails Defines that a more verboe level of logging is required
  102070. * @returns the string representation
  102071. */
  102072. toString(fullDetails?: boolean): string;
  102073. /**
  102074. * Gets the current world space position of the camera.
  102075. */
  102076. get globalPosition(): Vector3;
  102077. /**
  102078. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  102079. * @returns the active meshe list
  102080. */
  102081. getActiveMeshes(): SmartArray<AbstractMesh>;
  102082. /**
  102083. * Check whether a mesh is part of the current active mesh list of the camera
  102084. * @param mesh Defines the mesh to check
  102085. * @returns true if active, false otherwise
  102086. */
  102087. isActiveMesh(mesh: Mesh): boolean;
  102088. /**
  102089. * Is this camera ready to be used/rendered
  102090. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  102091. * @return true if the camera is ready
  102092. */
  102093. isReady(completeCheck?: boolean): boolean;
  102094. /** @hidden */
  102095. _initCache(): void;
  102096. /** @hidden */
  102097. _updateCache(ignoreParentClass?: boolean): void;
  102098. /** @hidden */
  102099. _isSynchronized(): boolean;
  102100. /** @hidden */
  102101. _isSynchronizedViewMatrix(): boolean;
  102102. /** @hidden */
  102103. _isSynchronizedProjectionMatrix(): boolean;
  102104. /**
  102105. * Attach the input controls to a specific dom element to get the input from.
  102106. * @param element Defines the element the controls should be listened from
  102107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102108. */
  102109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102110. /**
  102111. * Detach the current controls from the specified dom element.
  102112. * @param element Defines the element to stop listening the inputs from
  102113. */
  102114. detachControl(element: HTMLElement): void;
  102115. /**
  102116. * Update the camera state according to the different inputs gathered during the frame.
  102117. */
  102118. update(): void;
  102119. /** @hidden */
  102120. _checkInputs(): void;
  102121. /** @hidden */
  102122. get rigCameras(): Camera[];
  102123. /**
  102124. * Gets the post process used by the rig cameras
  102125. */
  102126. get rigPostProcess(): Nullable<PostProcess>;
  102127. /**
  102128. * Internal, gets the first post proces.
  102129. * @returns the first post process to be run on this camera.
  102130. */
  102131. _getFirstPostProcess(): Nullable<PostProcess>;
  102132. private _cascadePostProcessesToRigCams;
  102133. /**
  102134. * Attach a post process to the camera.
  102135. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102136. * @param postProcess The post process to attach to the camera
  102137. * @param insertAt The position of the post process in case several of them are in use in the scene
  102138. * @returns the position the post process has been inserted at
  102139. */
  102140. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  102141. /**
  102142. * Detach a post process to the camera.
  102143. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  102144. * @param postProcess The post process to detach from the camera
  102145. */
  102146. detachPostProcess(postProcess: PostProcess): void;
  102147. /**
  102148. * Gets the current world matrix of the camera
  102149. */
  102150. getWorldMatrix(): Matrix;
  102151. /** @hidden */
  102152. _getViewMatrix(): Matrix;
  102153. /**
  102154. * Gets the current view matrix of the camera.
  102155. * @param force forces the camera to recompute the matrix without looking at the cached state
  102156. * @returns the view matrix
  102157. */
  102158. getViewMatrix(force?: boolean): Matrix;
  102159. /**
  102160. * Freeze the projection matrix.
  102161. * It will prevent the cache check of the camera projection compute and can speed up perf
  102162. * if no parameter of the camera are meant to change
  102163. * @param projection Defines manually a projection if necessary
  102164. */
  102165. freezeProjectionMatrix(projection?: Matrix): void;
  102166. /**
  102167. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  102168. */
  102169. unfreezeProjectionMatrix(): void;
  102170. /**
  102171. * Gets the current projection matrix of the camera.
  102172. * @param force forces the camera to recompute the matrix without looking at the cached state
  102173. * @returns the projection matrix
  102174. */
  102175. getProjectionMatrix(force?: boolean): Matrix;
  102176. /**
  102177. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  102178. * @returns a Matrix
  102179. */
  102180. getTransformationMatrix(): Matrix;
  102181. private _updateFrustumPlanes;
  102182. /**
  102183. * Checks if a cullable object (mesh...) is in the camera frustum
  102184. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  102185. * @param target The object to check
  102186. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  102187. * @returns true if the object is in frustum otherwise false
  102188. */
  102189. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  102190. /**
  102191. * Checks if a cullable object (mesh...) is in the camera frustum
  102192. * Unlike isInFrustum this cheks the full bounding box
  102193. * @param target The object to check
  102194. * @returns true if the object is in frustum otherwise false
  102195. */
  102196. isCompletelyInFrustum(target: ICullable): boolean;
  102197. /**
  102198. * Gets a ray in the forward direction from the camera.
  102199. * @param length Defines the length of the ray to create
  102200. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  102201. * @param origin Defines the start point of the ray which defaults to the camera position
  102202. * @returns the forward ray
  102203. */
  102204. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  102205. /**
  102206. * Releases resources associated with this node.
  102207. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102208. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102209. */
  102210. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102211. /** @hidden */
  102212. _isLeftCamera: boolean;
  102213. /**
  102214. * Gets the left camera of a rig setup in case of Rigged Camera
  102215. */
  102216. get isLeftCamera(): boolean;
  102217. /** @hidden */
  102218. _isRightCamera: boolean;
  102219. /**
  102220. * Gets the right camera of a rig setup in case of Rigged Camera
  102221. */
  102222. get isRightCamera(): boolean;
  102223. /**
  102224. * Gets the left camera of a rig setup in case of Rigged Camera
  102225. */
  102226. get leftCamera(): Nullable<FreeCamera>;
  102227. /**
  102228. * Gets the right camera of a rig setup in case of Rigged Camera
  102229. */
  102230. get rightCamera(): Nullable<FreeCamera>;
  102231. /**
  102232. * Gets the left camera target of a rig setup in case of Rigged Camera
  102233. * @returns the target position
  102234. */
  102235. getLeftTarget(): Nullable<Vector3>;
  102236. /**
  102237. * Gets the right camera target of a rig setup in case of Rigged Camera
  102238. * @returns the target position
  102239. */
  102240. getRightTarget(): Nullable<Vector3>;
  102241. /**
  102242. * @hidden
  102243. */
  102244. setCameraRigMode(mode: number, rigParams: any): void;
  102245. /** @hidden */
  102246. static _setStereoscopicRigMode(camera: Camera): void;
  102247. /** @hidden */
  102248. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102249. /** @hidden */
  102250. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102251. /** @hidden */
  102252. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102253. /** @hidden */
  102254. _getVRProjectionMatrix(): Matrix;
  102255. protected _updateCameraRotationMatrix(): void;
  102256. protected _updateWebVRCameraRotationMatrix(): void;
  102257. /**
  102258. * This function MUST be overwritten by the different WebVR cameras available.
  102259. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102260. * @hidden
  102261. */
  102262. _getWebVRProjectionMatrix(): Matrix;
  102263. /**
  102264. * This function MUST be overwritten by the different WebVR cameras available.
  102265. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102266. * @hidden
  102267. */
  102268. _getWebVRViewMatrix(): Matrix;
  102269. /** @hidden */
  102270. setCameraRigParameter(name: string, value: any): void;
  102271. /**
  102272. * needs to be overridden by children so sub has required properties to be copied
  102273. * @hidden
  102274. */
  102275. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102276. /**
  102277. * May need to be overridden by children
  102278. * @hidden
  102279. */
  102280. _updateRigCameras(): void;
  102281. /** @hidden */
  102282. _setupInputs(): void;
  102283. /**
  102284. * Serialiaze the camera setup to a json represention
  102285. * @returns the JSON representation
  102286. */
  102287. serialize(): any;
  102288. /**
  102289. * Clones the current camera.
  102290. * @param name The cloned camera name
  102291. * @returns the cloned camera
  102292. */
  102293. clone(name: string): Camera;
  102294. /**
  102295. * Gets the direction of the camera relative to a given local axis.
  102296. * @param localAxis Defines the reference axis to provide a relative direction.
  102297. * @return the direction
  102298. */
  102299. getDirection(localAxis: Vector3): Vector3;
  102300. /**
  102301. * Returns the current camera absolute rotation
  102302. */
  102303. get absoluteRotation(): Quaternion;
  102304. /**
  102305. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102306. * @param localAxis Defines the reference axis to provide a relative direction.
  102307. * @param result Defines the vector to store the result in
  102308. */
  102309. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102310. /**
  102311. * Gets a camera constructor for a given camera type
  102312. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102313. * @param name The name of the camera the result will be able to instantiate
  102314. * @param scene The scene the result will construct the camera in
  102315. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102316. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102317. * @returns a factory method to construc the camera
  102318. */
  102319. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102320. /**
  102321. * Compute the world matrix of the camera.
  102322. * @returns the camera world matrix
  102323. */
  102324. computeWorldMatrix(): Matrix;
  102325. /**
  102326. * Parse a JSON and creates the camera from the parsed information
  102327. * @param parsedCamera The JSON to parse
  102328. * @param scene The scene to instantiate the camera in
  102329. * @returns the newly constructed camera
  102330. */
  102331. static Parse(parsedCamera: any, scene: Scene): Camera;
  102332. }
  102333. }
  102334. declare module BABYLON {
  102335. /**
  102336. * Class containing static functions to help procedurally build meshes
  102337. */
  102338. export class DiscBuilder {
  102339. /**
  102340. * Creates a plane polygonal mesh. By default, this is a disc
  102341. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102342. * * 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
  102343. * * 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
  102344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102347. * @param name defines the name of the mesh
  102348. * @param options defines the options used to create the mesh
  102349. * @param scene defines the hosting scene
  102350. * @returns the plane polygonal mesh
  102351. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102352. */
  102353. static CreateDisc(name: string, options: {
  102354. radius?: number;
  102355. tessellation?: number;
  102356. arc?: number;
  102357. updatable?: boolean;
  102358. sideOrientation?: number;
  102359. frontUVs?: Vector4;
  102360. backUVs?: Vector4;
  102361. }, scene?: Nullable<Scene>): Mesh;
  102362. }
  102363. }
  102364. declare module BABYLON {
  102365. /**
  102366. * Options to be used when creating a FresnelParameters.
  102367. */
  102368. export type IFresnelParametersCreationOptions = {
  102369. /**
  102370. * Define the color used on edges (grazing angle)
  102371. */
  102372. leftColor?: Color3;
  102373. /**
  102374. * Define the color used on center
  102375. */
  102376. rightColor?: Color3;
  102377. /**
  102378. * Define bias applied to computed fresnel term
  102379. */
  102380. bias?: number;
  102381. /**
  102382. * Defined the power exponent applied to fresnel term
  102383. */
  102384. power?: number;
  102385. /**
  102386. * Define if the fresnel effect is enable or not.
  102387. */
  102388. isEnabled?: boolean;
  102389. };
  102390. /**
  102391. * Serialized format for FresnelParameters.
  102392. */
  102393. export type IFresnelParametersSerialized = {
  102394. /**
  102395. * Define the color used on edges (grazing angle) [as an array]
  102396. */
  102397. leftColor: number[];
  102398. /**
  102399. * Define the color used on center [as an array]
  102400. */
  102401. rightColor: number[];
  102402. /**
  102403. * Define bias applied to computed fresnel term
  102404. */
  102405. bias: number;
  102406. /**
  102407. * Defined the power exponent applied to fresnel term
  102408. */
  102409. power?: number;
  102410. /**
  102411. * Define if the fresnel effect is enable or not.
  102412. */
  102413. isEnabled: boolean;
  102414. };
  102415. /**
  102416. * This represents all the required information to add a fresnel effect on a material:
  102417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102418. */
  102419. export class FresnelParameters {
  102420. private _isEnabled;
  102421. /**
  102422. * Define if the fresnel effect is enable or not.
  102423. */
  102424. get isEnabled(): boolean;
  102425. set isEnabled(value: boolean);
  102426. /**
  102427. * Define the color used on edges (grazing angle)
  102428. */
  102429. leftColor: Color3;
  102430. /**
  102431. * Define the color used on center
  102432. */
  102433. rightColor: Color3;
  102434. /**
  102435. * Define bias applied to computed fresnel term
  102436. */
  102437. bias: number;
  102438. /**
  102439. * Defined the power exponent applied to fresnel term
  102440. */
  102441. power: number;
  102442. /**
  102443. * Creates a new FresnelParameters object.
  102444. *
  102445. * @param options provide your own settings to optionally to override defaults
  102446. */
  102447. constructor(options?: IFresnelParametersCreationOptions);
  102448. /**
  102449. * Clones the current fresnel and its valuues
  102450. * @returns a clone fresnel configuration
  102451. */
  102452. clone(): FresnelParameters;
  102453. /**
  102454. * Determines equality between FresnelParameters objects
  102455. * @param otherFresnelParameters defines the second operand
  102456. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102457. */
  102458. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102459. /**
  102460. * Serializes the current fresnel parameters to a JSON representation.
  102461. * @return the JSON serialization
  102462. */
  102463. serialize(): IFresnelParametersSerialized;
  102464. /**
  102465. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102466. * @param parsedFresnelParameters Define the JSON representation
  102467. * @returns the parsed parameters
  102468. */
  102469. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102470. }
  102471. }
  102472. declare module BABYLON {
  102473. /**
  102474. * Base class of materials working in push mode in babylon JS
  102475. * @hidden
  102476. */
  102477. export class PushMaterial extends Material {
  102478. protected _activeEffect: Effect;
  102479. protected _normalMatrix: Matrix;
  102480. /**
  102481. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102482. * This means that the material can keep using a previous shader while a new one is being compiled.
  102483. * This is mostly used when shader parallel compilation is supported (true by default)
  102484. */
  102485. allowShaderHotSwapping: boolean;
  102486. constructor(name: string, scene: Scene);
  102487. getEffect(): Effect;
  102488. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102489. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102490. /**
  102491. * Binds the given world matrix to the active effect
  102492. *
  102493. * @param world the matrix to bind
  102494. */
  102495. bindOnlyWorldMatrix(world: Matrix): void;
  102496. /**
  102497. * Binds the given normal matrix to the active effect
  102498. *
  102499. * @param normalMatrix the matrix to bind
  102500. */
  102501. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102502. bind(world: Matrix, mesh?: Mesh): void;
  102503. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102504. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102505. }
  102506. }
  102507. declare module BABYLON {
  102508. /**
  102509. * This groups all the flags used to control the materials channel.
  102510. */
  102511. export class MaterialFlags {
  102512. private static _DiffuseTextureEnabled;
  102513. /**
  102514. * Are diffuse textures enabled in the application.
  102515. */
  102516. static get DiffuseTextureEnabled(): boolean;
  102517. static set DiffuseTextureEnabled(value: boolean);
  102518. private static _AmbientTextureEnabled;
  102519. /**
  102520. * Are ambient textures enabled in the application.
  102521. */
  102522. static get AmbientTextureEnabled(): boolean;
  102523. static set AmbientTextureEnabled(value: boolean);
  102524. private static _OpacityTextureEnabled;
  102525. /**
  102526. * Are opacity textures enabled in the application.
  102527. */
  102528. static get OpacityTextureEnabled(): boolean;
  102529. static set OpacityTextureEnabled(value: boolean);
  102530. private static _ReflectionTextureEnabled;
  102531. /**
  102532. * Are reflection textures enabled in the application.
  102533. */
  102534. static get ReflectionTextureEnabled(): boolean;
  102535. static set ReflectionTextureEnabled(value: boolean);
  102536. private static _EmissiveTextureEnabled;
  102537. /**
  102538. * Are emissive textures enabled in the application.
  102539. */
  102540. static get EmissiveTextureEnabled(): boolean;
  102541. static set EmissiveTextureEnabled(value: boolean);
  102542. private static _SpecularTextureEnabled;
  102543. /**
  102544. * Are specular textures enabled in the application.
  102545. */
  102546. static get SpecularTextureEnabled(): boolean;
  102547. static set SpecularTextureEnabled(value: boolean);
  102548. private static _BumpTextureEnabled;
  102549. /**
  102550. * Are bump textures enabled in the application.
  102551. */
  102552. static get BumpTextureEnabled(): boolean;
  102553. static set BumpTextureEnabled(value: boolean);
  102554. private static _LightmapTextureEnabled;
  102555. /**
  102556. * Are lightmap textures enabled in the application.
  102557. */
  102558. static get LightmapTextureEnabled(): boolean;
  102559. static set LightmapTextureEnabled(value: boolean);
  102560. private static _RefractionTextureEnabled;
  102561. /**
  102562. * Are refraction textures enabled in the application.
  102563. */
  102564. static get RefractionTextureEnabled(): boolean;
  102565. static set RefractionTextureEnabled(value: boolean);
  102566. private static _ColorGradingTextureEnabled;
  102567. /**
  102568. * Are color grading textures enabled in the application.
  102569. */
  102570. static get ColorGradingTextureEnabled(): boolean;
  102571. static set ColorGradingTextureEnabled(value: boolean);
  102572. private static _FresnelEnabled;
  102573. /**
  102574. * Are fresnels enabled in the application.
  102575. */
  102576. static get FresnelEnabled(): boolean;
  102577. static set FresnelEnabled(value: boolean);
  102578. private static _ClearCoatTextureEnabled;
  102579. /**
  102580. * Are clear coat textures enabled in the application.
  102581. */
  102582. static get ClearCoatTextureEnabled(): boolean;
  102583. static set ClearCoatTextureEnabled(value: boolean);
  102584. private static _ClearCoatBumpTextureEnabled;
  102585. /**
  102586. * Are clear coat bump textures enabled in the application.
  102587. */
  102588. static get ClearCoatBumpTextureEnabled(): boolean;
  102589. static set ClearCoatBumpTextureEnabled(value: boolean);
  102590. private static _ClearCoatTintTextureEnabled;
  102591. /**
  102592. * Are clear coat tint textures enabled in the application.
  102593. */
  102594. static get ClearCoatTintTextureEnabled(): boolean;
  102595. static set ClearCoatTintTextureEnabled(value: boolean);
  102596. private static _SheenTextureEnabled;
  102597. /**
  102598. * Are sheen textures enabled in the application.
  102599. */
  102600. static get SheenTextureEnabled(): boolean;
  102601. static set SheenTextureEnabled(value: boolean);
  102602. private static _AnisotropicTextureEnabled;
  102603. /**
  102604. * Are anisotropic textures enabled in the application.
  102605. */
  102606. static get AnisotropicTextureEnabled(): boolean;
  102607. static set AnisotropicTextureEnabled(value: boolean);
  102608. private static _ThicknessTextureEnabled;
  102609. /**
  102610. * Are thickness textures enabled in the application.
  102611. */
  102612. static get ThicknessTextureEnabled(): boolean;
  102613. static set ThicknessTextureEnabled(value: boolean);
  102614. }
  102615. }
  102616. declare module BABYLON {
  102617. /** @hidden */
  102618. export var defaultFragmentDeclaration: {
  102619. name: string;
  102620. shader: string;
  102621. };
  102622. }
  102623. declare module BABYLON {
  102624. /** @hidden */
  102625. export var defaultUboDeclaration: {
  102626. name: string;
  102627. shader: string;
  102628. };
  102629. }
  102630. declare module BABYLON {
  102631. /** @hidden */
  102632. export var lightFragmentDeclaration: {
  102633. name: string;
  102634. shader: string;
  102635. };
  102636. }
  102637. declare module BABYLON {
  102638. /** @hidden */
  102639. export var lightUboDeclaration: {
  102640. name: string;
  102641. shader: string;
  102642. };
  102643. }
  102644. declare module BABYLON {
  102645. /** @hidden */
  102646. export var lightsFragmentFunctions: {
  102647. name: string;
  102648. shader: string;
  102649. };
  102650. }
  102651. declare module BABYLON {
  102652. /** @hidden */
  102653. export var shadowsFragmentFunctions: {
  102654. name: string;
  102655. shader: string;
  102656. };
  102657. }
  102658. declare module BABYLON {
  102659. /** @hidden */
  102660. export var fresnelFunction: {
  102661. name: string;
  102662. shader: string;
  102663. };
  102664. }
  102665. declare module BABYLON {
  102666. /** @hidden */
  102667. export var reflectionFunction: {
  102668. name: string;
  102669. shader: string;
  102670. };
  102671. }
  102672. declare module BABYLON {
  102673. /** @hidden */
  102674. export var bumpFragmentMainFunctions: {
  102675. name: string;
  102676. shader: string;
  102677. };
  102678. }
  102679. declare module BABYLON {
  102680. /** @hidden */
  102681. export var bumpFragmentFunctions: {
  102682. name: string;
  102683. shader: string;
  102684. };
  102685. }
  102686. declare module BABYLON {
  102687. /** @hidden */
  102688. export var logDepthDeclaration: {
  102689. name: string;
  102690. shader: string;
  102691. };
  102692. }
  102693. declare module BABYLON {
  102694. /** @hidden */
  102695. export var bumpFragment: {
  102696. name: string;
  102697. shader: string;
  102698. };
  102699. }
  102700. declare module BABYLON {
  102701. /** @hidden */
  102702. export var depthPrePass: {
  102703. name: string;
  102704. shader: string;
  102705. };
  102706. }
  102707. declare module BABYLON {
  102708. /** @hidden */
  102709. export var lightFragment: {
  102710. name: string;
  102711. shader: string;
  102712. };
  102713. }
  102714. declare module BABYLON {
  102715. /** @hidden */
  102716. export var logDepthFragment: {
  102717. name: string;
  102718. shader: string;
  102719. };
  102720. }
  102721. declare module BABYLON {
  102722. /** @hidden */
  102723. export var defaultPixelShader: {
  102724. name: string;
  102725. shader: string;
  102726. };
  102727. }
  102728. declare module BABYLON {
  102729. /** @hidden */
  102730. export var defaultVertexDeclaration: {
  102731. name: string;
  102732. shader: string;
  102733. };
  102734. }
  102735. declare module BABYLON {
  102736. /** @hidden */
  102737. export var bumpVertexDeclaration: {
  102738. name: string;
  102739. shader: string;
  102740. };
  102741. }
  102742. declare module BABYLON {
  102743. /** @hidden */
  102744. export var bumpVertex: {
  102745. name: string;
  102746. shader: string;
  102747. };
  102748. }
  102749. declare module BABYLON {
  102750. /** @hidden */
  102751. export var fogVertex: {
  102752. name: string;
  102753. shader: string;
  102754. };
  102755. }
  102756. declare module BABYLON {
  102757. /** @hidden */
  102758. export var shadowsVertex: {
  102759. name: string;
  102760. shader: string;
  102761. };
  102762. }
  102763. declare module BABYLON {
  102764. /** @hidden */
  102765. export var pointCloudVertex: {
  102766. name: string;
  102767. shader: string;
  102768. };
  102769. }
  102770. declare module BABYLON {
  102771. /** @hidden */
  102772. export var logDepthVertex: {
  102773. name: string;
  102774. shader: string;
  102775. };
  102776. }
  102777. declare module BABYLON {
  102778. /** @hidden */
  102779. export var defaultVertexShader: {
  102780. name: string;
  102781. shader: string;
  102782. };
  102783. }
  102784. declare module BABYLON {
  102785. /** @hidden */
  102786. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102787. MAINUV1: boolean;
  102788. MAINUV2: boolean;
  102789. DIFFUSE: boolean;
  102790. DIFFUSEDIRECTUV: number;
  102791. AMBIENT: boolean;
  102792. AMBIENTDIRECTUV: number;
  102793. OPACITY: boolean;
  102794. OPACITYDIRECTUV: number;
  102795. OPACITYRGB: boolean;
  102796. REFLECTION: boolean;
  102797. EMISSIVE: boolean;
  102798. EMISSIVEDIRECTUV: number;
  102799. SPECULAR: boolean;
  102800. SPECULARDIRECTUV: number;
  102801. BUMP: boolean;
  102802. BUMPDIRECTUV: number;
  102803. PARALLAX: boolean;
  102804. PARALLAXOCCLUSION: boolean;
  102805. SPECULAROVERALPHA: boolean;
  102806. CLIPPLANE: boolean;
  102807. CLIPPLANE2: boolean;
  102808. CLIPPLANE3: boolean;
  102809. CLIPPLANE4: boolean;
  102810. CLIPPLANE5: boolean;
  102811. CLIPPLANE6: boolean;
  102812. ALPHATEST: boolean;
  102813. DEPTHPREPASS: boolean;
  102814. ALPHAFROMDIFFUSE: boolean;
  102815. POINTSIZE: boolean;
  102816. FOG: boolean;
  102817. SPECULARTERM: boolean;
  102818. DIFFUSEFRESNEL: boolean;
  102819. OPACITYFRESNEL: boolean;
  102820. REFLECTIONFRESNEL: boolean;
  102821. REFRACTIONFRESNEL: boolean;
  102822. EMISSIVEFRESNEL: boolean;
  102823. FRESNEL: boolean;
  102824. NORMAL: boolean;
  102825. UV1: boolean;
  102826. UV2: boolean;
  102827. VERTEXCOLOR: boolean;
  102828. VERTEXALPHA: boolean;
  102829. NUM_BONE_INFLUENCERS: number;
  102830. BonesPerMesh: number;
  102831. BONETEXTURE: boolean;
  102832. INSTANCES: boolean;
  102833. GLOSSINESS: boolean;
  102834. ROUGHNESS: boolean;
  102835. EMISSIVEASILLUMINATION: boolean;
  102836. LINKEMISSIVEWITHDIFFUSE: boolean;
  102837. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102838. LIGHTMAP: boolean;
  102839. LIGHTMAPDIRECTUV: number;
  102840. OBJECTSPACE_NORMALMAP: boolean;
  102841. USELIGHTMAPASSHADOWMAP: boolean;
  102842. REFLECTIONMAP_3D: boolean;
  102843. REFLECTIONMAP_SPHERICAL: boolean;
  102844. REFLECTIONMAP_PLANAR: boolean;
  102845. REFLECTIONMAP_CUBIC: boolean;
  102846. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102847. REFLECTIONMAP_PROJECTION: boolean;
  102848. REFLECTIONMAP_SKYBOX: boolean;
  102849. REFLECTIONMAP_EXPLICIT: boolean;
  102850. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102851. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102852. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102853. INVERTCUBICMAP: boolean;
  102854. LOGARITHMICDEPTH: boolean;
  102855. REFRACTION: boolean;
  102856. REFRACTIONMAP_3D: boolean;
  102857. REFLECTIONOVERALPHA: boolean;
  102858. TWOSIDEDLIGHTING: boolean;
  102859. SHADOWFLOAT: boolean;
  102860. MORPHTARGETS: boolean;
  102861. MORPHTARGETS_NORMAL: boolean;
  102862. MORPHTARGETS_TANGENT: boolean;
  102863. MORPHTARGETS_UV: boolean;
  102864. NUM_MORPH_INFLUENCERS: number;
  102865. NONUNIFORMSCALING: boolean;
  102866. PREMULTIPLYALPHA: boolean;
  102867. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102868. ALPHABLEND: boolean;
  102869. IMAGEPROCESSING: boolean;
  102870. VIGNETTE: boolean;
  102871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102872. VIGNETTEBLENDMODEOPAQUE: boolean;
  102873. TONEMAPPING: boolean;
  102874. TONEMAPPING_ACES: boolean;
  102875. CONTRAST: boolean;
  102876. COLORCURVES: boolean;
  102877. COLORGRADING: boolean;
  102878. COLORGRADING3D: boolean;
  102879. SAMPLER3DGREENDEPTH: boolean;
  102880. SAMPLER3DBGRMAP: boolean;
  102881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102882. MULTIVIEW: boolean;
  102883. /**
  102884. * If the reflection texture on this material is in linear color space
  102885. * @hidden
  102886. */
  102887. IS_REFLECTION_LINEAR: boolean;
  102888. /**
  102889. * If the refraction texture on this material is in linear color space
  102890. * @hidden
  102891. */
  102892. IS_REFRACTION_LINEAR: boolean;
  102893. EXPOSURE: boolean;
  102894. constructor();
  102895. setReflectionMode(modeToEnable: string): void;
  102896. }
  102897. /**
  102898. * This is the default material used in Babylon. It is the best trade off between quality
  102899. * and performances.
  102900. * @see http://doc.babylonjs.com/babylon101/materials
  102901. */
  102902. export class StandardMaterial extends PushMaterial {
  102903. private _diffuseTexture;
  102904. /**
  102905. * The basic texture of the material as viewed under a light.
  102906. */
  102907. diffuseTexture: Nullable<BaseTexture>;
  102908. private _ambientTexture;
  102909. /**
  102910. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102911. */
  102912. ambientTexture: Nullable<BaseTexture>;
  102913. private _opacityTexture;
  102914. /**
  102915. * Define the transparency of the material from a texture.
  102916. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102917. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102918. */
  102919. opacityTexture: Nullable<BaseTexture>;
  102920. private _reflectionTexture;
  102921. /**
  102922. * Define the texture used to display the reflection.
  102923. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102924. */
  102925. reflectionTexture: Nullable<BaseTexture>;
  102926. private _emissiveTexture;
  102927. /**
  102928. * Define texture of the material as if self lit.
  102929. * This will be mixed in the final result even in the absence of light.
  102930. */
  102931. emissiveTexture: Nullable<BaseTexture>;
  102932. private _specularTexture;
  102933. /**
  102934. * Define how the color and intensity of the highlight given by the light in the material.
  102935. */
  102936. specularTexture: Nullable<BaseTexture>;
  102937. private _bumpTexture;
  102938. /**
  102939. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102940. * 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.
  102941. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102942. */
  102943. bumpTexture: Nullable<BaseTexture>;
  102944. private _lightmapTexture;
  102945. /**
  102946. * Complex lighting can be computationally expensive to compute at runtime.
  102947. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102948. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102949. */
  102950. lightmapTexture: Nullable<BaseTexture>;
  102951. private _refractionTexture;
  102952. /**
  102953. * Define the texture used to display the refraction.
  102954. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102955. */
  102956. refractionTexture: Nullable<BaseTexture>;
  102957. /**
  102958. * The color of the material lit by the environmental background lighting.
  102959. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102960. */
  102961. ambientColor: Color3;
  102962. /**
  102963. * The basic color of the material as viewed under a light.
  102964. */
  102965. diffuseColor: Color3;
  102966. /**
  102967. * Define how the color and intensity of the highlight given by the light in the material.
  102968. */
  102969. specularColor: Color3;
  102970. /**
  102971. * Define the color of the material as if self lit.
  102972. * This will be mixed in the final result even in the absence of light.
  102973. */
  102974. emissiveColor: Color3;
  102975. /**
  102976. * Defines how sharp are the highlights in the material.
  102977. * The bigger the value the sharper giving a more glossy feeling to the result.
  102978. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102979. */
  102980. specularPower: number;
  102981. private _useAlphaFromDiffuseTexture;
  102982. /**
  102983. * Does the transparency come from the diffuse texture alpha channel.
  102984. */
  102985. useAlphaFromDiffuseTexture: boolean;
  102986. private _useEmissiveAsIllumination;
  102987. /**
  102988. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102989. */
  102990. useEmissiveAsIllumination: boolean;
  102991. private _linkEmissiveWithDiffuse;
  102992. /**
  102993. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102994. * the emissive level when the final color is close to one.
  102995. */
  102996. linkEmissiveWithDiffuse: boolean;
  102997. private _useSpecularOverAlpha;
  102998. /**
  102999. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103000. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103001. */
  103002. useSpecularOverAlpha: boolean;
  103003. private _useReflectionOverAlpha;
  103004. /**
  103005. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103006. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103007. */
  103008. useReflectionOverAlpha: boolean;
  103009. private _disableLighting;
  103010. /**
  103011. * Does lights from the scene impacts this material.
  103012. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103013. */
  103014. disableLighting: boolean;
  103015. private _useObjectSpaceNormalMap;
  103016. /**
  103017. * Allows using an object space normal map (instead of tangent space).
  103018. */
  103019. useObjectSpaceNormalMap: boolean;
  103020. private _useParallax;
  103021. /**
  103022. * Is parallax enabled or not.
  103023. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103024. */
  103025. useParallax: boolean;
  103026. private _useParallaxOcclusion;
  103027. /**
  103028. * Is parallax occlusion enabled or not.
  103029. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103030. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103031. */
  103032. useParallaxOcclusion: boolean;
  103033. /**
  103034. * 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.
  103035. */
  103036. parallaxScaleBias: number;
  103037. private _roughness;
  103038. /**
  103039. * Helps to define how blurry the reflections should appears in the material.
  103040. */
  103041. roughness: number;
  103042. /**
  103043. * In case of refraction, define the value of the index of refraction.
  103044. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103045. */
  103046. indexOfRefraction: number;
  103047. /**
  103048. * Invert the refraction texture alongside the y axis.
  103049. * It can be useful with procedural textures or probe for instance.
  103050. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103051. */
  103052. invertRefractionY: boolean;
  103053. /**
  103054. * Defines the alpha limits in alpha test mode.
  103055. */
  103056. alphaCutOff: number;
  103057. private _useLightmapAsShadowmap;
  103058. /**
  103059. * In case of light mapping, define whether the map contains light or shadow informations.
  103060. */
  103061. useLightmapAsShadowmap: boolean;
  103062. private _diffuseFresnelParameters;
  103063. /**
  103064. * Define the diffuse fresnel parameters of the material.
  103065. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103066. */
  103067. diffuseFresnelParameters: FresnelParameters;
  103068. private _opacityFresnelParameters;
  103069. /**
  103070. * Define the opacity fresnel parameters of the material.
  103071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103072. */
  103073. opacityFresnelParameters: FresnelParameters;
  103074. private _reflectionFresnelParameters;
  103075. /**
  103076. * Define the reflection fresnel parameters of the material.
  103077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103078. */
  103079. reflectionFresnelParameters: FresnelParameters;
  103080. private _refractionFresnelParameters;
  103081. /**
  103082. * Define the refraction fresnel parameters of the material.
  103083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103084. */
  103085. refractionFresnelParameters: FresnelParameters;
  103086. private _emissiveFresnelParameters;
  103087. /**
  103088. * Define the emissive fresnel parameters of the material.
  103089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103090. */
  103091. emissiveFresnelParameters: FresnelParameters;
  103092. private _useReflectionFresnelFromSpecular;
  103093. /**
  103094. * If true automatically deducts the fresnels values from the material specularity.
  103095. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103096. */
  103097. useReflectionFresnelFromSpecular: boolean;
  103098. private _useGlossinessFromSpecularMapAlpha;
  103099. /**
  103100. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103101. */
  103102. useGlossinessFromSpecularMapAlpha: boolean;
  103103. private _maxSimultaneousLights;
  103104. /**
  103105. * Defines the maximum number of lights that can be used in the material
  103106. */
  103107. maxSimultaneousLights: number;
  103108. private _invertNormalMapX;
  103109. /**
  103110. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103111. */
  103112. invertNormalMapX: boolean;
  103113. private _invertNormalMapY;
  103114. /**
  103115. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103116. */
  103117. invertNormalMapY: boolean;
  103118. private _twoSidedLighting;
  103119. /**
  103120. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103121. */
  103122. twoSidedLighting: boolean;
  103123. /**
  103124. * Default configuration related to image processing available in the standard Material.
  103125. */
  103126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103127. /**
  103128. * Gets the image processing configuration used either in this material.
  103129. */
  103130. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103131. /**
  103132. * Sets the Default image processing configuration used either in the this material.
  103133. *
  103134. * If sets to null, the scene one is in use.
  103135. */
  103136. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103137. /**
  103138. * Keep track of the image processing observer to allow dispose and replace.
  103139. */
  103140. private _imageProcessingObserver;
  103141. /**
  103142. * Attaches a new image processing configuration to the Standard Material.
  103143. * @param configuration
  103144. */
  103145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103146. /**
  103147. * Gets wether the color curves effect is enabled.
  103148. */
  103149. get cameraColorCurvesEnabled(): boolean;
  103150. /**
  103151. * Sets wether the color curves effect is enabled.
  103152. */
  103153. set cameraColorCurvesEnabled(value: boolean);
  103154. /**
  103155. * Gets wether the color grading effect is enabled.
  103156. */
  103157. get cameraColorGradingEnabled(): boolean;
  103158. /**
  103159. * Gets wether the color grading effect is enabled.
  103160. */
  103161. set cameraColorGradingEnabled(value: boolean);
  103162. /**
  103163. * Gets wether tonemapping is enabled or not.
  103164. */
  103165. get cameraToneMappingEnabled(): boolean;
  103166. /**
  103167. * Sets wether tonemapping is enabled or not
  103168. */
  103169. set cameraToneMappingEnabled(value: boolean);
  103170. /**
  103171. * The camera exposure used on this material.
  103172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103173. * This corresponds to a photographic exposure.
  103174. */
  103175. get cameraExposure(): number;
  103176. /**
  103177. * The camera exposure used on this material.
  103178. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103179. * This corresponds to a photographic exposure.
  103180. */
  103181. set cameraExposure(value: number);
  103182. /**
  103183. * Gets The camera contrast used on this material.
  103184. */
  103185. get cameraContrast(): number;
  103186. /**
  103187. * Sets The camera contrast used on this material.
  103188. */
  103189. set cameraContrast(value: number);
  103190. /**
  103191. * Gets the Color Grading 2D Lookup Texture.
  103192. */
  103193. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103194. /**
  103195. * Sets the Color Grading 2D Lookup Texture.
  103196. */
  103197. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103198. /**
  103199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103201. * 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;
  103202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103203. */
  103204. get cameraColorCurves(): Nullable<ColorCurves>;
  103205. /**
  103206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103208. * 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;
  103209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103210. */
  103211. set cameraColorCurves(value: Nullable<ColorCurves>);
  103212. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103213. protected _worldViewProjectionMatrix: Matrix;
  103214. protected _globalAmbientColor: Color3;
  103215. protected _useLogarithmicDepth: boolean;
  103216. protected _rebuildInParallel: boolean;
  103217. /**
  103218. * Instantiates a new standard material.
  103219. * This is the default material used in Babylon. It is the best trade off between quality
  103220. * and performances.
  103221. * @see http://doc.babylonjs.com/babylon101/materials
  103222. * @param name Define the name of the material in the scene
  103223. * @param scene Define the scene the material belong to
  103224. */
  103225. constructor(name: string, scene: Scene);
  103226. /**
  103227. * Gets a boolean indicating that current material needs to register RTT
  103228. */
  103229. get hasRenderTargetTextures(): boolean;
  103230. /**
  103231. * Gets the current class name of the material e.g. "StandardMaterial"
  103232. * Mainly use in serialization.
  103233. * @returns the class name
  103234. */
  103235. getClassName(): string;
  103236. /**
  103237. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103238. * You can try switching to logarithmic depth.
  103239. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103240. */
  103241. get useLogarithmicDepth(): boolean;
  103242. set useLogarithmicDepth(value: boolean);
  103243. /**
  103244. * Specifies if the material will require alpha blending
  103245. * @returns a boolean specifying if alpha blending is needed
  103246. */
  103247. needAlphaBlending(): boolean;
  103248. /**
  103249. * Specifies if this material should be rendered in alpha test mode
  103250. * @returns a boolean specifying if an alpha test is needed.
  103251. */
  103252. needAlphaTesting(): boolean;
  103253. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103254. /**
  103255. * Get the texture used for alpha test purpose.
  103256. * @returns the diffuse texture in case of the standard material.
  103257. */
  103258. getAlphaTestTexture(): Nullable<BaseTexture>;
  103259. /**
  103260. * Get if the submesh is ready to be used and all its information available.
  103261. * Child classes can use it to update shaders
  103262. * @param mesh defines the mesh to check
  103263. * @param subMesh defines which submesh to check
  103264. * @param useInstances specifies that instances should be used
  103265. * @returns a boolean indicating that the submesh is ready or not
  103266. */
  103267. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103268. /**
  103269. * Builds the material UBO layouts.
  103270. * Used internally during the effect preparation.
  103271. */
  103272. buildUniformLayout(): void;
  103273. /**
  103274. * Unbinds the material from the mesh
  103275. */
  103276. unbind(): void;
  103277. /**
  103278. * Binds the submesh to this material by preparing the effect and shader to draw
  103279. * @param world defines the world transformation matrix
  103280. * @param mesh defines the mesh containing the submesh
  103281. * @param subMesh defines the submesh to bind the material to
  103282. */
  103283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103284. /**
  103285. * Get the list of animatables in the material.
  103286. * @returns the list of animatables object used in the material
  103287. */
  103288. getAnimatables(): IAnimatable[];
  103289. /**
  103290. * Gets the active textures from the material
  103291. * @returns an array of textures
  103292. */
  103293. getActiveTextures(): BaseTexture[];
  103294. /**
  103295. * Specifies if the material uses a texture
  103296. * @param texture defines the texture to check against the material
  103297. * @returns a boolean specifying if the material uses the texture
  103298. */
  103299. hasTexture(texture: BaseTexture): boolean;
  103300. /**
  103301. * Disposes the material
  103302. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103303. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103304. */
  103305. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103306. /**
  103307. * Makes a duplicate of the material, and gives it a new name
  103308. * @param name defines the new name for the duplicated material
  103309. * @returns the cloned material
  103310. */
  103311. clone(name: string): StandardMaterial;
  103312. /**
  103313. * Serializes this material in a JSON representation
  103314. * @returns the serialized material object
  103315. */
  103316. serialize(): any;
  103317. /**
  103318. * Creates a standard material from parsed material data
  103319. * @param source defines the JSON representation of the material
  103320. * @param scene defines the hosting scene
  103321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103322. * @returns a new standard material
  103323. */
  103324. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103325. /**
  103326. * Are diffuse textures enabled in the application.
  103327. */
  103328. static get DiffuseTextureEnabled(): boolean;
  103329. static set DiffuseTextureEnabled(value: boolean);
  103330. /**
  103331. * Are ambient textures enabled in the application.
  103332. */
  103333. static get AmbientTextureEnabled(): boolean;
  103334. static set AmbientTextureEnabled(value: boolean);
  103335. /**
  103336. * Are opacity textures enabled in the application.
  103337. */
  103338. static get OpacityTextureEnabled(): boolean;
  103339. static set OpacityTextureEnabled(value: boolean);
  103340. /**
  103341. * Are reflection textures enabled in the application.
  103342. */
  103343. static get ReflectionTextureEnabled(): boolean;
  103344. static set ReflectionTextureEnabled(value: boolean);
  103345. /**
  103346. * Are emissive textures enabled in the application.
  103347. */
  103348. static get EmissiveTextureEnabled(): boolean;
  103349. static set EmissiveTextureEnabled(value: boolean);
  103350. /**
  103351. * Are specular textures enabled in the application.
  103352. */
  103353. static get SpecularTextureEnabled(): boolean;
  103354. static set SpecularTextureEnabled(value: boolean);
  103355. /**
  103356. * Are bump textures enabled in the application.
  103357. */
  103358. static get BumpTextureEnabled(): boolean;
  103359. static set BumpTextureEnabled(value: boolean);
  103360. /**
  103361. * Are lightmap textures enabled in the application.
  103362. */
  103363. static get LightmapTextureEnabled(): boolean;
  103364. static set LightmapTextureEnabled(value: boolean);
  103365. /**
  103366. * Are refraction textures enabled in the application.
  103367. */
  103368. static get RefractionTextureEnabled(): boolean;
  103369. static set RefractionTextureEnabled(value: boolean);
  103370. /**
  103371. * Are color grading textures enabled in the application.
  103372. */
  103373. static get ColorGradingTextureEnabled(): boolean;
  103374. static set ColorGradingTextureEnabled(value: boolean);
  103375. /**
  103376. * Are fresnels enabled in the application.
  103377. */
  103378. static get FresnelEnabled(): boolean;
  103379. static set FresnelEnabled(value: boolean);
  103380. }
  103381. }
  103382. declare module BABYLON {
  103383. /**
  103384. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103385. *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.
  103386. * The SPS is also a particle system. It provides some methods to manage the particles.
  103387. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103388. *
  103389. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103390. */
  103391. export class SolidParticleSystem implements IDisposable {
  103392. /**
  103393. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103394. * Example : var p = SPS.particles[i];
  103395. */
  103396. particles: SolidParticle[];
  103397. /**
  103398. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103399. */
  103400. nbParticles: number;
  103401. /**
  103402. * If the particles must ever face the camera (default false). Useful for planar particles.
  103403. */
  103404. billboard: boolean;
  103405. /**
  103406. * Recompute normals when adding a shape
  103407. */
  103408. recomputeNormals: boolean;
  103409. /**
  103410. * This a counter ofr your own usage. It's not set by any SPS functions.
  103411. */
  103412. counter: number;
  103413. /**
  103414. * The SPS name. This name is also given to the underlying mesh.
  103415. */
  103416. name: string;
  103417. /**
  103418. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103419. */
  103420. mesh: Mesh;
  103421. /**
  103422. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103423. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103424. */
  103425. vars: any;
  103426. /**
  103427. * This array is populated when the SPS is set as 'pickable'.
  103428. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103429. * Each element of this array is an object `{idx: int, faceId: int}`.
  103430. * `idx` is the picked particle index in the `SPS.particles` array
  103431. * `faceId` is the picked face index counted within this particle.
  103432. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103433. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103434. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103435. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103436. */
  103437. pickedParticles: {
  103438. idx: number;
  103439. faceId: number;
  103440. }[];
  103441. /**
  103442. * This array is populated when the SPS is set as 'pickable'
  103443. * Each key of this array is a submesh index.
  103444. * Each element of this array is a second array defined like this :
  103445. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103446. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103447. * `idx` is the picked particle index in the `SPS.particles` array
  103448. * `faceId` is the picked face index counted within this particle.
  103449. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103450. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103451. */
  103452. pickedBySubMesh: {
  103453. idx: number;
  103454. faceId: number;
  103455. }[][];
  103456. /**
  103457. * This array is populated when `enableDepthSort` is set to true.
  103458. * Each element of this array is an instance of the class DepthSortedParticle.
  103459. */
  103460. depthSortedParticles: DepthSortedParticle[];
  103461. /**
  103462. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103463. * @hidden
  103464. */
  103465. _bSphereOnly: boolean;
  103466. /**
  103467. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103468. * @hidden
  103469. */
  103470. _bSphereRadiusFactor: number;
  103471. private _scene;
  103472. private _positions;
  103473. private _indices;
  103474. private _normals;
  103475. private _colors;
  103476. private _uvs;
  103477. private _indices32;
  103478. private _positions32;
  103479. private _normals32;
  103480. private _fixedNormal32;
  103481. private _colors32;
  103482. private _uvs32;
  103483. private _index;
  103484. private _updatable;
  103485. private _pickable;
  103486. private _isVisibilityBoxLocked;
  103487. private _alwaysVisible;
  103488. private _depthSort;
  103489. private _expandable;
  103490. private _shapeCounter;
  103491. private _copy;
  103492. private _color;
  103493. private _computeParticleColor;
  103494. private _computeParticleTexture;
  103495. private _computeParticleRotation;
  103496. private _computeParticleVertex;
  103497. private _computeBoundingBox;
  103498. private _depthSortParticles;
  103499. private _camera;
  103500. private _mustUnrotateFixedNormals;
  103501. private _particlesIntersect;
  103502. private _needs32Bits;
  103503. private _isNotBuilt;
  103504. private _lastParticleId;
  103505. private _idxOfId;
  103506. private _multimaterialEnabled;
  103507. private _useModelMaterial;
  103508. private _indicesByMaterial;
  103509. private _materialIndexes;
  103510. private _depthSortFunction;
  103511. private _materialSortFunction;
  103512. private _materials;
  103513. private _multimaterial;
  103514. private _materialIndexesById;
  103515. private _defaultMaterial;
  103516. private _autoUpdateSubMeshes;
  103517. private _tmpVertex;
  103518. /**
  103519. * Creates a SPS (Solid Particle System) object.
  103520. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103521. * @param scene (Scene) is the scene in which the SPS is added.
  103522. * @param options defines the options of the sps e.g.
  103523. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103524. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103525. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103526. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  103527. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103528. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103529. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103530. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103531. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103532. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103533. */
  103534. constructor(name: string, scene: Scene, options?: {
  103535. updatable?: boolean;
  103536. isPickable?: boolean;
  103537. enableDepthSort?: boolean;
  103538. particleIntersection?: boolean;
  103539. boundingSphereOnly?: boolean;
  103540. bSphereRadiusFactor?: number;
  103541. expandable?: boolean;
  103542. useModelMaterial?: boolean;
  103543. enableMultiMaterial?: boolean;
  103544. });
  103545. /**
  103546. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103547. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103548. * @returns the created mesh
  103549. */
  103550. buildMesh(): Mesh;
  103551. /**
  103552. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103553. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103554. * Thus the particles generated from `digest()` have their property `position` set yet.
  103555. * @param mesh ( Mesh ) is the mesh to be digested
  103556. * @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
  103557. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103558. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103559. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103560. * @returns the current SPS
  103561. */
  103562. digest(mesh: Mesh, options?: {
  103563. facetNb?: number;
  103564. number?: number;
  103565. delta?: number;
  103566. storage?: [];
  103567. }): SolidParticleSystem;
  103568. /**
  103569. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103570. * @hidden
  103571. */
  103572. private _unrotateFixedNormals;
  103573. /**
  103574. * Resets the temporary working copy particle
  103575. * @hidden
  103576. */
  103577. private _resetCopy;
  103578. /**
  103579. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103580. * @param p the current index in the positions array to be updated
  103581. * @param ind the current index in the indices array
  103582. * @param shape a Vector3 array, the shape geometry
  103583. * @param positions the positions array to be updated
  103584. * @param meshInd the shape indices array
  103585. * @param indices the indices array to be updated
  103586. * @param meshUV the shape uv array
  103587. * @param uvs the uv array to be updated
  103588. * @param meshCol the shape color array
  103589. * @param colors the color array to be updated
  103590. * @param meshNor the shape normals array
  103591. * @param normals the normals array to be updated
  103592. * @param idx the particle index
  103593. * @param idxInShape the particle index in its shape
  103594. * @param options the addShape() method passed options
  103595. * @model the particle model
  103596. * @hidden
  103597. */
  103598. private _meshBuilder;
  103599. /**
  103600. * Returns a shape Vector3 array from positions float array
  103601. * @param positions float array
  103602. * @returns a vector3 array
  103603. * @hidden
  103604. */
  103605. private _posToShape;
  103606. /**
  103607. * Returns a shapeUV array from a float uvs (array deep copy)
  103608. * @param uvs as a float array
  103609. * @returns a shapeUV array
  103610. * @hidden
  103611. */
  103612. private _uvsToShapeUV;
  103613. /**
  103614. * Adds a new particle object in the particles array
  103615. * @param idx particle index in particles array
  103616. * @param id particle id
  103617. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103618. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103619. * @param model particle ModelShape object
  103620. * @param shapeId model shape identifier
  103621. * @param idxInShape index of the particle in the current model
  103622. * @param bInfo model bounding info object
  103623. * @param storage target storage array, if any
  103624. * @hidden
  103625. */
  103626. private _addParticle;
  103627. /**
  103628. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103629. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103630. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103631. * @param nb (positive integer) the number of particles to be created from this model
  103632. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103633. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103634. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103635. * @returns the number of shapes in the system
  103636. */
  103637. addShape(mesh: Mesh, nb: number, options?: {
  103638. positionFunction?: any;
  103639. vertexFunction?: any;
  103640. storage?: [];
  103641. }): number;
  103642. /**
  103643. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103644. * @hidden
  103645. */
  103646. private _rebuildParticle;
  103647. /**
  103648. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103649. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  103650. * @returns the SPS.
  103651. */
  103652. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103653. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103654. * Returns an array with the removed particles.
  103655. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  103656. * The SPS can't be empty so at least one particle needs to remain in place.
  103657. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103658. * @param start index of the first particle to remove
  103659. * @param end index of the last particle to remove (included)
  103660. * @returns an array populated with the removed particles
  103661. */
  103662. removeParticles(start: number, end: number): SolidParticle[];
  103663. /**
  103664. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103665. * @param solidParticleArray an array populated with Solid Particles objects
  103666. * @returns the SPS
  103667. */
  103668. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103669. /**
  103670. * Creates a new particle and modifies the SPS mesh geometry :
  103671. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103672. * - calls _addParticle() to populate the particle array
  103673. * factorized code from addShape() and insertParticlesFromArray()
  103674. * @param idx particle index in the particles array
  103675. * @param i particle index in its shape
  103676. * @param modelShape particle ModelShape object
  103677. * @param shape shape vertex array
  103678. * @param meshInd shape indices array
  103679. * @param meshUV shape uv array
  103680. * @param meshCol shape color array
  103681. * @param meshNor shape normals array
  103682. * @param bbInfo shape bounding info
  103683. * @param storage target particle storage
  103684. * @options addShape() passed options
  103685. * @hidden
  103686. */
  103687. private _insertNewParticle;
  103688. /**
  103689. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103690. * This method calls `updateParticle()` for each particle of the SPS.
  103691. * For an animated SPS, it is usually called within the render loop.
  103692. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  103693. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103694. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103695. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103696. * @returns the SPS.
  103697. */
  103698. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103699. /**
  103700. * Disposes the SPS.
  103701. */
  103702. dispose(): void;
  103703. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103704. * idx is the particle index in the SPS
  103705. * faceId is the picked face index counted within this particle.
  103706. * Returns null if the pickInfo can't identify a picked particle.
  103707. * @param pickingInfo (PickingInfo object)
  103708. * @returns {idx: number, faceId: number} or null
  103709. */
  103710. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103711. idx: number;
  103712. faceId: number;
  103713. }>;
  103714. /**
  103715. * Returns a SolidParticle object from its identifier : particle.id
  103716. * @param id (integer) the particle Id
  103717. * @returns the searched particle or null if not found in the SPS.
  103718. */
  103719. getParticleById(id: number): Nullable<SolidParticle>;
  103720. /**
  103721. * Returns a new array populated with the particles having the passed shapeId.
  103722. * @param shapeId (integer) the shape identifier
  103723. * @returns a new solid particle array
  103724. */
  103725. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103726. /**
  103727. * Populates the passed array "ref" with the particles having the passed shapeId.
  103728. * @param shapeId the shape identifier
  103729. * @returns the SPS
  103730. * @param ref
  103731. */
  103732. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103733. /**
  103734. * Computes the required SubMeshes according the materials assigned to the particles.
  103735. * @returns the solid particle system.
  103736. * Does nothing if called before the SPS mesh is built.
  103737. */
  103738. computeSubMeshes(): SolidParticleSystem;
  103739. /**
  103740. * Sorts the solid particles by material when MultiMaterial is enabled.
  103741. * Updates the indices32 array.
  103742. * Updates the indicesByMaterial array.
  103743. * Updates the mesh indices array.
  103744. * @returns the SPS
  103745. * @hidden
  103746. */
  103747. private _sortParticlesByMaterial;
  103748. /**
  103749. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103750. * @hidden
  103751. */
  103752. private _setMaterialIndexesById;
  103753. /**
  103754. * Returns an array with unique values of Materials from the passed array
  103755. * @param array the material array to be checked and filtered
  103756. * @hidden
  103757. */
  103758. private _filterUniqueMaterialId;
  103759. /**
  103760. * Sets a new Standard Material as _defaultMaterial if not already set.
  103761. * @hidden
  103762. */
  103763. private _setDefaultMaterial;
  103764. /**
  103765. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103766. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103767. * @returns the SPS.
  103768. */
  103769. refreshVisibleSize(): SolidParticleSystem;
  103770. /**
  103771. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103772. * @param size the size (float) of the visibility box
  103773. * note : this doesn't lock the SPS mesh bounding box.
  103774. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103775. */
  103776. setVisibilityBox(size: number): void;
  103777. /**
  103778. * Gets whether the SPS as always visible or not
  103779. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103780. */
  103781. get isAlwaysVisible(): boolean;
  103782. /**
  103783. * Sets the SPS as always visible or not
  103784. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103785. */
  103786. set isAlwaysVisible(val: boolean);
  103787. /**
  103788. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103789. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103790. */
  103791. set isVisibilityBoxLocked(val: boolean);
  103792. /**
  103793. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103795. */
  103796. get isVisibilityBoxLocked(): boolean;
  103797. /**
  103798. * Tells to `setParticles()` to compute the particle rotations or not.
  103799. * Default value : true. The SPS is faster when it's set to false.
  103800. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103801. */
  103802. set computeParticleRotation(val: boolean);
  103803. /**
  103804. * Tells to `setParticles()` to compute the particle colors or not.
  103805. * Default value : true. The SPS is faster when it's set to false.
  103806. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103807. */
  103808. set computeParticleColor(val: boolean);
  103809. set computeParticleTexture(val: boolean);
  103810. /**
  103811. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103812. * Default value : false. The SPS is faster when it's set to false.
  103813. * Note : the particle custom vertex positions aren't stored values.
  103814. */
  103815. set computeParticleVertex(val: boolean);
  103816. /**
  103817. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103818. */
  103819. set computeBoundingBox(val: boolean);
  103820. /**
  103821. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103822. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103823. * Default : `true`
  103824. */
  103825. set depthSortParticles(val: boolean);
  103826. /**
  103827. * Gets if `setParticles()` computes the particle rotations or not.
  103828. * Default value : true. The SPS is faster when it's set to false.
  103829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103830. */
  103831. get computeParticleRotation(): boolean;
  103832. /**
  103833. * Gets if `setParticles()` computes the particle colors or not.
  103834. * Default value : true. The SPS is faster when it's set to false.
  103835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103836. */
  103837. get computeParticleColor(): boolean;
  103838. /**
  103839. * Gets if `setParticles()` computes the particle textures or not.
  103840. * Default value : true. The SPS is faster when it's set to false.
  103841. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103842. */
  103843. get computeParticleTexture(): boolean;
  103844. /**
  103845. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103846. * Default value : false. The SPS is faster when it's set to false.
  103847. * Note : the particle custom vertex positions aren't stored values.
  103848. */
  103849. get computeParticleVertex(): boolean;
  103850. /**
  103851. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103852. */
  103853. get computeBoundingBox(): boolean;
  103854. /**
  103855. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103856. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103857. * Default : `true`
  103858. */
  103859. get depthSortParticles(): boolean;
  103860. /**
  103861. * Gets if the SPS is created as expandable at construction time.
  103862. * Default : `false`
  103863. */
  103864. get expandable(): boolean;
  103865. /**
  103866. * Gets if the SPS supports the Multi Materials
  103867. */
  103868. get multimaterialEnabled(): boolean;
  103869. /**
  103870. * Gets if the SPS uses the model materials for its own multimaterial.
  103871. */
  103872. get useModelMaterial(): boolean;
  103873. /**
  103874. * The SPS used material array.
  103875. */
  103876. get materials(): Material[];
  103877. /**
  103878. * Sets the SPS MultiMaterial from the passed materials.
  103879. * Note : the passed array is internally copied and not used then by reference.
  103880. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103881. */
  103882. setMultiMaterial(materials: Material[]): void;
  103883. /**
  103884. * The SPS computed multimaterial object
  103885. */
  103886. get multimaterial(): MultiMaterial;
  103887. set multimaterial(mm: MultiMaterial);
  103888. /**
  103889. * If the subMeshes must be updated on the next call to setParticles()
  103890. */
  103891. get autoUpdateSubMeshes(): boolean;
  103892. set autoUpdateSubMeshes(val: boolean);
  103893. /**
  103894. * This function does nothing. It may be overwritten to set all the particle first values.
  103895. * The SPS doesn't call this function, you may have to call it by your own.
  103896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103897. */
  103898. initParticles(): void;
  103899. /**
  103900. * This function does nothing. It may be overwritten to recycle a particle.
  103901. * The SPS doesn't call this function, you may have to call it by your own.
  103902. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103903. * @param particle The particle to recycle
  103904. * @returns the recycled particle
  103905. */
  103906. recycleParticle(particle: SolidParticle): SolidParticle;
  103907. /**
  103908. * Updates a particle : this function should be overwritten by the user.
  103909. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103910. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103911. * @example : just set a particle position or velocity and recycle conditions
  103912. * @param particle The particle to update
  103913. * @returns the updated particle
  103914. */
  103915. updateParticle(particle: SolidParticle): SolidParticle;
  103916. /**
  103917. * Updates a vertex of a particle : it can be overwritten by the user.
  103918. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103919. * @param particle the current particle
  103920. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  103921. * @param pt the index of the current vertex in the particle shape
  103922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103923. * @example : just set a vertex particle position or color
  103924. * @returns the sps
  103925. */
  103926. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  103927. /**
  103928. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103929. * This does nothing and may be overwritten by the user.
  103930. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103931. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103932. * @param update the boolean update value actually passed to setParticles()
  103933. */
  103934. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103935. /**
  103936. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103937. * This will be passed three parameters.
  103938. * This does nothing and may be overwritten by the user.
  103939. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103940. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103941. * @param update the boolean update value actually passed to setParticles()
  103942. */
  103943. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103944. }
  103945. }
  103946. declare module BABYLON {
  103947. /**
  103948. * Represents one particle of a solid particle system.
  103949. */
  103950. export class SolidParticle {
  103951. /**
  103952. * particle global index
  103953. */
  103954. idx: number;
  103955. /**
  103956. * particle identifier
  103957. */
  103958. id: number;
  103959. /**
  103960. * The color of the particle
  103961. */
  103962. color: Nullable<Color4>;
  103963. /**
  103964. * The world space position of the particle.
  103965. */
  103966. position: Vector3;
  103967. /**
  103968. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  103969. */
  103970. rotation: Vector3;
  103971. /**
  103972. * The world space rotation quaternion of the particle.
  103973. */
  103974. rotationQuaternion: Nullable<Quaternion>;
  103975. /**
  103976. * The scaling of the particle.
  103977. */
  103978. scaling: Vector3;
  103979. /**
  103980. * The uvs of the particle.
  103981. */
  103982. uvs: Vector4;
  103983. /**
  103984. * The current speed of the particle.
  103985. */
  103986. velocity: Vector3;
  103987. /**
  103988. * The pivot point in the particle local space.
  103989. */
  103990. pivot: Vector3;
  103991. /**
  103992. * Must the particle be translated from its pivot point in its local space ?
  103993. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  103994. * Default : false
  103995. */
  103996. translateFromPivot: boolean;
  103997. /**
  103998. * Is the particle active or not ?
  103999. */
  104000. alive: boolean;
  104001. /**
  104002. * Is the particle visible or not ?
  104003. */
  104004. isVisible: boolean;
  104005. /**
  104006. * Index of this particle in the global "positions" array (Internal use)
  104007. * @hidden
  104008. */
  104009. _pos: number;
  104010. /**
  104011. * @hidden Index of this particle in the global "indices" array (Internal use)
  104012. */
  104013. _ind: number;
  104014. /**
  104015. * @hidden ModelShape of this particle (Internal use)
  104016. */
  104017. _model: ModelShape;
  104018. /**
  104019. * ModelShape id of this particle
  104020. */
  104021. shapeId: number;
  104022. /**
  104023. * Index of the particle in its shape id
  104024. */
  104025. idxInShape: number;
  104026. /**
  104027. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  104028. */
  104029. _modelBoundingInfo: BoundingInfo;
  104030. /**
  104031. * @hidden Particle BoundingInfo object (Internal use)
  104032. */
  104033. _boundingInfo: BoundingInfo;
  104034. /**
  104035. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  104036. */
  104037. _sps: SolidParticleSystem;
  104038. /**
  104039. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  104040. */
  104041. _stillInvisible: boolean;
  104042. /**
  104043. * @hidden Last computed particle rotation matrix
  104044. */
  104045. _rotationMatrix: number[];
  104046. /**
  104047. * Parent particle Id, if any.
  104048. * Default null.
  104049. */
  104050. parentId: Nullable<number>;
  104051. /**
  104052. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  104053. */
  104054. materialIndex: Nullable<number>;
  104055. /**
  104056. * Custom object or properties.
  104057. */
  104058. props: Nullable<any>;
  104059. /**
  104060. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  104061. * The possible values are :
  104062. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104063. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104064. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104065. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104066. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104067. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  104068. * */
  104069. cullingStrategy: number;
  104070. /**
  104071. * @hidden Internal global position in the SPS.
  104072. */
  104073. _globalPosition: Vector3;
  104074. /**
  104075. * Creates a Solid Particle object.
  104076. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  104077. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  104078. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  104079. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  104080. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  104081. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  104082. * @param shapeId (integer) is the model shape identifier in the SPS.
  104083. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  104084. * @param sps defines the sps it is associated to
  104085. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  104086. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  104087. */
  104088. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  104089. /**
  104090. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  104091. * @param target the particle target
  104092. * @returns the current particle
  104093. */
  104094. copyToRef(target: SolidParticle): SolidParticle;
  104095. /**
  104096. * Legacy support, changed scale to scaling
  104097. */
  104098. get scale(): Vector3;
  104099. /**
  104100. * Legacy support, changed scale to scaling
  104101. */
  104102. set scale(scale: Vector3);
  104103. /**
  104104. * Legacy support, changed quaternion to rotationQuaternion
  104105. */
  104106. get quaternion(): Nullable<Quaternion>;
  104107. /**
  104108. * Legacy support, changed quaternion to rotationQuaternion
  104109. */
  104110. set quaternion(q: Nullable<Quaternion>);
  104111. /**
  104112. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  104113. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  104114. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  104115. * @returns true if it intersects
  104116. */
  104117. intersectsMesh(target: Mesh | SolidParticle): boolean;
  104118. /**
  104119. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  104120. * A particle is in the frustum if its bounding box intersects the frustum
  104121. * @param frustumPlanes defines the frustum to test
  104122. * @returns true if the particle is in the frustum planes
  104123. */
  104124. isInFrustum(frustumPlanes: Plane[]): boolean;
  104125. /**
  104126. * get the rotation matrix of the particle
  104127. * @hidden
  104128. */
  104129. getRotationMatrix(m: Matrix): void;
  104130. }
  104131. /**
  104132. * Represents the shape of the model used by one particle of a solid particle system.
  104133. * SPS internal tool, don't use it manually.
  104134. */
  104135. export class ModelShape {
  104136. /**
  104137. * The shape id
  104138. * @hidden
  104139. */
  104140. shapeID: number;
  104141. /**
  104142. * flat array of model positions (internal use)
  104143. * @hidden
  104144. */
  104145. _shape: Vector3[];
  104146. /**
  104147. * flat array of model UVs (internal use)
  104148. * @hidden
  104149. */
  104150. _shapeUV: number[];
  104151. /**
  104152. * color array of the model
  104153. * @hidden
  104154. */
  104155. _shapeColors: number[];
  104156. /**
  104157. * indices array of the model
  104158. * @hidden
  104159. */
  104160. _indices: number[];
  104161. /**
  104162. * normals array of the model
  104163. * @hidden
  104164. */
  104165. _normals: number[];
  104166. /**
  104167. * length of the shape in the model indices array (internal use)
  104168. * @hidden
  104169. */
  104170. _indicesLength: number;
  104171. /**
  104172. * Custom position function (internal use)
  104173. * @hidden
  104174. */
  104175. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  104176. /**
  104177. * Custom vertex function (internal use)
  104178. * @hidden
  104179. */
  104180. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  104181. /**
  104182. * Model material (internal use)
  104183. * @hidden
  104184. */
  104185. _material: Nullable<Material>;
  104186. /**
  104187. * 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.
  104188. * SPS internal tool, don't use it manually.
  104189. * @hidden
  104190. */
  104191. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  104192. }
  104193. /**
  104194. * Represents a Depth Sorted Particle in the solid particle system.
  104195. * @hidden
  104196. */
  104197. export class DepthSortedParticle {
  104198. /**
  104199. * Particle index
  104200. */
  104201. idx: number;
  104202. /**
  104203. * Index of the particle in the "indices" array
  104204. */
  104205. ind: number;
  104206. /**
  104207. * Length of the particle shape in the "indices" array
  104208. */
  104209. indicesLength: number;
  104210. /**
  104211. * Squared distance from the particle to the camera
  104212. */
  104213. sqDistance: number;
  104214. /**
  104215. * Material index when used with MultiMaterials
  104216. */
  104217. materialIndex: number;
  104218. /**
  104219. * Creates a new sorted particle
  104220. * @param materialIndex
  104221. */
  104222. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104223. }
  104224. /**
  104225. * Represents a solid particle vertex
  104226. */
  104227. export class SolidParticleVertex {
  104228. /**
  104229. * Vertex position
  104230. */
  104231. position: Vector3;
  104232. /**
  104233. * Vertex color
  104234. */
  104235. color: Color4;
  104236. /**
  104237. * Vertex UV
  104238. */
  104239. uv: Vector2;
  104240. /**
  104241. * Creates a new solid particle vertex
  104242. */
  104243. constructor();
  104244. /** Vertex x coordinate */
  104245. get x(): number;
  104246. set x(val: number);
  104247. /** Vertex y coordinate */
  104248. get y(): number;
  104249. set y(val: number);
  104250. /** Vertex z coordinate */
  104251. get z(): number;
  104252. set z(val: number);
  104253. }
  104254. }
  104255. declare module BABYLON {
  104256. /**
  104257. * @hidden
  104258. */
  104259. export class _MeshCollisionData {
  104260. _checkCollisions: boolean;
  104261. _collisionMask: number;
  104262. _collisionGroup: number;
  104263. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104264. _collider: Nullable<Collider>;
  104265. _oldPositionForCollisions: Vector3;
  104266. _diffPositionForCollisions: Vector3;
  104267. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104268. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /** @hidden */
  104273. class _FacetDataStorage {
  104274. facetPositions: Vector3[];
  104275. facetNormals: Vector3[];
  104276. facetPartitioning: number[][];
  104277. facetNb: number;
  104278. partitioningSubdivisions: number;
  104279. partitioningBBoxRatio: number;
  104280. facetDataEnabled: boolean;
  104281. facetParameters: any;
  104282. bbSize: Vector3;
  104283. subDiv: {
  104284. max: number;
  104285. X: number;
  104286. Y: number;
  104287. Z: number;
  104288. };
  104289. facetDepthSort: boolean;
  104290. facetDepthSortEnabled: boolean;
  104291. depthSortedIndices: IndicesArray;
  104292. depthSortedFacets: {
  104293. ind: number;
  104294. sqDistance: number;
  104295. }[];
  104296. facetDepthSortFunction: (f1: {
  104297. ind: number;
  104298. sqDistance: number;
  104299. }, f2: {
  104300. ind: number;
  104301. sqDistance: number;
  104302. }) => number;
  104303. facetDepthSortFrom: Vector3;
  104304. facetDepthSortOrigin: Vector3;
  104305. invertedMatrix: Matrix;
  104306. }
  104307. /**
  104308. * @hidden
  104309. **/
  104310. class _InternalAbstractMeshDataInfo {
  104311. _hasVertexAlpha: boolean;
  104312. _useVertexColors: boolean;
  104313. _numBoneInfluencers: number;
  104314. _applyFog: boolean;
  104315. _receiveShadows: boolean;
  104316. _facetData: _FacetDataStorage;
  104317. _visibility: number;
  104318. _skeleton: Nullable<Skeleton>;
  104319. _layerMask: number;
  104320. _computeBonesUsingShaders: boolean;
  104321. _isActive: boolean;
  104322. _onlyForInstances: boolean;
  104323. _isActiveIntermediate: boolean;
  104324. _onlyForInstancesIntermediate: boolean;
  104325. _actAsRegularMesh: boolean;
  104326. }
  104327. /**
  104328. * Class used to store all common mesh properties
  104329. */
  104330. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104331. /** No occlusion */
  104332. static OCCLUSION_TYPE_NONE: number;
  104333. /** Occlusion set to optimisitic */
  104334. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104335. /** Occlusion set to strict */
  104336. static OCCLUSION_TYPE_STRICT: number;
  104337. /** Use an accurante occlusion algorithm */
  104338. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104339. /** Use a conservative occlusion algorithm */
  104340. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104341. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104342. * Test order :
  104343. * Is the bounding sphere outside the frustum ?
  104344. * If not, are the bounding box vertices outside the frustum ?
  104345. * It not, then the cullable object is in the frustum.
  104346. */
  104347. static readonly CULLINGSTRATEGY_STANDARD: number;
  104348. /** Culling strategy : Bounding Sphere Only.
  104349. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104350. * It's also less accurate than the standard because some not visible objects can still be selected.
  104351. * Test : is the bounding sphere outside the frustum ?
  104352. * If not, then the cullable object is in the frustum.
  104353. */
  104354. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104355. /** Culling strategy : Optimistic Inclusion.
  104356. * This in an inclusion test first, then the standard exclusion test.
  104357. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104358. * 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.
  104359. * Anyway, it's as accurate as the standard strategy.
  104360. * Test :
  104361. * Is the cullable object bounding sphere center in the frustum ?
  104362. * If not, apply the default culling strategy.
  104363. */
  104364. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104365. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104366. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104367. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104368. * 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.
  104369. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104370. * Test :
  104371. * Is the cullable object bounding sphere center in the frustum ?
  104372. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104373. */
  104374. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104375. /**
  104376. * No billboard
  104377. */
  104378. static get BILLBOARDMODE_NONE(): number;
  104379. /** Billboard on X axis */
  104380. static get BILLBOARDMODE_X(): number;
  104381. /** Billboard on Y axis */
  104382. static get BILLBOARDMODE_Y(): number;
  104383. /** Billboard on Z axis */
  104384. static get BILLBOARDMODE_Z(): number;
  104385. /** Billboard on all axes */
  104386. static get BILLBOARDMODE_ALL(): number;
  104387. /** Billboard on using position instead of orientation */
  104388. static get BILLBOARDMODE_USE_POSITION(): number;
  104389. /** @hidden */
  104390. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104391. /**
  104392. * The culling strategy to use to check whether the mesh must be rendered or not.
  104393. * This value can be changed at any time and will be used on the next render mesh selection.
  104394. * The possible values are :
  104395. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104396. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104397. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104399. * Please read each static variable documentation to get details about the culling process.
  104400. * */
  104401. cullingStrategy: number;
  104402. /**
  104403. * Gets the number of facets in the mesh
  104404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104405. */
  104406. get facetNb(): number;
  104407. /**
  104408. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104410. */
  104411. get partitioningSubdivisions(): number;
  104412. set partitioningSubdivisions(nb: number);
  104413. /**
  104414. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104415. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104417. */
  104418. get partitioningBBoxRatio(): number;
  104419. set partitioningBBoxRatio(ratio: number);
  104420. /**
  104421. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104422. * Works only for updatable meshes.
  104423. * Doesn't work with multi-materials
  104424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104425. */
  104426. get mustDepthSortFacets(): boolean;
  104427. set mustDepthSortFacets(sort: boolean);
  104428. /**
  104429. * The location (Vector3) where the facet depth sort must be computed from.
  104430. * By default, the active camera position.
  104431. * Used only when facet depth sort is enabled
  104432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104433. */
  104434. get facetDepthSortFrom(): Vector3;
  104435. set facetDepthSortFrom(location: Vector3);
  104436. /**
  104437. * gets a boolean indicating if facetData is enabled
  104438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104439. */
  104440. get isFacetDataEnabled(): boolean;
  104441. /** @hidden */
  104442. _updateNonUniformScalingState(value: boolean): boolean;
  104443. /**
  104444. * An event triggered when this mesh collides with another one
  104445. */
  104446. onCollideObservable: Observable<AbstractMesh>;
  104447. /** Set a function to call when this mesh collides with another one */
  104448. set onCollide(callback: () => void);
  104449. /**
  104450. * An event triggered when the collision's position changes
  104451. */
  104452. onCollisionPositionChangeObservable: Observable<Vector3>;
  104453. /** Set a function to call when the collision's position changes */
  104454. set onCollisionPositionChange(callback: () => void);
  104455. /**
  104456. * An event triggered when material is changed
  104457. */
  104458. onMaterialChangedObservable: Observable<AbstractMesh>;
  104459. /**
  104460. * Gets or sets the orientation for POV movement & rotation
  104461. */
  104462. definedFacingForward: boolean;
  104463. /** @hidden */
  104464. _occlusionQuery: Nullable<WebGLQuery>;
  104465. /** @hidden */
  104466. _renderingGroup: Nullable<RenderingGroup>;
  104467. /**
  104468. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104469. */
  104470. get visibility(): number;
  104471. /**
  104472. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104473. */
  104474. set visibility(value: number);
  104475. /** Gets or sets the alpha index used to sort transparent meshes
  104476. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104477. */
  104478. alphaIndex: number;
  104479. /**
  104480. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104481. */
  104482. isVisible: boolean;
  104483. /**
  104484. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104485. */
  104486. isPickable: boolean;
  104487. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104488. showSubMeshesBoundingBox: boolean;
  104489. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104490. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104491. */
  104492. isBlocker: boolean;
  104493. /**
  104494. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104495. */
  104496. enablePointerMoveEvents: boolean;
  104497. /**
  104498. * Specifies the rendering group id for this mesh (0 by default)
  104499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104500. */
  104501. renderingGroupId: number;
  104502. private _material;
  104503. /** Gets or sets current material */
  104504. get material(): Nullable<Material>;
  104505. set material(value: Nullable<Material>);
  104506. /**
  104507. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104508. * @see http://doc.babylonjs.com/babylon101/shadows
  104509. */
  104510. get receiveShadows(): boolean;
  104511. set receiveShadows(value: boolean);
  104512. /** Defines color to use when rendering outline */
  104513. outlineColor: Color3;
  104514. /** Define width to use when rendering outline */
  104515. outlineWidth: number;
  104516. /** Defines color to use when rendering overlay */
  104517. overlayColor: Color3;
  104518. /** Defines alpha to use when rendering overlay */
  104519. overlayAlpha: number;
  104520. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104521. get hasVertexAlpha(): boolean;
  104522. set hasVertexAlpha(value: boolean);
  104523. /** 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) */
  104524. get useVertexColors(): boolean;
  104525. set useVertexColors(value: boolean);
  104526. /**
  104527. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104528. */
  104529. get computeBonesUsingShaders(): boolean;
  104530. set computeBonesUsingShaders(value: boolean);
  104531. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104532. get numBoneInfluencers(): number;
  104533. set numBoneInfluencers(value: number);
  104534. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104535. get applyFog(): boolean;
  104536. set applyFog(value: boolean);
  104537. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104538. useOctreeForRenderingSelection: boolean;
  104539. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104540. useOctreeForPicking: boolean;
  104541. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104542. useOctreeForCollisions: boolean;
  104543. /**
  104544. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104545. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104546. */
  104547. get layerMask(): number;
  104548. set layerMask(value: number);
  104549. /**
  104550. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104551. */
  104552. alwaysSelectAsActiveMesh: boolean;
  104553. /**
  104554. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104555. */
  104556. doNotSyncBoundingInfo: boolean;
  104557. /**
  104558. * Gets or sets the current action manager
  104559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104560. */
  104561. actionManager: Nullable<AbstractActionManager>;
  104562. private _meshCollisionData;
  104563. /**
  104564. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104566. */
  104567. ellipsoid: Vector3;
  104568. /**
  104569. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104571. */
  104572. ellipsoidOffset: Vector3;
  104573. /**
  104574. * Gets or sets a collision mask used to mask collisions (default is -1).
  104575. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104576. */
  104577. get collisionMask(): number;
  104578. set collisionMask(mask: number);
  104579. /**
  104580. * Gets or sets the current collision group mask (-1 by default).
  104581. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104582. */
  104583. get collisionGroup(): number;
  104584. set collisionGroup(mask: number);
  104585. /**
  104586. * Gets or sets current surrounding meshes (null by default).
  104587. *
  104588. * By default collision detection is tested against every mesh in the scene.
  104589. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104590. * meshes will be tested for the collision.
  104591. *
  104592. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104593. */
  104594. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104595. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104596. /**
  104597. * Defines edge width used when edgesRenderer is enabled
  104598. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104599. */
  104600. edgesWidth: number;
  104601. /**
  104602. * Defines edge color used when edgesRenderer is enabled
  104603. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104604. */
  104605. edgesColor: Color4;
  104606. /** @hidden */
  104607. _edgesRenderer: Nullable<IEdgesRenderer>;
  104608. /** @hidden */
  104609. _masterMesh: Nullable<AbstractMesh>;
  104610. /** @hidden */
  104611. _boundingInfo: Nullable<BoundingInfo>;
  104612. /** @hidden */
  104613. _renderId: number;
  104614. /**
  104615. * Gets or sets the list of subMeshes
  104616. * @see http://doc.babylonjs.com/how_to/multi_materials
  104617. */
  104618. subMeshes: SubMesh[];
  104619. /** @hidden */
  104620. _intersectionsInProgress: AbstractMesh[];
  104621. /** @hidden */
  104622. _unIndexed: boolean;
  104623. /** @hidden */
  104624. _lightSources: Light[];
  104625. /** Gets the list of lights affecting that mesh */
  104626. get lightSources(): Light[];
  104627. /** @hidden */
  104628. get _positions(): Nullable<Vector3[]>;
  104629. /** @hidden */
  104630. _waitingData: {
  104631. lods: Nullable<any>;
  104632. actions: Nullable<any>;
  104633. freezeWorldMatrix: Nullable<boolean>;
  104634. };
  104635. /** @hidden */
  104636. _bonesTransformMatrices: Nullable<Float32Array>;
  104637. /** @hidden */
  104638. _transformMatrixTexture: Nullable<RawTexture>;
  104639. /**
  104640. * Gets or sets a skeleton to apply skining transformations
  104641. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104642. */
  104643. set skeleton(value: Nullable<Skeleton>);
  104644. get skeleton(): Nullable<Skeleton>;
  104645. /**
  104646. * An event triggered when the mesh is rebuilt.
  104647. */
  104648. onRebuildObservable: Observable<AbstractMesh>;
  104649. /**
  104650. * Creates a new AbstractMesh
  104651. * @param name defines the name of the mesh
  104652. * @param scene defines the hosting scene
  104653. */
  104654. constructor(name: string, scene?: Nullable<Scene>);
  104655. /**
  104656. * Returns the string "AbstractMesh"
  104657. * @returns "AbstractMesh"
  104658. */
  104659. getClassName(): string;
  104660. /**
  104661. * Gets a string representation of the current mesh
  104662. * @param fullDetails defines a boolean indicating if full details must be included
  104663. * @returns a string representation of the current mesh
  104664. */
  104665. toString(fullDetails?: boolean): string;
  104666. /**
  104667. * @hidden
  104668. */
  104669. protected _getEffectiveParent(): Nullable<Node>;
  104670. /** @hidden */
  104671. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104672. /** @hidden */
  104673. _rebuild(): void;
  104674. /** @hidden */
  104675. _resyncLightSources(): void;
  104676. /** @hidden */
  104677. _resyncLightSource(light: Light): void;
  104678. /** @hidden */
  104679. _unBindEffect(): void;
  104680. /** @hidden */
  104681. _removeLightSource(light: Light, dispose: boolean): void;
  104682. private _markSubMeshesAsDirty;
  104683. /** @hidden */
  104684. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104685. /** @hidden */
  104686. _markSubMeshesAsAttributesDirty(): void;
  104687. /** @hidden */
  104688. _markSubMeshesAsMiscDirty(): void;
  104689. /**
  104690. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104691. */
  104692. get scaling(): Vector3;
  104693. set scaling(newScaling: Vector3);
  104694. /**
  104695. * Returns true if the mesh is blocked. Implemented by child classes
  104696. */
  104697. get isBlocked(): boolean;
  104698. /**
  104699. * Returns the mesh itself by default. Implemented by child classes
  104700. * @param camera defines the camera to use to pick the right LOD level
  104701. * @returns the currentAbstractMesh
  104702. */
  104703. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104704. /**
  104705. * Returns 0 by default. Implemented by child classes
  104706. * @returns an integer
  104707. */
  104708. getTotalVertices(): number;
  104709. /**
  104710. * Returns a positive integer : the total number of indices in this mesh geometry.
  104711. * @returns the numner of indices or zero if the mesh has no geometry.
  104712. */
  104713. getTotalIndices(): number;
  104714. /**
  104715. * Returns null by default. Implemented by child classes
  104716. * @returns null
  104717. */
  104718. getIndices(): Nullable<IndicesArray>;
  104719. /**
  104720. * Returns the array of the requested vertex data kind. Implemented by child classes
  104721. * @param kind defines the vertex data kind to use
  104722. * @returns null
  104723. */
  104724. getVerticesData(kind: string): Nullable<FloatArray>;
  104725. /**
  104726. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104727. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104728. * Note that a new underlying VertexBuffer object is created each call.
  104729. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104730. * @param kind defines vertex data kind:
  104731. * * VertexBuffer.PositionKind
  104732. * * VertexBuffer.UVKind
  104733. * * VertexBuffer.UV2Kind
  104734. * * VertexBuffer.UV3Kind
  104735. * * VertexBuffer.UV4Kind
  104736. * * VertexBuffer.UV5Kind
  104737. * * VertexBuffer.UV6Kind
  104738. * * VertexBuffer.ColorKind
  104739. * * VertexBuffer.MatricesIndicesKind
  104740. * * VertexBuffer.MatricesIndicesExtraKind
  104741. * * VertexBuffer.MatricesWeightsKind
  104742. * * VertexBuffer.MatricesWeightsExtraKind
  104743. * @param data defines the data source
  104744. * @param updatable defines if the data must be flagged as updatable (or static)
  104745. * @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
  104746. * @returns the current mesh
  104747. */
  104748. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104749. /**
  104750. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104751. * If the mesh has no geometry, it is simply returned as it is.
  104752. * @param kind defines vertex data kind:
  104753. * * VertexBuffer.PositionKind
  104754. * * VertexBuffer.UVKind
  104755. * * VertexBuffer.UV2Kind
  104756. * * VertexBuffer.UV3Kind
  104757. * * VertexBuffer.UV4Kind
  104758. * * VertexBuffer.UV5Kind
  104759. * * VertexBuffer.UV6Kind
  104760. * * VertexBuffer.ColorKind
  104761. * * VertexBuffer.MatricesIndicesKind
  104762. * * VertexBuffer.MatricesIndicesExtraKind
  104763. * * VertexBuffer.MatricesWeightsKind
  104764. * * VertexBuffer.MatricesWeightsExtraKind
  104765. * @param data defines the data source
  104766. * @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
  104767. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104768. * @returns the current mesh
  104769. */
  104770. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104771. /**
  104772. * Sets the mesh indices,
  104773. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104774. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104775. * @param totalVertices Defines the total number of vertices
  104776. * @returns the current mesh
  104777. */
  104778. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104779. /**
  104780. * Gets a boolean indicating if specific vertex data is present
  104781. * @param kind defines the vertex data kind to use
  104782. * @returns true is data kind is present
  104783. */
  104784. isVerticesDataPresent(kind: string): boolean;
  104785. /**
  104786. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104787. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104788. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104789. * @returns a BoundingInfo
  104790. */
  104791. getBoundingInfo(): BoundingInfo;
  104792. /**
  104793. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104794. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104795. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104796. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104797. * @returns the current mesh
  104798. */
  104799. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104800. /**
  104801. * Overwrite the current bounding info
  104802. * @param boundingInfo defines the new bounding info
  104803. * @returns the current mesh
  104804. */
  104805. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104806. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104807. get useBones(): boolean;
  104808. /** @hidden */
  104809. _preActivate(): void;
  104810. /** @hidden */
  104811. _preActivateForIntermediateRendering(renderId: number): void;
  104812. /** @hidden */
  104813. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104814. /** @hidden */
  104815. _postActivate(): void;
  104816. /** @hidden */
  104817. _freeze(): void;
  104818. /** @hidden */
  104819. _unFreeze(): void;
  104820. /**
  104821. * Gets the current world matrix
  104822. * @returns a Matrix
  104823. */
  104824. getWorldMatrix(): Matrix;
  104825. /** @hidden */
  104826. _getWorldMatrixDeterminant(): number;
  104827. /**
  104828. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104829. */
  104830. get isAnInstance(): boolean;
  104831. /**
  104832. * Gets a boolean indicating if this mesh has instances
  104833. */
  104834. get hasInstances(): boolean;
  104835. /**
  104836. * Perform relative position change from the point of view of behind the front of the mesh.
  104837. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104838. * Supports definition of mesh facing forward or backward
  104839. * @param amountRight defines the distance on the right axis
  104840. * @param amountUp defines the distance on the up axis
  104841. * @param amountForward defines the distance on the forward axis
  104842. * @returns the current mesh
  104843. */
  104844. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104845. /**
  104846. * Calculate relative position change from the point of view of behind the front of the mesh.
  104847. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104848. * Supports definition of mesh facing forward or backward
  104849. * @param amountRight defines the distance on the right axis
  104850. * @param amountUp defines the distance on the up axis
  104851. * @param amountForward defines the distance on the forward axis
  104852. * @returns the new displacement vector
  104853. */
  104854. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104855. /**
  104856. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104857. * Supports definition of mesh facing forward or backward
  104858. * @param flipBack defines the flip
  104859. * @param twirlClockwise defines the twirl
  104860. * @param tiltRight defines the tilt
  104861. * @returns the current mesh
  104862. */
  104863. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104864. /**
  104865. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104866. * Supports definition of mesh facing forward or backward.
  104867. * @param flipBack defines the flip
  104868. * @param twirlClockwise defines the twirl
  104869. * @param tiltRight defines the tilt
  104870. * @returns the new rotation vector
  104871. */
  104872. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104873. /**
  104874. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104875. * This means the mesh underlying bounding box and sphere are recomputed.
  104876. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104877. * @returns the current mesh
  104878. */
  104879. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104880. /** @hidden */
  104881. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104882. /** @hidden */
  104883. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104884. /** @hidden */
  104885. _updateBoundingInfo(): AbstractMesh;
  104886. /** @hidden */
  104887. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104888. /** @hidden */
  104889. protected _afterComputeWorldMatrix(): void;
  104890. /** @hidden */
  104891. get _effectiveMesh(): AbstractMesh;
  104892. /**
  104893. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104894. * A mesh is in the frustum if its bounding box intersects the frustum
  104895. * @param frustumPlanes defines the frustum to test
  104896. * @returns true if the mesh is in the frustum planes
  104897. */
  104898. isInFrustum(frustumPlanes: Plane[]): boolean;
  104899. /**
  104900. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104901. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104902. * @param frustumPlanes defines the frustum to test
  104903. * @returns true if the mesh is completely in the frustum planes
  104904. */
  104905. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104906. /**
  104907. * True if the mesh intersects another mesh or a SolidParticle object
  104908. * @param mesh defines a target mesh or SolidParticle to test
  104909. * @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)
  104910. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104911. * @returns true if there is an intersection
  104912. */
  104913. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104914. /**
  104915. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104916. * @param point defines the point to test
  104917. * @returns true if there is an intersection
  104918. */
  104919. intersectsPoint(point: Vector3): boolean;
  104920. /**
  104921. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104923. */
  104924. get checkCollisions(): boolean;
  104925. set checkCollisions(collisionEnabled: boolean);
  104926. /**
  104927. * Gets Collider object used to compute collisions (not physics)
  104928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104929. */
  104930. get collider(): Nullable<Collider>;
  104931. /**
  104932. * Move the mesh using collision engine
  104933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104934. * @param displacement defines the requested displacement vector
  104935. * @returns the current mesh
  104936. */
  104937. moveWithCollisions(displacement: Vector3): AbstractMesh;
  104938. private _onCollisionPositionChange;
  104939. /** @hidden */
  104940. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  104941. /** @hidden */
  104942. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  104943. /** @hidden */
  104944. _checkCollision(collider: Collider): AbstractMesh;
  104945. /** @hidden */
  104946. _generatePointsArray(): boolean;
  104947. /**
  104948. * Checks if the passed Ray intersects with the mesh
  104949. * @param ray defines the ray to use
  104950. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  104951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104952. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  104953. * @returns the picking info
  104954. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  104955. */
  104956. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  104957. /**
  104958. * Clones the current mesh
  104959. * @param name defines the mesh name
  104960. * @param newParent defines the new mesh parent
  104961. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  104962. * @returns the new mesh
  104963. */
  104964. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  104965. /**
  104966. * Disposes all the submeshes of the current meshnp
  104967. * @returns the current mesh
  104968. */
  104969. releaseSubMeshes(): AbstractMesh;
  104970. /**
  104971. * Releases resources associated with this abstract mesh.
  104972. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104973. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104974. */
  104975. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104976. /**
  104977. * Adds the passed mesh as a child to the current mesh
  104978. * @param mesh defines the child mesh
  104979. * @returns the current mesh
  104980. */
  104981. addChild(mesh: AbstractMesh): AbstractMesh;
  104982. /**
  104983. * Removes the passed mesh from the current mesh children list
  104984. * @param mesh defines the child mesh
  104985. * @returns the current mesh
  104986. */
  104987. removeChild(mesh: AbstractMesh): AbstractMesh;
  104988. /** @hidden */
  104989. private _initFacetData;
  104990. /**
  104991. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  104992. * This method can be called within the render loop.
  104993. * 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
  104994. * @returns the current mesh
  104995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104996. */
  104997. updateFacetData(): AbstractMesh;
  104998. /**
  104999. * Returns the facetLocalNormals array.
  105000. * The normals are expressed in the mesh local spac
  105001. * @returns an array of Vector3
  105002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105003. */
  105004. getFacetLocalNormals(): Vector3[];
  105005. /**
  105006. * Returns the facetLocalPositions array.
  105007. * The facet positions are expressed in the mesh local space
  105008. * @returns an array of Vector3
  105009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105010. */
  105011. getFacetLocalPositions(): Vector3[];
  105012. /**
  105013. * Returns the facetLocalPartioning array
  105014. * @returns an array of array of numbers
  105015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105016. */
  105017. getFacetLocalPartitioning(): number[][];
  105018. /**
  105019. * Returns the i-th facet position in the world system.
  105020. * This method allocates a new Vector3 per call
  105021. * @param i defines the facet index
  105022. * @returns a new Vector3
  105023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105024. */
  105025. getFacetPosition(i: number): Vector3;
  105026. /**
  105027. * Sets the reference Vector3 with the i-th facet position in the world system
  105028. * @param i defines the facet index
  105029. * @param ref defines the target vector
  105030. * @returns the current mesh
  105031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105032. */
  105033. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  105034. /**
  105035. * Returns the i-th facet normal in the world system.
  105036. * This method allocates a new Vector3 per call
  105037. * @param i defines the facet index
  105038. * @returns a new Vector3
  105039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105040. */
  105041. getFacetNormal(i: number): Vector3;
  105042. /**
  105043. * Sets the reference Vector3 with the i-th facet normal in the world system
  105044. * @param i defines the facet index
  105045. * @param ref defines the target vector
  105046. * @returns the current mesh
  105047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105048. */
  105049. getFacetNormalToRef(i: number, ref: Vector3): this;
  105050. /**
  105051. * 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)
  105052. * @param x defines x coordinate
  105053. * @param y defines y coordinate
  105054. * @param z defines z coordinate
  105055. * @returns the array of facet indexes
  105056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105057. */
  105058. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  105059. /**
  105060. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  105061. * @param projected sets as the (x,y,z) world projection on the facet
  105062. * @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
  105063. * @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
  105064. * @param x defines x coordinate
  105065. * @param y defines y coordinate
  105066. * @param z defines z coordinate
  105067. * @returns the face index if found (or null instead)
  105068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105069. */
  105070. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105071. /**
  105072. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  105073. * @param projected sets as the (x,y,z) local projection on the facet
  105074. * @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
  105075. * @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
  105076. * @param x defines x coordinate
  105077. * @param y defines y coordinate
  105078. * @param z defines z coordinate
  105079. * @returns the face index if found (or null instead)
  105080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105081. */
  105082. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  105083. /**
  105084. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  105085. * @returns the parameters
  105086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105087. */
  105088. getFacetDataParameters(): any;
  105089. /**
  105090. * Disables the feature FacetData and frees the related memory
  105091. * @returns the current mesh
  105092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  105093. */
  105094. disableFacetData(): AbstractMesh;
  105095. /**
  105096. * Updates the AbstractMesh indices array
  105097. * @param indices defines the data source
  105098. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105099. * @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)
  105100. * @returns the current mesh
  105101. */
  105102. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105103. /**
  105104. * Creates new normals data for the mesh
  105105. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  105106. * @returns the current mesh
  105107. */
  105108. createNormals(updatable: boolean): AbstractMesh;
  105109. /**
  105110. * Align the mesh with a normal
  105111. * @param normal defines the normal to use
  105112. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  105113. * @returns the current mesh
  105114. */
  105115. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  105116. /** @hidden */
  105117. _checkOcclusionQuery(): boolean;
  105118. /**
  105119. * Disables the mesh edge rendering mode
  105120. * @returns the currentAbstractMesh
  105121. */
  105122. disableEdgesRendering(): AbstractMesh;
  105123. /**
  105124. * Enables the edge rendering mode on the mesh.
  105125. * This mode makes the mesh edges visible
  105126. * @param epsilon defines the maximal distance between two angles to detect a face
  105127. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  105128. * @returns the currentAbstractMesh
  105129. * @see https://www.babylonjs-playground.com/#19O9TU#0
  105130. */
  105131. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Interface used to define ActionEvent
  105137. */
  105138. export interface IActionEvent {
  105139. /** The mesh or sprite that triggered the action */
  105140. source: any;
  105141. /** The X mouse cursor position at the time of the event */
  105142. pointerX: number;
  105143. /** The Y mouse cursor position at the time of the event */
  105144. pointerY: number;
  105145. /** The mesh that is currently pointed at (can be null) */
  105146. meshUnderPointer: Nullable<AbstractMesh>;
  105147. /** the original (browser) event that triggered the ActionEvent */
  105148. sourceEvent?: any;
  105149. /** additional data for the event */
  105150. additionalData?: any;
  105151. }
  105152. /**
  105153. * ActionEvent is the event being sent when an action is triggered.
  105154. */
  105155. export class ActionEvent implements IActionEvent {
  105156. /** The mesh or sprite that triggered the action */
  105157. source: any;
  105158. /** The X mouse cursor position at the time of the event */
  105159. pointerX: number;
  105160. /** The Y mouse cursor position at the time of the event */
  105161. pointerY: number;
  105162. /** The mesh that is currently pointed at (can be null) */
  105163. meshUnderPointer: Nullable<AbstractMesh>;
  105164. /** the original (browser) event that triggered the ActionEvent */
  105165. sourceEvent?: any;
  105166. /** additional data for the event */
  105167. additionalData?: any;
  105168. /**
  105169. * Creates a new ActionEvent
  105170. * @param source The mesh or sprite that triggered the action
  105171. * @param pointerX The X mouse cursor position at the time of the event
  105172. * @param pointerY The Y mouse cursor position at the time of the event
  105173. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  105174. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  105175. * @param additionalData additional data for the event
  105176. */
  105177. constructor(
  105178. /** The mesh or sprite that triggered the action */
  105179. source: any,
  105180. /** The X mouse cursor position at the time of the event */
  105181. pointerX: number,
  105182. /** The Y mouse cursor position at the time of the event */
  105183. pointerY: number,
  105184. /** The mesh that is currently pointed at (can be null) */
  105185. meshUnderPointer: Nullable<AbstractMesh>,
  105186. /** the original (browser) event that triggered the ActionEvent */
  105187. sourceEvent?: any,
  105188. /** additional data for the event */
  105189. additionalData?: any);
  105190. /**
  105191. * Helper function to auto-create an ActionEvent from a source mesh.
  105192. * @param source The source mesh that triggered the event
  105193. * @param evt The original (browser) event
  105194. * @param additionalData additional data for the event
  105195. * @returns the new ActionEvent
  105196. */
  105197. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  105198. /**
  105199. * Helper function to auto-create an ActionEvent from a source sprite
  105200. * @param source The source sprite that triggered the event
  105201. * @param scene Scene associated with the sprite
  105202. * @param evt The original (browser) event
  105203. * @param additionalData additional data for the event
  105204. * @returns the new ActionEvent
  105205. */
  105206. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  105207. /**
  105208. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  105209. * @param scene the scene where the event occurred
  105210. * @param evt The original (browser) event
  105211. * @returns the new ActionEvent
  105212. */
  105213. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105214. /**
  105215. * Helper function to auto-create an ActionEvent from a primitive
  105216. * @param prim defines the target primitive
  105217. * @param pointerPos defines the pointer position
  105218. * @param evt The original (browser) event
  105219. * @param additionalData additional data for the event
  105220. * @returns the new ActionEvent
  105221. */
  105222. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105223. }
  105224. }
  105225. declare module BABYLON {
  105226. /**
  105227. * Abstract class used to decouple action Manager from scene and meshes.
  105228. * Do not instantiate.
  105229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105230. */
  105231. export abstract class AbstractActionManager implements IDisposable {
  105232. /** Gets the list of active triggers */
  105233. static Triggers: {
  105234. [key: string]: number;
  105235. };
  105236. /** Gets the cursor to use when hovering items */
  105237. hoverCursor: string;
  105238. /** Gets the list of actions */
  105239. actions: IAction[];
  105240. /**
  105241. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105242. */
  105243. isRecursive: boolean;
  105244. /**
  105245. * Releases all associated resources
  105246. */
  105247. abstract dispose(): void;
  105248. /**
  105249. * Does this action manager has pointer triggers
  105250. */
  105251. abstract get hasPointerTriggers(): boolean;
  105252. /**
  105253. * Does this action manager has pick triggers
  105254. */
  105255. abstract get hasPickTriggers(): boolean;
  105256. /**
  105257. * Process a specific trigger
  105258. * @param trigger defines the trigger to process
  105259. * @param evt defines the event details to be processed
  105260. */
  105261. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105262. /**
  105263. * Does this action manager handles actions of any of the given triggers
  105264. * @param triggers defines the triggers to be tested
  105265. * @return a boolean indicating whether one (or more) of the triggers is handled
  105266. */
  105267. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105268. /**
  105269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105270. * speed.
  105271. * @param triggerA defines the trigger to be tested
  105272. * @param triggerB defines the trigger to be tested
  105273. * @return a boolean indicating whether one (or more) of the triggers is handled
  105274. */
  105275. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105276. /**
  105277. * Does this action manager handles actions of a given trigger
  105278. * @param trigger defines the trigger to be tested
  105279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105280. * @return whether the trigger is handled
  105281. */
  105282. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105283. /**
  105284. * Serialize this manager to a JSON object
  105285. * @param name defines the property name to store this manager
  105286. * @returns a JSON representation of this manager
  105287. */
  105288. abstract serialize(name: string): any;
  105289. /**
  105290. * Registers an action to this action manager
  105291. * @param action defines the action to be registered
  105292. * @return the action amended (prepared) after registration
  105293. */
  105294. abstract registerAction(action: IAction): Nullable<IAction>;
  105295. /**
  105296. * Unregisters an action to this action manager
  105297. * @param action defines the action to be unregistered
  105298. * @return a boolean indicating whether the action has been unregistered
  105299. */
  105300. abstract unregisterAction(action: IAction): Boolean;
  105301. /**
  105302. * Does exist one action manager with at least one trigger
  105303. **/
  105304. static get HasTriggers(): boolean;
  105305. /**
  105306. * Does exist one action manager with at least one pick trigger
  105307. **/
  105308. static get HasPickTriggers(): boolean;
  105309. /**
  105310. * Does exist one action manager that handles actions of a given trigger
  105311. * @param trigger defines the trigger to be tested
  105312. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105313. **/
  105314. static HasSpecificTrigger(trigger: number): boolean;
  105315. }
  105316. }
  105317. declare module BABYLON {
  105318. /**
  105319. * Defines how a node can be built from a string name.
  105320. */
  105321. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105322. /**
  105323. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105324. */
  105325. export class Node implements IBehaviorAware<Node> {
  105326. /** @hidden */
  105327. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105328. private static _NodeConstructors;
  105329. /**
  105330. * Add a new node constructor
  105331. * @param type defines the type name of the node to construct
  105332. * @param constructorFunc defines the constructor function
  105333. */
  105334. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105335. /**
  105336. * Returns a node constructor based on type name
  105337. * @param type defines the type name
  105338. * @param name defines the new node name
  105339. * @param scene defines the hosting scene
  105340. * @param options defines optional options to transmit to constructors
  105341. * @returns the new constructor or null
  105342. */
  105343. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105344. /**
  105345. * Gets or sets the name of the node
  105346. */
  105347. name: string;
  105348. /**
  105349. * Gets or sets the id of the node
  105350. */
  105351. id: string;
  105352. /**
  105353. * Gets or sets the unique id of the node
  105354. */
  105355. uniqueId: number;
  105356. /**
  105357. * Gets or sets a string used to store user defined state for the node
  105358. */
  105359. state: string;
  105360. /**
  105361. * Gets or sets an object used to store user defined information for the node
  105362. */
  105363. metadata: any;
  105364. /**
  105365. * For internal use only. Please do not use.
  105366. */
  105367. reservedDataStore: any;
  105368. /**
  105369. * List of inspectable custom properties (used by the Inspector)
  105370. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105371. */
  105372. inspectableCustomProperties: IInspectable[];
  105373. private _doNotSerialize;
  105374. /**
  105375. * Gets or sets a boolean used to define if the node must be serialized
  105376. */
  105377. get doNotSerialize(): boolean;
  105378. set doNotSerialize(value: boolean);
  105379. /** @hidden */
  105380. _isDisposed: boolean;
  105381. /**
  105382. * Gets a list of Animations associated with the node
  105383. */
  105384. animations: Animation[];
  105385. protected _ranges: {
  105386. [name: string]: Nullable<AnimationRange>;
  105387. };
  105388. /**
  105389. * Callback raised when the node is ready to be used
  105390. */
  105391. onReady: Nullable<(node: Node) => void>;
  105392. private _isEnabled;
  105393. private _isParentEnabled;
  105394. private _isReady;
  105395. /** @hidden */
  105396. _currentRenderId: number;
  105397. private _parentUpdateId;
  105398. /** @hidden */
  105399. _childUpdateId: number;
  105400. /** @hidden */
  105401. _waitingParentId: Nullable<string>;
  105402. /** @hidden */
  105403. _scene: Scene;
  105404. /** @hidden */
  105405. _cache: any;
  105406. private _parentNode;
  105407. private _children;
  105408. /** @hidden */
  105409. _worldMatrix: Matrix;
  105410. /** @hidden */
  105411. _worldMatrixDeterminant: number;
  105412. /** @hidden */
  105413. _worldMatrixDeterminantIsDirty: boolean;
  105414. /** @hidden */
  105415. private _sceneRootNodesIndex;
  105416. /**
  105417. * Gets a boolean indicating if the node has been disposed
  105418. * @returns true if the node was disposed
  105419. */
  105420. isDisposed(): boolean;
  105421. /**
  105422. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105423. * @see https://doc.babylonjs.com/how_to/parenting
  105424. */
  105425. set parent(parent: Nullable<Node>);
  105426. get parent(): Nullable<Node>;
  105427. /** @hidden */
  105428. _addToSceneRootNodes(): void;
  105429. /** @hidden */
  105430. _removeFromSceneRootNodes(): void;
  105431. private _animationPropertiesOverride;
  105432. /**
  105433. * Gets or sets the animation properties override
  105434. */
  105435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105436. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105437. /**
  105438. * Gets a string idenfifying the name of the class
  105439. * @returns "Node" string
  105440. */
  105441. getClassName(): string;
  105442. /** @hidden */
  105443. readonly _isNode: boolean;
  105444. /**
  105445. * An event triggered when the mesh is disposed
  105446. */
  105447. onDisposeObservable: Observable<Node>;
  105448. private _onDisposeObserver;
  105449. /**
  105450. * Sets a callback that will be raised when the node will be disposed
  105451. */
  105452. set onDispose(callback: () => void);
  105453. /**
  105454. * Creates a new Node
  105455. * @param name the name and id to be given to this node
  105456. * @param scene the scene this node will be added to
  105457. */
  105458. constructor(name: string, scene?: Nullable<Scene>);
  105459. /**
  105460. * Gets the scene of the node
  105461. * @returns a scene
  105462. */
  105463. getScene(): Scene;
  105464. /**
  105465. * Gets the engine of the node
  105466. * @returns a Engine
  105467. */
  105468. getEngine(): Engine;
  105469. private _behaviors;
  105470. /**
  105471. * Attach a behavior to the node
  105472. * @see http://doc.babylonjs.com/features/behaviour
  105473. * @param behavior defines the behavior to attach
  105474. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105475. * @returns the current Node
  105476. */
  105477. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105478. /**
  105479. * Remove an attached behavior
  105480. * @see http://doc.babylonjs.com/features/behaviour
  105481. * @param behavior defines the behavior to attach
  105482. * @returns the current Node
  105483. */
  105484. removeBehavior(behavior: Behavior<Node>): Node;
  105485. /**
  105486. * Gets the list of attached behaviors
  105487. * @see http://doc.babylonjs.com/features/behaviour
  105488. */
  105489. get behaviors(): Behavior<Node>[];
  105490. /**
  105491. * Gets an attached behavior by name
  105492. * @param name defines the name of the behavior to look for
  105493. * @see http://doc.babylonjs.com/features/behaviour
  105494. * @returns null if behavior was not found else the requested behavior
  105495. */
  105496. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105497. /**
  105498. * Returns the latest update of the World matrix
  105499. * @returns a Matrix
  105500. */
  105501. getWorldMatrix(): Matrix;
  105502. /** @hidden */
  105503. _getWorldMatrixDeterminant(): number;
  105504. /**
  105505. * Returns directly the latest state of the mesh World matrix.
  105506. * A Matrix is returned.
  105507. */
  105508. get worldMatrixFromCache(): Matrix;
  105509. /** @hidden */
  105510. _initCache(): void;
  105511. /** @hidden */
  105512. updateCache(force?: boolean): void;
  105513. /** @hidden */
  105514. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105515. /** @hidden */
  105516. _updateCache(ignoreParentClass?: boolean): void;
  105517. /** @hidden */
  105518. _isSynchronized(): boolean;
  105519. /** @hidden */
  105520. _markSyncedWithParent(): void;
  105521. /** @hidden */
  105522. isSynchronizedWithParent(): boolean;
  105523. /** @hidden */
  105524. isSynchronized(): boolean;
  105525. /**
  105526. * Is this node ready to be used/rendered
  105527. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105528. * @return true if the node is ready
  105529. */
  105530. isReady(completeCheck?: boolean): boolean;
  105531. /**
  105532. * Is this node enabled?
  105533. * 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
  105534. * @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
  105535. * @return whether this node (and its parent) is enabled
  105536. */
  105537. isEnabled(checkAncestors?: boolean): boolean;
  105538. /** @hidden */
  105539. protected _syncParentEnabledState(): void;
  105540. /**
  105541. * Set the enabled state of this node
  105542. * @param value defines the new enabled state
  105543. */
  105544. setEnabled(value: boolean): void;
  105545. /**
  105546. * Is this node a descendant of the given node?
  105547. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105548. * @param ancestor defines the parent node to inspect
  105549. * @returns a boolean indicating if this node is a descendant of the given node
  105550. */
  105551. isDescendantOf(ancestor: Node): boolean;
  105552. /** @hidden */
  105553. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105554. /**
  105555. * Will return all nodes that have this node as ascendant
  105556. * @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
  105557. * @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
  105558. * @return all children nodes of all types
  105559. */
  105560. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105561. /**
  105562. * Get all child-meshes of this node
  105563. * @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)
  105564. * @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
  105565. * @returns an array of AbstractMesh
  105566. */
  105567. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105568. /**
  105569. * Get all direct children of this node
  105570. * @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
  105571. * @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)
  105572. * @returns an array of Node
  105573. */
  105574. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105575. /** @hidden */
  105576. _setReady(state: boolean): void;
  105577. /**
  105578. * Get an animation by name
  105579. * @param name defines the name of the animation to look for
  105580. * @returns null if not found else the requested animation
  105581. */
  105582. getAnimationByName(name: string): Nullable<Animation>;
  105583. /**
  105584. * Creates an animation range for this node
  105585. * @param name defines the name of the range
  105586. * @param from defines the starting key
  105587. * @param to defines the end key
  105588. */
  105589. createAnimationRange(name: string, from: number, to: number): void;
  105590. /**
  105591. * Delete a specific animation range
  105592. * @param name defines the name of the range to delete
  105593. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105594. */
  105595. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105596. /**
  105597. * Get an animation range by name
  105598. * @param name defines the name of the animation range to look for
  105599. * @returns null if not found else the requested animation range
  105600. */
  105601. getAnimationRange(name: string): Nullable<AnimationRange>;
  105602. /**
  105603. * Gets the list of all animation ranges defined on this node
  105604. * @returns an array
  105605. */
  105606. getAnimationRanges(): Nullable<AnimationRange>[];
  105607. /**
  105608. * Will start the animation sequence
  105609. * @param name defines the range frames for animation sequence
  105610. * @param loop defines if the animation should loop (false by default)
  105611. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105612. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105613. * @returns the object created for this animation. If range does not exist, it will return null
  105614. */
  105615. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105616. /**
  105617. * Serialize animation ranges into a JSON compatible object
  105618. * @returns serialization object
  105619. */
  105620. serializeAnimationRanges(): any;
  105621. /**
  105622. * Computes the world matrix of the node
  105623. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105624. * @returns the world matrix
  105625. */
  105626. computeWorldMatrix(force?: boolean): Matrix;
  105627. /**
  105628. * Releases resources associated with this node.
  105629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105631. */
  105632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105633. /**
  105634. * Parse animation range data from a serialization object and store them into a given node
  105635. * @param node defines where to store the animation ranges
  105636. * @param parsedNode defines the serialization object to read data from
  105637. * @param scene defines the hosting scene
  105638. */
  105639. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105640. /**
  105641. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105642. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105643. * @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
  105644. * @returns the new bounding vectors
  105645. */
  105646. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105647. min: Vector3;
  105648. max: Vector3;
  105649. };
  105650. }
  105651. }
  105652. declare module BABYLON {
  105653. /**
  105654. * @hidden
  105655. */
  105656. export class _IAnimationState {
  105657. key: number;
  105658. repeatCount: number;
  105659. workValue?: any;
  105660. loopMode?: number;
  105661. offsetValue?: any;
  105662. highLimitValue?: any;
  105663. }
  105664. /**
  105665. * Class used to store any kind of animation
  105666. */
  105667. export class Animation {
  105668. /**Name of the animation */
  105669. name: string;
  105670. /**Property to animate */
  105671. targetProperty: string;
  105672. /**The frames per second of the animation */
  105673. framePerSecond: number;
  105674. /**The data type of the animation */
  105675. dataType: number;
  105676. /**The loop mode of the animation */
  105677. loopMode?: number | undefined;
  105678. /**Specifies if blending should be enabled */
  105679. enableBlending?: boolean | undefined;
  105680. /**
  105681. * Use matrix interpolation instead of using direct key value when animating matrices
  105682. */
  105683. static AllowMatricesInterpolation: boolean;
  105684. /**
  105685. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105686. */
  105687. static AllowMatrixDecomposeForInterpolation: boolean;
  105688. /**
  105689. * Stores the key frames of the animation
  105690. */
  105691. private _keys;
  105692. /**
  105693. * Stores the easing function of the animation
  105694. */
  105695. private _easingFunction;
  105696. /**
  105697. * @hidden Internal use only
  105698. */
  105699. _runtimeAnimations: RuntimeAnimation[];
  105700. /**
  105701. * The set of event that will be linked to this animation
  105702. */
  105703. private _events;
  105704. /**
  105705. * Stores an array of target property paths
  105706. */
  105707. targetPropertyPath: string[];
  105708. /**
  105709. * Stores the blending speed of the animation
  105710. */
  105711. blendingSpeed: number;
  105712. /**
  105713. * Stores the animation ranges for the animation
  105714. */
  105715. private _ranges;
  105716. /**
  105717. * @hidden Internal use
  105718. */
  105719. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105720. /**
  105721. * Sets up an animation
  105722. * @param property The property to animate
  105723. * @param animationType The animation type to apply
  105724. * @param framePerSecond The frames per second of the animation
  105725. * @param easingFunction The easing function used in the animation
  105726. * @returns The created animation
  105727. */
  105728. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105729. /**
  105730. * Create and start an animation on a node
  105731. * @param name defines the name of the global animation that will be run on all nodes
  105732. * @param node defines the root node where the animation will take place
  105733. * @param targetProperty defines property to animate
  105734. * @param framePerSecond defines the number of frame per second yo use
  105735. * @param totalFrame defines the number of frames in total
  105736. * @param from defines the initial value
  105737. * @param to defines the final value
  105738. * @param loopMode defines which loop mode you want to use (off by default)
  105739. * @param easingFunction defines the easing function to use (linear by default)
  105740. * @param onAnimationEnd defines the callback to call when animation end
  105741. * @returns the animatable created for this animation
  105742. */
  105743. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105744. /**
  105745. * Create and start an animation on a node and its descendants
  105746. * @param name defines the name of the global animation that will be run on all nodes
  105747. * @param node defines the root node where the animation will take place
  105748. * @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
  105749. * @param targetProperty defines property to animate
  105750. * @param framePerSecond defines the number of frame per second to use
  105751. * @param totalFrame defines the number of frames in total
  105752. * @param from defines the initial value
  105753. * @param to defines the final value
  105754. * @param loopMode defines which loop mode you want to use (off by default)
  105755. * @param easingFunction defines the easing function to use (linear by default)
  105756. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105757. * @returns the list of animatables created for all nodes
  105758. * @example https://www.babylonjs-playground.com/#MH0VLI
  105759. */
  105760. 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[]>;
  105761. /**
  105762. * Creates a new animation, merges it with the existing animations and starts it
  105763. * @param name Name of the animation
  105764. * @param node Node which contains the scene that begins the animations
  105765. * @param targetProperty Specifies which property to animate
  105766. * @param framePerSecond The frames per second of the animation
  105767. * @param totalFrame The total number of frames
  105768. * @param from The frame at the beginning of the animation
  105769. * @param to The frame at the end of the animation
  105770. * @param loopMode Specifies the loop mode of the animation
  105771. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105772. * @param onAnimationEnd Callback to run once the animation is complete
  105773. * @returns Nullable animation
  105774. */
  105775. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105776. /**
  105777. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105778. * @param sourceAnimation defines the Animation containing keyframes to convert
  105779. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105780. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105781. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105782. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105783. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105784. */
  105785. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105786. /**
  105787. * Transition property of an host to the target Value
  105788. * @param property The property to transition
  105789. * @param targetValue The target Value of the property
  105790. * @param host The object where the property to animate belongs
  105791. * @param scene Scene used to run the animation
  105792. * @param frameRate Framerate (in frame/s) to use
  105793. * @param transition The transition type we want to use
  105794. * @param duration The duration of the animation, in milliseconds
  105795. * @param onAnimationEnd Callback trigger at the end of the animation
  105796. * @returns Nullable animation
  105797. */
  105798. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105799. /**
  105800. * Return the array of runtime animations currently using this animation
  105801. */
  105802. get runtimeAnimations(): RuntimeAnimation[];
  105803. /**
  105804. * Specifies if any of the runtime animations are currently running
  105805. */
  105806. get hasRunningRuntimeAnimations(): boolean;
  105807. /**
  105808. * Initializes the animation
  105809. * @param name Name of the animation
  105810. * @param targetProperty Property to animate
  105811. * @param framePerSecond The frames per second of the animation
  105812. * @param dataType The data type of the animation
  105813. * @param loopMode The loop mode of the animation
  105814. * @param enableBlending Specifies if blending should be enabled
  105815. */
  105816. constructor(
  105817. /**Name of the animation */
  105818. name: string,
  105819. /**Property to animate */
  105820. targetProperty: string,
  105821. /**The frames per second of the animation */
  105822. framePerSecond: number,
  105823. /**The data type of the animation */
  105824. dataType: number,
  105825. /**The loop mode of the animation */
  105826. loopMode?: number | undefined,
  105827. /**Specifies if blending should be enabled */
  105828. enableBlending?: boolean | undefined);
  105829. /**
  105830. * Converts the animation to a string
  105831. * @param fullDetails support for multiple levels of logging within scene loading
  105832. * @returns String form of the animation
  105833. */
  105834. toString(fullDetails?: boolean): string;
  105835. /**
  105836. * Add an event to this animation
  105837. * @param event Event to add
  105838. */
  105839. addEvent(event: AnimationEvent): void;
  105840. /**
  105841. * Remove all events found at the given frame
  105842. * @param frame The frame to remove events from
  105843. */
  105844. removeEvents(frame: number): void;
  105845. /**
  105846. * Retrieves all the events from the animation
  105847. * @returns Events from the animation
  105848. */
  105849. getEvents(): AnimationEvent[];
  105850. /**
  105851. * Creates an animation range
  105852. * @param name Name of the animation range
  105853. * @param from Starting frame of the animation range
  105854. * @param to Ending frame of the animation
  105855. */
  105856. createRange(name: string, from: number, to: number): void;
  105857. /**
  105858. * Deletes an animation range by name
  105859. * @param name Name of the animation range to delete
  105860. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105861. */
  105862. deleteRange(name: string, deleteFrames?: boolean): void;
  105863. /**
  105864. * Gets the animation range by name, or null if not defined
  105865. * @param name Name of the animation range
  105866. * @returns Nullable animation range
  105867. */
  105868. getRange(name: string): Nullable<AnimationRange>;
  105869. /**
  105870. * Gets the key frames from the animation
  105871. * @returns The key frames of the animation
  105872. */
  105873. getKeys(): Array<IAnimationKey>;
  105874. /**
  105875. * Gets the highest frame rate of the animation
  105876. * @returns Highest frame rate of the animation
  105877. */
  105878. getHighestFrame(): number;
  105879. /**
  105880. * Gets the easing function of the animation
  105881. * @returns Easing function of the animation
  105882. */
  105883. getEasingFunction(): IEasingFunction;
  105884. /**
  105885. * Sets the easing function of the animation
  105886. * @param easingFunction A custom mathematical formula for animation
  105887. */
  105888. setEasingFunction(easingFunction: EasingFunction): void;
  105889. /**
  105890. * Interpolates a scalar linearly
  105891. * @param startValue Start value of the animation curve
  105892. * @param endValue End value of the animation curve
  105893. * @param gradient Scalar amount to interpolate
  105894. * @returns Interpolated scalar value
  105895. */
  105896. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105897. /**
  105898. * Interpolates a scalar cubically
  105899. * @param startValue Start value of the animation curve
  105900. * @param outTangent End tangent of the animation
  105901. * @param endValue End value of the animation curve
  105902. * @param inTangent Start tangent of the animation curve
  105903. * @param gradient Scalar amount to interpolate
  105904. * @returns Interpolated scalar value
  105905. */
  105906. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105907. /**
  105908. * Interpolates a quaternion using a spherical linear interpolation
  105909. * @param startValue Start value of the animation curve
  105910. * @param endValue End value of the animation curve
  105911. * @param gradient Scalar amount to interpolate
  105912. * @returns Interpolated quaternion value
  105913. */
  105914. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105915. /**
  105916. * Interpolates a quaternion cubically
  105917. * @param startValue Start value of the animation curve
  105918. * @param outTangent End tangent of the animation curve
  105919. * @param endValue End value of the animation curve
  105920. * @param inTangent Start tangent of the animation curve
  105921. * @param gradient Scalar amount to interpolate
  105922. * @returns Interpolated quaternion value
  105923. */
  105924. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105925. /**
  105926. * Interpolates a Vector3 linearl
  105927. * @param startValue Start value of the animation curve
  105928. * @param endValue End value of the animation curve
  105929. * @param gradient Scalar amount to interpolate
  105930. * @returns Interpolated scalar value
  105931. */
  105932. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105933. /**
  105934. * Interpolates a Vector3 cubically
  105935. * @param startValue Start value of the animation curve
  105936. * @param outTangent End tangent of the animation
  105937. * @param endValue End value of the animation curve
  105938. * @param inTangent Start tangent of the animation curve
  105939. * @param gradient Scalar amount to interpolate
  105940. * @returns InterpolatedVector3 value
  105941. */
  105942. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  105943. /**
  105944. * Interpolates a Vector2 linearly
  105945. * @param startValue Start value of the animation curve
  105946. * @param endValue End value of the animation curve
  105947. * @param gradient Scalar amount to interpolate
  105948. * @returns Interpolated Vector2 value
  105949. */
  105950. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  105951. /**
  105952. * Interpolates a Vector2 cubically
  105953. * @param startValue Start value of the animation curve
  105954. * @param outTangent End tangent of the animation
  105955. * @param endValue End value of the animation curve
  105956. * @param inTangent Start tangent of the animation curve
  105957. * @param gradient Scalar amount to interpolate
  105958. * @returns Interpolated Vector2 value
  105959. */
  105960. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  105961. /**
  105962. * Interpolates a size linearly
  105963. * @param startValue Start value of the animation curve
  105964. * @param endValue End value of the animation curve
  105965. * @param gradient Scalar amount to interpolate
  105966. * @returns Interpolated Size value
  105967. */
  105968. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  105969. /**
  105970. * Interpolates a Color3 linearly
  105971. * @param startValue Start value of the animation curve
  105972. * @param endValue End value of the animation curve
  105973. * @param gradient Scalar amount to interpolate
  105974. * @returns Interpolated Color3 value
  105975. */
  105976. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  105977. /**
  105978. * Interpolates a Color4 linearly
  105979. * @param startValue Start value of the animation curve
  105980. * @param endValue End value of the animation curve
  105981. * @param gradient Scalar amount to interpolate
  105982. * @returns Interpolated Color3 value
  105983. */
  105984. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  105985. /**
  105986. * @hidden Internal use only
  105987. */
  105988. _getKeyValue(value: any): any;
  105989. /**
  105990. * @hidden Internal use only
  105991. */
  105992. _interpolate(currentFrame: number, state: _IAnimationState): any;
  105993. /**
  105994. * Defines the function to use to interpolate matrices
  105995. * @param startValue defines the start matrix
  105996. * @param endValue defines the end matrix
  105997. * @param gradient defines the gradient between both matrices
  105998. * @param result defines an optional target matrix where to store the interpolation
  105999. * @returns the interpolated matrix
  106000. */
  106001. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  106002. /**
  106003. * Makes a copy of the animation
  106004. * @returns Cloned animation
  106005. */
  106006. clone(): Animation;
  106007. /**
  106008. * Sets the key frames of the animation
  106009. * @param values The animation key frames to set
  106010. */
  106011. setKeys(values: Array<IAnimationKey>): void;
  106012. /**
  106013. * Serializes the animation to an object
  106014. * @returns Serialized object
  106015. */
  106016. serialize(): any;
  106017. /**
  106018. * Float animation type
  106019. */
  106020. static readonly ANIMATIONTYPE_FLOAT: number;
  106021. /**
  106022. * Vector3 animation type
  106023. */
  106024. static readonly ANIMATIONTYPE_VECTOR3: number;
  106025. /**
  106026. * Quaternion animation type
  106027. */
  106028. static readonly ANIMATIONTYPE_QUATERNION: number;
  106029. /**
  106030. * Matrix animation type
  106031. */
  106032. static readonly ANIMATIONTYPE_MATRIX: number;
  106033. /**
  106034. * Color3 animation type
  106035. */
  106036. static readonly ANIMATIONTYPE_COLOR3: number;
  106037. /**
  106038. * Color3 animation type
  106039. */
  106040. static readonly ANIMATIONTYPE_COLOR4: number;
  106041. /**
  106042. * Vector2 animation type
  106043. */
  106044. static readonly ANIMATIONTYPE_VECTOR2: number;
  106045. /**
  106046. * Size animation type
  106047. */
  106048. static readonly ANIMATIONTYPE_SIZE: number;
  106049. /**
  106050. * Relative Loop Mode
  106051. */
  106052. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  106053. /**
  106054. * Cycle Loop Mode
  106055. */
  106056. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  106057. /**
  106058. * Constant Loop Mode
  106059. */
  106060. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  106061. /** @hidden */
  106062. static _UniversalLerp(left: any, right: any, amount: number): any;
  106063. /**
  106064. * Parses an animation object and creates an animation
  106065. * @param parsedAnimation Parsed animation object
  106066. * @returns Animation object
  106067. */
  106068. static Parse(parsedAnimation: any): Animation;
  106069. /**
  106070. * Appends the serialized animations from the source animations
  106071. * @param source Source containing the animations
  106072. * @param destination Target to store the animations
  106073. */
  106074. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106075. }
  106076. }
  106077. declare module BABYLON {
  106078. /**
  106079. * Interface containing an array of animations
  106080. */
  106081. export interface IAnimatable {
  106082. /**
  106083. * Array of animations
  106084. */
  106085. animations: Nullable<Array<Animation>>;
  106086. }
  106087. }
  106088. declare module BABYLON {
  106089. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  106090. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106091. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106092. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106093. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106094. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106095. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106096. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106097. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106098. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106099. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106100. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106101. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106102. /**
  106103. * Decorator used to define property that can be serialized as reference to a camera
  106104. * @param sourceName defines the name of the property to decorate
  106105. */
  106106. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  106107. /**
  106108. * Class used to help serialization objects
  106109. */
  106110. export class SerializationHelper {
  106111. /** @hidden */
  106112. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  106113. /** @hidden */
  106114. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  106115. /** @hidden */
  106116. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  106117. /** @hidden */
  106118. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  106119. /**
  106120. * Appends the serialized animations from the source animations
  106121. * @param source Source containing the animations
  106122. * @param destination Target to store the animations
  106123. */
  106124. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  106125. /**
  106126. * Static function used to serialized a specific entity
  106127. * @param entity defines the entity to serialize
  106128. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  106129. * @returns a JSON compatible object representing the serialization of the entity
  106130. */
  106131. static Serialize<T>(entity: T, serializationObject?: any): any;
  106132. /**
  106133. * Creates a new entity from a serialization data object
  106134. * @param creationFunction defines a function used to instanciated the new entity
  106135. * @param source defines the source serialization data
  106136. * @param scene defines the hosting scene
  106137. * @param rootUrl defines the root url for resources
  106138. * @returns a new entity
  106139. */
  106140. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  106141. /**
  106142. * Clones an object
  106143. * @param creationFunction defines the function used to instanciate the new object
  106144. * @param source defines the source object
  106145. * @returns the cloned object
  106146. */
  106147. static Clone<T>(creationFunction: () => T, source: T): T;
  106148. /**
  106149. * Instanciates a new object based on a source one (some data will be shared between both object)
  106150. * @param creationFunction defines the function used to instanciate the new object
  106151. * @param source defines the source object
  106152. * @returns the new object
  106153. */
  106154. static Instanciate<T>(creationFunction: () => T, source: T): T;
  106155. }
  106156. }
  106157. declare module BABYLON {
  106158. /**
  106159. * Base class of all the textures in babylon.
  106160. * It groups all the common properties the materials, post process, lights... might need
  106161. * in order to make a correct use of the texture.
  106162. */
  106163. export class BaseTexture implements IAnimatable {
  106164. /**
  106165. * Default anisotropic filtering level for the application.
  106166. * It is set to 4 as a good tradeoff between perf and quality.
  106167. */
  106168. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  106169. /**
  106170. * Gets or sets the unique id of the texture
  106171. */
  106172. uniqueId: number;
  106173. /**
  106174. * Define the name of the texture.
  106175. */
  106176. name: string;
  106177. /**
  106178. * Gets or sets an object used to store user defined information.
  106179. */
  106180. metadata: any;
  106181. /**
  106182. * For internal use only. Please do not use.
  106183. */
  106184. reservedDataStore: any;
  106185. private _hasAlpha;
  106186. /**
  106187. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  106188. */
  106189. set hasAlpha(value: boolean);
  106190. get hasAlpha(): boolean;
  106191. /**
  106192. * Defines if the alpha value should be determined via the rgb values.
  106193. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  106194. */
  106195. getAlphaFromRGB: boolean;
  106196. /**
  106197. * Intensity or strength of the texture.
  106198. * It is commonly used by materials to fine tune the intensity of the texture
  106199. */
  106200. level: number;
  106201. /**
  106202. * Define the UV chanel to use starting from 0 and defaulting to 0.
  106203. * This is part of the texture as textures usually maps to one uv set.
  106204. */
  106205. coordinatesIndex: number;
  106206. private _coordinatesMode;
  106207. /**
  106208. * How a texture is mapped.
  106209. *
  106210. * | Value | Type | Description |
  106211. * | ----- | ----------------------------------- | ----------- |
  106212. * | 0 | EXPLICIT_MODE | |
  106213. * | 1 | SPHERICAL_MODE | |
  106214. * | 2 | PLANAR_MODE | |
  106215. * | 3 | CUBIC_MODE | |
  106216. * | 4 | PROJECTION_MODE | |
  106217. * | 5 | SKYBOX_MODE | |
  106218. * | 6 | INVCUBIC_MODE | |
  106219. * | 7 | EQUIRECTANGULAR_MODE | |
  106220. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106221. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106222. */
  106223. set coordinatesMode(value: number);
  106224. get coordinatesMode(): number;
  106225. /**
  106226. * | Value | Type | Description |
  106227. * | ----- | ------------------ | ----------- |
  106228. * | 0 | CLAMP_ADDRESSMODE | |
  106229. * | 1 | WRAP_ADDRESSMODE | |
  106230. * | 2 | MIRROR_ADDRESSMODE | |
  106231. */
  106232. wrapU: number;
  106233. /**
  106234. * | Value | Type | Description |
  106235. * | ----- | ------------------ | ----------- |
  106236. * | 0 | CLAMP_ADDRESSMODE | |
  106237. * | 1 | WRAP_ADDRESSMODE | |
  106238. * | 2 | MIRROR_ADDRESSMODE | |
  106239. */
  106240. wrapV: number;
  106241. /**
  106242. * | Value | Type | Description |
  106243. * | ----- | ------------------ | ----------- |
  106244. * | 0 | CLAMP_ADDRESSMODE | |
  106245. * | 1 | WRAP_ADDRESSMODE | |
  106246. * | 2 | MIRROR_ADDRESSMODE | |
  106247. */
  106248. wrapR: number;
  106249. /**
  106250. * With compliant hardware and browser (supporting anisotropic filtering)
  106251. * this defines the level of anisotropic filtering in the texture.
  106252. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106253. */
  106254. anisotropicFilteringLevel: number;
  106255. /**
  106256. * Define if the texture is a cube texture or if false a 2d texture.
  106257. */
  106258. get isCube(): boolean;
  106259. set isCube(value: boolean);
  106260. /**
  106261. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106262. */
  106263. get is3D(): boolean;
  106264. set is3D(value: boolean);
  106265. /**
  106266. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106267. */
  106268. get is2DArray(): boolean;
  106269. set is2DArray(value: boolean);
  106270. /**
  106271. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106272. * HDR texture are usually stored in linear space.
  106273. * This only impacts the PBR and Background materials
  106274. */
  106275. gammaSpace: boolean;
  106276. /**
  106277. * Gets or sets whether or not the texture contains RGBD data.
  106278. */
  106279. get isRGBD(): boolean;
  106280. set isRGBD(value: boolean);
  106281. /**
  106282. * Is Z inverted in the texture (useful in a cube texture).
  106283. */
  106284. invertZ: boolean;
  106285. /**
  106286. * Are mip maps generated for this texture or not.
  106287. */
  106288. get noMipmap(): boolean;
  106289. /**
  106290. * @hidden
  106291. */
  106292. lodLevelInAlpha: boolean;
  106293. /**
  106294. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106295. */
  106296. get lodGenerationOffset(): number;
  106297. set lodGenerationOffset(value: number);
  106298. /**
  106299. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106300. */
  106301. get lodGenerationScale(): number;
  106302. set lodGenerationScale(value: number);
  106303. /**
  106304. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106305. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106306. * average roughness values.
  106307. */
  106308. get linearSpecularLOD(): boolean;
  106309. set linearSpecularLOD(value: boolean);
  106310. /**
  106311. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106312. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106313. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106314. */
  106315. get irradianceTexture(): Nullable<BaseTexture>;
  106316. set irradianceTexture(value: Nullable<BaseTexture>);
  106317. /**
  106318. * Define if the texture is a render target.
  106319. */
  106320. isRenderTarget: boolean;
  106321. /**
  106322. * Define the unique id of the texture in the scene.
  106323. */
  106324. get uid(): string;
  106325. /**
  106326. * Return a string representation of the texture.
  106327. * @returns the texture as a string
  106328. */
  106329. toString(): string;
  106330. /**
  106331. * Get the class name of the texture.
  106332. * @returns "BaseTexture"
  106333. */
  106334. getClassName(): string;
  106335. /**
  106336. * Define the list of animation attached to the texture.
  106337. */
  106338. animations: Animation[];
  106339. /**
  106340. * An event triggered when the texture is disposed.
  106341. */
  106342. onDisposeObservable: Observable<BaseTexture>;
  106343. private _onDisposeObserver;
  106344. /**
  106345. * Callback triggered when the texture has been disposed.
  106346. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106347. */
  106348. set onDispose(callback: () => void);
  106349. /**
  106350. * Define the current state of the loading sequence when in delayed load mode.
  106351. */
  106352. delayLoadState: number;
  106353. private _scene;
  106354. private _engine;
  106355. /** @hidden */
  106356. _texture: Nullable<InternalTexture>;
  106357. private _uid;
  106358. /**
  106359. * Define if the texture is preventinga material to render or not.
  106360. * If not and the texture is not ready, the engine will use a default black texture instead.
  106361. */
  106362. get isBlocking(): boolean;
  106363. /**
  106364. * Instantiates a new BaseTexture.
  106365. * Base class of all the textures in babylon.
  106366. * It groups all the common properties the materials, post process, lights... might need
  106367. * in order to make a correct use of the texture.
  106368. * @param sceneOrEngine Define the scene or engine the texture blongs to
  106369. */
  106370. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  106371. /**
  106372. * Get the scene the texture belongs to.
  106373. * @returns the scene or null if undefined
  106374. */
  106375. getScene(): Nullable<Scene>;
  106376. /** @hidden */
  106377. protected _getEngine(): Nullable<ThinEngine>;
  106378. /**
  106379. * Get the texture transform matrix used to offset tile the texture for istance.
  106380. * @returns the transformation matrix
  106381. */
  106382. getTextureMatrix(): Matrix;
  106383. /**
  106384. * Get the texture reflection matrix used to rotate/transform the reflection.
  106385. * @returns the reflection matrix
  106386. */
  106387. getReflectionTextureMatrix(): Matrix;
  106388. /**
  106389. * Get the underlying lower level texture from Babylon.
  106390. * @returns the insternal texture
  106391. */
  106392. getInternalTexture(): Nullable<InternalTexture>;
  106393. /**
  106394. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106395. * @returns true if ready or not blocking
  106396. */
  106397. isReadyOrNotBlocking(): boolean;
  106398. /**
  106399. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106400. * @returns true if fully ready
  106401. */
  106402. isReady(): boolean;
  106403. private _cachedSize;
  106404. /**
  106405. * Get the size of the texture.
  106406. * @returns the texture size.
  106407. */
  106408. getSize(): ISize;
  106409. /**
  106410. * Get the base size of the texture.
  106411. * It can be different from the size if the texture has been resized for POT for instance
  106412. * @returns the base size
  106413. */
  106414. getBaseSize(): ISize;
  106415. /**
  106416. * Update the sampling mode of the texture.
  106417. * Default is Trilinear mode.
  106418. *
  106419. * | Value | Type | Description |
  106420. * | ----- | ------------------ | ----------- |
  106421. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106422. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106423. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106424. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106425. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106426. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106427. * | 7 | NEAREST_LINEAR | |
  106428. * | 8 | NEAREST_NEAREST | |
  106429. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106430. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106431. * | 11 | LINEAR_LINEAR | |
  106432. * | 12 | LINEAR_NEAREST | |
  106433. *
  106434. * > _mag_: magnification filter (close to the viewer)
  106435. * > _min_: minification filter (far from the viewer)
  106436. * > _mip_: filter used between mip map levels
  106437. *@param samplingMode Define the new sampling mode of the texture
  106438. */
  106439. updateSamplingMode(samplingMode: number): void;
  106440. /**
  106441. * Scales the texture if is `canRescale()`
  106442. * @param ratio the resize factor we want to use to rescale
  106443. */
  106444. scale(ratio: number): void;
  106445. /**
  106446. * Get if the texture can rescale.
  106447. */
  106448. get canRescale(): boolean;
  106449. /** @hidden */
  106450. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106451. /** @hidden */
  106452. _rebuild(): void;
  106453. /**
  106454. * Triggers the load sequence in delayed load mode.
  106455. */
  106456. delayLoad(): void;
  106457. /**
  106458. * Clones the texture.
  106459. * @returns the cloned texture
  106460. */
  106461. clone(): Nullable<BaseTexture>;
  106462. /**
  106463. * Get the texture underlying type (INT, FLOAT...)
  106464. */
  106465. get textureType(): number;
  106466. /**
  106467. * Get the texture underlying format (RGB, RGBA...)
  106468. */
  106469. get textureFormat(): number;
  106470. /**
  106471. * Indicates that textures need to be re-calculated for all materials
  106472. */
  106473. protected _markAllSubMeshesAsTexturesDirty(): void;
  106474. /**
  106475. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106476. * This will returns an RGBA array buffer containing either in values (0-255) or
  106477. * float values (0-1) depending of the underlying buffer type.
  106478. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106479. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106480. * @param buffer defines a user defined buffer to fill with data (can be null)
  106481. * @returns The Array buffer containing the pixels data.
  106482. */
  106483. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106484. /**
  106485. * Release and destroy the underlying lower level texture aka internalTexture.
  106486. */
  106487. releaseInternalTexture(): void;
  106488. /** @hidden */
  106489. get _lodTextureHigh(): Nullable<BaseTexture>;
  106490. /** @hidden */
  106491. get _lodTextureMid(): Nullable<BaseTexture>;
  106492. /** @hidden */
  106493. get _lodTextureLow(): Nullable<BaseTexture>;
  106494. /**
  106495. * Dispose the texture and release its associated resources.
  106496. */
  106497. dispose(): void;
  106498. /**
  106499. * Serialize the texture into a JSON representation that can be parsed later on.
  106500. * @returns the JSON representation of the texture
  106501. */
  106502. serialize(): any;
  106503. /**
  106504. * Helper function to be called back once a list of texture contains only ready textures.
  106505. * @param textures Define the list of textures to wait for
  106506. * @param callback Define the callback triggered once the entire list will be ready
  106507. */
  106508. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106509. private static _isScene;
  106510. }
  106511. }
  106512. declare module BABYLON {
  106513. /**
  106514. * Options to be used when creating an effect.
  106515. */
  106516. export interface IEffectCreationOptions {
  106517. /**
  106518. * Atrributes that will be used in the shader.
  106519. */
  106520. attributes: string[];
  106521. /**
  106522. * Uniform varible names that will be set in the shader.
  106523. */
  106524. uniformsNames: string[];
  106525. /**
  106526. * Uniform buffer variable names that will be set in the shader.
  106527. */
  106528. uniformBuffersNames: string[];
  106529. /**
  106530. * Sampler texture variable names that will be set in the shader.
  106531. */
  106532. samplers: string[];
  106533. /**
  106534. * Define statements that will be set in the shader.
  106535. */
  106536. defines: any;
  106537. /**
  106538. * Possible fallbacks for this effect to improve performance when needed.
  106539. */
  106540. fallbacks: Nullable<IEffectFallbacks>;
  106541. /**
  106542. * Callback that will be called when the shader is compiled.
  106543. */
  106544. onCompiled: Nullable<(effect: Effect) => void>;
  106545. /**
  106546. * Callback that will be called if an error occurs during shader compilation.
  106547. */
  106548. onError: Nullable<(effect: Effect, errors: string) => void>;
  106549. /**
  106550. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106551. */
  106552. indexParameters?: any;
  106553. /**
  106554. * Max number of lights that can be used in the shader.
  106555. */
  106556. maxSimultaneousLights?: number;
  106557. /**
  106558. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106559. */
  106560. transformFeedbackVaryings?: Nullable<string[]>;
  106561. }
  106562. /**
  106563. * Effect containing vertex and fragment shader that can be executed on an object.
  106564. */
  106565. export class Effect implements IDisposable {
  106566. /**
  106567. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106568. */
  106569. static ShadersRepository: string;
  106570. /**
  106571. * Enable logging of the shader code when a compilation error occurs
  106572. */
  106573. static LogShaderCodeOnCompilationError: boolean;
  106574. /**
  106575. * Name of the effect.
  106576. */
  106577. name: any;
  106578. /**
  106579. * String container all the define statements that should be set on the shader.
  106580. */
  106581. defines: string;
  106582. /**
  106583. * Callback that will be called when the shader is compiled.
  106584. */
  106585. onCompiled: Nullable<(effect: Effect) => void>;
  106586. /**
  106587. * Callback that will be called if an error occurs during shader compilation.
  106588. */
  106589. onError: Nullable<(effect: Effect, errors: string) => void>;
  106590. /**
  106591. * Callback that will be called when effect is bound.
  106592. */
  106593. onBind: Nullable<(effect: Effect) => void>;
  106594. /**
  106595. * Unique ID of the effect.
  106596. */
  106597. uniqueId: number;
  106598. /**
  106599. * Observable that will be called when the shader is compiled.
  106600. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106601. */
  106602. onCompileObservable: Observable<Effect>;
  106603. /**
  106604. * Observable that will be called if an error occurs during shader compilation.
  106605. */
  106606. onErrorObservable: Observable<Effect>;
  106607. /** @hidden */
  106608. _onBindObservable: Nullable<Observable<Effect>>;
  106609. /**
  106610. * @hidden
  106611. * Specifies if the effect was previously ready
  106612. */
  106613. _wasPreviouslyReady: boolean;
  106614. /**
  106615. * Observable that will be called when effect is bound.
  106616. */
  106617. get onBindObservable(): Observable<Effect>;
  106618. /** @hidden */
  106619. _bonesComputationForcedToCPU: boolean;
  106620. private static _uniqueIdSeed;
  106621. private _engine;
  106622. private _uniformBuffersNames;
  106623. private _uniformBuffersNamesList;
  106624. private _uniformsNames;
  106625. private _samplerList;
  106626. private _samplers;
  106627. private _isReady;
  106628. private _compilationError;
  106629. private _allFallbacksProcessed;
  106630. private _attributesNames;
  106631. private _attributes;
  106632. private _attributeLocationByName;
  106633. private _uniforms;
  106634. /**
  106635. * Key for the effect.
  106636. * @hidden
  106637. */
  106638. _key: string;
  106639. private _indexParameters;
  106640. private _fallbacks;
  106641. private _vertexSourceCode;
  106642. private _fragmentSourceCode;
  106643. private _vertexSourceCodeOverride;
  106644. private _fragmentSourceCodeOverride;
  106645. private _transformFeedbackVaryings;
  106646. /**
  106647. * Compiled shader to webGL program.
  106648. * @hidden
  106649. */
  106650. _pipelineContext: Nullable<IPipelineContext>;
  106651. private _valueCache;
  106652. private static _baseCache;
  106653. /**
  106654. * Instantiates an effect.
  106655. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106656. * @param baseName Name of the effect.
  106657. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106658. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106659. * @param samplers List of sampler variables that will be passed to the shader.
  106660. * @param engine Engine to be used to render the effect
  106661. * @param defines Define statements to be added to the shader.
  106662. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106663. * @param onCompiled Callback that will be called when the shader is compiled.
  106664. * @param onError Callback that will be called if an error occurs during shader compilation.
  106665. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106666. */
  106667. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  106668. private _useFinalCode;
  106669. /**
  106670. * Unique key for this effect
  106671. */
  106672. get key(): string;
  106673. /**
  106674. * If the effect has been compiled and prepared.
  106675. * @returns if the effect is compiled and prepared.
  106676. */
  106677. isReady(): boolean;
  106678. private _isReadyInternal;
  106679. /**
  106680. * The engine the effect was initialized with.
  106681. * @returns the engine.
  106682. */
  106683. getEngine(): Engine;
  106684. /**
  106685. * The pipeline context for this effect
  106686. * @returns the associated pipeline context
  106687. */
  106688. getPipelineContext(): Nullable<IPipelineContext>;
  106689. /**
  106690. * The set of names of attribute variables for the shader.
  106691. * @returns An array of attribute names.
  106692. */
  106693. getAttributesNames(): string[];
  106694. /**
  106695. * Returns the attribute at the given index.
  106696. * @param index The index of the attribute.
  106697. * @returns The location of the attribute.
  106698. */
  106699. getAttributeLocation(index: number): number;
  106700. /**
  106701. * Returns the attribute based on the name of the variable.
  106702. * @param name of the attribute to look up.
  106703. * @returns the attribute location.
  106704. */
  106705. getAttributeLocationByName(name: string): number;
  106706. /**
  106707. * The number of attributes.
  106708. * @returns the numnber of attributes.
  106709. */
  106710. getAttributesCount(): number;
  106711. /**
  106712. * Gets the index of a uniform variable.
  106713. * @param uniformName of the uniform to look up.
  106714. * @returns the index.
  106715. */
  106716. getUniformIndex(uniformName: string): number;
  106717. /**
  106718. * Returns the attribute based on the name of the variable.
  106719. * @param uniformName of the uniform to look up.
  106720. * @returns the location of the uniform.
  106721. */
  106722. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106723. /**
  106724. * Returns an array of sampler variable names
  106725. * @returns The array of sampler variable names.
  106726. */
  106727. getSamplers(): string[];
  106728. /**
  106729. * Returns an array of uniform variable names
  106730. * @returns The array of uniform variable names.
  106731. */
  106732. getUniformNames(): string[];
  106733. /**
  106734. * Returns an array of uniform buffer variable names
  106735. * @returns The array of uniform buffer variable names.
  106736. */
  106737. getUniformBuffersNames(): string[];
  106738. /**
  106739. * Returns the index parameters used to create the effect
  106740. * @returns The index parameters object
  106741. */
  106742. getIndexParameters(): any;
  106743. /**
  106744. * The error from the last compilation.
  106745. * @returns the error string.
  106746. */
  106747. getCompilationError(): string;
  106748. /**
  106749. * Gets a boolean indicating that all fallbacks were used during compilation
  106750. * @returns true if all fallbacks were used
  106751. */
  106752. allFallbacksProcessed(): boolean;
  106753. /**
  106754. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106755. * @param func The callback to be used.
  106756. */
  106757. executeWhenCompiled(func: (effect: Effect) => void): void;
  106758. private _checkIsReady;
  106759. private _loadShader;
  106760. /**
  106761. * Gets the vertex shader source code of this effect
  106762. */
  106763. get vertexSourceCode(): string;
  106764. /**
  106765. * Gets the fragment shader source code of this effect
  106766. */
  106767. get fragmentSourceCode(): string;
  106768. /**
  106769. * Recompiles the webGL program
  106770. * @param vertexSourceCode The source code for the vertex shader.
  106771. * @param fragmentSourceCode The source code for the fragment shader.
  106772. * @param onCompiled Callback called when completed.
  106773. * @param onError Callback called on error.
  106774. * @hidden
  106775. */
  106776. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106777. /**
  106778. * Prepares the effect
  106779. * @hidden
  106780. */
  106781. _prepareEffect(): void;
  106782. private _getShaderCodeAndErrorLine;
  106783. private _processCompilationErrors;
  106784. /**
  106785. * Checks if the effect is supported. (Must be called after compilation)
  106786. */
  106787. get isSupported(): boolean;
  106788. /**
  106789. * Binds a texture to the engine to be used as output of the shader.
  106790. * @param channel Name of the output variable.
  106791. * @param texture Texture to bind.
  106792. * @hidden
  106793. */
  106794. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106795. /**
  106796. * Sets a texture on the engine to be used in the shader.
  106797. * @param channel Name of the sampler variable.
  106798. * @param texture Texture to set.
  106799. */
  106800. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106801. /**
  106802. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106803. * @param channel Name of the sampler variable.
  106804. * @param texture Texture to set.
  106805. */
  106806. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106807. /**
  106808. * Sets an array of textures on the engine to be used in the shader.
  106809. * @param channel Name of the variable.
  106810. * @param textures Textures to set.
  106811. */
  106812. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106813. /**
  106814. * 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)
  106815. * @param channel Name of the sampler variable.
  106816. * @param postProcess Post process to get the input texture from.
  106817. */
  106818. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106819. /**
  106820. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106821. * 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)
  106822. * @param channel Name of the sampler variable.
  106823. * @param postProcess Post process to get the output texture from.
  106824. */
  106825. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106826. /** @hidden */
  106827. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106828. /** @hidden */
  106829. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106830. /** @hidden */
  106831. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106832. /** @hidden */
  106833. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106834. /**
  106835. * Binds a buffer to a uniform.
  106836. * @param buffer Buffer to bind.
  106837. * @param name Name of the uniform variable to bind to.
  106838. */
  106839. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106840. /**
  106841. * Binds block to a uniform.
  106842. * @param blockName Name of the block to bind.
  106843. * @param index Index to bind.
  106844. */
  106845. bindUniformBlock(blockName: string, index: number): void;
  106846. /**
  106847. * Sets an interger value on a uniform variable.
  106848. * @param uniformName Name of the variable.
  106849. * @param value Value to be set.
  106850. * @returns this effect.
  106851. */
  106852. setInt(uniformName: string, value: number): Effect;
  106853. /**
  106854. * Sets an int array on a uniform variable.
  106855. * @param uniformName Name of the variable.
  106856. * @param array array to be set.
  106857. * @returns this effect.
  106858. */
  106859. setIntArray(uniformName: string, array: Int32Array): Effect;
  106860. /**
  106861. * 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)
  106862. * @param uniformName Name of the variable.
  106863. * @param array array to be set.
  106864. * @returns this effect.
  106865. */
  106866. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106867. /**
  106868. * 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)
  106869. * @param uniformName Name of the variable.
  106870. * @param array array to be set.
  106871. * @returns this effect.
  106872. */
  106873. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106874. /**
  106875. * 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)
  106876. * @param uniformName Name of the variable.
  106877. * @param array array to be set.
  106878. * @returns this effect.
  106879. */
  106880. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106881. /**
  106882. * Sets an float array on a uniform variable.
  106883. * @param uniformName Name of the variable.
  106884. * @param array array to be set.
  106885. * @returns this effect.
  106886. */
  106887. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106888. /**
  106889. * 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)
  106890. * @param uniformName Name of the variable.
  106891. * @param array array to be set.
  106892. * @returns this effect.
  106893. */
  106894. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106895. /**
  106896. * 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)
  106897. * @param uniformName Name of the variable.
  106898. * @param array array to be set.
  106899. * @returns this effect.
  106900. */
  106901. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106902. /**
  106903. * 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)
  106904. * @param uniformName Name of the variable.
  106905. * @param array array to be set.
  106906. * @returns this effect.
  106907. */
  106908. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106909. /**
  106910. * Sets an array on a uniform variable.
  106911. * @param uniformName Name of the variable.
  106912. * @param array array to be set.
  106913. * @returns this effect.
  106914. */
  106915. setArray(uniformName: string, array: number[]): Effect;
  106916. /**
  106917. * 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)
  106918. * @param uniformName Name of the variable.
  106919. * @param array array to be set.
  106920. * @returns this effect.
  106921. */
  106922. setArray2(uniformName: string, array: number[]): Effect;
  106923. /**
  106924. * 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)
  106925. * @param uniformName Name of the variable.
  106926. * @param array array to be set.
  106927. * @returns this effect.
  106928. */
  106929. setArray3(uniformName: string, array: number[]): Effect;
  106930. /**
  106931. * 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)
  106932. * @param uniformName Name of the variable.
  106933. * @param array array to be set.
  106934. * @returns this effect.
  106935. */
  106936. setArray4(uniformName: string, array: number[]): Effect;
  106937. /**
  106938. * Sets matrices on a uniform variable.
  106939. * @param uniformName Name of the variable.
  106940. * @param matrices matrices to be set.
  106941. * @returns this effect.
  106942. */
  106943. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  106944. /**
  106945. * Sets matrix on a uniform variable.
  106946. * @param uniformName Name of the variable.
  106947. * @param matrix matrix to be set.
  106948. * @returns this effect.
  106949. */
  106950. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  106951. /**
  106952. * 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)
  106953. * @param uniformName Name of the variable.
  106954. * @param matrix matrix to be set.
  106955. * @returns this effect.
  106956. */
  106957. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  106958. /**
  106959. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  106960. * @param uniformName Name of the variable.
  106961. * @param matrix matrix to be set.
  106962. * @returns this effect.
  106963. */
  106964. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  106965. /**
  106966. * Sets a float on a uniform variable.
  106967. * @param uniformName Name of the variable.
  106968. * @param value value to be set.
  106969. * @returns this effect.
  106970. */
  106971. setFloat(uniformName: string, value: number): Effect;
  106972. /**
  106973. * Sets a boolean on a uniform variable.
  106974. * @param uniformName Name of the variable.
  106975. * @param bool value to be set.
  106976. * @returns this effect.
  106977. */
  106978. setBool(uniformName: string, bool: boolean): Effect;
  106979. /**
  106980. * Sets a Vector2 on a uniform variable.
  106981. * @param uniformName Name of the variable.
  106982. * @param vector2 vector2 to be set.
  106983. * @returns this effect.
  106984. */
  106985. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  106986. /**
  106987. * Sets a float2 on a uniform variable.
  106988. * @param uniformName Name of the variable.
  106989. * @param x First float in float2.
  106990. * @param y Second float in float2.
  106991. * @returns this effect.
  106992. */
  106993. setFloat2(uniformName: string, x: number, y: number): Effect;
  106994. /**
  106995. * Sets a Vector3 on a uniform variable.
  106996. * @param uniformName Name of the variable.
  106997. * @param vector3 Value to be set.
  106998. * @returns this effect.
  106999. */
  107000. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  107001. /**
  107002. * Sets a float3 on a uniform variable.
  107003. * @param uniformName Name of the variable.
  107004. * @param x First float in float3.
  107005. * @param y Second float in float3.
  107006. * @param z Third float in float3.
  107007. * @returns this effect.
  107008. */
  107009. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  107010. /**
  107011. * Sets a Vector4 on a uniform variable.
  107012. * @param uniformName Name of the variable.
  107013. * @param vector4 Value to be set.
  107014. * @returns this effect.
  107015. */
  107016. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  107017. /**
  107018. * Sets a float4 on a uniform variable.
  107019. * @param uniformName Name of the variable.
  107020. * @param x First float in float4.
  107021. * @param y Second float in float4.
  107022. * @param z Third float in float4.
  107023. * @param w Fourth float in float4.
  107024. * @returns this effect.
  107025. */
  107026. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  107027. /**
  107028. * Sets a Color3 on a uniform variable.
  107029. * @param uniformName Name of the variable.
  107030. * @param color3 Value to be set.
  107031. * @returns this effect.
  107032. */
  107033. setColor3(uniformName: string, color3: IColor3Like): Effect;
  107034. /**
  107035. * Sets a Color4 on a uniform variable.
  107036. * @param uniformName Name of the variable.
  107037. * @param color3 Value to be set.
  107038. * @param alpha Alpha value to be set.
  107039. * @returns this effect.
  107040. */
  107041. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  107042. /**
  107043. * Sets a Color4 on a uniform variable
  107044. * @param uniformName defines the name of the variable
  107045. * @param color4 defines the value to be set
  107046. * @returns this effect.
  107047. */
  107048. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  107049. /** Release all associated resources */
  107050. dispose(): void;
  107051. /**
  107052. * This function will add a new shader to the shader store
  107053. * @param name the name of the shader
  107054. * @param pixelShader optional pixel shader content
  107055. * @param vertexShader optional vertex shader content
  107056. */
  107057. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  107058. /**
  107059. * Store of each shader (The can be looked up using effect.key)
  107060. */
  107061. static ShadersStore: {
  107062. [key: string]: string;
  107063. };
  107064. /**
  107065. * Store of each included file for a shader (The can be looked up using effect.key)
  107066. */
  107067. static IncludesShadersStore: {
  107068. [key: string]: string;
  107069. };
  107070. /**
  107071. * Resets the cache of effects.
  107072. */
  107073. static ResetCache(): void;
  107074. }
  107075. }
  107076. declare module BABYLON {
  107077. /**
  107078. * Interface used to describe the capabilities of the engine relatively to the current browser
  107079. */
  107080. export interface EngineCapabilities {
  107081. /** Maximum textures units per fragment shader */
  107082. maxTexturesImageUnits: number;
  107083. /** Maximum texture units per vertex shader */
  107084. maxVertexTextureImageUnits: number;
  107085. /** Maximum textures units in the entire pipeline */
  107086. maxCombinedTexturesImageUnits: number;
  107087. /** Maximum texture size */
  107088. maxTextureSize: number;
  107089. /** Maximum texture samples */
  107090. maxSamples?: number;
  107091. /** Maximum cube texture size */
  107092. maxCubemapTextureSize: number;
  107093. /** Maximum render texture size */
  107094. maxRenderTextureSize: number;
  107095. /** Maximum number of vertex attributes */
  107096. maxVertexAttribs: number;
  107097. /** Maximum number of varyings */
  107098. maxVaryingVectors: number;
  107099. /** Maximum number of uniforms per vertex shader */
  107100. maxVertexUniformVectors: number;
  107101. /** Maximum number of uniforms per fragment shader */
  107102. maxFragmentUniformVectors: number;
  107103. /** Defines if standard derivates (dx/dy) are supported */
  107104. standardDerivatives: boolean;
  107105. /** Defines if s3tc texture compression is supported */
  107106. s3tc?: WEBGL_compressed_texture_s3tc;
  107107. /** Defines if pvrtc texture compression is supported */
  107108. pvrtc: any;
  107109. /** Defines if etc1 texture compression is supported */
  107110. etc1: any;
  107111. /** Defines if etc2 texture compression is supported */
  107112. etc2: any;
  107113. /** Defines if astc texture compression is supported */
  107114. astc: any;
  107115. /** Defines if float textures are supported */
  107116. textureFloat: boolean;
  107117. /** Defines if vertex array objects are supported */
  107118. vertexArrayObject: boolean;
  107119. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  107120. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  107121. /** Gets the maximum level of anisotropy supported */
  107122. maxAnisotropy: number;
  107123. /** Defines if instancing is supported */
  107124. instancedArrays: boolean;
  107125. /** Defines if 32 bits indices are supported */
  107126. uintIndices: boolean;
  107127. /** Defines if high precision shaders are supported */
  107128. highPrecisionShaderSupported: boolean;
  107129. /** Defines if depth reading in the fragment shader is supported */
  107130. fragmentDepthSupported: boolean;
  107131. /** Defines if float texture linear filtering is supported*/
  107132. textureFloatLinearFiltering: boolean;
  107133. /** Defines if rendering to float textures is supported */
  107134. textureFloatRender: boolean;
  107135. /** Defines if half float textures are supported*/
  107136. textureHalfFloat: boolean;
  107137. /** Defines if half float texture linear filtering is supported*/
  107138. textureHalfFloatLinearFiltering: boolean;
  107139. /** Defines if rendering to half float textures is supported */
  107140. textureHalfFloatRender: boolean;
  107141. /** Defines if textureLOD shader command is supported */
  107142. textureLOD: boolean;
  107143. /** Defines if draw buffers extension is supported */
  107144. drawBuffersExtension: boolean;
  107145. /** Defines if depth textures are supported */
  107146. depthTextureExtension: boolean;
  107147. /** Defines if float color buffer are supported */
  107148. colorBufferFloat: boolean;
  107149. /** Gets disjoint timer query extension (null if not supported) */
  107150. timerQuery?: EXT_disjoint_timer_query;
  107151. /** Defines if timestamp can be used with timer query */
  107152. canUseTimestampForTimerQuery: boolean;
  107153. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  107154. multiview?: any;
  107155. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  107156. oculusMultiview?: any;
  107157. /** Function used to let the system compiles shaders in background */
  107158. parallelShaderCompile?: {
  107159. COMPLETION_STATUS_KHR: number;
  107160. };
  107161. /** Max number of texture samples for MSAA */
  107162. maxMSAASamples: number;
  107163. /** Defines if the blend min max extension is supported */
  107164. blendMinMax: boolean;
  107165. }
  107166. }
  107167. declare module BABYLON {
  107168. /**
  107169. * @hidden
  107170. **/
  107171. export class DepthCullingState {
  107172. private _isDepthTestDirty;
  107173. private _isDepthMaskDirty;
  107174. private _isDepthFuncDirty;
  107175. private _isCullFaceDirty;
  107176. private _isCullDirty;
  107177. private _isZOffsetDirty;
  107178. private _isFrontFaceDirty;
  107179. private _depthTest;
  107180. private _depthMask;
  107181. private _depthFunc;
  107182. private _cull;
  107183. private _cullFace;
  107184. private _zOffset;
  107185. private _frontFace;
  107186. /**
  107187. * Initializes the state.
  107188. */
  107189. constructor();
  107190. get isDirty(): boolean;
  107191. get zOffset(): number;
  107192. set zOffset(value: number);
  107193. get cullFace(): Nullable<number>;
  107194. set cullFace(value: Nullable<number>);
  107195. get cull(): Nullable<boolean>;
  107196. set cull(value: Nullable<boolean>);
  107197. get depthFunc(): Nullable<number>;
  107198. set depthFunc(value: Nullable<number>);
  107199. get depthMask(): boolean;
  107200. set depthMask(value: boolean);
  107201. get depthTest(): boolean;
  107202. set depthTest(value: boolean);
  107203. get frontFace(): Nullable<number>;
  107204. set frontFace(value: Nullable<number>);
  107205. reset(): void;
  107206. apply(gl: WebGLRenderingContext): void;
  107207. }
  107208. }
  107209. declare module BABYLON {
  107210. /**
  107211. * @hidden
  107212. **/
  107213. export class StencilState {
  107214. /** 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 */
  107215. static readonly ALWAYS: number;
  107216. /** Passed to stencilOperation to specify that stencil value must be kept */
  107217. static readonly KEEP: number;
  107218. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107219. static readonly REPLACE: number;
  107220. private _isStencilTestDirty;
  107221. private _isStencilMaskDirty;
  107222. private _isStencilFuncDirty;
  107223. private _isStencilOpDirty;
  107224. private _stencilTest;
  107225. private _stencilMask;
  107226. private _stencilFunc;
  107227. private _stencilFuncRef;
  107228. private _stencilFuncMask;
  107229. private _stencilOpStencilFail;
  107230. private _stencilOpDepthFail;
  107231. private _stencilOpStencilDepthPass;
  107232. get isDirty(): boolean;
  107233. get stencilFunc(): number;
  107234. set stencilFunc(value: number);
  107235. get stencilFuncRef(): number;
  107236. set stencilFuncRef(value: number);
  107237. get stencilFuncMask(): number;
  107238. set stencilFuncMask(value: number);
  107239. get stencilOpStencilFail(): number;
  107240. set stencilOpStencilFail(value: number);
  107241. get stencilOpDepthFail(): number;
  107242. set stencilOpDepthFail(value: number);
  107243. get stencilOpStencilDepthPass(): number;
  107244. set stencilOpStencilDepthPass(value: number);
  107245. get stencilMask(): number;
  107246. set stencilMask(value: number);
  107247. get stencilTest(): boolean;
  107248. set stencilTest(value: boolean);
  107249. constructor();
  107250. reset(): void;
  107251. apply(gl: WebGLRenderingContext): void;
  107252. }
  107253. }
  107254. declare module BABYLON {
  107255. /**
  107256. * @hidden
  107257. **/
  107258. export class AlphaState {
  107259. private _isAlphaBlendDirty;
  107260. private _isBlendFunctionParametersDirty;
  107261. private _isBlendEquationParametersDirty;
  107262. private _isBlendConstantsDirty;
  107263. private _alphaBlend;
  107264. private _blendFunctionParameters;
  107265. private _blendEquationParameters;
  107266. private _blendConstants;
  107267. /**
  107268. * Initializes the state.
  107269. */
  107270. constructor();
  107271. get isDirty(): boolean;
  107272. get alphaBlend(): boolean;
  107273. set alphaBlend(value: boolean);
  107274. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107275. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107276. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107277. reset(): void;
  107278. apply(gl: WebGLRenderingContext): void;
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /** @hidden */
  107283. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107284. attributeProcessor(attribute: string): string;
  107285. varyingProcessor(varying: string, isFragment: boolean): string;
  107286. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107287. }
  107288. }
  107289. declare module BABYLON {
  107290. /**
  107291. * Interface for attribute information associated with buffer instanciation
  107292. */
  107293. export interface InstancingAttributeInfo {
  107294. /**
  107295. * Name of the GLSL attribute
  107296. * if attribute index is not specified, this is used to retrieve the index from the effect
  107297. */
  107298. attributeName: string;
  107299. /**
  107300. * Index/offset of the attribute in the vertex shader
  107301. * if not specified, this will be computes from the name.
  107302. */
  107303. index?: number;
  107304. /**
  107305. * size of the attribute, 1, 2, 3 or 4
  107306. */
  107307. attributeSize: number;
  107308. /**
  107309. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107310. */
  107311. offset: number;
  107312. /**
  107313. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107314. * default to 1
  107315. */
  107316. divisor?: number;
  107317. /**
  107318. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107319. * default is FLOAT
  107320. */
  107321. attributeType?: number;
  107322. /**
  107323. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107324. */
  107325. normalized?: boolean;
  107326. }
  107327. }
  107328. declare module BABYLON {
  107329. interface ThinEngine {
  107330. /**
  107331. * Update a video texture
  107332. * @param texture defines the texture to update
  107333. * @param video defines the video element to use
  107334. * @param invertY defines if data must be stored with Y axis inverted
  107335. */
  107336. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107337. }
  107338. }
  107339. declare module BABYLON {
  107340. /**
  107341. * Settings for finer control over video usage
  107342. */
  107343. export interface VideoTextureSettings {
  107344. /**
  107345. * Applies `autoplay` to video, if specified
  107346. */
  107347. autoPlay?: boolean;
  107348. /**
  107349. * Applies `loop` to video, if specified
  107350. */
  107351. loop?: boolean;
  107352. /**
  107353. * Automatically updates internal texture from video at every frame in the render loop
  107354. */
  107355. autoUpdateTexture: boolean;
  107356. /**
  107357. * Image src displayed during the video loading or until the user interacts with the video.
  107358. */
  107359. poster?: string;
  107360. }
  107361. /**
  107362. * If you want to display a video in your scene, this is the special texture for that.
  107363. * This special texture works similar to other textures, with the exception of a few parameters.
  107364. * @see https://doc.babylonjs.com/how_to/video_texture
  107365. */
  107366. export class VideoTexture extends Texture {
  107367. /**
  107368. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107369. */
  107370. readonly autoUpdateTexture: boolean;
  107371. /**
  107372. * The video instance used by the texture internally
  107373. */
  107374. readonly video: HTMLVideoElement;
  107375. private _onUserActionRequestedObservable;
  107376. /**
  107377. * Event triggerd when a dom action is required by the user to play the video.
  107378. * This happens due to recent changes in browser policies preventing video to auto start.
  107379. */
  107380. get onUserActionRequestedObservable(): Observable<Texture>;
  107381. private _generateMipMaps;
  107382. private _stillImageCaptured;
  107383. private _displayingPosterTexture;
  107384. private _settings;
  107385. private _createInternalTextureOnEvent;
  107386. private _frameId;
  107387. private _currentSrc;
  107388. /**
  107389. * Creates a video texture.
  107390. * If you want to display a video in your scene, this is the special texture for that.
  107391. * This special texture works similar to other textures, with the exception of a few parameters.
  107392. * @see https://doc.babylonjs.com/how_to/video_texture
  107393. * @param name optional name, will detect from video source, if not defined
  107394. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107395. * @param scene is obviously the current scene.
  107396. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107397. * @param invertY is false by default but can be used to invert video on Y axis
  107398. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107399. * @param settings allows finer control over video usage
  107400. */
  107401. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107402. private _getName;
  107403. private _getVideo;
  107404. private _createInternalTexture;
  107405. private reset;
  107406. /**
  107407. * @hidden Internal method to initiate `update`.
  107408. */
  107409. _rebuild(): void;
  107410. /**
  107411. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107412. */
  107413. update(): void;
  107414. /**
  107415. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107416. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107417. */
  107418. updateTexture(isVisible: boolean): void;
  107419. protected _updateInternalTexture: () => void;
  107420. /**
  107421. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107422. * @param url New url.
  107423. */
  107424. updateURL(url: string): void;
  107425. /**
  107426. * Clones the texture.
  107427. * @returns the cloned texture
  107428. */
  107429. clone(): VideoTexture;
  107430. /**
  107431. * Dispose the texture and release its associated resources.
  107432. */
  107433. dispose(): void;
  107434. /**
  107435. * Creates a video texture straight from a stream.
  107436. * @param scene Define the scene the texture should be created in
  107437. * @param stream Define the stream the texture should be created from
  107438. * @returns The created video texture as a promise
  107439. */
  107440. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107441. /**
  107442. * Creates a video texture straight from your WebCam video feed.
  107443. * @param scene Define the scene the texture should be created in
  107444. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107445. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107446. * @returns The created video texture as a promise
  107447. */
  107448. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107449. minWidth: number;
  107450. maxWidth: number;
  107451. minHeight: number;
  107452. maxHeight: number;
  107453. deviceId: string;
  107454. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107455. /**
  107456. * Creates a video texture straight from your WebCam video feed.
  107457. * @param scene Define the scene the texture should be created in
  107458. * @param onReady Define a callback to triggered once the texture will be ready
  107459. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107460. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107461. */
  107462. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107463. minWidth: number;
  107464. maxWidth: number;
  107465. minHeight: number;
  107466. maxHeight: number;
  107467. deviceId: string;
  107468. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107469. }
  107470. }
  107471. declare module BABYLON {
  107472. /**
  107473. * Defines the interface used by objects working like Scene
  107474. * @hidden
  107475. */
  107476. export interface ISceneLike {
  107477. _addPendingData(data: any): void;
  107478. _removePendingData(data: any): void;
  107479. offlineProvider: IOfflineProvider;
  107480. }
  107481. /** Interface defining initialization parameters for Engine class */
  107482. export interface EngineOptions extends WebGLContextAttributes {
  107483. /**
  107484. * Defines if the engine should no exceed a specified device ratio
  107485. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107486. */
  107487. limitDeviceRatio?: number;
  107488. /**
  107489. * Defines if webvr should be enabled automatically
  107490. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107491. */
  107492. autoEnableWebVR?: boolean;
  107493. /**
  107494. * Defines if webgl2 should be turned off even if supported
  107495. * @see http://doc.babylonjs.com/features/webgl2
  107496. */
  107497. disableWebGL2Support?: boolean;
  107498. /**
  107499. * Defines if webaudio should be initialized as well
  107500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107501. */
  107502. audioEngine?: boolean;
  107503. /**
  107504. * Defines if animations should run using a deterministic lock step
  107505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107506. */
  107507. deterministicLockstep?: boolean;
  107508. /** Defines the maximum steps to use with deterministic lock step mode */
  107509. lockstepMaxSteps?: number;
  107510. /** Defines the seconds between each deterministic lock step */
  107511. timeStep?: number;
  107512. /**
  107513. * Defines that engine should ignore context lost events
  107514. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107515. */
  107516. doNotHandleContextLost?: boolean;
  107517. /**
  107518. * Defines that engine should ignore modifying touch action attribute and style
  107519. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107520. */
  107521. doNotHandleTouchAction?: boolean;
  107522. /**
  107523. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107524. */
  107525. useHighPrecisionFloats?: boolean;
  107526. }
  107527. /**
  107528. * The base engine class (root of all engines)
  107529. */
  107530. export class ThinEngine {
  107531. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107532. static ExceptionList: ({
  107533. key: string;
  107534. capture: string;
  107535. captureConstraint: number;
  107536. targets: string[];
  107537. } | {
  107538. key: string;
  107539. capture: null;
  107540. captureConstraint: null;
  107541. targets: string[];
  107542. })[];
  107543. /** @hidden */
  107544. static _TextureLoaders: IInternalTextureLoader[];
  107545. /**
  107546. * Returns the current npm package of the sdk
  107547. */
  107548. static get NpmPackage(): string;
  107549. /**
  107550. * Returns the current version of the framework
  107551. */
  107552. static get Version(): string;
  107553. /**
  107554. * Returns a string describing the current engine
  107555. */
  107556. get description(): string;
  107557. /**
  107558. * Gets or sets the epsilon value used by collision engine
  107559. */
  107560. static CollisionsEpsilon: number;
  107561. /**
  107562. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107563. */
  107564. static get ShadersRepository(): string;
  107565. static set ShadersRepository(value: string);
  107566. /** @hidden */
  107567. _shaderProcessor: IShaderProcessor;
  107568. /**
  107569. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107570. */
  107571. forcePOTTextures: boolean;
  107572. /**
  107573. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107574. */
  107575. isFullscreen: boolean;
  107576. /**
  107577. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107578. */
  107579. cullBackFaces: boolean;
  107580. /**
  107581. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107582. */
  107583. renderEvenInBackground: boolean;
  107584. /**
  107585. * Gets or sets a boolean indicating that cache can be kept between frames
  107586. */
  107587. preventCacheWipeBetweenFrames: boolean;
  107588. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107589. validateShaderPrograms: boolean;
  107590. /**
  107591. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107592. * This can provide greater z depth for distant objects.
  107593. */
  107594. useReverseDepthBuffer: boolean;
  107595. /**
  107596. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107597. */
  107598. disableUniformBuffers: boolean;
  107599. /** @hidden */
  107600. _uniformBuffers: UniformBuffer[];
  107601. /**
  107602. * Gets a boolean indicating that the engine supports uniform buffers
  107603. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107604. */
  107605. get supportsUniformBuffers(): boolean;
  107606. /** @hidden */
  107607. _gl: WebGLRenderingContext;
  107608. /** @hidden */
  107609. _webGLVersion: number;
  107610. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107611. protected _windowIsBackground: boolean;
  107612. protected _creationOptions: EngineOptions;
  107613. protected _highPrecisionShadersAllowed: boolean;
  107614. /** @hidden */
  107615. get _shouldUseHighPrecisionShader(): boolean;
  107616. /**
  107617. * Gets a boolean indicating that only power of 2 textures are supported
  107618. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107619. */
  107620. get needPOTTextures(): boolean;
  107621. /** @hidden */
  107622. _badOS: boolean;
  107623. /** @hidden */
  107624. _badDesktopOS: boolean;
  107625. private _hardwareScalingLevel;
  107626. /** @hidden */
  107627. _caps: EngineCapabilities;
  107628. private _isStencilEnable;
  107629. private _glVersion;
  107630. private _glRenderer;
  107631. private _glVendor;
  107632. /** @hidden */
  107633. _videoTextureSupported: boolean;
  107634. protected _renderingQueueLaunched: boolean;
  107635. protected _activeRenderLoops: (() => void)[];
  107636. /**
  107637. * Observable signaled when a context lost event is raised
  107638. */
  107639. onContextLostObservable: Observable<ThinEngine>;
  107640. /**
  107641. * Observable signaled when a context restored event is raised
  107642. */
  107643. onContextRestoredObservable: Observable<ThinEngine>;
  107644. private _onContextLost;
  107645. private _onContextRestored;
  107646. protected _contextWasLost: boolean;
  107647. /** @hidden */
  107648. _doNotHandleContextLost: boolean;
  107649. /**
  107650. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107652. */
  107653. get doNotHandleContextLost(): boolean;
  107654. set doNotHandleContextLost(value: boolean);
  107655. /**
  107656. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107657. */
  107658. disableVertexArrayObjects: boolean;
  107659. /** @hidden */
  107660. protected _colorWrite: boolean;
  107661. /** @hidden */
  107662. protected _colorWriteChanged: boolean;
  107663. /** @hidden */
  107664. protected _depthCullingState: DepthCullingState;
  107665. /** @hidden */
  107666. protected _stencilState: StencilState;
  107667. /** @hidden */
  107668. _alphaState: AlphaState;
  107669. /** @hidden */
  107670. _alphaMode: number;
  107671. /** @hidden */
  107672. _alphaEquation: number;
  107673. /** @hidden */
  107674. _internalTexturesCache: InternalTexture[];
  107675. /** @hidden */
  107676. protected _activeChannel: number;
  107677. private _currentTextureChannel;
  107678. /** @hidden */
  107679. protected _boundTexturesCache: {
  107680. [key: string]: Nullable<InternalTexture>;
  107681. };
  107682. /** @hidden */
  107683. protected _currentEffect: Nullable<Effect>;
  107684. /** @hidden */
  107685. protected _currentProgram: Nullable<WebGLProgram>;
  107686. private _compiledEffects;
  107687. private _vertexAttribArraysEnabled;
  107688. /** @hidden */
  107689. protected _cachedViewport: Nullable<IViewportLike>;
  107690. private _cachedVertexArrayObject;
  107691. /** @hidden */
  107692. protected _cachedVertexBuffers: any;
  107693. /** @hidden */
  107694. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107695. /** @hidden */
  107696. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107697. /** @hidden */
  107698. _currentRenderTarget: Nullable<InternalTexture>;
  107699. private _uintIndicesCurrentlySet;
  107700. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107701. /** @hidden */
  107702. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107703. /** @hidden */
  107704. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  107705. private _currentBufferPointers;
  107706. private _currentInstanceLocations;
  107707. private _currentInstanceBuffers;
  107708. private _textureUnits;
  107709. /** @hidden */
  107710. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107711. /** @hidden */
  107712. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107713. /** @hidden */
  107714. _boundRenderFunction: any;
  107715. private _vaoRecordInProgress;
  107716. private _mustWipeVertexAttributes;
  107717. private _emptyTexture;
  107718. private _emptyCubeTexture;
  107719. private _emptyTexture3D;
  107720. private _emptyTexture2DArray;
  107721. /** @hidden */
  107722. _frameHandler: number;
  107723. private _nextFreeTextureSlots;
  107724. private _maxSimultaneousTextures;
  107725. private _activeRequests;
  107726. /** @hidden */
  107727. _transformTextureUrl: Nullable<(url: string) => string>;
  107728. protected get _supportsHardwareTextureRescaling(): boolean;
  107729. private _framebufferDimensionsObject;
  107730. /**
  107731. * sets the object from which width and height will be taken from when getting render width and height
  107732. * Will fallback to the gl object
  107733. * @param dimensions the framebuffer width and height that will be used.
  107734. */
  107735. set framebufferDimensionsObject(dimensions: Nullable<{
  107736. framebufferWidth: number;
  107737. framebufferHeight: number;
  107738. }>);
  107739. /**
  107740. * Gets the current viewport
  107741. */
  107742. get currentViewport(): Nullable<IViewportLike>;
  107743. /**
  107744. * Gets the default empty texture
  107745. */
  107746. get emptyTexture(): InternalTexture;
  107747. /**
  107748. * Gets the default empty 3D texture
  107749. */
  107750. get emptyTexture3D(): InternalTexture;
  107751. /**
  107752. * Gets the default empty 2D array texture
  107753. */
  107754. get emptyTexture2DArray(): InternalTexture;
  107755. /**
  107756. * Gets the default empty cube texture
  107757. */
  107758. get emptyCubeTexture(): InternalTexture;
  107759. /**
  107760. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107761. */
  107762. readonly premultipliedAlpha: boolean;
  107763. /**
  107764. * Observable event triggered before each texture is initialized
  107765. */
  107766. onBeforeTextureInitObservable: Observable<Texture>;
  107767. /**
  107768. * Creates a new engine
  107769. * @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
  107770. * @param antialias defines enable antialiasing (default: false)
  107771. * @param options defines further options to be sent to the getContext() function
  107772. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107773. */
  107774. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107775. private _rebuildInternalTextures;
  107776. private _rebuildEffects;
  107777. /**
  107778. * Gets a boolean indicating if all created effects are ready
  107779. * @returns true if all effects are ready
  107780. */
  107781. areAllEffectsReady(): boolean;
  107782. protected _rebuildBuffers(): void;
  107783. protected _initGLContext(): void;
  107784. /**
  107785. * Gets version of the current webGL context
  107786. */
  107787. get webGLVersion(): number;
  107788. /**
  107789. * Gets a string idenfifying the name of the class
  107790. * @returns "Engine" string
  107791. */
  107792. getClassName(): string;
  107793. /**
  107794. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107795. */
  107796. get isStencilEnable(): boolean;
  107797. /** @hidden */
  107798. _prepareWorkingCanvas(): void;
  107799. /**
  107800. * Reset the texture cache to empty state
  107801. */
  107802. resetTextureCache(): void;
  107803. /**
  107804. * Gets an object containing information about the current webGL context
  107805. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107806. */
  107807. getGlInfo(): {
  107808. vendor: string;
  107809. renderer: string;
  107810. version: string;
  107811. };
  107812. /**
  107813. * Defines the hardware scaling level.
  107814. * By default the hardware scaling level is computed from the window device ratio.
  107815. * 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.
  107816. * @param level defines the level to use
  107817. */
  107818. setHardwareScalingLevel(level: number): void;
  107819. /**
  107820. * Gets the current hardware scaling level.
  107821. * By default the hardware scaling level is computed from the window device ratio.
  107822. * 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.
  107823. * @returns a number indicating the current hardware scaling level
  107824. */
  107825. getHardwareScalingLevel(): number;
  107826. /**
  107827. * Gets the list of loaded textures
  107828. * @returns an array containing all loaded textures
  107829. */
  107830. getLoadedTexturesCache(): InternalTexture[];
  107831. /**
  107832. * Gets the object containing all engine capabilities
  107833. * @returns the EngineCapabilities object
  107834. */
  107835. getCaps(): EngineCapabilities;
  107836. /**
  107837. * stop executing a render loop function and remove it from the execution array
  107838. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107839. */
  107840. stopRenderLoop(renderFunction?: () => void): void;
  107841. /** @hidden */
  107842. _renderLoop(): void;
  107843. /**
  107844. * Gets the HTML canvas attached with the current webGL context
  107845. * @returns a HTML canvas
  107846. */
  107847. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107848. /**
  107849. * Gets host window
  107850. * @returns the host window object
  107851. */
  107852. getHostWindow(): Nullable<Window>;
  107853. /**
  107854. * Gets the current render width
  107855. * @param useScreen defines if screen size must be used (or the current render target if any)
  107856. * @returns a number defining the current render width
  107857. */
  107858. getRenderWidth(useScreen?: boolean): number;
  107859. /**
  107860. * Gets the current render height
  107861. * @param useScreen defines if screen size must be used (or the current render target if any)
  107862. * @returns a number defining the current render height
  107863. */
  107864. getRenderHeight(useScreen?: boolean): number;
  107865. /**
  107866. * Can be used to override the current requestAnimationFrame requester.
  107867. * @hidden
  107868. */
  107869. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107870. /**
  107871. * Register and execute a render loop. The engine can have more than one render function
  107872. * @param renderFunction defines the function to continuously execute
  107873. */
  107874. runRenderLoop(renderFunction: () => void): void;
  107875. /**
  107876. * Clear the current render buffer or the current render target (if any is set up)
  107877. * @param color defines the color to use
  107878. * @param backBuffer defines if the back buffer must be cleared
  107879. * @param depth defines if the depth buffer must be cleared
  107880. * @param stencil defines if the stencil buffer must be cleared
  107881. */
  107882. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107883. private _viewportCached;
  107884. /** @hidden */
  107885. _viewport(x: number, y: number, width: number, height: number): void;
  107886. /**
  107887. * Set the WebGL's viewport
  107888. * @param viewport defines the viewport element to be used
  107889. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107890. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107891. */
  107892. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107893. /**
  107894. * Begin a new frame
  107895. */
  107896. beginFrame(): void;
  107897. /**
  107898. * Enf the current frame
  107899. */
  107900. endFrame(): void;
  107901. /**
  107902. * Resize the view according to the canvas' size
  107903. */
  107904. resize(): void;
  107905. /**
  107906. * Force a specific size of the canvas
  107907. * @param width defines the new canvas' width
  107908. * @param height defines the new canvas' height
  107909. */
  107910. setSize(width: number, height: number): void;
  107911. /**
  107912. * Binds the frame buffer to the specified texture.
  107913. * @param texture The texture to render to or null for the default canvas
  107914. * @param faceIndex The face of the texture to render to in case of cube texture
  107915. * @param requiredWidth The width of the target to render to
  107916. * @param requiredHeight The height of the target to render to
  107917. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107918. * @param lodLevel defines the lod level to bind to the frame buffer
  107919. * @param layer defines the 2d array index to bind to frame buffer to
  107920. */
  107921. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107922. /** @hidden */
  107923. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107924. /**
  107925. * Unbind the current render target texture from the webGL context
  107926. * @param texture defines the render target texture to unbind
  107927. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107928. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107929. */
  107930. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107931. /**
  107932. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107933. */
  107934. flushFramebuffer(): void;
  107935. /**
  107936. * Unbind the current render target and bind the default framebuffer
  107937. */
  107938. restoreDefaultFramebuffer(): void;
  107939. /** @hidden */
  107940. protected _resetVertexBufferBinding(): void;
  107941. /**
  107942. * Creates a vertex buffer
  107943. * @param data the data for the vertex buffer
  107944. * @returns the new WebGL static buffer
  107945. */
  107946. createVertexBuffer(data: DataArray): DataBuffer;
  107947. private _createVertexBuffer;
  107948. /**
  107949. * Creates a dynamic vertex buffer
  107950. * @param data the data for the dynamic vertex buffer
  107951. * @returns the new WebGL dynamic buffer
  107952. */
  107953. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  107954. protected _resetIndexBufferBinding(): void;
  107955. /**
  107956. * Creates a new index buffer
  107957. * @param indices defines the content of the index buffer
  107958. * @param updatable defines if the index buffer must be updatable
  107959. * @returns a new webGL buffer
  107960. */
  107961. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  107962. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  107963. /**
  107964. * Bind a webGL buffer to the webGL context
  107965. * @param buffer defines the buffer to bind
  107966. */
  107967. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  107968. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  107969. private bindBuffer;
  107970. /**
  107971. * update the bound buffer with the given data
  107972. * @param data defines the data to update
  107973. */
  107974. updateArrayBuffer(data: Float32Array): void;
  107975. private _vertexAttribPointer;
  107976. /** @hidden */
  107977. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  107978. private _bindVertexBuffersAttributes;
  107979. /**
  107980. * Records a vertex array object
  107981. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107982. * @param vertexBuffers defines the list of vertex buffers to store
  107983. * @param indexBuffer defines the index buffer to store
  107984. * @param effect defines the effect to store
  107985. * @returns the new vertex array object
  107986. */
  107987. recordVertexArrayObject(vertexBuffers: {
  107988. [key: string]: VertexBuffer;
  107989. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  107990. /**
  107991. * Bind a specific vertex array object
  107992. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107993. * @param vertexArrayObject defines the vertex array object to bind
  107994. * @param indexBuffer defines the index buffer to bind
  107995. */
  107996. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  107997. /**
  107998. * Bind webGl buffers directly to the webGL context
  107999. * @param vertexBuffer defines the vertex buffer to bind
  108000. * @param indexBuffer defines the index buffer to bind
  108001. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  108002. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  108003. * @param effect defines the effect associated with the vertex buffer
  108004. */
  108005. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  108006. private _unbindVertexArrayObject;
  108007. /**
  108008. * Bind a list of vertex buffers to the webGL context
  108009. * @param vertexBuffers defines the list of vertex buffers to bind
  108010. * @param indexBuffer defines the index buffer to bind
  108011. * @param effect defines the effect associated with the vertex buffers
  108012. */
  108013. bindBuffers(vertexBuffers: {
  108014. [key: string]: Nullable<VertexBuffer>;
  108015. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  108016. /**
  108017. * Unbind all instance attributes
  108018. */
  108019. unbindInstanceAttributes(): void;
  108020. /**
  108021. * Release and free the memory of a vertex array object
  108022. * @param vao defines the vertex array object to delete
  108023. */
  108024. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  108025. /** @hidden */
  108026. _releaseBuffer(buffer: DataBuffer): boolean;
  108027. protected _deleteBuffer(buffer: DataBuffer): void;
  108028. /**
  108029. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  108030. * @param instancesBuffer defines the webGL buffer to update and bind
  108031. * @param data defines the data to store in the buffer
  108032. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  108033. */
  108034. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  108035. /**
  108036. * Bind the content of a webGL buffer used with instantiation
  108037. * @param instancesBuffer defines the webGL buffer to bind
  108038. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  108039. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  108040. */
  108041. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  108042. /**
  108043. * Disable the instance attribute corresponding to the name in parameter
  108044. * @param name defines the name of the attribute to disable
  108045. */
  108046. disableInstanceAttributeByName(name: string): void;
  108047. /**
  108048. * Disable the instance attribute corresponding to the location in parameter
  108049. * @param attributeLocation defines the attribute location of the attribute to disable
  108050. */
  108051. disableInstanceAttribute(attributeLocation: number): void;
  108052. /**
  108053. * Disable the attribute corresponding to the location in parameter
  108054. * @param attributeLocation defines the attribute location of the attribute to disable
  108055. */
  108056. disableAttributeByIndex(attributeLocation: number): void;
  108057. /**
  108058. * Send a draw order
  108059. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108060. * @param indexStart defines the starting index
  108061. * @param indexCount defines the number of index to draw
  108062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108063. */
  108064. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108065. /**
  108066. * Draw a list of points
  108067. * @param verticesStart defines the index of first vertex to draw
  108068. * @param verticesCount defines the count of vertices to draw
  108069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108070. */
  108071. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108072. /**
  108073. * Draw a list of unindexed primitives
  108074. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  108075. * @param verticesStart defines the index of first vertex to draw
  108076. * @param verticesCount defines the count of vertices to draw
  108077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108078. */
  108079. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108080. /**
  108081. * Draw a list of indexed primitives
  108082. * @param fillMode defines the primitive to use
  108083. * @param indexStart defines the starting index
  108084. * @param indexCount defines the number of index to draw
  108085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108086. */
  108087. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108088. /**
  108089. * Draw a list of unindexed primitives
  108090. * @param fillMode defines the primitive to use
  108091. * @param verticesStart defines the index of first vertex to draw
  108092. * @param verticesCount defines the count of vertices to draw
  108093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  108094. */
  108095. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108096. private _drawMode;
  108097. /** @hidden */
  108098. protected _reportDrawCall(): void;
  108099. /** @hidden */
  108100. _releaseEffect(effect: Effect): void;
  108101. /** @hidden */
  108102. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108103. /**
  108104. * Create a new effect (used to store vertex/fragment shaders)
  108105. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  108106. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  108107. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  108108. * @param samplers defines an array of string used to represent textures
  108109. * @param defines defines the string containing the defines to use to compile the shaders
  108110. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108111. * @param onCompiled defines a function to call when the effect creation is successful
  108112. * @param onError defines a function to call when the effect creation has failed
  108113. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  108114. * @returns the new Effect
  108115. */
  108116. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  108117. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  108118. private _compileShader;
  108119. private _compileRawShader;
  108120. /** @hidden */
  108121. _getShaderSource(shader: WebGLShader): Nullable<string>;
  108122. /**
  108123. * Directly creates a webGL program
  108124. * @param pipelineContext defines the pipeline context to attach to
  108125. * @param vertexCode defines the vertex shader code to use
  108126. * @param fragmentCode defines the fragment shader code to use
  108127. * @param context defines the webGL context to use (if not set, the current one will be used)
  108128. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108129. * @returns the new webGL program
  108130. */
  108131. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108132. /**
  108133. * Creates a webGL program
  108134. * @param pipelineContext defines the pipeline context to attach to
  108135. * @param vertexCode defines the vertex shader code to use
  108136. * @param fragmentCode defines the fragment shader code to use
  108137. * @param defines defines the string containing the defines to use to compile the shaders
  108138. * @param context defines the webGL context to use (if not set, the current one will be used)
  108139. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  108140. * @returns the new webGL program
  108141. */
  108142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108143. /**
  108144. * Creates a new pipeline context
  108145. * @returns the new pipeline
  108146. */
  108147. createPipelineContext(): IPipelineContext;
  108148. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108149. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  108150. /** @hidden */
  108151. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  108152. /** @hidden */
  108153. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  108154. /** @hidden */
  108155. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  108156. /**
  108157. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  108158. * @param pipelineContext defines the pipeline context to use
  108159. * @param uniformsNames defines the list of uniform names
  108160. * @returns an array of webGL uniform locations
  108161. */
  108162. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108163. /**
  108164. * Gets the lsit of active attributes for a given webGL program
  108165. * @param pipelineContext defines the pipeline context to use
  108166. * @param attributesNames defines the list of attribute names to get
  108167. * @returns an array of indices indicating the offset of each attribute
  108168. */
  108169. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108170. /**
  108171. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  108172. * @param effect defines the effect to activate
  108173. */
  108174. enableEffect(effect: Nullable<Effect>): void;
  108175. /**
  108176. * Set the value of an uniform to a number (int)
  108177. * @param uniform defines the webGL uniform location where to store the value
  108178. * @param value defines the int number to store
  108179. */
  108180. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108181. /**
  108182. * Set the value of an uniform to an array of int32
  108183. * @param uniform defines the webGL uniform location where to store the value
  108184. * @param array defines the array of int32 to store
  108185. */
  108186. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108187. /**
  108188. * Set the value of an uniform to an array of int32 (stored as vec2)
  108189. * @param uniform defines the webGL uniform location where to store the value
  108190. * @param array defines the array of int32 to store
  108191. */
  108192. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108193. /**
  108194. * Set the value of an uniform to an array of int32 (stored as vec3)
  108195. * @param uniform defines the webGL uniform location where to store the value
  108196. * @param array defines the array of int32 to store
  108197. */
  108198. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108199. /**
  108200. * Set the value of an uniform to an array of int32 (stored as vec4)
  108201. * @param uniform defines the webGL uniform location where to store the value
  108202. * @param array defines the array of int32 to store
  108203. */
  108204. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  108205. /**
  108206. * Set the value of an uniform to an array of number
  108207. * @param uniform defines the webGL uniform location where to store the value
  108208. * @param array defines the array of number to store
  108209. */
  108210. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108211. /**
  108212. * Set the value of an uniform to an array of number (stored as vec2)
  108213. * @param uniform defines the webGL uniform location where to store the value
  108214. * @param array defines the array of number to store
  108215. */
  108216. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108217. /**
  108218. * Set the value of an uniform to an array of number (stored as vec3)
  108219. * @param uniform defines the webGL uniform location where to store the value
  108220. * @param array defines the array of number to store
  108221. */
  108222. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108223. /**
  108224. * Set the value of an uniform to an array of number (stored as vec4)
  108225. * @param uniform defines the webGL uniform location where to store the value
  108226. * @param array defines the array of number to store
  108227. */
  108228. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108229. /**
  108230. * Set the value of an uniform to an array of float32 (stored as matrices)
  108231. * @param uniform defines the webGL uniform location where to store the value
  108232. * @param matrices defines the array of float32 to store
  108233. */
  108234. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108235. /**
  108236. * Set the value of an uniform to a matrix (3x3)
  108237. * @param uniform defines the webGL uniform location where to store the value
  108238. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108239. */
  108240. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108241. /**
  108242. * Set the value of an uniform to a matrix (2x2)
  108243. * @param uniform defines the webGL uniform location where to store the value
  108244. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108245. */
  108246. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108247. /**
  108248. * Set the value of an uniform to a number (float)
  108249. * @param uniform defines the webGL uniform location where to store the value
  108250. * @param value defines the float number to store
  108251. */
  108252. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108253. /**
  108254. * Set the value of an uniform to a vec2
  108255. * @param uniform defines the webGL uniform location where to store the value
  108256. * @param x defines the 1st component of the value
  108257. * @param y defines the 2nd component of the value
  108258. */
  108259. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108260. /**
  108261. * Set the value of an uniform to a vec3
  108262. * @param uniform defines the webGL uniform location where to store the value
  108263. * @param x defines the 1st component of the value
  108264. * @param y defines the 2nd component of the value
  108265. * @param z defines the 3rd component of the value
  108266. */
  108267. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108268. /**
  108269. * Set the value of an uniform to a vec4
  108270. * @param uniform defines the webGL uniform location where to store the value
  108271. * @param x defines the 1st component of the value
  108272. * @param y defines the 2nd component of the value
  108273. * @param z defines the 3rd component of the value
  108274. * @param w defines the 4th component of the value
  108275. */
  108276. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108277. /**
  108278. * Apply all cached states (depth, culling, stencil and alpha)
  108279. */
  108280. applyStates(): void;
  108281. /**
  108282. * Enable or disable color writing
  108283. * @param enable defines the state to set
  108284. */
  108285. setColorWrite(enable: boolean): void;
  108286. /**
  108287. * Gets a boolean indicating if color writing is enabled
  108288. * @returns the current color writing state
  108289. */
  108290. getColorWrite(): boolean;
  108291. /**
  108292. * Gets the depth culling state manager
  108293. */
  108294. get depthCullingState(): DepthCullingState;
  108295. /**
  108296. * Gets the alpha state manager
  108297. */
  108298. get alphaState(): AlphaState;
  108299. /**
  108300. * Gets the stencil state manager
  108301. */
  108302. get stencilState(): StencilState;
  108303. /**
  108304. * Clears the list of texture accessible through engine.
  108305. * This can help preventing texture load conflict due to name collision.
  108306. */
  108307. clearInternalTexturesCache(): void;
  108308. /**
  108309. * Force the entire cache to be cleared
  108310. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108311. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108312. */
  108313. wipeCaches(bruteForce?: boolean): void;
  108314. /** @hidden */
  108315. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108316. min: number;
  108317. mag: number;
  108318. };
  108319. /** @hidden */
  108320. _createTexture(): WebGLTexture;
  108321. /**
  108322. * Usually called from Texture.ts.
  108323. * Passed information to create a WebGLTexture
  108324. * @param url defines a value which contains one of the following:
  108325. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108326. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108327. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108328. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108329. * @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)
  108330. * @param scene needed for loading to the correct scene
  108331. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108332. * @param onLoad optional callback to be called upon successful completion
  108333. * @param onError optional callback to be called upon failure
  108334. * @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
  108335. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108336. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108337. * @param forcedExtension defines the extension to use to pick the right loader
  108338. * @param mimeType defines an optional mime type
  108339. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108340. */
  108341. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  108342. /**
  108343. * Loads an image as an HTMLImageElement.
  108344. * @param input url string, ArrayBuffer, or Blob to load
  108345. * @param onLoad callback called when the image successfully loads
  108346. * @param onError callback called when the image fails to load
  108347. * @param offlineProvider offline provider for caching
  108348. * @param mimeType optional mime type
  108349. * @returns the HTMLImageElement of the loaded image
  108350. * @hidden
  108351. */
  108352. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108353. /**
  108354. * @hidden
  108355. */
  108356. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108357. private _unpackFlipYCached;
  108358. /**
  108359. * In case you are sharing the context with other applications, it might
  108360. * be interested to not cache the unpack flip y state to ensure a consistent
  108361. * value would be set.
  108362. */
  108363. enableUnpackFlipYCached: boolean;
  108364. /** @hidden */
  108365. _unpackFlipY(value: boolean): void;
  108366. /** @hidden */
  108367. _getUnpackAlignement(): number;
  108368. private _getTextureTarget;
  108369. /**
  108370. * Update the sampling mode of a given texture
  108371. * @param samplingMode defines the required sampling mode
  108372. * @param texture defines the texture to update
  108373. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108374. */
  108375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108376. /**
  108377. * Update the sampling mode of a given texture
  108378. * @param texture defines the texture to update
  108379. * @param wrapU defines the texture wrap mode of the u coordinates
  108380. * @param wrapV defines the texture wrap mode of the v coordinates
  108381. * @param wrapR defines the texture wrap mode of the r coordinates
  108382. */
  108383. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108384. /** @hidden */
  108385. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108386. width: number;
  108387. height: number;
  108388. layers?: number;
  108389. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108390. /** @hidden */
  108391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108392. /** @hidden */
  108393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108394. /**
  108395. * Update a portion of an internal texture
  108396. * @param texture defines the texture to update
  108397. * @param imageData defines the data to store into the texture
  108398. * @param xOffset defines the x coordinates of the update rectangle
  108399. * @param yOffset defines the y coordinates of the update rectangle
  108400. * @param width defines the width of the update rectangle
  108401. * @param height defines the height of the update rectangle
  108402. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108403. * @param lod defines the lod level to update (0 by default)
  108404. */
  108405. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108406. /** @hidden */
  108407. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108408. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108409. private _prepareWebGLTexture;
  108410. /** @hidden */
  108411. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108412. private _getDepthStencilBuffer;
  108413. /** @hidden */
  108414. _releaseFramebufferObjects(texture: InternalTexture): void;
  108415. /** @hidden */
  108416. _releaseTexture(texture: InternalTexture): void;
  108417. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108418. protected _setProgram(program: WebGLProgram): void;
  108419. protected _boundUniforms: {
  108420. [key: number]: WebGLUniformLocation;
  108421. };
  108422. /**
  108423. * Binds an effect to the webGL context
  108424. * @param effect defines the effect to bind
  108425. */
  108426. bindSamplers(effect: Effect): void;
  108427. private _activateCurrentTexture;
  108428. /** @hidden */
  108429. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108430. /** @hidden */
  108431. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108432. /**
  108433. * Unbind all textures from the webGL context
  108434. */
  108435. unbindAllTextures(): void;
  108436. /**
  108437. * Sets a texture to the according uniform.
  108438. * @param channel The texture channel
  108439. * @param uniform The uniform to set
  108440. * @param texture The texture to apply
  108441. */
  108442. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108443. private _bindSamplerUniformToChannel;
  108444. private _getTextureWrapMode;
  108445. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108446. /**
  108447. * Sets an array of texture to the webGL context
  108448. * @param channel defines the channel where the texture array must be set
  108449. * @param uniform defines the associated uniform location
  108450. * @param textures defines the array of textures to bind
  108451. */
  108452. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108453. /** @hidden */
  108454. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108455. private _setTextureParameterFloat;
  108456. private _setTextureParameterInteger;
  108457. /**
  108458. * Unbind all vertex attributes from the webGL context
  108459. */
  108460. unbindAllAttributes(): void;
  108461. /**
  108462. * 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
  108463. */
  108464. releaseEffects(): void;
  108465. /**
  108466. * Dispose and release all associated resources
  108467. */
  108468. dispose(): void;
  108469. /**
  108470. * Attach a new callback raised when context lost event is fired
  108471. * @param callback defines the callback to call
  108472. */
  108473. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108474. /**
  108475. * Attach a new callback raised when context restored event is fired
  108476. * @param callback defines the callback to call
  108477. */
  108478. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108479. /**
  108480. * Get the current error code of the webGL context
  108481. * @returns the error code
  108482. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108483. */
  108484. getError(): number;
  108485. private _canRenderToFloatFramebuffer;
  108486. private _canRenderToHalfFloatFramebuffer;
  108487. private _canRenderToFramebuffer;
  108488. /** @hidden */
  108489. _getWebGLTextureType(type: number): number;
  108490. /** @hidden */
  108491. _getInternalFormat(format: number): number;
  108492. /** @hidden */
  108493. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108494. /** @hidden */
  108495. _getRGBAMultiSampleBufferFormat(type: number): number;
  108496. /** @hidden */
  108497. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  108498. /**
  108499. * Loads a file from a url
  108500. * @param url url to load
  108501. * @param onSuccess callback called when the file successfully loads
  108502. * @param onProgress callback called while file is loading (if the server supports this mode)
  108503. * @param offlineProvider defines the offline provider for caching
  108504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108505. * @param onError callback called when the file fails to load
  108506. * @returns a file request object
  108507. * @hidden
  108508. */
  108509. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  108510. /**
  108511. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108512. * @param x defines the x coordinate of the rectangle where pixels must be read
  108513. * @param y defines the y coordinate of the rectangle where pixels must be read
  108514. * @param width defines the width of the rectangle where pixels must be read
  108515. * @param height defines the height of the rectangle where pixels must be read
  108516. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108517. * @returns a Uint8Array containing RGBA colors
  108518. */
  108519. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108520. private static _isSupported;
  108521. /**
  108522. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108523. * @returns true if the engine can be created
  108524. * @ignorenaming
  108525. */
  108526. static isSupported(): boolean;
  108527. /**
  108528. * Find the next highest power of two.
  108529. * @param x Number to start search from.
  108530. * @return Next highest power of two.
  108531. */
  108532. static CeilingPOT(x: number): number;
  108533. /**
  108534. * Find the next lowest power of two.
  108535. * @param x Number to start search from.
  108536. * @return Next lowest power of two.
  108537. */
  108538. static FloorPOT(x: number): number;
  108539. /**
  108540. * Find the nearest power of two.
  108541. * @param x Number to start search from.
  108542. * @return Next nearest power of two.
  108543. */
  108544. static NearestPOT(x: number): number;
  108545. /**
  108546. * Get the closest exponent of two
  108547. * @param value defines the value to approximate
  108548. * @param max defines the maximum value to return
  108549. * @param mode defines how to define the closest value
  108550. * @returns closest exponent of two of the given value
  108551. */
  108552. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108553. /**
  108554. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108555. * @param func - the function to be called
  108556. * @param requester - the object that will request the next frame. Falls back to window.
  108557. * @returns frame number
  108558. */
  108559. static QueueNewFrame(func: () => void, requester?: any): number;
  108560. /**
  108561. * Gets host document
  108562. * @returns the host document object
  108563. */
  108564. getHostDocument(): Nullable<Document>;
  108565. }
  108566. }
  108567. declare module BABYLON {
  108568. /**
  108569. * Class representing spherical harmonics coefficients to the 3rd degree
  108570. */
  108571. export class SphericalHarmonics {
  108572. /**
  108573. * Defines whether or not the harmonics have been prescaled for rendering.
  108574. */
  108575. preScaled: boolean;
  108576. /**
  108577. * The l0,0 coefficients of the spherical harmonics
  108578. */
  108579. l00: Vector3;
  108580. /**
  108581. * The l1,-1 coefficients of the spherical harmonics
  108582. */
  108583. l1_1: Vector3;
  108584. /**
  108585. * The l1,0 coefficients of the spherical harmonics
  108586. */
  108587. l10: Vector3;
  108588. /**
  108589. * The l1,1 coefficients of the spherical harmonics
  108590. */
  108591. l11: Vector3;
  108592. /**
  108593. * The l2,-2 coefficients of the spherical harmonics
  108594. */
  108595. l2_2: Vector3;
  108596. /**
  108597. * The l2,-1 coefficients of the spherical harmonics
  108598. */
  108599. l2_1: Vector3;
  108600. /**
  108601. * The l2,0 coefficients of the spherical harmonics
  108602. */
  108603. l20: Vector3;
  108604. /**
  108605. * The l2,1 coefficients of the spherical harmonics
  108606. */
  108607. l21: Vector3;
  108608. /**
  108609. * The l2,2 coefficients of the spherical harmonics
  108610. */
  108611. l22: Vector3;
  108612. /**
  108613. * Adds a light to the spherical harmonics
  108614. * @param direction the direction of the light
  108615. * @param color the color of the light
  108616. * @param deltaSolidAngle the delta solid angle of the light
  108617. */
  108618. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108619. /**
  108620. * Scales the spherical harmonics by the given amount
  108621. * @param scale the amount to scale
  108622. */
  108623. scaleInPlace(scale: number): void;
  108624. /**
  108625. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108626. *
  108627. * ```
  108628. * E_lm = A_l * L_lm
  108629. * ```
  108630. *
  108631. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108632. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108633. * the scaling factors are given in equation 9.
  108634. */
  108635. convertIncidentRadianceToIrradiance(): void;
  108636. /**
  108637. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108638. *
  108639. * ```
  108640. * L = (1/pi) * E * rho
  108641. * ```
  108642. *
  108643. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108644. */
  108645. convertIrradianceToLambertianRadiance(): void;
  108646. /**
  108647. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108648. * required operations at run time.
  108649. *
  108650. * This is simply done by scaling back the SH with Ylm constants parameter.
  108651. * The trigonometric part being applied by the shader at run time.
  108652. */
  108653. preScaleForRendering(): void;
  108654. /**
  108655. * Constructs a spherical harmonics from an array.
  108656. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108657. * @returns the spherical harmonics
  108658. */
  108659. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108660. /**
  108661. * Gets the spherical harmonics from polynomial
  108662. * @param polynomial the spherical polynomial
  108663. * @returns the spherical harmonics
  108664. */
  108665. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108666. }
  108667. /**
  108668. * Class representing spherical polynomial coefficients to the 3rd degree
  108669. */
  108670. export class SphericalPolynomial {
  108671. private _harmonics;
  108672. /**
  108673. * The spherical harmonics used to create the polynomials.
  108674. */
  108675. get preScaledHarmonics(): SphericalHarmonics;
  108676. /**
  108677. * The x coefficients of the spherical polynomial
  108678. */
  108679. x: Vector3;
  108680. /**
  108681. * The y coefficients of the spherical polynomial
  108682. */
  108683. y: Vector3;
  108684. /**
  108685. * The z coefficients of the spherical polynomial
  108686. */
  108687. z: Vector3;
  108688. /**
  108689. * The xx coefficients of the spherical polynomial
  108690. */
  108691. xx: Vector3;
  108692. /**
  108693. * The yy coefficients of the spherical polynomial
  108694. */
  108695. yy: Vector3;
  108696. /**
  108697. * The zz coefficients of the spherical polynomial
  108698. */
  108699. zz: Vector3;
  108700. /**
  108701. * The xy coefficients of the spherical polynomial
  108702. */
  108703. xy: Vector3;
  108704. /**
  108705. * The yz coefficients of the spherical polynomial
  108706. */
  108707. yz: Vector3;
  108708. /**
  108709. * The zx coefficients of the spherical polynomial
  108710. */
  108711. zx: Vector3;
  108712. /**
  108713. * Adds an ambient color to the spherical polynomial
  108714. * @param color the color to add
  108715. */
  108716. addAmbient(color: Color3): void;
  108717. /**
  108718. * Scales the spherical polynomial by the given amount
  108719. * @param scale the amount to scale
  108720. */
  108721. scaleInPlace(scale: number): void;
  108722. /**
  108723. * Gets the spherical polynomial from harmonics
  108724. * @param harmonics the spherical harmonics
  108725. * @returns the spherical polynomial
  108726. */
  108727. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108728. /**
  108729. * Constructs a spherical polynomial from an array.
  108730. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108731. * @returns the spherical polynomial
  108732. */
  108733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108734. }
  108735. }
  108736. declare module BABYLON {
  108737. /**
  108738. * Defines the source of the internal texture
  108739. */
  108740. export enum InternalTextureSource {
  108741. /**
  108742. * The source of the texture data is unknown
  108743. */
  108744. Unknown = 0,
  108745. /**
  108746. * Texture data comes from an URL
  108747. */
  108748. Url = 1,
  108749. /**
  108750. * Texture data is only used for temporary storage
  108751. */
  108752. Temp = 2,
  108753. /**
  108754. * Texture data comes from raw data (ArrayBuffer)
  108755. */
  108756. Raw = 3,
  108757. /**
  108758. * Texture content is dynamic (video or dynamic texture)
  108759. */
  108760. Dynamic = 4,
  108761. /**
  108762. * Texture content is generated by rendering to it
  108763. */
  108764. RenderTarget = 5,
  108765. /**
  108766. * Texture content is part of a multi render target process
  108767. */
  108768. MultiRenderTarget = 6,
  108769. /**
  108770. * Texture data comes from a cube data file
  108771. */
  108772. Cube = 7,
  108773. /**
  108774. * Texture data comes from a raw cube data
  108775. */
  108776. CubeRaw = 8,
  108777. /**
  108778. * Texture data come from a prefiltered cube data file
  108779. */
  108780. CubePrefiltered = 9,
  108781. /**
  108782. * Texture content is raw 3D data
  108783. */
  108784. Raw3D = 10,
  108785. /**
  108786. * Texture content is raw 2D array data
  108787. */
  108788. Raw2DArray = 11,
  108789. /**
  108790. * Texture content is a depth texture
  108791. */
  108792. Depth = 12,
  108793. /**
  108794. * Texture data comes from a raw cube data encoded with RGBD
  108795. */
  108796. CubeRawRGBD = 13
  108797. }
  108798. /**
  108799. * Class used to store data associated with WebGL texture data for the engine
  108800. * This class should not be used directly
  108801. */
  108802. export class InternalTexture {
  108803. /** @hidden */
  108804. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108805. /**
  108806. * Defines if the texture is ready
  108807. */
  108808. isReady: boolean;
  108809. /**
  108810. * Defines if the texture is a cube texture
  108811. */
  108812. isCube: boolean;
  108813. /**
  108814. * Defines if the texture contains 3D data
  108815. */
  108816. is3D: boolean;
  108817. /**
  108818. * Defines if the texture contains 2D array data
  108819. */
  108820. is2DArray: boolean;
  108821. /**
  108822. * Defines if the texture contains multiview data
  108823. */
  108824. isMultiview: boolean;
  108825. /**
  108826. * Gets the URL used to load this texture
  108827. */
  108828. url: string;
  108829. /**
  108830. * Gets the sampling mode of the texture
  108831. */
  108832. samplingMode: number;
  108833. /**
  108834. * Gets a boolean indicating if the texture needs mipmaps generation
  108835. */
  108836. generateMipMaps: boolean;
  108837. /**
  108838. * Gets the number of samples used by the texture (WebGL2+ only)
  108839. */
  108840. samples: number;
  108841. /**
  108842. * Gets the type of the texture (int, float...)
  108843. */
  108844. type: number;
  108845. /**
  108846. * Gets the format of the texture (RGB, RGBA...)
  108847. */
  108848. format: number;
  108849. /**
  108850. * Observable called when the texture is loaded
  108851. */
  108852. onLoadedObservable: Observable<InternalTexture>;
  108853. /**
  108854. * Gets the width of the texture
  108855. */
  108856. width: number;
  108857. /**
  108858. * Gets the height of the texture
  108859. */
  108860. height: number;
  108861. /**
  108862. * Gets the depth of the texture
  108863. */
  108864. depth: number;
  108865. /**
  108866. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108867. */
  108868. baseWidth: number;
  108869. /**
  108870. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108871. */
  108872. baseHeight: number;
  108873. /**
  108874. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108875. */
  108876. baseDepth: number;
  108877. /**
  108878. * Gets a boolean indicating if the texture is inverted on Y axis
  108879. */
  108880. invertY: boolean;
  108881. /** @hidden */
  108882. _invertVScale: boolean;
  108883. /** @hidden */
  108884. _associatedChannel: number;
  108885. /** @hidden */
  108886. _source: InternalTextureSource;
  108887. /** @hidden */
  108888. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108889. /** @hidden */
  108890. _bufferView: Nullable<ArrayBufferView>;
  108891. /** @hidden */
  108892. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108893. /** @hidden */
  108894. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108895. /** @hidden */
  108896. _size: number;
  108897. /** @hidden */
  108898. _extension: string;
  108899. /** @hidden */
  108900. _files: Nullable<string[]>;
  108901. /** @hidden */
  108902. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108903. /** @hidden */
  108904. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108905. /** @hidden */
  108906. _framebuffer: Nullable<WebGLFramebuffer>;
  108907. /** @hidden */
  108908. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108909. /** @hidden */
  108910. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108911. /** @hidden */
  108912. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108913. /** @hidden */
  108914. _attachments: Nullable<number[]>;
  108915. /** @hidden */
  108916. _cachedCoordinatesMode: Nullable<number>;
  108917. /** @hidden */
  108918. _cachedWrapU: Nullable<number>;
  108919. /** @hidden */
  108920. _cachedWrapV: Nullable<number>;
  108921. /** @hidden */
  108922. _cachedWrapR: Nullable<number>;
  108923. /** @hidden */
  108924. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108925. /** @hidden */
  108926. _isDisabled: boolean;
  108927. /** @hidden */
  108928. _compression: Nullable<string>;
  108929. /** @hidden */
  108930. _generateStencilBuffer: boolean;
  108931. /** @hidden */
  108932. _generateDepthBuffer: boolean;
  108933. /** @hidden */
  108934. _comparisonFunction: number;
  108935. /** @hidden */
  108936. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108937. /** @hidden */
  108938. _lodGenerationScale: number;
  108939. /** @hidden */
  108940. _lodGenerationOffset: number;
  108941. /** @hidden */
  108942. _depthStencilTexture: Nullable<InternalTexture>;
  108943. /** @hidden */
  108944. _colorTextureArray: Nullable<WebGLTexture>;
  108945. /** @hidden */
  108946. _depthStencilTextureArray: Nullable<WebGLTexture>;
  108947. /** @hidden */
  108948. _lodTextureHigh: Nullable<BaseTexture>;
  108949. /** @hidden */
  108950. _lodTextureMid: Nullable<BaseTexture>;
  108951. /** @hidden */
  108952. _lodTextureLow: Nullable<BaseTexture>;
  108953. /** @hidden */
  108954. _isRGBD: boolean;
  108955. /** @hidden */
  108956. _linearSpecularLOD: boolean;
  108957. /** @hidden */
  108958. _irradianceTexture: Nullable<BaseTexture>;
  108959. /** @hidden */
  108960. _webGLTexture: Nullable<WebGLTexture>;
  108961. /** @hidden */
  108962. _references: number;
  108963. private _engine;
  108964. /**
  108965. * Gets the Engine the texture belongs to.
  108966. * @returns The babylon engine
  108967. */
  108968. getEngine(): ThinEngine;
  108969. /**
  108970. * Gets the data source type of the texture
  108971. */
  108972. get source(): InternalTextureSource;
  108973. /**
  108974. * Creates a new InternalTexture
  108975. * @param engine defines the engine to use
  108976. * @param source defines the type of data that will be used
  108977. * @param delayAllocation if the texture allocation should be delayed (default: false)
  108978. */
  108979. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  108980. /**
  108981. * Increments the number of references (ie. the number of Texture that point to it)
  108982. */
  108983. incrementReferences(): void;
  108984. /**
  108985. * Change the size of the texture (not the size of the content)
  108986. * @param width defines the new width
  108987. * @param height defines the new height
  108988. * @param depth defines the new depth (1 by default)
  108989. */
  108990. updateSize(width: int, height: int, depth?: int): void;
  108991. /** @hidden */
  108992. _rebuild(): void;
  108993. /** @hidden */
  108994. _swapAndDie(target: InternalTexture): void;
  108995. /**
  108996. * Dispose the current allocated resources
  108997. */
  108998. dispose(): void;
  108999. }
  109000. }
  109001. declare module BABYLON {
  109002. /**
  109003. * Class used to work with sound analyzer using fast fourier transform (FFT)
  109004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109005. */
  109006. export class Analyser {
  109007. /**
  109008. * Gets or sets the smoothing
  109009. * @ignorenaming
  109010. */
  109011. SMOOTHING: number;
  109012. /**
  109013. * Gets or sets the FFT table size
  109014. * @ignorenaming
  109015. */
  109016. FFT_SIZE: number;
  109017. /**
  109018. * Gets or sets the bar graph amplitude
  109019. * @ignorenaming
  109020. */
  109021. BARGRAPHAMPLITUDE: number;
  109022. /**
  109023. * Gets or sets the position of the debug canvas
  109024. * @ignorenaming
  109025. */
  109026. DEBUGCANVASPOS: {
  109027. x: number;
  109028. y: number;
  109029. };
  109030. /**
  109031. * Gets or sets the debug canvas size
  109032. * @ignorenaming
  109033. */
  109034. DEBUGCANVASSIZE: {
  109035. width: number;
  109036. height: number;
  109037. };
  109038. private _byteFreqs;
  109039. private _byteTime;
  109040. private _floatFreqs;
  109041. private _webAudioAnalyser;
  109042. private _debugCanvas;
  109043. private _debugCanvasContext;
  109044. private _scene;
  109045. private _registerFunc;
  109046. private _audioEngine;
  109047. /**
  109048. * Creates a new analyser
  109049. * @param scene defines hosting scene
  109050. */
  109051. constructor(scene: Scene);
  109052. /**
  109053. * Get the number of data values you will have to play with for the visualization
  109054. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  109055. * @returns a number
  109056. */
  109057. getFrequencyBinCount(): number;
  109058. /**
  109059. * Gets the current frequency data as a byte array
  109060. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109061. * @returns a Uint8Array
  109062. */
  109063. getByteFrequencyData(): Uint8Array;
  109064. /**
  109065. * Gets the current waveform as a byte array
  109066. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  109067. * @returns a Uint8Array
  109068. */
  109069. getByteTimeDomainData(): Uint8Array;
  109070. /**
  109071. * Gets the current frequency data as a float array
  109072. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  109073. * @returns a Float32Array
  109074. */
  109075. getFloatFrequencyData(): Float32Array;
  109076. /**
  109077. * Renders the debug canvas
  109078. */
  109079. drawDebugCanvas(): void;
  109080. /**
  109081. * Stops rendering the debug canvas and removes it
  109082. */
  109083. stopDebugCanvas(): void;
  109084. /**
  109085. * Connects two audio nodes
  109086. * @param inputAudioNode defines first node to connect
  109087. * @param outputAudioNode defines second node to connect
  109088. */
  109089. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  109090. /**
  109091. * Releases all associated resources
  109092. */
  109093. dispose(): void;
  109094. }
  109095. }
  109096. declare module BABYLON {
  109097. /**
  109098. * This represents an audio engine and it is responsible
  109099. * to play, synchronize and analyse sounds throughout the application.
  109100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109101. */
  109102. export interface IAudioEngine extends IDisposable {
  109103. /**
  109104. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109105. */
  109106. readonly canUseWebAudio: boolean;
  109107. /**
  109108. * Gets the current AudioContext if available.
  109109. */
  109110. readonly audioContext: Nullable<AudioContext>;
  109111. /**
  109112. * The master gain node defines the global audio volume of your audio engine.
  109113. */
  109114. readonly masterGain: GainNode;
  109115. /**
  109116. * Gets whether or not mp3 are supported by your browser.
  109117. */
  109118. readonly isMP3supported: boolean;
  109119. /**
  109120. * Gets whether or not ogg are supported by your browser.
  109121. */
  109122. readonly isOGGsupported: boolean;
  109123. /**
  109124. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109125. * @ignoreNaming
  109126. */
  109127. WarnedWebAudioUnsupported: boolean;
  109128. /**
  109129. * Defines if the audio engine relies on a custom unlocked button.
  109130. * In this case, the embedded button will not be displayed.
  109131. */
  109132. useCustomUnlockedButton: boolean;
  109133. /**
  109134. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  109135. */
  109136. readonly unlocked: boolean;
  109137. /**
  109138. * Event raised when audio has been unlocked on the browser.
  109139. */
  109140. onAudioUnlockedObservable: Observable<AudioEngine>;
  109141. /**
  109142. * Event raised when audio has been locked on the browser.
  109143. */
  109144. onAudioLockedObservable: Observable<AudioEngine>;
  109145. /**
  109146. * Flags the audio engine in Locked state.
  109147. * This happens due to new browser policies preventing audio to autoplay.
  109148. */
  109149. lock(): void;
  109150. /**
  109151. * Unlocks the audio engine once a user action has been done on the dom.
  109152. * This is helpful to resume play once browser policies have been satisfied.
  109153. */
  109154. unlock(): void;
  109155. /**
  109156. * Gets the global volume sets on the master gain.
  109157. * @returns the global volume if set or -1 otherwise
  109158. */
  109159. getGlobalVolume(): number;
  109160. /**
  109161. * Sets the global volume of your experience (sets on the master gain).
  109162. * @param newVolume Defines the new global volume of the application
  109163. */
  109164. setGlobalVolume(newVolume: number): void;
  109165. /**
  109166. * Connect the audio engine to an audio analyser allowing some amazing
  109167. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109169. * @param analyser The analyser to connect to the engine
  109170. */
  109171. connectToAnalyser(analyser: Analyser): void;
  109172. }
  109173. /**
  109174. * This represents the default audio engine used in babylon.
  109175. * It is responsible to play, synchronize and analyse sounds throughout the application.
  109176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109177. */
  109178. export class AudioEngine implements IAudioEngine {
  109179. private _audioContext;
  109180. private _audioContextInitialized;
  109181. private _muteButton;
  109182. private _hostElement;
  109183. /**
  109184. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  109185. */
  109186. canUseWebAudio: boolean;
  109187. /**
  109188. * The master gain node defines the global audio volume of your audio engine.
  109189. */
  109190. masterGain: GainNode;
  109191. /**
  109192. * Defines if Babylon should emit a warning if WebAudio is not supported.
  109193. * @ignoreNaming
  109194. */
  109195. WarnedWebAudioUnsupported: boolean;
  109196. /**
  109197. * Gets whether or not mp3 are supported by your browser.
  109198. */
  109199. isMP3supported: boolean;
  109200. /**
  109201. * Gets whether or not ogg are supported by your browser.
  109202. */
  109203. isOGGsupported: boolean;
  109204. /**
  109205. * Gets whether audio has been unlocked on the device.
  109206. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  109207. * a user interaction has happened.
  109208. */
  109209. unlocked: boolean;
  109210. /**
  109211. * Defines if the audio engine relies on a custom unlocked button.
  109212. * In this case, the embedded button will not be displayed.
  109213. */
  109214. useCustomUnlockedButton: boolean;
  109215. /**
  109216. * Event raised when audio has been unlocked on the browser.
  109217. */
  109218. onAudioUnlockedObservable: Observable<AudioEngine>;
  109219. /**
  109220. * Event raised when audio has been locked on the browser.
  109221. */
  109222. onAudioLockedObservable: Observable<AudioEngine>;
  109223. /**
  109224. * Gets the current AudioContext if available.
  109225. */
  109226. get audioContext(): Nullable<AudioContext>;
  109227. private _connectedAnalyser;
  109228. /**
  109229. * Instantiates a new audio engine.
  109230. *
  109231. * There should be only one per page as some browsers restrict the number
  109232. * of audio contexts you can create.
  109233. * @param hostElement defines the host element where to display the mute icon if necessary
  109234. */
  109235. constructor(hostElement?: Nullable<HTMLElement>);
  109236. /**
  109237. * Flags the audio engine in Locked state.
  109238. * This happens due to new browser policies preventing audio to autoplay.
  109239. */
  109240. lock(): void;
  109241. /**
  109242. * Unlocks the audio engine once a user action has been done on the dom.
  109243. * This is helpful to resume play once browser policies have been satisfied.
  109244. */
  109245. unlock(): void;
  109246. private _resumeAudioContext;
  109247. private _initializeAudioContext;
  109248. private _tryToRun;
  109249. private _triggerRunningState;
  109250. private _triggerSuspendedState;
  109251. private _displayMuteButton;
  109252. private _moveButtonToTopLeft;
  109253. private _onResize;
  109254. private _hideMuteButton;
  109255. /**
  109256. * Destroy and release the resources associated with the audio ccontext.
  109257. */
  109258. dispose(): void;
  109259. /**
  109260. * Gets the global volume sets on the master gain.
  109261. * @returns the global volume if set or -1 otherwise
  109262. */
  109263. getGlobalVolume(): number;
  109264. /**
  109265. * Sets the global volume of your experience (sets on the master gain).
  109266. * @param newVolume Defines the new global volume of the application
  109267. */
  109268. setGlobalVolume(newVolume: number): void;
  109269. /**
  109270. * Connect the audio engine to an audio analyser allowing some amazing
  109271. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109273. * @param analyser The analyser to connect to the engine
  109274. */
  109275. connectToAnalyser(analyser: Analyser): void;
  109276. }
  109277. }
  109278. declare module BABYLON {
  109279. /**
  109280. * Interface used to present a loading screen while loading a scene
  109281. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109282. */
  109283. export interface ILoadingScreen {
  109284. /**
  109285. * Function called to display the loading screen
  109286. */
  109287. displayLoadingUI: () => void;
  109288. /**
  109289. * Function called to hide the loading screen
  109290. */
  109291. hideLoadingUI: () => void;
  109292. /**
  109293. * Gets or sets the color to use for the background
  109294. */
  109295. loadingUIBackgroundColor: string;
  109296. /**
  109297. * Gets or sets the text to display while loading
  109298. */
  109299. loadingUIText: string;
  109300. }
  109301. /**
  109302. * Class used for the default loading screen
  109303. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109304. */
  109305. export class DefaultLoadingScreen implements ILoadingScreen {
  109306. private _renderingCanvas;
  109307. private _loadingText;
  109308. private _loadingDivBackgroundColor;
  109309. private _loadingDiv;
  109310. private _loadingTextDiv;
  109311. /** Gets or sets the logo url to use for the default loading screen */
  109312. static DefaultLogoUrl: string;
  109313. /** Gets or sets the spinner url to use for the default loading screen */
  109314. static DefaultSpinnerUrl: string;
  109315. /**
  109316. * Creates a new default loading screen
  109317. * @param _renderingCanvas defines the canvas used to render the scene
  109318. * @param _loadingText defines the default text to display
  109319. * @param _loadingDivBackgroundColor defines the default background color
  109320. */
  109321. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109322. /**
  109323. * Function called to display the loading screen
  109324. */
  109325. displayLoadingUI(): void;
  109326. /**
  109327. * Function called to hide the loading screen
  109328. */
  109329. hideLoadingUI(): void;
  109330. /**
  109331. * Gets or sets the text to display while loading
  109332. */
  109333. set loadingUIText(text: string);
  109334. get loadingUIText(): string;
  109335. /**
  109336. * Gets or sets the color to use for the background
  109337. */
  109338. get loadingUIBackgroundColor(): string;
  109339. set loadingUIBackgroundColor(color: string);
  109340. private _resizeLoadingUI;
  109341. }
  109342. }
  109343. declare module BABYLON {
  109344. /**
  109345. * Interface for any object that can request an animation frame
  109346. */
  109347. export interface ICustomAnimationFrameRequester {
  109348. /**
  109349. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109350. */
  109351. renderFunction?: Function;
  109352. /**
  109353. * Called to request the next frame to render to
  109354. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109355. */
  109356. requestAnimationFrame: Function;
  109357. /**
  109358. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109359. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109360. */
  109361. requestID?: number;
  109362. }
  109363. }
  109364. declare module BABYLON {
  109365. /**
  109366. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109367. */
  109368. export class PerformanceMonitor {
  109369. private _enabled;
  109370. private _rollingFrameTime;
  109371. private _lastFrameTimeMs;
  109372. /**
  109373. * constructor
  109374. * @param frameSampleSize The number of samples required to saturate the sliding window
  109375. */
  109376. constructor(frameSampleSize?: number);
  109377. /**
  109378. * Samples current frame
  109379. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109380. */
  109381. sampleFrame(timeMs?: number): void;
  109382. /**
  109383. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109384. */
  109385. get averageFrameTime(): number;
  109386. /**
  109387. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109388. */
  109389. get averageFrameTimeVariance(): number;
  109390. /**
  109391. * Returns the frame time of the most recent frame
  109392. */
  109393. get instantaneousFrameTime(): number;
  109394. /**
  109395. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109396. */
  109397. get averageFPS(): number;
  109398. /**
  109399. * Returns the average framerate in frames per second using the most recent frame time
  109400. */
  109401. get instantaneousFPS(): number;
  109402. /**
  109403. * Returns true if enough samples have been taken to completely fill the sliding window
  109404. */
  109405. get isSaturated(): boolean;
  109406. /**
  109407. * Enables contributions to the sliding window sample set
  109408. */
  109409. enable(): void;
  109410. /**
  109411. * Disables contributions to the sliding window sample set
  109412. * Samples will not be interpolated over the disabled period
  109413. */
  109414. disable(): void;
  109415. /**
  109416. * Returns true if sampling is enabled
  109417. */
  109418. get isEnabled(): boolean;
  109419. /**
  109420. * Resets performance monitor
  109421. */
  109422. reset(): void;
  109423. }
  109424. /**
  109425. * RollingAverage
  109426. *
  109427. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109428. */
  109429. export class RollingAverage {
  109430. /**
  109431. * Current average
  109432. */
  109433. average: number;
  109434. /**
  109435. * Current variance
  109436. */
  109437. variance: number;
  109438. protected _samples: Array<number>;
  109439. protected _sampleCount: number;
  109440. protected _pos: number;
  109441. protected _m2: number;
  109442. /**
  109443. * constructor
  109444. * @param length The number of samples required to saturate the sliding window
  109445. */
  109446. constructor(length: number);
  109447. /**
  109448. * Adds a sample to the sample set
  109449. * @param v The sample value
  109450. */
  109451. add(v: number): void;
  109452. /**
  109453. * Returns previously added values or null if outside of history or outside the sliding window domain
  109454. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109455. * @return Value previously recorded with add() or null if outside of range
  109456. */
  109457. history(i: number): number;
  109458. /**
  109459. * Returns true if enough samples have been taken to completely fill the sliding window
  109460. * @return true if sample-set saturated
  109461. */
  109462. isSaturated(): boolean;
  109463. /**
  109464. * Resets the rolling average (equivalent to 0 samples taken so far)
  109465. */
  109466. reset(): void;
  109467. /**
  109468. * Wraps a value around the sample range boundaries
  109469. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109470. * @return Wrapped position in sample range
  109471. */
  109472. protected _wrapPosition(i: number): number;
  109473. }
  109474. }
  109475. declare module BABYLON {
  109476. /**
  109477. * This class is used to track a performance counter which is number based.
  109478. * The user has access to many properties which give statistics of different nature.
  109479. *
  109480. * The implementer can track two kinds of Performance Counter: time and count.
  109481. * 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.
  109482. * 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.
  109483. */
  109484. export class PerfCounter {
  109485. /**
  109486. * Gets or sets a global boolean to turn on and off all the counters
  109487. */
  109488. static Enabled: boolean;
  109489. /**
  109490. * Returns the smallest value ever
  109491. */
  109492. get min(): number;
  109493. /**
  109494. * Returns the biggest value ever
  109495. */
  109496. get max(): number;
  109497. /**
  109498. * Returns the average value since the performance counter is running
  109499. */
  109500. get average(): number;
  109501. /**
  109502. * Returns the average value of the last second the counter was monitored
  109503. */
  109504. get lastSecAverage(): number;
  109505. /**
  109506. * Returns the current value
  109507. */
  109508. get current(): number;
  109509. /**
  109510. * Gets the accumulated total
  109511. */
  109512. get total(): number;
  109513. /**
  109514. * Gets the total value count
  109515. */
  109516. get count(): number;
  109517. /**
  109518. * Creates a new counter
  109519. */
  109520. constructor();
  109521. /**
  109522. * Call this method to start monitoring a new frame.
  109523. * 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.
  109524. */
  109525. fetchNewFrame(): void;
  109526. /**
  109527. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109528. * @param newCount the count value to add to the monitored count
  109529. * @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.
  109530. */
  109531. addCount(newCount: number, fetchResult: boolean): void;
  109532. /**
  109533. * Start monitoring this performance counter
  109534. */
  109535. beginMonitoring(): void;
  109536. /**
  109537. * Compute the time lapsed since the previous beginMonitoring() call.
  109538. * @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
  109539. */
  109540. endMonitoring(newFrame?: boolean): void;
  109541. private _fetchResult;
  109542. private _startMonitoringTime;
  109543. private _min;
  109544. private _max;
  109545. private _average;
  109546. private _current;
  109547. private _totalValueCount;
  109548. private _totalAccumulated;
  109549. private _lastSecAverage;
  109550. private _lastSecAccumulated;
  109551. private _lastSecTime;
  109552. private _lastSecValueCount;
  109553. }
  109554. }
  109555. declare module BABYLON {
  109556. interface ThinEngine {
  109557. /**
  109558. * Sets alpha constants used by some alpha blending modes
  109559. * @param r defines the red component
  109560. * @param g defines the green component
  109561. * @param b defines the blue component
  109562. * @param a defines the alpha component
  109563. */
  109564. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109565. /**
  109566. * Sets the current alpha mode
  109567. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109568. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109569. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109570. */
  109571. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109572. /**
  109573. * Gets the current alpha mode
  109574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109575. * @returns the current alpha mode
  109576. */
  109577. getAlphaMode(): number;
  109578. /**
  109579. * Sets the current alpha equation
  109580. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109581. */
  109582. setAlphaEquation(equation: number): void;
  109583. /**
  109584. * Gets the current alpha equation.
  109585. * @returns the current alpha equation
  109586. */
  109587. getAlphaEquation(): number;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. interface ThinEngine {
  109592. /** @hidden */
  109593. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  109594. }
  109595. }
  109596. declare module BABYLON {
  109597. /**
  109598. * Defines the interface used by display changed events
  109599. */
  109600. export interface IDisplayChangedEventArgs {
  109601. /** Gets the vrDisplay object (if any) */
  109602. vrDisplay: Nullable<any>;
  109603. /** Gets a boolean indicating if webVR is supported */
  109604. vrSupported: boolean;
  109605. }
  109606. /**
  109607. * Defines the interface used by objects containing a viewport (like a camera)
  109608. */
  109609. interface IViewportOwnerLike {
  109610. /**
  109611. * Gets or sets the viewport
  109612. */
  109613. viewport: IViewportLike;
  109614. }
  109615. /**
  109616. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109617. */
  109618. export class Engine extends ThinEngine {
  109619. /** Defines that alpha blending is disabled */
  109620. static readonly ALPHA_DISABLE: number;
  109621. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109622. static readonly ALPHA_ADD: number;
  109623. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109624. static readonly ALPHA_COMBINE: number;
  109625. /** Defines that alpha blending to DEST - SRC * DEST */
  109626. static readonly ALPHA_SUBTRACT: number;
  109627. /** Defines that alpha blending to SRC * DEST */
  109628. static readonly ALPHA_MULTIPLY: number;
  109629. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109630. static readonly ALPHA_MAXIMIZED: number;
  109631. /** Defines that alpha blending to SRC + DEST */
  109632. static readonly ALPHA_ONEONE: number;
  109633. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109634. static readonly ALPHA_PREMULTIPLIED: number;
  109635. /**
  109636. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109637. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109638. */
  109639. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109640. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109641. static readonly ALPHA_INTERPOLATE: number;
  109642. /**
  109643. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109644. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109645. */
  109646. static readonly ALPHA_SCREENMODE: number;
  109647. /** Defines that the ressource is not delayed*/
  109648. static readonly DELAYLOADSTATE_NONE: number;
  109649. /** Defines that the ressource was successfully delay loaded */
  109650. static readonly DELAYLOADSTATE_LOADED: number;
  109651. /** Defines that the ressource is currently delay loading */
  109652. static readonly DELAYLOADSTATE_LOADING: number;
  109653. /** Defines that the ressource is delayed and has not started loading */
  109654. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109655. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109656. static readonly NEVER: number;
  109657. /** 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 */
  109658. static readonly ALWAYS: number;
  109659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109660. static readonly LESS: number;
  109661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109662. static readonly EQUAL: number;
  109663. /** 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 */
  109664. static readonly LEQUAL: number;
  109665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109666. static readonly GREATER: number;
  109667. /** 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 */
  109668. static readonly GEQUAL: number;
  109669. /** 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 */
  109670. static readonly NOTEQUAL: number;
  109671. /** Passed to stencilOperation to specify that stencil value must be kept */
  109672. static readonly KEEP: number;
  109673. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109674. static readonly REPLACE: number;
  109675. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109676. static readonly INCR: number;
  109677. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109678. static readonly DECR: number;
  109679. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109680. static readonly INVERT: number;
  109681. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109682. static readonly INCR_WRAP: number;
  109683. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109684. static readonly DECR_WRAP: number;
  109685. /** Texture is not repeating outside of 0..1 UVs */
  109686. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109687. /** Texture is repeating outside of 0..1 UVs */
  109688. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109689. /** Texture is repeating and mirrored */
  109690. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109691. /** ALPHA */
  109692. static readonly TEXTUREFORMAT_ALPHA: number;
  109693. /** LUMINANCE */
  109694. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109695. /** LUMINANCE_ALPHA */
  109696. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109697. /** RGB */
  109698. static readonly TEXTUREFORMAT_RGB: number;
  109699. /** RGBA */
  109700. static readonly TEXTUREFORMAT_RGBA: number;
  109701. /** RED */
  109702. static readonly TEXTUREFORMAT_RED: number;
  109703. /** RED (2nd reference) */
  109704. static readonly TEXTUREFORMAT_R: number;
  109705. /** RG */
  109706. static readonly TEXTUREFORMAT_RG: number;
  109707. /** RED_INTEGER */
  109708. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109709. /** RED_INTEGER (2nd reference) */
  109710. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109711. /** RG_INTEGER */
  109712. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109713. /** RGB_INTEGER */
  109714. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109715. /** RGBA_INTEGER */
  109716. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109717. /** UNSIGNED_BYTE */
  109718. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109719. /** UNSIGNED_BYTE (2nd reference) */
  109720. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109721. /** FLOAT */
  109722. static readonly TEXTURETYPE_FLOAT: number;
  109723. /** HALF_FLOAT */
  109724. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109725. /** BYTE */
  109726. static readonly TEXTURETYPE_BYTE: number;
  109727. /** SHORT */
  109728. static readonly TEXTURETYPE_SHORT: number;
  109729. /** UNSIGNED_SHORT */
  109730. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109731. /** INT */
  109732. static readonly TEXTURETYPE_INT: number;
  109733. /** UNSIGNED_INT */
  109734. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109735. /** UNSIGNED_SHORT_4_4_4_4 */
  109736. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109737. /** UNSIGNED_SHORT_5_5_5_1 */
  109738. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109739. /** UNSIGNED_SHORT_5_6_5 */
  109740. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109741. /** UNSIGNED_INT_2_10_10_10_REV */
  109742. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109743. /** UNSIGNED_INT_24_8 */
  109744. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109745. /** UNSIGNED_INT_10F_11F_11F_REV */
  109746. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109747. /** UNSIGNED_INT_5_9_9_9_REV */
  109748. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109749. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109750. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109751. /** nearest is mag = nearest and min = nearest and mip = linear */
  109752. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109753. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109754. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109755. /** Trilinear is mag = linear and min = linear and mip = linear */
  109756. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109757. /** nearest is mag = nearest and min = nearest and mip = linear */
  109758. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109760. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109761. /** Trilinear is mag = linear and min = linear and mip = linear */
  109762. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109763. /** mag = nearest and min = nearest and mip = nearest */
  109764. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109765. /** mag = nearest and min = linear and mip = nearest */
  109766. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109767. /** mag = nearest and min = linear and mip = linear */
  109768. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109769. /** mag = nearest and min = linear and mip = none */
  109770. static readonly TEXTURE_NEAREST_LINEAR: number;
  109771. /** mag = nearest and min = nearest and mip = none */
  109772. static readonly TEXTURE_NEAREST_NEAREST: number;
  109773. /** mag = linear and min = nearest and mip = nearest */
  109774. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109775. /** mag = linear and min = nearest and mip = linear */
  109776. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109777. /** mag = linear and min = linear and mip = none */
  109778. static readonly TEXTURE_LINEAR_LINEAR: number;
  109779. /** mag = linear and min = nearest and mip = none */
  109780. static readonly TEXTURE_LINEAR_NEAREST: number;
  109781. /** Explicit coordinates mode */
  109782. static readonly TEXTURE_EXPLICIT_MODE: number;
  109783. /** Spherical coordinates mode */
  109784. static readonly TEXTURE_SPHERICAL_MODE: number;
  109785. /** Planar coordinates mode */
  109786. static readonly TEXTURE_PLANAR_MODE: number;
  109787. /** Cubic coordinates mode */
  109788. static readonly TEXTURE_CUBIC_MODE: number;
  109789. /** Projection coordinates mode */
  109790. static readonly TEXTURE_PROJECTION_MODE: number;
  109791. /** Skybox coordinates mode */
  109792. static readonly TEXTURE_SKYBOX_MODE: number;
  109793. /** Inverse Cubic coordinates mode */
  109794. static readonly TEXTURE_INVCUBIC_MODE: number;
  109795. /** Equirectangular coordinates mode */
  109796. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109797. /** Equirectangular Fixed coordinates mode */
  109798. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109799. /** Equirectangular Fixed Mirrored coordinates mode */
  109800. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109801. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109802. static readonly SCALEMODE_FLOOR: number;
  109803. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109804. static readonly SCALEMODE_NEAREST: number;
  109805. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109806. static readonly SCALEMODE_CEILING: number;
  109807. /**
  109808. * Returns the current npm package of the sdk
  109809. */
  109810. static get NpmPackage(): string;
  109811. /**
  109812. * Returns the current version of the framework
  109813. */
  109814. static get Version(): string;
  109815. /** Gets the list of created engines */
  109816. static get Instances(): Engine[];
  109817. /**
  109818. * Gets the latest created engine
  109819. */
  109820. static get LastCreatedEngine(): Nullable<Engine>;
  109821. /**
  109822. * Gets the latest created scene
  109823. */
  109824. static get LastCreatedScene(): Nullable<Scene>;
  109825. /**
  109826. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109827. * @param flag defines which part of the materials must be marked as dirty
  109828. * @param predicate defines a predicate used to filter which materials should be affected
  109829. */
  109830. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109831. /**
  109832. * Method called to create the default loading screen.
  109833. * This can be overriden in your own app.
  109834. * @param canvas The rendering canvas element
  109835. * @returns The loading screen
  109836. */
  109837. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109838. /**
  109839. * Method called to create the default rescale post process on each engine.
  109840. */
  109841. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109842. /**
  109843. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109844. **/
  109845. enableOfflineSupport: boolean;
  109846. /**
  109847. * 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)
  109848. **/
  109849. disableManifestCheck: boolean;
  109850. /**
  109851. * Gets the list of created scenes
  109852. */
  109853. scenes: Scene[];
  109854. /**
  109855. * Event raised when a new scene is created
  109856. */
  109857. onNewSceneAddedObservable: Observable<Scene>;
  109858. /**
  109859. * Gets the list of created postprocesses
  109860. */
  109861. postProcesses: PostProcess[];
  109862. /**
  109863. * Gets a boolean indicating if the pointer is currently locked
  109864. */
  109865. isPointerLock: boolean;
  109866. /**
  109867. * Observable event triggered each time the rendering canvas is resized
  109868. */
  109869. onResizeObservable: Observable<Engine>;
  109870. /**
  109871. * Observable event triggered each time the canvas loses focus
  109872. */
  109873. onCanvasBlurObservable: Observable<Engine>;
  109874. /**
  109875. * Observable event triggered each time the canvas gains focus
  109876. */
  109877. onCanvasFocusObservable: Observable<Engine>;
  109878. /**
  109879. * Observable event triggered each time the canvas receives pointerout event
  109880. */
  109881. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109882. /**
  109883. * Observable raised when the engine begins a new frame
  109884. */
  109885. onBeginFrameObservable: Observable<Engine>;
  109886. /**
  109887. * If set, will be used to request the next animation frame for the render loop
  109888. */
  109889. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109890. /**
  109891. * Observable raised when the engine ends the current frame
  109892. */
  109893. onEndFrameObservable: Observable<Engine>;
  109894. /**
  109895. * Observable raised when the engine is about to compile a shader
  109896. */
  109897. onBeforeShaderCompilationObservable: Observable<Engine>;
  109898. /**
  109899. * Observable raised when the engine has jsut compiled a shader
  109900. */
  109901. onAfterShaderCompilationObservable: Observable<Engine>;
  109902. /**
  109903. * Gets the audio engine
  109904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109905. * @ignorenaming
  109906. */
  109907. static audioEngine: IAudioEngine;
  109908. /**
  109909. * Default AudioEngine factory responsible of creating the Audio Engine.
  109910. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109911. */
  109912. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109913. /**
  109914. * Default offline support factory responsible of creating a tool used to store data locally.
  109915. * By default, this will create a Database object if the workload has been embedded.
  109916. */
  109917. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109918. private _loadingScreen;
  109919. private _pointerLockRequested;
  109920. private _rescalePostProcess;
  109921. private _deterministicLockstep;
  109922. private _lockstepMaxSteps;
  109923. private _timeStep;
  109924. protected get _supportsHardwareTextureRescaling(): boolean;
  109925. private _fps;
  109926. private _deltaTime;
  109927. /** @hidden */
  109928. _drawCalls: PerfCounter;
  109929. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  109930. canvasTabIndex: number;
  109931. /**
  109932. * Turn this value on if you want to pause FPS computation when in background
  109933. */
  109934. disablePerformanceMonitorInBackground: boolean;
  109935. private _performanceMonitor;
  109936. /**
  109937. * Gets the performance monitor attached to this engine
  109938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109939. */
  109940. get performanceMonitor(): PerformanceMonitor;
  109941. private _onFocus;
  109942. private _onBlur;
  109943. private _onCanvasPointerOut;
  109944. private _onCanvasBlur;
  109945. private _onCanvasFocus;
  109946. private _onFullscreenChange;
  109947. private _onPointerLockChange;
  109948. /**
  109949. * Gets the HTML element used to attach event listeners
  109950. * @returns a HTML element
  109951. */
  109952. getInputElement(): Nullable<HTMLElement>;
  109953. /**
  109954. * Creates a new engine
  109955. * @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
  109956. * @param antialias defines enable antialiasing (default: false)
  109957. * @param options defines further options to be sent to the getContext() function
  109958. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  109959. */
  109960. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  109961. /**
  109962. * Gets current aspect ratio
  109963. * @param viewportOwner defines the camera to use to get the aspect ratio
  109964. * @param useScreen defines if screen size must be used (or the current render target if any)
  109965. * @returns a number defining the aspect ratio
  109966. */
  109967. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  109968. /**
  109969. * Gets current screen aspect ratio
  109970. * @returns a number defining the aspect ratio
  109971. */
  109972. getScreenAspectRatio(): number;
  109973. /**
  109974. * Gets the client rect of the HTML canvas attached with the current webGL context
  109975. * @returns a client rectanglee
  109976. */
  109977. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  109978. /**
  109979. * Gets the client rect of the HTML element used for events
  109980. * @returns a client rectanglee
  109981. */
  109982. getInputElementClientRect(): Nullable<ClientRect>;
  109983. /**
  109984. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109985. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109986. * @returns true if engine is in deterministic lock step mode
  109987. */
  109988. isDeterministicLockStep(): boolean;
  109989. /**
  109990. * Gets the max steps when engine is running in deterministic lock step
  109991. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109992. * @returns the max steps
  109993. */
  109994. getLockstepMaxSteps(): number;
  109995. /**
  109996. * Returns the time in ms between steps when using deterministic lock step.
  109997. * @returns time step in (ms)
  109998. */
  109999. getTimeStep(): number;
  110000. /**
  110001. * Force the mipmap generation for the given render target texture
  110002. * @param texture defines the render target texture to use
  110003. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  110004. */
  110005. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  110006. /** States */
  110007. /**
  110008. * Set various states to the webGL context
  110009. * @param culling defines backface culling state
  110010. * @param zOffset defines the value to apply to zOffset (0 by default)
  110011. * @param force defines if states must be applied even if cache is up to date
  110012. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110013. */
  110014. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110015. /**
  110016. * Set the z offset to apply to current rendering
  110017. * @param value defines the offset to apply
  110018. */
  110019. setZOffset(value: number): void;
  110020. /**
  110021. * Gets the current value of the zOffset
  110022. * @returns the current zOffset state
  110023. */
  110024. getZOffset(): number;
  110025. /**
  110026. * Enable or disable depth buffering
  110027. * @param enable defines the state to set
  110028. */
  110029. setDepthBuffer(enable: boolean): void;
  110030. /**
  110031. * Gets a boolean indicating if depth writing is enabled
  110032. * @returns the current depth writing state
  110033. */
  110034. getDepthWrite(): boolean;
  110035. /**
  110036. * Enable or disable depth writing
  110037. * @param enable defines the state to set
  110038. */
  110039. setDepthWrite(enable: boolean): void;
  110040. /**
  110041. * Gets a boolean indicating if stencil buffer is enabled
  110042. * @returns the current stencil buffer state
  110043. */
  110044. getStencilBuffer(): boolean;
  110045. /**
  110046. * Enable or disable the stencil buffer
  110047. * @param enable defines if the stencil buffer must be enabled or disabled
  110048. */
  110049. setStencilBuffer(enable: boolean): void;
  110050. /**
  110051. * Gets the current stencil mask
  110052. * @returns a number defining the new stencil mask to use
  110053. */
  110054. getStencilMask(): number;
  110055. /**
  110056. * Sets the current stencil mask
  110057. * @param mask defines the new stencil mask to use
  110058. */
  110059. setStencilMask(mask: number): void;
  110060. /**
  110061. * Gets the current stencil function
  110062. * @returns a number defining the stencil function to use
  110063. */
  110064. getStencilFunction(): number;
  110065. /**
  110066. * Gets the current stencil reference value
  110067. * @returns a number defining the stencil reference value to use
  110068. */
  110069. getStencilFunctionReference(): number;
  110070. /**
  110071. * Gets the current stencil mask
  110072. * @returns a number defining the stencil mask to use
  110073. */
  110074. getStencilFunctionMask(): number;
  110075. /**
  110076. * Sets the current stencil function
  110077. * @param stencilFunc defines the new stencil function to use
  110078. */
  110079. setStencilFunction(stencilFunc: number): void;
  110080. /**
  110081. * Sets the current stencil reference
  110082. * @param reference defines the new stencil reference to use
  110083. */
  110084. setStencilFunctionReference(reference: number): void;
  110085. /**
  110086. * Sets the current stencil mask
  110087. * @param mask defines the new stencil mask to use
  110088. */
  110089. setStencilFunctionMask(mask: number): void;
  110090. /**
  110091. * Gets the current stencil operation when stencil fails
  110092. * @returns a number defining stencil operation to use when stencil fails
  110093. */
  110094. getStencilOperationFail(): number;
  110095. /**
  110096. * Gets the current stencil operation when depth fails
  110097. * @returns a number defining stencil operation to use when depth fails
  110098. */
  110099. getStencilOperationDepthFail(): number;
  110100. /**
  110101. * Gets the current stencil operation when stencil passes
  110102. * @returns a number defining stencil operation to use when stencil passes
  110103. */
  110104. getStencilOperationPass(): number;
  110105. /**
  110106. * Sets the stencil operation to use when stencil fails
  110107. * @param operation defines the stencil operation to use when stencil fails
  110108. */
  110109. setStencilOperationFail(operation: number): void;
  110110. /**
  110111. * Sets the stencil operation to use when depth fails
  110112. * @param operation defines the stencil operation to use when depth fails
  110113. */
  110114. setStencilOperationDepthFail(operation: number): void;
  110115. /**
  110116. * Sets the stencil operation to use when stencil passes
  110117. * @param operation defines the stencil operation to use when stencil passes
  110118. */
  110119. setStencilOperationPass(operation: number): void;
  110120. /**
  110121. * Sets a boolean indicating if the dithering state is enabled or disabled
  110122. * @param value defines the dithering state
  110123. */
  110124. setDitheringState(value: boolean): void;
  110125. /**
  110126. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  110127. * @param value defines the rasterizer state
  110128. */
  110129. setRasterizerState(value: boolean): void;
  110130. /**
  110131. * Gets the current depth function
  110132. * @returns a number defining the depth function
  110133. */
  110134. getDepthFunction(): Nullable<number>;
  110135. /**
  110136. * Sets the current depth function
  110137. * @param depthFunc defines the function to use
  110138. */
  110139. setDepthFunction(depthFunc: number): void;
  110140. /**
  110141. * Sets the current depth function to GREATER
  110142. */
  110143. setDepthFunctionToGreater(): void;
  110144. /**
  110145. * Sets the current depth function to GEQUAL
  110146. */
  110147. setDepthFunctionToGreaterOrEqual(): void;
  110148. /**
  110149. * Sets the current depth function to LESS
  110150. */
  110151. setDepthFunctionToLess(): void;
  110152. /**
  110153. * Sets the current depth function to LEQUAL
  110154. */
  110155. setDepthFunctionToLessOrEqual(): void;
  110156. private _cachedStencilBuffer;
  110157. private _cachedStencilFunction;
  110158. private _cachedStencilMask;
  110159. private _cachedStencilOperationPass;
  110160. private _cachedStencilOperationFail;
  110161. private _cachedStencilOperationDepthFail;
  110162. private _cachedStencilReference;
  110163. /**
  110164. * Caches the the state of the stencil buffer
  110165. */
  110166. cacheStencilState(): void;
  110167. /**
  110168. * Restores the state of the stencil buffer
  110169. */
  110170. restoreStencilState(): void;
  110171. /**
  110172. * Directly set the WebGL Viewport
  110173. * @param x defines the x coordinate of the viewport (in screen space)
  110174. * @param y defines the y coordinate of the viewport (in screen space)
  110175. * @param width defines the width of the viewport (in screen space)
  110176. * @param height defines the height of the viewport (in screen space)
  110177. * @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
  110178. */
  110179. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  110180. /**
  110181. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  110182. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110183. * @param y defines the y-coordinate of the corner of the clear rectangle
  110184. * @param width defines the width of the clear rectangle
  110185. * @param height defines the height of the clear rectangle
  110186. * @param clearColor defines the clear color
  110187. */
  110188. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  110189. /**
  110190. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  110191. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  110192. * @param y defines the y-coordinate of the corner of the clear rectangle
  110193. * @param width defines the width of the clear rectangle
  110194. * @param height defines the height of the clear rectangle
  110195. */
  110196. enableScissor(x: number, y: number, width: number, height: number): void;
  110197. /**
  110198. * Disable previously set scissor test rectangle
  110199. */
  110200. disableScissor(): void;
  110201. protected _reportDrawCall(): void;
  110202. /**
  110203. * Initializes a webVR display and starts listening to display change events
  110204. * The onVRDisplayChangedObservable will be notified upon these changes
  110205. * @returns The onVRDisplayChangedObservable
  110206. */
  110207. initWebVR(): Observable<IDisplayChangedEventArgs>;
  110208. /** @hidden */
  110209. _prepareVRComponent(): void;
  110210. /** @hidden */
  110211. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  110212. /** @hidden */
  110213. _submitVRFrame(): void;
  110214. /**
  110215. * Call this function to leave webVR mode
  110216. * Will do nothing if webVR is not supported or if there is no webVR device
  110217. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110218. */
  110219. disableVR(): void;
  110220. /**
  110221. * Gets a boolean indicating that the system is in VR mode and is presenting
  110222. * @returns true if VR mode is engaged
  110223. */
  110224. isVRPresenting(): boolean;
  110225. /** @hidden */
  110226. _requestVRFrame(): void;
  110227. /** @hidden */
  110228. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110229. /**
  110230. * Gets the source code of the vertex shader associated with a specific webGL program
  110231. * @param program defines the program to use
  110232. * @returns a string containing the source code of the vertex shader associated with the program
  110233. */
  110234. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110235. /**
  110236. * Gets the source code of the fragment shader associated with a specific webGL program
  110237. * @param program defines the program to use
  110238. * @returns a string containing the source code of the fragment shader associated with the program
  110239. */
  110240. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110241. /**
  110242. * Sets a depth stencil texture from a render target to the according uniform.
  110243. * @param channel The texture channel
  110244. * @param uniform The uniform to set
  110245. * @param texture The render target texture containing the depth stencil texture to apply
  110246. */
  110247. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110248. /**
  110249. * Sets a texture to the webGL context from a postprocess
  110250. * @param channel defines the channel to use
  110251. * @param postProcess defines the source postprocess
  110252. */
  110253. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110254. /**
  110255. * Binds the output of the passed in post process to the texture channel specified
  110256. * @param channel The channel the texture should be bound to
  110257. * @param postProcess The post process which's output should be bound
  110258. */
  110259. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110260. protected _rebuildBuffers(): void;
  110261. /** @hidden */
  110262. _renderFrame(): void;
  110263. _renderLoop(): void;
  110264. /** @hidden */
  110265. _renderViews(): boolean;
  110266. /**
  110267. * Toggle full screen mode
  110268. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110269. */
  110270. switchFullscreen(requestPointerLock: boolean): void;
  110271. /**
  110272. * Enters full screen mode
  110273. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110274. */
  110275. enterFullscreen(requestPointerLock: boolean): void;
  110276. /**
  110277. * Exits full screen mode
  110278. */
  110279. exitFullscreen(): void;
  110280. /**
  110281. * Enters Pointerlock mode
  110282. */
  110283. enterPointerlock(): void;
  110284. /**
  110285. * Exits Pointerlock mode
  110286. */
  110287. exitPointerlock(): void;
  110288. /**
  110289. * Begin a new frame
  110290. */
  110291. beginFrame(): void;
  110292. /**
  110293. * Enf the current frame
  110294. */
  110295. endFrame(): void;
  110296. resize(): void;
  110297. /**
  110298. * Force a specific size of the canvas
  110299. * @param width defines the new canvas' width
  110300. * @param height defines the new canvas' height
  110301. */
  110302. setSize(width: number, height: number): void;
  110303. /**
  110304. * Updates a dynamic vertex buffer.
  110305. * @param vertexBuffer the vertex buffer to update
  110306. * @param data the data used to update the vertex buffer
  110307. * @param byteOffset the byte offset of the data
  110308. * @param byteLength the byte length of the data
  110309. */
  110310. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110311. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110312. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110313. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110314. _releaseTexture(texture: InternalTexture): void;
  110315. /**
  110316. * @hidden
  110317. * Rescales a texture
  110318. * @param source input texutre
  110319. * @param destination destination texture
  110320. * @param scene scene to use to render the resize
  110321. * @param internalFormat format to use when resizing
  110322. * @param onComplete callback to be called when resize has completed
  110323. */
  110324. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110325. /**
  110326. * Gets the current framerate
  110327. * @returns a number representing the framerate
  110328. */
  110329. getFps(): number;
  110330. /**
  110331. * Gets the time spent between current and previous frame
  110332. * @returns a number representing the delta time in ms
  110333. */
  110334. getDeltaTime(): number;
  110335. private _measureFps;
  110336. /** @hidden */
  110337. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110338. /**
  110339. * Update a dynamic index buffer
  110340. * @param indexBuffer defines the target index buffer
  110341. * @param indices defines the data to update
  110342. * @param offset defines the offset in the target index buffer where update should start
  110343. */
  110344. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110345. /**
  110346. * Updates the sample count of a render target texture
  110347. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110348. * @param texture defines the texture to update
  110349. * @param samples defines the sample count to set
  110350. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110351. */
  110352. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110353. /**
  110354. * Updates a depth texture Comparison Mode and Function.
  110355. * If the comparison Function is equal to 0, the mode will be set to none.
  110356. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110357. * @param texture The texture to set the comparison function for
  110358. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110359. */
  110360. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110361. /**
  110362. * Creates a webGL buffer to use with instanciation
  110363. * @param capacity defines the size of the buffer
  110364. * @returns the webGL buffer
  110365. */
  110366. createInstancesBuffer(capacity: number): DataBuffer;
  110367. /**
  110368. * Delete a webGL buffer used with instanciation
  110369. * @param buffer defines the webGL buffer to delete
  110370. */
  110371. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110372. private _clientWaitAsync;
  110373. /** @hidden */
  110374. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110375. dispose(): void;
  110376. private _disableTouchAction;
  110377. /**
  110378. * Display the loading screen
  110379. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110380. */
  110381. displayLoadingUI(): void;
  110382. /**
  110383. * Hide the loading screen
  110384. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110385. */
  110386. hideLoadingUI(): void;
  110387. /**
  110388. * Gets the current loading screen object
  110389. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110390. */
  110391. get loadingScreen(): ILoadingScreen;
  110392. /**
  110393. * Sets the current loading screen object
  110394. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110395. */
  110396. set loadingScreen(loadingScreen: ILoadingScreen);
  110397. /**
  110398. * Sets the current loading screen text
  110399. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110400. */
  110401. set loadingUIText(text: string);
  110402. /**
  110403. * Sets the current loading screen background color
  110404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110405. */
  110406. set loadingUIBackgroundColor(color: string);
  110407. /** Pointerlock and fullscreen */
  110408. /**
  110409. * Ask the browser to promote the current element to pointerlock mode
  110410. * @param element defines the DOM element to promote
  110411. */
  110412. static _RequestPointerlock(element: HTMLElement): void;
  110413. /**
  110414. * Asks the browser to exit pointerlock mode
  110415. */
  110416. static _ExitPointerlock(): void;
  110417. /**
  110418. * Ask the browser to promote the current element to fullscreen rendering mode
  110419. * @param element defines the DOM element to promote
  110420. */
  110421. static _RequestFullscreen(element: HTMLElement): void;
  110422. /**
  110423. * Asks the browser to exit fullscreen mode
  110424. */
  110425. static _ExitFullscreen(): void;
  110426. }
  110427. }
  110428. declare module BABYLON {
  110429. /**
  110430. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110431. * during the life time of the application.
  110432. */
  110433. export class EngineStore {
  110434. /** Gets the list of created engines */
  110435. static Instances: Engine[];
  110436. /** @hidden */
  110437. static _LastCreatedScene: Nullable<Scene>;
  110438. /**
  110439. * Gets the latest created engine
  110440. */
  110441. static get LastCreatedEngine(): Nullable<Engine>;
  110442. /**
  110443. * Gets the latest created scene
  110444. */
  110445. static get LastCreatedScene(): Nullable<Scene>;
  110446. /**
  110447. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110448. * @ignorenaming
  110449. */
  110450. static UseFallbackTexture: boolean;
  110451. /**
  110452. * Texture content used if a texture cannot loaded
  110453. * @ignorenaming
  110454. */
  110455. static FallbackTexture: string;
  110456. }
  110457. }
  110458. declare module BABYLON {
  110459. /**
  110460. * Helper class that provides a small promise polyfill
  110461. */
  110462. export class PromisePolyfill {
  110463. /**
  110464. * Static function used to check if the polyfill is required
  110465. * If this is the case then the function will inject the polyfill to window.Promise
  110466. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110467. */
  110468. static Apply(force?: boolean): void;
  110469. }
  110470. }
  110471. declare module BABYLON {
  110472. /**
  110473. * Interface for screenshot methods with describe argument called `size` as object with options
  110474. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110475. */
  110476. export interface IScreenshotSize {
  110477. /**
  110478. * number in pixels for canvas height
  110479. */
  110480. height?: number;
  110481. /**
  110482. * multiplier allowing render at a higher or lower resolution
  110483. * If value is defined then height and width will be ignored and taken from camera
  110484. */
  110485. precision?: number;
  110486. /**
  110487. * number in pixels for canvas width
  110488. */
  110489. width?: number;
  110490. }
  110491. }
  110492. declare module BABYLON {
  110493. interface IColor4Like {
  110494. r: float;
  110495. g: float;
  110496. b: float;
  110497. a: float;
  110498. }
  110499. /**
  110500. * Class containing a set of static utilities functions
  110501. */
  110502. export class Tools {
  110503. /**
  110504. * Gets or sets the base URL to use to load assets
  110505. */
  110506. static get BaseUrl(): string;
  110507. static set BaseUrl(value: string);
  110508. /**
  110509. * Enable/Disable Custom HTTP Request Headers globally.
  110510. * default = false
  110511. * @see CustomRequestHeaders
  110512. */
  110513. static UseCustomRequestHeaders: boolean;
  110514. /**
  110515. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110516. * i.e. when loading files, where the server/service expects an Authorization header
  110517. */
  110518. static CustomRequestHeaders: {
  110519. [key: string]: string;
  110520. };
  110521. /**
  110522. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110523. */
  110524. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110525. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110526. /**
  110527. * Default behaviour for cors in the application.
  110528. * It can be a string if the expected behavior is identical in the entire app.
  110529. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110530. */
  110531. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110532. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110533. /**
  110534. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110535. * @ignorenaming
  110536. */
  110537. static get UseFallbackTexture(): boolean;
  110538. static set UseFallbackTexture(value: boolean);
  110539. /**
  110540. * Use this object to register external classes like custom textures or material
  110541. * to allow the laoders to instantiate them
  110542. */
  110543. static get RegisteredExternalClasses(): {
  110544. [key: string]: Object;
  110545. };
  110546. static set RegisteredExternalClasses(classes: {
  110547. [key: string]: Object;
  110548. });
  110549. /**
  110550. * Texture content used if a texture cannot loaded
  110551. * @ignorenaming
  110552. */
  110553. static get fallbackTexture(): string;
  110554. static set fallbackTexture(value: string);
  110555. /**
  110556. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110557. * @param u defines the coordinate on X axis
  110558. * @param v defines the coordinate on Y axis
  110559. * @param width defines the width of the source data
  110560. * @param height defines the height of the source data
  110561. * @param pixels defines the source byte array
  110562. * @param color defines the output color
  110563. */
  110564. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110565. /**
  110566. * Interpolates between a and b via alpha
  110567. * @param a The lower value (returned when alpha = 0)
  110568. * @param b The upper value (returned when alpha = 1)
  110569. * @param alpha The interpolation-factor
  110570. * @return The mixed value
  110571. */
  110572. static Mix(a: number, b: number, alpha: number): number;
  110573. /**
  110574. * Tries to instantiate a new object from a given class name
  110575. * @param className defines the class name to instantiate
  110576. * @returns the new object or null if the system was not able to do the instantiation
  110577. */
  110578. static Instantiate(className: string): any;
  110579. /**
  110580. * Provides a slice function that will work even on IE
  110581. * @param data defines the array to slice
  110582. * @param start defines the start of the data (optional)
  110583. * @param end defines the end of the data (optional)
  110584. * @returns the new sliced array
  110585. */
  110586. static Slice<T>(data: T, start?: number, end?: number): T;
  110587. /**
  110588. * Polyfill for setImmediate
  110589. * @param action defines the action to execute after the current execution block
  110590. */
  110591. static SetImmediate(action: () => void): void;
  110592. /**
  110593. * Function indicating if a number is an exponent of 2
  110594. * @param value defines the value to test
  110595. * @returns true if the value is an exponent of 2
  110596. */
  110597. static IsExponentOfTwo(value: number): boolean;
  110598. private static _tmpFloatArray;
  110599. /**
  110600. * Returns the nearest 32-bit single precision float representation of a Number
  110601. * @param value A Number. If the parameter is of a different type, it will get converted
  110602. * to a number or to NaN if it cannot be converted
  110603. * @returns number
  110604. */
  110605. static FloatRound(value: number): number;
  110606. /**
  110607. * Extracts the filename from a path
  110608. * @param path defines the path to use
  110609. * @returns the filename
  110610. */
  110611. static GetFilename(path: string): string;
  110612. /**
  110613. * Extracts the "folder" part of a path (everything before the filename).
  110614. * @param uri The URI to extract the info from
  110615. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110616. * @returns The "folder" part of the path
  110617. */
  110618. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110619. /**
  110620. * Extracts text content from a DOM element hierarchy
  110621. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110622. */
  110623. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110624. /**
  110625. * Convert an angle in radians to degrees
  110626. * @param angle defines the angle to convert
  110627. * @returns the angle in degrees
  110628. */
  110629. static ToDegrees(angle: number): number;
  110630. /**
  110631. * Convert an angle in degrees to radians
  110632. * @param angle defines the angle to convert
  110633. * @returns the angle in radians
  110634. */
  110635. static ToRadians(angle: number): number;
  110636. /**
  110637. * Returns an array if obj is not an array
  110638. * @param obj defines the object to evaluate as an array
  110639. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110640. * @returns either obj directly if obj is an array or a new array containing obj
  110641. */
  110642. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110643. /**
  110644. * Gets the pointer prefix to use
  110645. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110646. */
  110647. static GetPointerPrefix(): string;
  110648. /**
  110649. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110650. * @param url define the url we are trying
  110651. * @param element define the dom element where to configure the cors policy
  110652. */
  110653. static SetCorsBehavior(url: string | string[], element: {
  110654. crossOrigin: string | null;
  110655. }): void;
  110656. /**
  110657. * Removes unwanted characters from an url
  110658. * @param url defines the url to clean
  110659. * @returns the cleaned url
  110660. */
  110661. static CleanUrl(url: string): string;
  110662. /**
  110663. * Gets or sets a function used to pre-process url before using them to load assets
  110664. */
  110665. static get PreprocessUrl(): (url: string) => string;
  110666. static set PreprocessUrl(processor: (url: string) => string);
  110667. /**
  110668. * Loads an image as an HTMLImageElement.
  110669. * @param input url string, ArrayBuffer, or Blob to load
  110670. * @param onLoad callback called when the image successfully loads
  110671. * @param onError callback called when the image fails to load
  110672. * @param offlineProvider offline provider for caching
  110673. * @param mimeType optional mime type
  110674. * @returns the HTMLImageElement of the loaded image
  110675. */
  110676. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110677. /**
  110678. * Loads a file from a url
  110679. * @param url url string, ArrayBuffer, or Blob to load
  110680. * @param onSuccess callback called when the file successfully loads
  110681. * @param onProgress callback called while file is loading (if the server supports this mode)
  110682. * @param offlineProvider defines the offline provider for caching
  110683. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110684. * @param onError callback called when the file fails to load
  110685. * @returns a file request object
  110686. */
  110687. 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;
  110688. /**
  110689. * Loads a file from a url
  110690. * @param url the file url to load
  110691. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110692. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110693. */
  110694. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110695. /**
  110696. * Load a script (identified by an url). When the url returns, the
  110697. * content of this file is added into a new script element, attached to the DOM (body element)
  110698. * @param scriptUrl defines the url of the script to laod
  110699. * @param onSuccess defines the callback called when the script is loaded
  110700. * @param onError defines the callback to call if an error occurs
  110701. * @param scriptId defines the id of the script element
  110702. */
  110703. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110704. /**
  110705. * Load an asynchronous script (identified by an url). When the url returns, the
  110706. * content of this file is added into a new script element, attached to the DOM (body element)
  110707. * @param scriptUrl defines the url of the script to laod
  110708. * @param scriptId defines the id of the script element
  110709. * @returns a promise request object
  110710. */
  110711. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110712. /**
  110713. * Loads a file from a blob
  110714. * @param fileToLoad defines the blob to use
  110715. * @param callback defines the callback to call when data is loaded
  110716. * @param progressCallback defines the callback to call during loading process
  110717. * @returns a file request object
  110718. */
  110719. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110720. /**
  110721. * Reads a file from a File object
  110722. * @param file defines the file to load
  110723. * @param onSuccess defines the callback to call when data is loaded
  110724. * @param onProgress defines the callback to call during loading process
  110725. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110726. * @param onError defines the callback to call when an error occurs
  110727. * @returns a file request object
  110728. */
  110729. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110730. /**
  110731. * Creates a data url from a given string content
  110732. * @param content defines the content to convert
  110733. * @returns the new data url link
  110734. */
  110735. static FileAsURL(content: string): string;
  110736. /**
  110737. * Format the given number to a specific decimal format
  110738. * @param value defines the number to format
  110739. * @param decimals defines the number of decimals to use
  110740. * @returns the formatted string
  110741. */
  110742. static Format(value: number, decimals?: number): string;
  110743. /**
  110744. * Tries to copy an object by duplicating every property
  110745. * @param source defines the source object
  110746. * @param destination defines the target object
  110747. * @param doNotCopyList defines a list of properties to avoid
  110748. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110749. */
  110750. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110751. /**
  110752. * Gets a boolean indicating if the given object has no own property
  110753. * @param obj defines the object to test
  110754. * @returns true if object has no own property
  110755. */
  110756. static IsEmpty(obj: any): boolean;
  110757. /**
  110758. * Function used to register events at window level
  110759. * @param windowElement defines the Window object to use
  110760. * @param events defines the events to register
  110761. */
  110762. static RegisterTopRootEvents(windowElement: Window, events: {
  110763. name: string;
  110764. handler: Nullable<(e: FocusEvent) => any>;
  110765. }[]): void;
  110766. /**
  110767. * Function used to unregister events from window level
  110768. * @param windowElement defines the Window object to use
  110769. * @param events defines the events to unregister
  110770. */
  110771. static UnregisterTopRootEvents(windowElement: Window, events: {
  110772. name: string;
  110773. handler: Nullable<(e: FocusEvent) => any>;
  110774. }[]): void;
  110775. /**
  110776. * @ignore
  110777. */
  110778. static _ScreenshotCanvas: HTMLCanvasElement;
  110779. /**
  110780. * Dumps the current bound framebuffer
  110781. * @param width defines the rendering width
  110782. * @param height defines the rendering height
  110783. * @param engine defines the hosting engine
  110784. * @param successCallback defines the callback triggered once the data are available
  110785. * @param mimeType defines the mime type of the result
  110786. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110787. */
  110788. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110789. /**
  110790. * Converts the canvas data to blob.
  110791. * This acts as a polyfill for browsers not supporting the to blob function.
  110792. * @param canvas Defines the canvas to extract the data from
  110793. * @param successCallback Defines the callback triggered once the data are available
  110794. * @param mimeType Defines the mime type of the result
  110795. */
  110796. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110797. /**
  110798. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110799. * @param successCallback defines the callback triggered once the data are available
  110800. * @param mimeType defines the mime type of the result
  110801. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110802. */
  110803. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110804. /**
  110805. * Downloads a blob in the browser
  110806. * @param blob defines the blob to download
  110807. * @param fileName defines the name of the downloaded file
  110808. */
  110809. static Download(blob: Blob, fileName: string): void;
  110810. /**
  110811. * Captures a screenshot of the current rendering
  110812. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110813. * @param engine defines the rendering engine
  110814. * @param camera defines the source camera
  110815. * @param size This parameter can be set to a single number or to an object with the
  110816. * following (optional) properties: precision, width, height. If a single number is passed,
  110817. * it will be used for both width and height. If an object is passed, the screenshot size
  110818. * will be derived from the parameters. The precision property is a multiplier allowing
  110819. * rendering at a higher or lower resolution
  110820. * @param successCallback defines the callback receives a single parameter which contains the
  110821. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110822. * src parameter of an <img> to display it
  110823. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110824. * Check your browser for supported MIME types
  110825. */
  110826. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110827. /**
  110828. * Captures a screenshot of the current rendering
  110829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110830. * @param engine defines the rendering engine
  110831. * @param camera defines the source camera
  110832. * @param size This parameter can be set to a single number or to an object with the
  110833. * following (optional) properties: precision, width, height. If a single number is passed,
  110834. * it will be used for both width and height. If an object is passed, the screenshot size
  110835. * will be derived from the parameters. The precision property is a multiplier allowing
  110836. * rendering at a higher or lower resolution
  110837. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110838. * Check your browser for supported MIME types
  110839. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110840. * to the src parameter of an <img> to display it
  110841. */
  110842. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110843. /**
  110844. * Generates an image screenshot from the specified camera.
  110845. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110846. * @param engine The engine to use for rendering
  110847. * @param camera The camera to use for rendering
  110848. * @param size This parameter can be set to a single number or to an object with the
  110849. * following (optional) properties: precision, width, height. If a single number is passed,
  110850. * it will be used for both width and height. If an object is passed, the screenshot size
  110851. * will be derived from the parameters. The precision property is a multiplier allowing
  110852. * rendering at a higher or lower resolution
  110853. * @param successCallback The callback receives a single parameter which contains the
  110854. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110855. * src parameter of an <img> to display it
  110856. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110857. * Check your browser for supported MIME types
  110858. * @param samples Texture samples (default: 1)
  110859. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110860. * @param fileName A name for for the downloaded file.
  110861. */
  110862. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110863. /**
  110864. * Generates an image screenshot from the specified camera.
  110865. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110866. * @param engine The engine to use for rendering
  110867. * @param camera The camera to use for rendering
  110868. * @param size This parameter can be set to a single number or to an object with the
  110869. * following (optional) properties: precision, width, height. If a single number is passed,
  110870. * it will be used for both width and height. If an object is passed, the screenshot size
  110871. * will be derived from the parameters. The precision property is a multiplier allowing
  110872. * rendering at a higher or lower resolution
  110873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110874. * Check your browser for supported MIME types
  110875. * @param samples Texture samples (default: 1)
  110876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110877. * @param fileName A name for for the downloaded file.
  110878. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110879. * to the src parameter of an <img> to display it
  110880. */
  110881. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110882. /**
  110883. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110884. * Be aware Math.random() could cause collisions, but:
  110885. * "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"
  110886. * @returns a pseudo random id
  110887. */
  110888. static RandomId(): string;
  110889. /**
  110890. * Test if the given uri is a base64 string
  110891. * @param uri The uri to test
  110892. * @return True if the uri is a base64 string or false otherwise
  110893. */
  110894. static IsBase64(uri: string): boolean;
  110895. /**
  110896. * Decode the given base64 uri.
  110897. * @param uri The uri to decode
  110898. * @return The decoded base64 data.
  110899. */
  110900. static DecodeBase64(uri: string): ArrayBuffer;
  110901. /**
  110902. * Gets the absolute url.
  110903. * @param url the input url
  110904. * @return the absolute url
  110905. */
  110906. static GetAbsoluteUrl(url: string): string;
  110907. /**
  110908. * No log
  110909. */
  110910. static readonly NoneLogLevel: number;
  110911. /**
  110912. * Only message logs
  110913. */
  110914. static readonly MessageLogLevel: number;
  110915. /**
  110916. * Only warning logs
  110917. */
  110918. static readonly WarningLogLevel: number;
  110919. /**
  110920. * Only error logs
  110921. */
  110922. static readonly ErrorLogLevel: number;
  110923. /**
  110924. * All logs
  110925. */
  110926. static readonly AllLogLevel: number;
  110927. /**
  110928. * Gets a value indicating the number of loading errors
  110929. * @ignorenaming
  110930. */
  110931. static get errorsCount(): number;
  110932. /**
  110933. * Callback called when a new log is added
  110934. */
  110935. static OnNewCacheEntry: (entry: string) => void;
  110936. /**
  110937. * Log a message to the console
  110938. * @param message defines the message to log
  110939. */
  110940. static Log(message: string): void;
  110941. /**
  110942. * Write a warning message to the console
  110943. * @param message defines the message to log
  110944. */
  110945. static Warn(message: string): void;
  110946. /**
  110947. * Write an error message to the console
  110948. * @param message defines the message to log
  110949. */
  110950. static Error(message: string): void;
  110951. /**
  110952. * Gets current log cache (list of logs)
  110953. */
  110954. static get LogCache(): string;
  110955. /**
  110956. * Clears the log cache
  110957. */
  110958. static ClearLogCache(): void;
  110959. /**
  110960. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  110961. */
  110962. static set LogLevels(level: number);
  110963. /**
  110964. * Checks if the window object exists
  110965. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  110966. */
  110967. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  110968. /**
  110969. * No performance log
  110970. */
  110971. static readonly PerformanceNoneLogLevel: number;
  110972. /**
  110973. * Use user marks to log performance
  110974. */
  110975. static readonly PerformanceUserMarkLogLevel: number;
  110976. /**
  110977. * Log performance to the console
  110978. */
  110979. static readonly PerformanceConsoleLogLevel: number;
  110980. private static _performance;
  110981. /**
  110982. * Sets the current performance log level
  110983. */
  110984. static set PerformanceLogLevel(level: number);
  110985. private static _StartPerformanceCounterDisabled;
  110986. private static _EndPerformanceCounterDisabled;
  110987. private static _StartUserMark;
  110988. private static _EndUserMark;
  110989. private static _StartPerformanceConsole;
  110990. private static _EndPerformanceConsole;
  110991. /**
  110992. * Starts a performance counter
  110993. */
  110994. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110995. /**
  110996. * Ends a specific performance coutner
  110997. */
  110998. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110999. /**
  111000. * Gets either window.performance.now() if supported or Date.now() else
  111001. */
  111002. static get Now(): number;
  111003. /**
  111004. * This method will return the name of the class used to create the instance of the given object.
  111005. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  111006. * @param object the object to get the class name from
  111007. * @param isType defines if the object is actually a type
  111008. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  111009. */
  111010. static GetClassName(object: any, isType?: boolean): string;
  111011. /**
  111012. * Gets the first element of an array satisfying a given predicate
  111013. * @param array defines the array to browse
  111014. * @param predicate defines the predicate to use
  111015. * @returns null if not found or the element
  111016. */
  111017. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  111018. /**
  111019. * This method will return the name of the full name of the class, including its owning module (if any).
  111020. * 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).
  111021. * @param object the object to get the class name from
  111022. * @param isType defines if the object is actually a type
  111023. * @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.
  111024. * @ignorenaming
  111025. */
  111026. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  111027. /**
  111028. * Returns a promise that resolves after the given amount of time.
  111029. * @param delay Number of milliseconds to delay
  111030. * @returns Promise that resolves after the given amount of time
  111031. */
  111032. static DelayAsync(delay: number): Promise<void>;
  111033. /**
  111034. * Utility function to detect if the current user agent is Safari
  111035. * @returns whether or not the current user agent is safari
  111036. */
  111037. static IsSafari(): boolean;
  111038. }
  111039. /**
  111040. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  111041. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  111042. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  111043. * @param name The name of the class, case should be preserved
  111044. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  111045. */
  111046. export function className(name: string, module?: string): (target: Object) => void;
  111047. /**
  111048. * An implementation of a loop for asynchronous functions.
  111049. */
  111050. export class AsyncLoop {
  111051. /**
  111052. * Defines the number of iterations for the loop
  111053. */
  111054. iterations: number;
  111055. /**
  111056. * Defines the current index of the loop.
  111057. */
  111058. index: number;
  111059. private _done;
  111060. private _fn;
  111061. private _successCallback;
  111062. /**
  111063. * Constructor.
  111064. * @param iterations the number of iterations.
  111065. * @param func the function to run each iteration
  111066. * @param successCallback the callback that will be called upon succesful execution
  111067. * @param offset starting offset.
  111068. */
  111069. constructor(
  111070. /**
  111071. * Defines the number of iterations for the loop
  111072. */
  111073. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  111074. /**
  111075. * Execute the next iteration. Must be called after the last iteration was finished.
  111076. */
  111077. executeNext(): void;
  111078. /**
  111079. * Break the loop and run the success callback.
  111080. */
  111081. breakLoop(): void;
  111082. /**
  111083. * Create and run an async loop.
  111084. * @param iterations the number of iterations.
  111085. * @param fn the function to run each iteration
  111086. * @param successCallback the callback that will be called upon succesful execution
  111087. * @param offset starting offset.
  111088. * @returns the created async loop object
  111089. */
  111090. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  111091. /**
  111092. * A for-loop that will run a given number of iterations synchronous and the rest async.
  111093. * @param iterations total number of iterations
  111094. * @param syncedIterations number of synchronous iterations in each async iteration.
  111095. * @param fn the function to call each iteration.
  111096. * @param callback a success call back that will be called when iterating stops.
  111097. * @param breakFunction a break condition (optional)
  111098. * @param timeout timeout settings for the setTimeout function. default - 0.
  111099. * @returns the created async loop object
  111100. */
  111101. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  111102. }
  111103. }
  111104. declare module BABYLON {
  111105. /**
  111106. * This class implement a typical dictionary using a string as key and the generic type T as value.
  111107. * The underlying implementation relies on an associative array to ensure the best performances.
  111108. * The value can be anything including 'null' but except 'undefined'
  111109. */
  111110. export class StringDictionary<T> {
  111111. /**
  111112. * This will clear this dictionary and copy the content from the 'source' one.
  111113. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  111114. * @param source the dictionary to take the content from and copy to this dictionary
  111115. */
  111116. copyFrom(source: StringDictionary<T>): void;
  111117. /**
  111118. * Get a value based from its key
  111119. * @param key the given key to get the matching value from
  111120. * @return the value if found, otherwise undefined is returned
  111121. */
  111122. get(key: string): T | undefined;
  111123. /**
  111124. * Get a value from its key or add it if it doesn't exist.
  111125. * This method will ensure you that a given key/data will be present in the dictionary.
  111126. * @param key the given key to get the matching value from
  111127. * @param factory the factory that will create the value if the key is not present in the dictionary.
  111128. * The factory will only be invoked if there's no data for the given key.
  111129. * @return the value corresponding to the key.
  111130. */
  111131. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  111132. /**
  111133. * Get a value from its key if present in the dictionary otherwise add it
  111134. * @param key the key to get the value from
  111135. * @param val if there's no such key/value pair in the dictionary add it with this value
  111136. * @return the value corresponding to the key
  111137. */
  111138. getOrAdd(key: string, val: T): T;
  111139. /**
  111140. * Check if there's a given key in the dictionary
  111141. * @param key the key to check for
  111142. * @return true if the key is present, false otherwise
  111143. */
  111144. contains(key: string): boolean;
  111145. /**
  111146. * Add a new key and its corresponding value
  111147. * @param key the key to add
  111148. * @param value the value corresponding to the key
  111149. * @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
  111150. */
  111151. add(key: string, value: T): boolean;
  111152. /**
  111153. * Update a specific value associated to a key
  111154. * @param key defines the key to use
  111155. * @param value defines the value to store
  111156. * @returns true if the value was updated (or false if the key was not found)
  111157. */
  111158. set(key: string, value: T): boolean;
  111159. /**
  111160. * Get the element of the given key and remove it from the dictionary
  111161. * @param key defines the key to search
  111162. * @returns the value associated with the key or null if not found
  111163. */
  111164. getAndRemove(key: string): Nullable<T>;
  111165. /**
  111166. * Remove a key/value from the dictionary.
  111167. * @param key the key to remove
  111168. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  111169. */
  111170. remove(key: string): boolean;
  111171. /**
  111172. * Clear the whole content of the dictionary
  111173. */
  111174. clear(): void;
  111175. /**
  111176. * Gets the current count
  111177. */
  111178. get count(): number;
  111179. /**
  111180. * Execute a callback on each key/val of the dictionary.
  111181. * Note that you can remove any element in this dictionary in the callback implementation
  111182. * @param callback the callback to execute on a given key/value pair
  111183. */
  111184. forEach(callback: (key: string, val: T) => void): void;
  111185. /**
  111186. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  111187. * If the callback returns null or undefined the method will iterate to the next key/value pair
  111188. * Note that you can remove any element in this dictionary in the callback implementation
  111189. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  111190. * @returns the first item
  111191. */
  111192. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  111193. private _count;
  111194. private _data;
  111195. }
  111196. }
  111197. declare module BABYLON {
  111198. /** @hidden */
  111199. export interface ICollisionCoordinator {
  111200. createCollider(): Collider;
  111201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111202. init(scene: Scene): void;
  111203. }
  111204. /** @hidden */
  111205. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  111206. private _scene;
  111207. private _scaledPosition;
  111208. private _scaledVelocity;
  111209. private _finalPosition;
  111210. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111211. createCollider(): Collider;
  111212. init(scene: Scene): void;
  111213. private _collideWithWorld;
  111214. }
  111215. }
  111216. declare module BABYLON {
  111217. /**
  111218. * Class used to manage all inputs for the scene.
  111219. */
  111220. export class InputManager {
  111221. /** The distance in pixel that you have to move to prevent some events */
  111222. static DragMovementThreshold: number;
  111223. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111224. static LongPressDelay: number;
  111225. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111226. static DoubleClickDelay: number;
  111227. /** If you need to check double click without raising a single click at first click, enable this flag */
  111228. static ExclusiveDoubleClickMode: boolean;
  111229. private _wheelEventName;
  111230. private _onPointerMove;
  111231. private _onPointerDown;
  111232. private _onPointerUp;
  111233. private _initClickEvent;
  111234. private _initActionManager;
  111235. private _delayedSimpleClick;
  111236. private _delayedSimpleClickTimeout;
  111237. private _previousDelayedSimpleClickTimeout;
  111238. private _meshPickProceed;
  111239. private _previousButtonPressed;
  111240. private _currentPickResult;
  111241. private _previousPickResult;
  111242. private _totalPointersPressed;
  111243. private _doubleClickOccured;
  111244. private _pointerOverMesh;
  111245. private _pickedDownMesh;
  111246. private _pickedUpMesh;
  111247. private _pointerX;
  111248. private _pointerY;
  111249. private _unTranslatedPointerX;
  111250. private _unTranslatedPointerY;
  111251. private _startingPointerPosition;
  111252. private _previousStartingPointerPosition;
  111253. private _startingPointerTime;
  111254. private _previousStartingPointerTime;
  111255. private _pointerCaptures;
  111256. private _onKeyDown;
  111257. private _onKeyUp;
  111258. private _onCanvasFocusObserver;
  111259. private _onCanvasBlurObserver;
  111260. private _scene;
  111261. /**
  111262. * Creates a new InputManager
  111263. * @param scene defines the hosting scene
  111264. */
  111265. constructor(scene: Scene);
  111266. /**
  111267. * Gets the mesh that is currently under the pointer
  111268. */
  111269. get meshUnderPointer(): Nullable<AbstractMesh>;
  111270. /**
  111271. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111272. */
  111273. get unTranslatedPointer(): Vector2;
  111274. /**
  111275. * Gets or sets the current on-screen X position of the pointer
  111276. */
  111277. get pointerX(): number;
  111278. set pointerX(value: number);
  111279. /**
  111280. * Gets or sets the current on-screen Y position of the pointer
  111281. */
  111282. get pointerY(): number;
  111283. set pointerY(value: number);
  111284. private _updatePointerPosition;
  111285. private _processPointerMove;
  111286. private _setRayOnPointerInfo;
  111287. private _checkPrePointerObservable;
  111288. /**
  111289. * Use this method to simulate a pointer move on a mesh
  111290. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111291. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111292. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111293. */
  111294. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111295. /**
  111296. * Use this method to simulate a pointer down on a mesh
  111297. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111298. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111299. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111300. */
  111301. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111302. private _processPointerDown;
  111303. /** @hidden */
  111304. _isPointerSwiping(): boolean;
  111305. /**
  111306. * Use this method to simulate a pointer up on a mesh
  111307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111310. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111311. */
  111312. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111313. private _processPointerUp;
  111314. /**
  111315. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111316. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111317. * @returns true if the pointer was captured
  111318. */
  111319. isPointerCaptured(pointerId?: number): boolean;
  111320. /**
  111321. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111322. * @param attachUp defines if you want to attach events to pointerup
  111323. * @param attachDown defines if you want to attach events to pointerdown
  111324. * @param attachMove defines if you want to attach events to pointermove
  111325. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111326. */
  111327. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111328. /**
  111329. * Detaches all event handlers
  111330. */
  111331. detachControl(): void;
  111332. /**
  111333. * Force the value of meshUnderPointer
  111334. * @param mesh defines the mesh to use
  111335. */
  111336. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111337. /**
  111338. * Gets the mesh under the pointer
  111339. * @returns a Mesh or null if no mesh is under the pointer
  111340. */
  111341. getPointerOverMesh(): Nullable<AbstractMesh>;
  111342. }
  111343. }
  111344. declare module BABYLON {
  111345. /**
  111346. * Helper class used to generate session unique ID
  111347. */
  111348. export class UniqueIdGenerator {
  111349. private static _UniqueIdCounter;
  111350. /**
  111351. * Gets an unique (relatively to the current scene) Id
  111352. */
  111353. static get UniqueId(): number;
  111354. }
  111355. }
  111356. declare module BABYLON {
  111357. /**
  111358. * This class defines the direct association between an animation and a target
  111359. */
  111360. export class TargetedAnimation {
  111361. /**
  111362. * Animation to perform
  111363. */
  111364. animation: Animation;
  111365. /**
  111366. * Target to animate
  111367. */
  111368. target: any;
  111369. /**
  111370. * Serialize the object
  111371. * @returns the JSON object representing the current entity
  111372. */
  111373. serialize(): any;
  111374. }
  111375. /**
  111376. * Use this class to create coordinated animations on multiple targets
  111377. */
  111378. export class AnimationGroup implements IDisposable {
  111379. /** The name of the animation group */
  111380. name: string;
  111381. private _scene;
  111382. private _targetedAnimations;
  111383. private _animatables;
  111384. private _from;
  111385. private _to;
  111386. private _isStarted;
  111387. private _isPaused;
  111388. private _speedRatio;
  111389. private _loopAnimation;
  111390. private _isAdditive;
  111391. /**
  111392. * Gets or sets the unique id of the node
  111393. */
  111394. uniqueId: number;
  111395. /**
  111396. * This observable will notify when one animation have ended
  111397. */
  111398. onAnimationEndObservable: Observable<TargetedAnimation>;
  111399. /**
  111400. * Observer raised when one animation loops
  111401. */
  111402. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111403. /**
  111404. * Observer raised when all animations have looped
  111405. */
  111406. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111407. /**
  111408. * This observable will notify when all animations have ended.
  111409. */
  111410. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111411. /**
  111412. * This observable will notify when all animations have paused.
  111413. */
  111414. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111415. /**
  111416. * This observable will notify when all animations are playing.
  111417. */
  111418. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111419. /**
  111420. * Gets the first frame
  111421. */
  111422. get from(): number;
  111423. /**
  111424. * Gets the last frame
  111425. */
  111426. get to(): number;
  111427. /**
  111428. * Define if the animations are started
  111429. */
  111430. get isStarted(): boolean;
  111431. /**
  111432. * Gets a value indicating that the current group is playing
  111433. */
  111434. get isPlaying(): boolean;
  111435. /**
  111436. * Gets or sets the speed ratio to use for all animations
  111437. */
  111438. get speedRatio(): number;
  111439. /**
  111440. * Gets or sets the speed ratio to use for all animations
  111441. */
  111442. set speedRatio(value: number);
  111443. /**
  111444. * Gets or sets if all animations should loop or not
  111445. */
  111446. get loopAnimation(): boolean;
  111447. set loopAnimation(value: boolean);
  111448. /**
  111449. * Gets or sets if all animations should be evaluated additively
  111450. */
  111451. get isAdditive(): boolean;
  111452. set isAdditive(value: boolean);
  111453. /**
  111454. * Gets the targeted animations for this animation group
  111455. */
  111456. get targetedAnimations(): Array<TargetedAnimation>;
  111457. /**
  111458. * returning the list of animatables controlled by this animation group.
  111459. */
  111460. get animatables(): Array<Animatable>;
  111461. /**
  111462. * Instantiates a new Animation Group.
  111463. * This helps managing several animations at once.
  111464. * @see http://doc.babylonjs.com/how_to/group
  111465. * @param name Defines the name of the group
  111466. * @param scene Defines the scene the group belongs to
  111467. */
  111468. constructor(
  111469. /** The name of the animation group */
  111470. name: string, scene?: Nullable<Scene>);
  111471. /**
  111472. * Add an animation (with its target) in the group
  111473. * @param animation defines the animation we want to add
  111474. * @param target defines the target of the animation
  111475. * @returns the TargetedAnimation object
  111476. */
  111477. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111478. /**
  111479. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111480. * It can add constant keys at begin or end
  111481. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111482. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111483. * @returns the animation group
  111484. */
  111485. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111486. private _animationLoopCount;
  111487. private _animationLoopFlags;
  111488. private _processLoop;
  111489. /**
  111490. * Start all animations on given targets
  111491. * @param loop defines if animations must loop
  111492. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111493. * @param from defines the from key (optional)
  111494. * @param to defines the to key (optional)
  111495. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111496. * @returns the current animation group
  111497. */
  111498. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111499. /**
  111500. * Pause all animations
  111501. * @returns the animation group
  111502. */
  111503. pause(): AnimationGroup;
  111504. /**
  111505. * Play all animations to initial state
  111506. * This function will start() the animations if they were not started or will restart() them if they were paused
  111507. * @param loop defines if animations must loop
  111508. * @returns the animation group
  111509. */
  111510. play(loop?: boolean): AnimationGroup;
  111511. /**
  111512. * Reset all animations to initial state
  111513. * @returns the animation group
  111514. */
  111515. reset(): AnimationGroup;
  111516. /**
  111517. * Restart animations from key 0
  111518. * @returns the animation group
  111519. */
  111520. restart(): AnimationGroup;
  111521. /**
  111522. * Stop all animations
  111523. * @returns the animation group
  111524. */
  111525. stop(): AnimationGroup;
  111526. /**
  111527. * Set animation weight for all animatables
  111528. * @param weight defines the weight to use
  111529. * @return the animationGroup
  111530. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111531. */
  111532. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111533. /**
  111534. * Synchronize and normalize all animatables with a source animatable
  111535. * @param root defines the root animatable to synchronize with
  111536. * @return the animationGroup
  111537. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111538. */
  111539. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111540. /**
  111541. * Goes to a specific frame in this animation group
  111542. * @param frame the frame number to go to
  111543. * @return the animationGroup
  111544. */
  111545. goToFrame(frame: number): AnimationGroup;
  111546. /**
  111547. * Dispose all associated resources
  111548. */
  111549. dispose(): void;
  111550. private _checkAnimationGroupEnded;
  111551. /**
  111552. * Clone the current animation group and returns a copy
  111553. * @param newName defines the name of the new group
  111554. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111555. * @returns the new aniamtion group
  111556. */
  111557. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111558. /**
  111559. * Serializes the animationGroup to an object
  111560. * @returns Serialized object
  111561. */
  111562. serialize(): any;
  111563. /**
  111564. * Returns a new AnimationGroup object parsed from the source provided.
  111565. * @param parsedAnimationGroup defines the source
  111566. * @param scene defines the scene that will receive the animationGroup
  111567. * @returns a new AnimationGroup
  111568. */
  111569. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111570. /**
  111571. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111572. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111573. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111574. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111575. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111576. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111577. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111578. */
  111579. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111580. /**
  111581. * Returns the string "AnimationGroup"
  111582. * @returns "AnimationGroup"
  111583. */
  111584. getClassName(): string;
  111585. /**
  111586. * Creates a detailled string about the object
  111587. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111588. * @returns a string representing the object
  111589. */
  111590. toString(fullDetails?: boolean): string;
  111591. }
  111592. }
  111593. declare module BABYLON {
  111594. /**
  111595. * Define an interface for all classes that will hold resources
  111596. */
  111597. export interface IDisposable {
  111598. /**
  111599. * Releases all held resources
  111600. */
  111601. dispose(): void;
  111602. }
  111603. /** Interface defining initialization parameters for Scene class */
  111604. export interface SceneOptions {
  111605. /**
  111606. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111607. * It will improve performance when the number of geometries becomes important.
  111608. */
  111609. useGeometryUniqueIdsMap?: boolean;
  111610. /**
  111611. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111612. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111613. */
  111614. useMaterialMeshMap?: boolean;
  111615. /**
  111616. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111617. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111618. */
  111619. useClonedMeshMap?: boolean;
  111620. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111621. virtual?: boolean;
  111622. }
  111623. /**
  111624. * Represents a scene to be rendered by the engine.
  111625. * @see http://doc.babylonjs.com/features/scene
  111626. */
  111627. export class Scene extends AbstractScene implements IAnimatable {
  111628. /** The fog is deactivated */
  111629. static readonly FOGMODE_NONE: number;
  111630. /** The fog density is following an exponential function */
  111631. static readonly FOGMODE_EXP: number;
  111632. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111633. static readonly FOGMODE_EXP2: number;
  111634. /** The fog density is following a linear function. */
  111635. static readonly FOGMODE_LINEAR: number;
  111636. /**
  111637. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111638. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111639. */
  111640. static MinDeltaTime: number;
  111641. /**
  111642. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111644. */
  111645. static MaxDeltaTime: number;
  111646. /**
  111647. * Factory used to create the default material.
  111648. * @param name The name of the material to create
  111649. * @param scene The scene to create the material for
  111650. * @returns The default material
  111651. */
  111652. static DefaultMaterialFactory(scene: Scene): Material;
  111653. /**
  111654. * Factory used to create the a collision coordinator.
  111655. * @returns The collision coordinator
  111656. */
  111657. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111658. /** @hidden */
  111659. _inputManager: InputManager;
  111660. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111661. cameraToUseForPointers: Nullable<Camera>;
  111662. /** @hidden */
  111663. readonly _isScene: boolean;
  111664. /** @hidden */
  111665. _blockEntityCollection: boolean;
  111666. /**
  111667. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111668. */
  111669. autoClear: boolean;
  111670. /**
  111671. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111672. */
  111673. autoClearDepthAndStencil: boolean;
  111674. /**
  111675. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111676. */
  111677. clearColor: Color4;
  111678. /**
  111679. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111680. */
  111681. ambientColor: Color3;
  111682. /**
  111683. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111684. * It should only be one of the following (if not the default embedded one):
  111685. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111686. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111687. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111688. * The material properties need to be setup according to the type of texture in use.
  111689. */
  111690. environmentBRDFTexture: BaseTexture;
  111691. /** @hidden */
  111692. protected _environmentTexture: Nullable<BaseTexture>;
  111693. /**
  111694. * Texture used in all pbr material as the reflection texture.
  111695. * As in the majority of the scene they are the same (exception for multi room and so on),
  111696. * this is easier to reference from here than from all the materials.
  111697. */
  111698. get environmentTexture(): Nullable<BaseTexture>;
  111699. /**
  111700. * Texture used in all pbr material as the reflection texture.
  111701. * As in the majority of the scene they are the same (exception for multi room and so on),
  111702. * this is easier to set here than in all the materials.
  111703. */
  111704. set environmentTexture(value: Nullable<BaseTexture>);
  111705. /** @hidden */
  111706. protected _environmentIntensity: number;
  111707. /**
  111708. * Intensity of the environment in all pbr material.
  111709. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111710. * As in the majority of the scene they are the same (exception for multi room and so on),
  111711. * this is easier to reference from here than from all the materials.
  111712. */
  111713. get environmentIntensity(): number;
  111714. /**
  111715. * Intensity of the environment in all pbr material.
  111716. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111717. * As in the majority of the scene they are the same (exception for multi room and so on),
  111718. * this is easier to set here than in all the materials.
  111719. */
  111720. set environmentIntensity(value: number);
  111721. /** @hidden */
  111722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111723. /**
  111724. * Default image processing configuration used either in the rendering
  111725. * Forward main pass or through the imageProcessingPostProcess if present.
  111726. * As in the majority of the scene they are the same (exception for multi camera),
  111727. * this is easier to reference from here than from all the materials and post process.
  111728. *
  111729. * No setter as we it is a shared configuration, you can set the values instead.
  111730. */
  111731. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111732. private _forceWireframe;
  111733. /**
  111734. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111735. */
  111736. set forceWireframe(value: boolean);
  111737. get forceWireframe(): boolean;
  111738. private _skipFrustumClipping;
  111739. /**
  111740. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111741. */
  111742. set skipFrustumClipping(value: boolean);
  111743. get skipFrustumClipping(): boolean;
  111744. private _forcePointsCloud;
  111745. /**
  111746. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111747. */
  111748. set forcePointsCloud(value: boolean);
  111749. get forcePointsCloud(): boolean;
  111750. /**
  111751. * Gets or sets the active clipplane 1
  111752. */
  111753. clipPlane: Nullable<Plane>;
  111754. /**
  111755. * Gets or sets the active clipplane 2
  111756. */
  111757. clipPlane2: Nullable<Plane>;
  111758. /**
  111759. * Gets or sets the active clipplane 3
  111760. */
  111761. clipPlane3: Nullable<Plane>;
  111762. /**
  111763. * Gets or sets the active clipplane 4
  111764. */
  111765. clipPlane4: Nullable<Plane>;
  111766. /**
  111767. * Gets or sets the active clipplane 5
  111768. */
  111769. clipPlane5: Nullable<Plane>;
  111770. /**
  111771. * Gets or sets the active clipplane 6
  111772. */
  111773. clipPlane6: Nullable<Plane>;
  111774. /**
  111775. * Gets or sets a boolean indicating if animations are enabled
  111776. */
  111777. animationsEnabled: boolean;
  111778. private _animationPropertiesOverride;
  111779. /**
  111780. * Gets or sets the animation properties override
  111781. */
  111782. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111783. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111784. /**
  111785. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111786. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111787. */
  111788. useConstantAnimationDeltaTime: boolean;
  111789. /**
  111790. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111791. * Please note that it requires to run a ray cast through the scene on every frame
  111792. */
  111793. constantlyUpdateMeshUnderPointer: boolean;
  111794. /**
  111795. * Defines the HTML cursor to use when hovering over interactive elements
  111796. */
  111797. hoverCursor: string;
  111798. /**
  111799. * Defines the HTML default cursor to use (empty by default)
  111800. */
  111801. defaultCursor: string;
  111802. /**
  111803. * Defines whether cursors are handled by the scene.
  111804. */
  111805. doNotHandleCursors: boolean;
  111806. /**
  111807. * This is used to call preventDefault() on pointer down
  111808. * in order to block unwanted artifacts like system double clicks
  111809. */
  111810. preventDefaultOnPointerDown: boolean;
  111811. /**
  111812. * This is used to call preventDefault() on pointer up
  111813. * in order to block unwanted artifacts like system double clicks
  111814. */
  111815. preventDefaultOnPointerUp: boolean;
  111816. /**
  111817. * Gets or sets user defined metadata
  111818. */
  111819. metadata: any;
  111820. /**
  111821. * For internal use only. Please do not use.
  111822. */
  111823. reservedDataStore: any;
  111824. /**
  111825. * Gets the name of the plugin used to load this scene (null by default)
  111826. */
  111827. loadingPluginName: string;
  111828. /**
  111829. * Use this array to add regular expressions used to disable offline support for specific urls
  111830. */
  111831. disableOfflineSupportExceptionRules: RegExp[];
  111832. /**
  111833. * An event triggered when the scene is disposed.
  111834. */
  111835. onDisposeObservable: Observable<Scene>;
  111836. private _onDisposeObserver;
  111837. /** Sets a function to be executed when this scene is disposed. */
  111838. set onDispose(callback: () => void);
  111839. /**
  111840. * An event triggered before rendering the scene (right after animations and physics)
  111841. */
  111842. onBeforeRenderObservable: Observable<Scene>;
  111843. private _onBeforeRenderObserver;
  111844. /** Sets a function to be executed before rendering this scene */
  111845. set beforeRender(callback: Nullable<() => void>);
  111846. /**
  111847. * An event triggered after rendering the scene
  111848. */
  111849. onAfterRenderObservable: Observable<Scene>;
  111850. /**
  111851. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111852. */
  111853. onAfterRenderCameraObservable: Observable<Camera>;
  111854. private _onAfterRenderObserver;
  111855. /** Sets a function to be executed after rendering this scene */
  111856. set afterRender(callback: Nullable<() => void>);
  111857. /**
  111858. * An event triggered before animating the scene
  111859. */
  111860. onBeforeAnimationsObservable: Observable<Scene>;
  111861. /**
  111862. * An event triggered after animations processing
  111863. */
  111864. onAfterAnimationsObservable: Observable<Scene>;
  111865. /**
  111866. * An event triggered before draw calls are ready to be sent
  111867. */
  111868. onBeforeDrawPhaseObservable: Observable<Scene>;
  111869. /**
  111870. * An event triggered after draw calls have been sent
  111871. */
  111872. onAfterDrawPhaseObservable: Observable<Scene>;
  111873. /**
  111874. * An event triggered when the scene is ready
  111875. */
  111876. onReadyObservable: Observable<Scene>;
  111877. /**
  111878. * An event triggered before rendering a camera
  111879. */
  111880. onBeforeCameraRenderObservable: Observable<Camera>;
  111881. private _onBeforeCameraRenderObserver;
  111882. /** Sets a function to be executed before rendering a camera*/
  111883. set beforeCameraRender(callback: () => void);
  111884. /**
  111885. * An event triggered after rendering a camera
  111886. */
  111887. onAfterCameraRenderObservable: Observable<Camera>;
  111888. private _onAfterCameraRenderObserver;
  111889. /** Sets a function to be executed after rendering a camera*/
  111890. set afterCameraRender(callback: () => void);
  111891. /**
  111892. * An event triggered when active meshes evaluation is about to start
  111893. */
  111894. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111895. /**
  111896. * An event triggered when active meshes evaluation is done
  111897. */
  111898. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111899. /**
  111900. * An event triggered when particles rendering is about to start
  111901. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111902. */
  111903. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111904. /**
  111905. * An event triggered when particles rendering is done
  111906. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111907. */
  111908. onAfterParticlesRenderingObservable: Observable<Scene>;
  111909. /**
  111910. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111911. */
  111912. onDataLoadedObservable: Observable<Scene>;
  111913. /**
  111914. * An event triggered when a camera is created
  111915. */
  111916. onNewCameraAddedObservable: Observable<Camera>;
  111917. /**
  111918. * An event triggered when a camera is removed
  111919. */
  111920. onCameraRemovedObservable: Observable<Camera>;
  111921. /**
  111922. * An event triggered when a light is created
  111923. */
  111924. onNewLightAddedObservable: Observable<Light>;
  111925. /**
  111926. * An event triggered when a light is removed
  111927. */
  111928. onLightRemovedObservable: Observable<Light>;
  111929. /**
  111930. * An event triggered when a geometry is created
  111931. */
  111932. onNewGeometryAddedObservable: Observable<Geometry>;
  111933. /**
  111934. * An event triggered when a geometry is removed
  111935. */
  111936. onGeometryRemovedObservable: Observable<Geometry>;
  111937. /**
  111938. * An event triggered when a transform node is created
  111939. */
  111940. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  111941. /**
  111942. * An event triggered when a transform node is removed
  111943. */
  111944. onTransformNodeRemovedObservable: Observable<TransformNode>;
  111945. /**
  111946. * An event triggered when a mesh is created
  111947. */
  111948. onNewMeshAddedObservable: Observable<AbstractMesh>;
  111949. /**
  111950. * An event triggered when a mesh is removed
  111951. */
  111952. onMeshRemovedObservable: Observable<AbstractMesh>;
  111953. /**
  111954. * An event triggered when a skeleton is created
  111955. */
  111956. onNewSkeletonAddedObservable: Observable<Skeleton>;
  111957. /**
  111958. * An event triggered when a skeleton is removed
  111959. */
  111960. onSkeletonRemovedObservable: Observable<Skeleton>;
  111961. /**
  111962. * An event triggered when a material is created
  111963. */
  111964. onNewMaterialAddedObservable: Observable<Material>;
  111965. /**
  111966. * An event triggered when a material is removed
  111967. */
  111968. onMaterialRemovedObservable: Observable<Material>;
  111969. /**
  111970. * An event triggered when a texture is created
  111971. */
  111972. onNewTextureAddedObservable: Observable<BaseTexture>;
  111973. /**
  111974. * An event triggered when a texture is removed
  111975. */
  111976. onTextureRemovedObservable: Observable<BaseTexture>;
  111977. /**
  111978. * An event triggered when render targets are about to be rendered
  111979. * Can happen multiple times per frame.
  111980. */
  111981. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  111982. /**
  111983. * An event triggered when render targets were rendered.
  111984. * Can happen multiple times per frame.
  111985. */
  111986. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  111987. /**
  111988. * An event triggered before calculating deterministic simulation step
  111989. */
  111990. onBeforeStepObservable: Observable<Scene>;
  111991. /**
  111992. * An event triggered after calculating deterministic simulation step
  111993. */
  111994. onAfterStepObservable: Observable<Scene>;
  111995. /**
  111996. * An event triggered when the activeCamera property is updated
  111997. */
  111998. onActiveCameraChanged: Observable<Scene>;
  111999. /**
  112000. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  112001. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112002. * 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)
  112003. */
  112004. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112005. /**
  112006. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  112007. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  112008. * 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)
  112009. */
  112010. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  112011. /**
  112012. * This Observable will when a mesh has been imported into the scene.
  112013. */
  112014. onMeshImportedObservable: Observable<AbstractMesh>;
  112015. /**
  112016. * This Observable will when an animation file has been imported into the scene.
  112017. */
  112018. onAnimationFileImportedObservable: Observable<Scene>;
  112019. /**
  112020. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  112021. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  112022. */
  112023. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  112024. /** @hidden */
  112025. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  112026. /**
  112027. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  112028. */
  112029. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  112030. /**
  112031. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  112032. */
  112033. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  112034. /**
  112035. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  112036. */
  112037. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  112038. /** Callback called when a pointer move is detected */
  112039. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112040. /** Callback called when a pointer down is detected */
  112041. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  112042. /** Callback called when a pointer up is detected */
  112043. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  112044. /** Callback called when a pointer pick is detected */
  112045. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  112046. /**
  112047. * 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).
  112048. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  112049. */
  112050. onPrePointerObservable: Observable<PointerInfoPre>;
  112051. /**
  112052. * Observable event triggered each time an input event is received from the rendering canvas
  112053. */
  112054. onPointerObservable: Observable<PointerInfo>;
  112055. /**
  112056. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  112057. */
  112058. get unTranslatedPointer(): Vector2;
  112059. /**
  112060. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  112061. */
  112062. static get DragMovementThreshold(): number;
  112063. static set DragMovementThreshold(value: number);
  112064. /**
  112065. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  112066. */
  112067. static get LongPressDelay(): number;
  112068. static set LongPressDelay(value: number);
  112069. /**
  112070. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  112071. */
  112072. static get DoubleClickDelay(): number;
  112073. static set DoubleClickDelay(value: number);
  112074. /** If you need to check double click without raising a single click at first click, enable this flag */
  112075. static get ExclusiveDoubleClickMode(): boolean;
  112076. static set ExclusiveDoubleClickMode(value: boolean);
  112077. /** @hidden */
  112078. _mirroredCameraPosition: Nullable<Vector3>;
  112079. /**
  112080. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  112081. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  112082. */
  112083. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  112084. /**
  112085. * Observable event triggered each time an keyboard event is received from the hosting window
  112086. */
  112087. onKeyboardObservable: Observable<KeyboardInfo>;
  112088. private _useRightHandedSystem;
  112089. /**
  112090. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  112091. */
  112092. set useRightHandedSystem(value: boolean);
  112093. get useRightHandedSystem(): boolean;
  112094. private _timeAccumulator;
  112095. private _currentStepId;
  112096. private _currentInternalStep;
  112097. /**
  112098. * Sets the step Id used by deterministic lock step
  112099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112100. * @param newStepId defines the step Id
  112101. */
  112102. setStepId(newStepId: number): void;
  112103. /**
  112104. * Gets the step Id used by deterministic lock step
  112105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112106. * @returns the step Id
  112107. */
  112108. getStepId(): number;
  112109. /**
  112110. * Gets the internal step used by deterministic lock step
  112111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112112. * @returns the internal step
  112113. */
  112114. getInternalStep(): number;
  112115. private _fogEnabled;
  112116. /**
  112117. * Gets or sets a boolean indicating if fog is enabled on this scene
  112118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112119. * (Default is true)
  112120. */
  112121. set fogEnabled(value: boolean);
  112122. get fogEnabled(): boolean;
  112123. private _fogMode;
  112124. /**
  112125. * Gets or sets the fog mode to use
  112126. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112127. * | mode | value |
  112128. * | --- | --- |
  112129. * | FOGMODE_NONE | 0 |
  112130. * | FOGMODE_EXP | 1 |
  112131. * | FOGMODE_EXP2 | 2 |
  112132. * | FOGMODE_LINEAR | 3 |
  112133. */
  112134. set fogMode(value: number);
  112135. get fogMode(): number;
  112136. /**
  112137. * Gets or sets the fog color to use
  112138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112139. * (Default is Color3(0.2, 0.2, 0.3))
  112140. */
  112141. fogColor: Color3;
  112142. /**
  112143. * Gets or sets the fog density to use
  112144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112145. * (Default is 0.1)
  112146. */
  112147. fogDensity: number;
  112148. /**
  112149. * Gets or sets the fog start distance to use
  112150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112151. * (Default is 0)
  112152. */
  112153. fogStart: number;
  112154. /**
  112155. * Gets or sets the fog end distance to use
  112156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  112157. * (Default is 1000)
  112158. */
  112159. fogEnd: number;
  112160. private _shadowsEnabled;
  112161. /**
  112162. * Gets or sets a boolean indicating if shadows are enabled on this scene
  112163. */
  112164. set shadowsEnabled(value: boolean);
  112165. get shadowsEnabled(): boolean;
  112166. private _lightsEnabled;
  112167. /**
  112168. * Gets or sets a boolean indicating if lights are enabled on this scene
  112169. */
  112170. set lightsEnabled(value: boolean);
  112171. get lightsEnabled(): boolean;
  112172. /** All of the active cameras added to this scene. */
  112173. activeCameras: Camera[];
  112174. /** @hidden */
  112175. _activeCamera: Nullable<Camera>;
  112176. /** Gets or sets the current active camera */
  112177. get activeCamera(): Nullable<Camera>;
  112178. set activeCamera(value: Nullable<Camera>);
  112179. private _defaultMaterial;
  112180. /** The default material used on meshes when no material is affected */
  112181. get defaultMaterial(): Material;
  112182. /** The default material used on meshes when no material is affected */
  112183. set defaultMaterial(value: Material);
  112184. private _texturesEnabled;
  112185. /**
  112186. * Gets or sets a boolean indicating if textures are enabled on this scene
  112187. */
  112188. set texturesEnabled(value: boolean);
  112189. get texturesEnabled(): boolean;
  112190. /**
  112191. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  112192. */
  112193. physicsEnabled: boolean;
  112194. /**
  112195. * Gets or sets a boolean indicating if particles are enabled on this scene
  112196. */
  112197. particlesEnabled: boolean;
  112198. /**
  112199. * Gets or sets a boolean indicating if sprites are enabled on this scene
  112200. */
  112201. spritesEnabled: boolean;
  112202. private _skeletonsEnabled;
  112203. /**
  112204. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  112205. */
  112206. set skeletonsEnabled(value: boolean);
  112207. get skeletonsEnabled(): boolean;
  112208. /**
  112209. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  112210. */
  112211. lensFlaresEnabled: boolean;
  112212. /**
  112213. * Gets or sets a boolean indicating if collisions are enabled on this scene
  112214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112215. */
  112216. collisionsEnabled: boolean;
  112217. private _collisionCoordinator;
  112218. /** @hidden */
  112219. get collisionCoordinator(): ICollisionCoordinator;
  112220. /**
  112221. * Defines the gravity applied to this scene (used only for collisions)
  112222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112223. */
  112224. gravity: Vector3;
  112225. /**
  112226. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112227. */
  112228. postProcessesEnabled: boolean;
  112229. /**
  112230. * The list of postprocesses added to the scene
  112231. */
  112232. postProcesses: PostProcess[];
  112233. /**
  112234. * Gets the current postprocess manager
  112235. */
  112236. postProcessManager: PostProcessManager;
  112237. /**
  112238. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112239. */
  112240. renderTargetsEnabled: boolean;
  112241. /**
  112242. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112243. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112244. */
  112245. dumpNextRenderTargets: boolean;
  112246. /**
  112247. * The list of user defined render targets added to the scene
  112248. */
  112249. customRenderTargets: RenderTargetTexture[];
  112250. /**
  112251. * Defines if texture loading must be delayed
  112252. * If true, textures will only be loaded when they need to be rendered
  112253. */
  112254. useDelayedTextureLoading: boolean;
  112255. /**
  112256. * Gets the list of meshes imported to the scene through SceneLoader
  112257. */
  112258. importedMeshesFiles: String[];
  112259. /**
  112260. * Gets or sets a boolean indicating if probes are enabled on this scene
  112261. */
  112262. probesEnabled: boolean;
  112263. /**
  112264. * Gets or sets the current offline provider to use to store scene data
  112265. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112266. */
  112267. offlineProvider: IOfflineProvider;
  112268. /**
  112269. * Gets or sets the action manager associated with the scene
  112270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112271. */
  112272. actionManager: AbstractActionManager;
  112273. private _meshesForIntersections;
  112274. /**
  112275. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112276. */
  112277. proceduralTexturesEnabled: boolean;
  112278. private _engine;
  112279. private _totalVertices;
  112280. /** @hidden */
  112281. _activeIndices: PerfCounter;
  112282. /** @hidden */
  112283. _activeParticles: PerfCounter;
  112284. /** @hidden */
  112285. _activeBones: PerfCounter;
  112286. private _animationRatio;
  112287. /** @hidden */
  112288. _animationTimeLast: number;
  112289. /** @hidden */
  112290. _animationTime: number;
  112291. /**
  112292. * Gets or sets a general scale for animation speed
  112293. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112294. */
  112295. animationTimeScale: number;
  112296. /** @hidden */
  112297. _cachedMaterial: Nullable<Material>;
  112298. /** @hidden */
  112299. _cachedEffect: Nullable<Effect>;
  112300. /** @hidden */
  112301. _cachedVisibility: Nullable<number>;
  112302. private _renderId;
  112303. private _frameId;
  112304. private _executeWhenReadyTimeoutId;
  112305. private _intermediateRendering;
  112306. private _viewUpdateFlag;
  112307. private _projectionUpdateFlag;
  112308. /** @hidden */
  112309. _toBeDisposed: Nullable<IDisposable>[];
  112310. private _activeRequests;
  112311. /** @hidden */
  112312. _pendingData: any[];
  112313. private _isDisposed;
  112314. /**
  112315. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112316. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112317. */
  112318. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112319. private _activeMeshes;
  112320. private _processedMaterials;
  112321. private _renderTargets;
  112322. /** @hidden */
  112323. _activeParticleSystems: SmartArray<IParticleSystem>;
  112324. private _activeSkeletons;
  112325. private _softwareSkinnedMeshes;
  112326. private _renderingManager;
  112327. /** @hidden */
  112328. _activeAnimatables: Animatable[];
  112329. private _transformMatrix;
  112330. private _sceneUbo;
  112331. /** @hidden */
  112332. _viewMatrix: Matrix;
  112333. private _projectionMatrix;
  112334. /** @hidden */
  112335. _forcedViewPosition: Nullable<Vector3>;
  112336. /** @hidden */
  112337. _frustumPlanes: Plane[];
  112338. /**
  112339. * Gets the list of frustum planes (built from the active camera)
  112340. */
  112341. get frustumPlanes(): Plane[];
  112342. /**
  112343. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112344. * This is useful if there are more lights that the maximum simulteanous authorized
  112345. */
  112346. requireLightSorting: boolean;
  112347. /** @hidden */
  112348. readonly useMaterialMeshMap: boolean;
  112349. /** @hidden */
  112350. readonly useClonedMeshMap: boolean;
  112351. private _externalData;
  112352. private _uid;
  112353. /**
  112354. * @hidden
  112355. * Backing store of defined scene components.
  112356. */
  112357. _components: ISceneComponent[];
  112358. /**
  112359. * @hidden
  112360. * Backing store of defined scene components.
  112361. */
  112362. _serializableComponents: ISceneSerializableComponent[];
  112363. /**
  112364. * List of components to register on the next registration step.
  112365. */
  112366. private _transientComponents;
  112367. /**
  112368. * Registers the transient components if needed.
  112369. */
  112370. private _registerTransientComponents;
  112371. /**
  112372. * @hidden
  112373. * Add a component to the scene.
  112374. * Note that the ccomponent could be registered on th next frame if this is called after
  112375. * the register component stage.
  112376. * @param component Defines the component to add to the scene
  112377. */
  112378. _addComponent(component: ISceneComponent): void;
  112379. /**
  112380. * @hidden
  112381. * Gets a component from the scene.
  112382. * @param name defines the name of the component to retrieve
  112383. * @returns the component or null if not present
  112384. */
  112385. _getComponent(name: string): Nullable<ISceneComponent>;
  112386. /**
  112387. * @hidden
  112388. * Defines the actions happening before camera updates.
  112389. */
  112390. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112391. /**
  112392. * @hidden
  112393. * Defines the actions happening before clear the canvas.
  112394. */
  112395. _beforeClearStage: Stage<SimpleStageAction>;
  112396. /**
  112397. * @hidden
  112398. * Defines the actions when collecting render targets for the frame.
  112399. */
  112400. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112401. /**
  112402. * @hidden
  112403. * Defines the actions happening for one camera in the frame.
  112404. */
  112405. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112406. /**
  112407. * @hidden
  112408. * Defines the actions happening during the per mesh ready checks.
  112409. */
  112410. _isReadyForMeshStage: Stage<MeshStageAction>;
  112411. /**
  112412. * @hidden
  112413. * Defines the actions happening before evaluate active mesh checks.
  112414. */
  112415. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112416. /**
  112417. * @hidden
  112418. * Defines the actions happening during the evaluate sub mesh checks.
  112419. */
  112420. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112421. /**
  112422. * @hidden
  112423. * Defines the actions happening during the active mesh stage.
  112424. */
  112425. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112426. /**
  112427. * @hidden
  112428. * Defines the actions happening during the per camera render target step.
  112429. */
  112430. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112431. /**
  112432. * @hidden
  112433. * Defines the actions happening just before the active camera is drawing.
  112434. */
  112435. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112436. /**
  112437. * @hidden
  112438. * Defines the actions happening just before a render target is drawing.
  112439. */
  112440. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112441. /**
  112442. * @hidden
  112443. * Defines the actions happening just before a rendering group is drawing.
  112444. */
  112445. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112446. /**
  112447. * @hidden
  112448. * Defines the actions happening just before a mesh is drawing.
  112449. */
  112450. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112451. /**
  112452. * @hidden
  112453. * Defines the actions happening just after a mesh has been drawn.
  112454. */
  112455. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112456. /**
  112457. * @hidden
  112458. * Defines the actions happening just after a rendering group has been drawn.
  112459. */
  112460. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112461. /**
  112462. * @hidden
  112463. * Defines the actions happening just after the active camera has been drawn.
  112464. */
  112465. _afterCameraDrawStage: Stage<CameraStageAction>;
  112466. /**
  112467. * @hidden
  112468. * Defines the actions happening just after a render target has been drawn.
  112469. */
  112470. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112471. /**
  112472. * @hidden
  112473. * Defines the actions happening just after rendering all cameras and computing intersections.
  112474. */
  112475. _afterRenderStage: Stage<SimpleStageAction>;
  112476. /**
  112477. * @hidden
  112478. * Defines the actions happening when a pointer move event happens.
  112479. */
  112480. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112481. /**
  112482. * @hidden
  112483. * Defines the actions happening when a pointer down event happens.
  112484. */
  112485. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112486. /**
  112487. * @hidden
  112488. * Defines the actions happening when a pointer up event happens.
  112489. */
  112490. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112491. /**
  112492. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112493. */
  112494. private geometriesByUniqueId;
  112495. /**
  112496. * Creates a new Scene
  112497. * @param engine defines the engine to use to render this scene
  112498. * @param options defines the scene options
  112499. */
  112500. constructor(engine: Engine, options?: SceneOptions);
  112501. /**
  112502. * Gets a string idenfifying the name of the class
  112503. * @returns "Scene" string
  112504. */
  112505. getClassName(): string;
  112506. private _defaultMeshCandidates;
  112507. /**
  112508. * @hidden
  112509. */
  112510. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112511. private _defaultSubMeshCandidates;
  112512. /**
  112513. * @hidden
  112514. */
  112515. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112516. /**
  112517. * Sets the default candidate providers for the scene.
  112518. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112519. * and getCollidingSubMeshCandidates to their default function
  112520. */
  112521. setDefaultCandidateProviders(): void;
  112522. /**
  112523. * Gets the mesh that is currently under the pointer
  112524. */
  112525. get meshUnderPointer(): Nullable<AbstractMesh>;
  112526. /**
  112527. * Gets or sets the current on-screen X position of the pointer
  112528. */
  112529. get pointerX(): number;
  112530. set pointerX(value: number);
  112531. /**
  112532. * Gets or sets the current on-screen Y position of the pointer
  112533. */
  112534. get pointerY(): number;
  112535. set pointerY(value: number);
  112536. /**
  112537. * Gets the cached material (ie. the latest rendered one)
  112538. * @returns the cached material
  112539. */
  112540. getCachedMaterial(): Nullable<Material>;
  112541. /**
  112542. * Gets the cached effect (ie. the latest rendered one)
  112543. * @returns the cached effect
  112544. */
  112545. getCachedEffect(): Nullable<Effect>;
  112546. /**
  112547. * Gets the cached visibility state (ie. the latest rendered one)
  112548. * @returns the cached visibility state
  112549. */
  112550. getCachedVisibility(): Nullable<number>;
  112551. /**
  112552. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112553. * @param material defines the current material
  112554. * @param effect defines the current effect
  112555. * @param visibility defines the current visibility state
  112556. * @returns true if one parameter is not cached
  112557. */
  112558. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112559. /**
  112560. * Gets the engine associated with the scene
  112561. * @returns an Engine
  112562. */
  112563. getEngine(): Engine;
  112564. /**
  112565. * Gets the total number of vertices rendered per frame
  112566. * @returns the total number of vertices rendered per frame
  112567. */
  112568. getTotalVertices(): number;
  112569. /**
  112570. * Gets the performance counter for total vertices
  112571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112572. */
  112573. get totalVerticesPerfCounter(): PerfCounter;
  112574. /**
  112575. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112576. * @returns the total number of active indices rendered per frame
  112577. */
  112578. getActiveIndices(): number;
  112579. /**
  112580. * Gets the performance counter for active indices
  112581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112582. */
  112583. get totalActiveIndicesPerfCounter(): PerfCounter;
  112584. /**
  112585. * Gets the total number of active particles rendered per frame
  112586. * @returns the total number of active particles rendered per frame
  112587. */
  112588. getActiveParticles(): number;
  112589. /**
  112590. * Gets the performance counter for active particles
  112591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112592. */
  112593. get activeParticlesPerfCounter(): PerfCounter;
  112594. /**
  112595. * Gets the total number of active bones rendered per frame
  112596. * @returns the total number of active bones rendered per frame
  112597. */
  112598. getActiveBones(): number;
  112599. /**
  112600. * Gets the performance counter for active bones
  112601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112602. */
  112603. get activeBonesPerfCounter(): PerfCounter;
  112604. /**
  112605. * Gets the array of active meshes
  112606. * @returns an array of AbstractMesh
  112607. */
  112608. getActiveMeshes(): SmartArray<AbstractMesh>;
  112609. /**
  112610. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112611. * @returns a number
  112612. */
  112613. getAnimationRatio(): number;
  112614. /**
  112615. * Gets an unique Id for the current render phase
  112616. * @returns a number
  112617. */
  112618. getRenderId(): number;
  112619. /**
  112620. * Gets an unique Id for the current frame
  112621. * @returns a number
  112622. */
  112623. getFrameId(): number;
  112624. /** Call this function if you want to manually increment the render Id*/
  112625. incrementRenderId(): void;
  112626. private _createUbo;
  112627. /**
  112628. * Use this method to simulate a pointer move on a mesh
  112629. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112630. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112631. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112632. * @returns the current scene
  112633. */
  112634. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112635. /**
  112636. * Use this method to simulate a pointer down on a mesh
  112637. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112638. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112639. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112640. * @returns the current scene
  112641. */
  112642. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112643. /**
  112644. * Use this method to simulate a pointer up on a mesh
  112645. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112646. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112647. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112648. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112649. * @returns the current scene
  112650. */
  112651. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112652. /**
  112653. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112654. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112655. * @returns true if the pointer was captured
  112656. */
  112657. isPointerCaptured(pointerId?: number): boolean;
  112658. /**
  112659. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112660. * @param attachUp defines if you want to attach events to pointerup
  112661. * @param attachDown defines if you want to attach events to pointerdown
  112662. * @param attachMove defines if you want to attach events to pointermove
  112663. */
  112664. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112665. /** Detaches all event handlers*/
  112666. detachControl(): void;
  112667. /**
  112668. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112669. * Delay loaded resources are not taking in account
  112670. * @return true if all required resources are ready
  112671. */
  112672. isReady(): boolean;
  112673. /** Resets all cached information relative to material (including effect and visibility) */
  112674. resetCachedMaterial(): void;
  112675. /**
  112676. * Registers a function to be called before every frame render
  112677. * @param func defines the function to register
  112678. */
  112679. registerBeforeRender(func: () => void): void;
  112680. /**
  112681. * Unregisters a function called before every frame render
  112682. * @param func defines the function to unregister
  112683. */
  112684. unregisterBeforeRender(func: () => void): void;
  112685. /**
  112686. * Registers a function to be called after every frame render
  112687. * @param func defines the function to register
  112688. */
  112689. registerAfterRender(func: () => void): void;
  112690. /**
  112691. * Unregisters a function called after every frame render
  112692. * @param func defines the function to unregister
  112693. */
  112694. unregisterAfterRender(func: () => void): void;
  112695. private _executeOnceBeforeRender;
  112696. /**
  112697. * The provided function will run before render once and will be disposed afterwards.
  112698. * A timeout delay can be provided so that the function will be executed in N ms.
  112699. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112700. * @param func The function to be executed.
  112701. * @param timeout optional delay in ms
  112702. */
  112703. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112704. /** @hidden */
  112705. _addPendingData(data: any): void;
  112706. /** @hidden */
  112707. _removePendingData(data: any): void;
  112708. /**
  112709. * Returns the number of items waiting to be loaded
  112710. * @returns the number of items waiting to be loaded
  112711. */
  112712. getWaitingItemsCount(): number;
  112713. /**
  112714. * Returns a boolean indicating if the scene is still loading data
  112715. */
  112716. get isLoading(): boolean;
  112717. /**
  112718. * Registers a function to be executed when the scene is ready
  112719. * @param {Function} func - the function to be executed
  112720. */
  112721. executeWhenReady(func: () => void): void;
  112722. /**
  112723. * Returns a promise that resolves when the scene is ready
  112724. * @returns A promise that resolves when the scene is ready
  112725. */
  112726. whenReadyAsync(): Promise<void>;
  112727. /** @hidden */
  112728. _checkIsReady(): void;
  112729. /**
  112730. * Gets all animatable attached to the scene
  112731. */
  112732. get animatables(): Animatable[];
  112733. /**
  112734. * Resets the last animation time frame.
  112735. * Useful to override when animations start running when loading a scene for the first time.
  112736. */
  112737. resetLastAnimationTimeFrame(): void;
  112738. /**
  112739. * Gets the current view matrix
  112740. * @returns a Matrix
  112741. */
  112742. getViewMatrix(): Matrix;
  112743. /**
  112744. * Gets the current projection matrix
  112745. * @returns a Matrix
  112746. */
  112747. getProjectionMatrix(): Matrix;
  112748. /**
  112749. * Gets the current transform matrix
  112750. * @returns a Matrix made of View * Projection
  112751. */
  112752. getTransformMatrix(): Matrix;
  112753. /**
  112754. * Sets the current transform matrix
  112755. * @param viewL defines the View matrix to use
  112756. * @param projectionL defines the Projection matrix to use
  112757. * @param viewR defines the right View matrix to use (if provided)
  112758. * @param projectionR defines the right Projection matrix to use (if provided)
  112759. */
  112760. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112761. /**
  112762. * Gets the uniform buffer used to store scene data
  112763. * @returns a UniformBuffer
  112764. */
  112765. getSceneUniformBuffer(): UniformBuffer;
  112766. /**
  112767. * Gets an unique (relatively to the current scene) Id
  112768. * @returns an unique number for the scene
  112769. */
  112770. getUniqueId(): number;
  112771. /**
  112772. * Add a mesh to the list of scene's meshes
  112773. * @param newMesh defines the mesh to add
  112774. * @param recursive if all child meshes should also be added to the scene
  112775. */
  112776. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112777. /**
  112778. * Remove a mesh for the list of scene's meshes
  112779. * @param toRemove defines the mesh to remove
  112780. * @param recursive if all child meshes should also be removed from the scene
  112781. * @returns the index where the mesh was in the mesh list
  112782. */
  112783. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112784. /**
  112785. * Add a transform node to the list of scene's transform nodes
  112786. * @param newTransformNode defines the transform node to add
  112787. */
  112788. addTransformNode(newTransformNode: TransformNode): void;
  112789. /**
  112790. * Remove a transform node for the list of scene's transform nodes
  112791. * @param toRemove defines the transform node to remove
  112792. * @returns the index where the transform node was in the transform node list
  112793. */
  112794. removeTransformNode(toRemove: TransformNode): number;
  112795. /**
  112796. * Remove a skeleton for the list of scene's skeletons
  112797. * @param toRemove defines the skeleton to remove
  112798. * @returns the index where the skeleton was in the skeleton list
  112799. */
  112800. removeSkeleton(toRemove: Skeleton): number;
  112801. /**
  112802. * Remove a morph target for the list of scene's morph targets
  112803. * @param toRemove defines the morph target to remove
  112804. * @returns the index where the morph target was in the morph target list
  112805. */
  112806. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112807. /**
  112808. * Remove a light for the list of scene's lights
  112809. * @param toRemove defines the light to remove
  112810. * @returns the index where the light was in the light list
  112811. */
  112812. removeLight(toRemove: Light): number;
  112813. /**
  112814. * Remove a camera for the list of scene's cameras
  112815. * @param toRemove defines the camera to remove
  112816. * @returns the index where the camera was in the camera list
  112817. */
  112818. removeCamera(toRemove: Camera): number;
  112819. /**
  112820. * Remove a particle system for the list of scene's particle systems
  112821. * @param toRemove defines the particle system to remove
  112822. * @returns the index where the particle system was in the particle system list
  112823. */
  112824. removeParticleSystem(toRemove: IParticleSystem): number;
  112825. /**
  112826. * Remove a animation for the list of scene's animations
  112827. * @param toRemove defines the animation to remove
  112828. * @returns the index where the animation was in the animation list
  112829. */
  112830. removeAnimation(toRemove: Animation): number;
  112831. /**
  112832. * Will stop the animation of the given target
  112833. * @param target - the target
  112834. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112835. * @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)
  112836. */
  112837. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112838. /**
  112839. * Removes the given animation group from this scene.
  112840. * @param toRemove The animation group to remove
  112841. * @returns The index of the removed animation group
  112842. */
  112843. removeAnimationGroup(toRemove: AnimationGroup): number;
  112844. /**
  112845. * Removes the given multi-material from this scene.
  112846. * @param toRemove The multi-material to remove
  112847. * @returns The index of the removed multi-material
  112848. */
  112849. removeMultiMaterial(toRemove: MultiMaterial): number;
  112850. /**
  112851. * Removes the given material from this scene.
  112852. * @param toRemove The material to remove
  112853. * @returns The index of the removed material
  112854. */
  112855. removeMaterial(toRemove: Material): number;
  112856. /**
  112857. * Removes the given action manager from this scene.
  112858. * @param toRemove The action manager to remove
  112859. * @returns The index of the removed action manager
  112860. */
  112861. removeActionManager(toRemove: AbstractActionManager): number;
  112862. /**
  112863. * Removes the given texture from this scene.
  112864. * @param toRemove The texture to remove
  112865. * @returns The index of the removed texture
  112866. */
  112867. removeTexture(toRemove: BaseTexture): number;
  112868. /**
  112869. * Adds the given light to this scene
  112870. * @param newLight The light to add
  112871. */
  112872. addLight(newLight: Light): void;
  112873. /**
  112874. * Sorts the list list based on light priorities
  112875. */
  112876. sortLightsByPriority(): void;
  112877. /**
  112878. * Adds the given camera to this scene
  112879. * @param newCamera The camera to add
  112880. */
  112881. addCamera(newCamera: Camera): void;
  112882. /**
  112883. * Adds the given skeleton to this scene
  112884. * @param newSkeleton The skeleton to add
  112885. */
  112886. addSkeleton(newSkeleton: Skeleton): void;
  112887. /**
  112888. * Adds the given particle system to this scene
  112889. * @param newParticleSystem The particle system to add
  112890. */
  112891. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112892. /**
  112893. * Adds the given animation to this scene
  112894. * @param newAnimation The animation to add
  112895. */
  112896. addAnimation(newAnimation: Animation): void;
  112897. /**
  112898. * Adds the given animation group to this scene.
  112899. * @param newAnimationGroup The animation group to add
  112900. */
  112901. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112902. /**
  112903. * Adds the given multi-material to this scene
  112904. * @param newMultiMaterial The multi-material to add
  112905. */
  112906. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112907. /**
  112908. * Adds the given material to this scene
  112909. * @param newMaterial The material to add
  112910. */
  112911. addMaterial(newMaterial: Material): void;
  112912. /**
  112913. * Adds the given morph target to this scene
  112914. * @param newMorphTargetManager The morph target to add
  112915. */
  112916. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112917. /**
  112918. * Adds the given geometry to this scene
  112919. * @param newGeometry The geometry to add
  112920. */
  112921. addGeometry(newGeometry: Geometry): void;
  112922. /**
  112923. * Adds the given action manager to this scene
  112924. * @param newActionManager The action manager to add
  112925. */
  112926. addActionManager(newActionManager: AbstractActionManager): void;
  112927. /**
  112928. * Adds the given texture to this scene.
  112929. * @param newTexture The texture to add
  112930. */
  112931. addTexture(newTexture: BaseTexture): void;
  112932. /**
  112933. * Switch active camera
  112934. * @param newCamera defines the new active camera
  112935. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112936. */
  112937. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  112938. /**
  112939. * sets the active camera of the scene using its ID
  112940. * @param id defines the camera's ID
  112941. * @return the new active camera or null if none found.
  112942. */
  112943. setActiveCameraByID(id: string): Nullable<Camera>;
  112944. /**
  112945. * sets the active camera of the scene using its name
  112946. * @param name defines the camera's name
  112947. * @returns the new active camera or null if none found.
  112948. */
  112949. setActiveCameraByName(name: string): Nullable<Camera>;
  112950. /**
  112951. * get an animation group using its name
  112952. * @param name defines the material's name
  112953. * @return the animation group or null if none found.
  112954. */
  112955. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  112956. /**
  112957. * Get a material using its unique id
  112958. * @param uniqueId defines the material's unique id
  112959. * @return the material or null if none found.
  112960. */
  112961. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  112962. /**
  112963. * get a material using its id
  112964. * @param id defines the material's ID
  112965. * @return the material or null if none found.
  112966. */
  112967. getMaterialByID(id: string): Nullable<Material>;
  112968. /**
  112969. * Gets a the last added material using a given id
  112970. * @param id defines the material's ID
  112971. * @return the last material with the given id or null if none found.
  112972. */
  112973. getLastMaterialByID(id: string): Nullable<Material>;
  112974. /**
  112975. * Gets a material using its name
  112976. * @param name defines the material's name
  112977. * @return the material or null if none found.
  112978. */
  112979. getMaterialByName(name: string): Nullable<Material>;
  112980. /**
  112981. * Get a texture using its unique id
  112982. * @param uniqueId defines the texture's unique id
  112983. * @return the texture or null if none found.
  112984. */
  112985. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  112986. /**
  112987. * Gets a camera using its id
  112988. * @param id defines the id to look for
  112989. * @returns the camera or null if not found
  112990. */
  112991. getCameraByID(id: string): Nullable<Camera>;
  112992. /**
  112993. * Gets a camera using its unique id
  112994. * @param uniqueId defines the unique id to look for
  112995. * @returns the camera or null if not found
  112996. */
  112997. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  112998. /**
  112999. * Gets a camera using its name
  113000. * @param name defines the camera's name
  113001. * @return the camera or null if none found.
  113002. */
  113003. getCameraByName(name: string): Nullable<Camera>;
  113004. /**
  113005. * Gets a bone using its id
  113006. * @param id defines the bone's id
  113007. * @return the bone or null if not found
  113008. */
  113009. getBoneByID(id: string): Nullable<Bone>;
  113010. /**
  113011. * Gets a bone using its id
  113012. * @param name defines the bone's name
  113013. * @return the bone or null if not found
  113014. */
  113015. getBoneByName(name: string): Nullable<Bone>;
  113016. /**
  113017. * Gets a light node using its name
  113018. * @param name defines the the light's name
  113019. * @return the light or null if none found.
  113020. */
  113021. getLightByName(name: string): Nullable<Light>;
  113022. /**
  113023. * Gets a light node using its id
  113024. * @param id defines the light's id
  113025. * @return the light or null if none found.
  113026. */
  113027. getLightByID(id: string): Nullable<Light>;
  113028. /**
  113029. * Gets a light node using its scene-generated unique ID
  113030. * @param uniqueId defines the light's unique id
  113031. * @return the light or null if none found.
  113032. */
  113033. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  113034. /**
  113035. * Gets a particle system by id
  113036. * @param id defines the particle system id
  113037. * @return the corresponding system or null if none found
  113038. */
  113039. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  113040. /**
  113041. * Gets a geometry using its ID
  113042. * @param id defines the geometry's id
  113043. * @return the geometry or null if none found.
  113044. */
  113045. getGeometryByID(id: string): Nullable<Geometry>;
  113046. private _getGeometryByUniqueID;
  113047. /**
  113048. * Add a new geometry to this scene
  113049. * @param geometry defines the geometry to be added to the scene.
  113050. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  113051. * @return a boolean defining if the geometry was added or not
  113052. */
  113053. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  113054. /**
  113055. * Removes an existing geometry
  113056. * @param geometry defines the geometry to be removed from the scene
  113057. * @return a boolean defining if the geometry was removed or not
  113058. */
  113059. removeGeometry(geometry: Geometry): boolean;
  113060. /**
  113061. * Gets the list of geometries attached to the scene
  113062. * @returns an array of Geometry
  113063. */
  113064. getGeometries(): Geometry[];
  113065. /**
  113066. * Gets the first added mesh found of a given ID
  113067. * @param id defines the id to search for
  113068. * @return the mesh found or null if not found at all
  113069. */
  113070. getMeshByID(id: string): Nullable<AbstractMesh>;
  113071. /**
  113072. * Gets a list of meshes using their id
  113073. * @param id defines the id to search for
  113074. * @returns a list of meshes
  113075. */
  113076. getMeshesByID(id: string): Array<AbstractMesh>;
  113077. /**
  113078. * Gets the first added transform node found of a given ID
  113079. * @param id defines the id to search for
  113080. * @return the found transform node or null if not found at all.
  113081. */
  113082. getTransformNodeByID(id: string): Nullable<TransformNode>;
  113083. /**
  113084. * Gets a transform node with its auto-generated unique id
  113085. * @param uniqueId efines the unique id to search for
  113086. * @return the found transform node or null if not found at all.
  113087. */
  113088. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  113089. /**
  113090. * Gets a list of transform nodes using their id
  113091. * @param id defines the id to search for
  113092. * @returns a list of transform nodes
  113093. */
  113094. getTransformNodesByID(id: string): Array<TransformNode>;
  113095. /**
  113096. * Gets a mesh with its auto-generated unique id
  113097. * @param uniqueId defines the unique id to search for
  113098. * @return the found mesh or null if not found at all.
  113099. */
  113100. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  113101. /**
  113102. * Gets a the last added mesh using a given id
  113103. * @param id defines the id to search for
  113104. * @return the found mesh or null if not found at all.
  113105. */
  113106. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  113107. /**
  113108. * Gets a the last added node (Mesh, Camera, Light) using a given id
  113109. * @param id defines the id to search for
  113110. * @return the found node or null if not found at all
  113111. */
  113112. getLastEntryByID(id: string): Nullable<Node>;
  113113. /**
  113114. * Gets a node (Mesh, Camera, Light) using a given id
  113115. * @param id defines the id to search for
  113116. * @return the found node or null if not found at all
  113117. */
  113118. getNodeByID(id: string): Nullable<Node>;
  113119. /**
  113120. * Gets a node (Mesh, Camera, Light) using a given name
  113121. * @param name defines the name to search for
  113122. * @return the found node or null if not found at all.
  113123. */
  113124. getNodeByName(name: string): Nullable<Node>;
  113125. /**
  113126. * Gets a mesh using a given name
  113127. * @param name defines the name to search for
  113128. * @return the found mesh or null if not found at all.
  113129. */
  113130. getMeshByName(name: string): Nullable<AbstractMesh>;
  113131. /**
  113132. * Gets a transform node using a given name
  113133. * @param name defines the name to search for
  113134. * @return the found transform node or null if not found at all.
  113135. */
  113136. getTransformNodeByName(name: string): Nullable<TransformNode>;
  113137. /**
  113138. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  113139. * @param id defines the id to search for
  113140. * @return the found skeleton or null if not found at all.
  113141. */
  113142. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  113143. /**
  113144. * Gets a skeleton using a given auto generated unique id
  113145. * @param uniqueId defines the unique id to search for
  113146. * @return the found skeleton or null if not found at all.
  113147. */
  113148. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  113149. /**
  113150. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  113151. * @param id defines the id to search for
  113152. * @return the found skeleton or null if not found at all.
  113153. */
  113154. getSkeletonById(id: string): Nullable<Skeleton>;
  113155. /**
  113156. * Gets a skeleton using a given name
  113157. * @param name defines the name to search for
  113158. * @return the found skeleton or null if not found at all.
  113159. */
  113160. getSkeletonByName(name: string): Nullable<Skeleton>;
  113161. /**
  113162. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  113163. * @param id defines the id to search for
  113164. * @return the found morph target manager or null if not found at all.
  113165. */
  113166. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  113167. /**
  113168. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  113169. * @param id defines the id to search for
  113170. * @return the found morph target or null if not found at all.
  113171. */
  113172. getMorphTargetById(id: string): Nullable<MorphTarget>;
  113173. /**
  113174. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  113175. * @param name defines the name to search for
  113176. * @return the found morph target or null if not found at all.
  113177. */
  113178. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  113179. /**
  113180. * Gets a boolean indicating if the given mesh is active
  113181. * @param mesh defines the mesh to look for
  113182. * @returns true if the mesh is in the active list
  113183. */
  113184. isActiveMesh(mesh: AbstractMesh): boolean;
  113185. /**
  113186. * Return a unique id as a string which can serve as an identifier for the scene
  113187. */
  113188. get uid(): string;
  113189. /**
  113190. * Add an externaly attached data from its key.
  113191. * This method call will fail and return false, if such key already exists.
  113192. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  113193. * @param key the unique key that identifies the data
  113194. * @param data the data object to associate to the key for this Engine instance
  113195. * @return true if no such key were already present and the data was added successfully, false otherwise
  113196. */
  113197. addExternalData<T>(key: string, data: T): boolean;
  113198. /**
  113199. * Get an externaly attached data from its key
  113200. * @param key the unique key that identifies the data
  113201. * @return the associated data, if present (can be null), or undefined if not present
  113202. */
  113203. getExternalData<T>(key: string): Nullable<T>;
  113204. /**
  113205. * Get an externaly attached data from its key, create it using a factory if it's not already present
  113206. * @param key the unique key that identifies the data
  113207. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  113208. * @return the associated data, can be null if the factory returned null.
  113209. */
  113210. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  113211. /**
  113212. * Remove an externaly attached data from the Engine instance
  113213. * @param key the unique key that identifies the data
  113214. * @return true if the data was successfully removed, false if it doesn't exist
  113215. */
  113216. removeExternalData(key: string): boolean;
  113217. private _evaluateSubMesh;
  113218. /**
  113219. * Clear the processed materials smart array preventing retention point in material dispose.
  113220. */
  113221. freeProcessedMaterials(): void;
  113222. private _preventFreeActiveMeshesAndRenderingGroups;
  113223. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113224. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113225. * when disposing several meshes in a row or a hierarchy of meshes.
  113226. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113227. */
  113228. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113229. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113230. /**
  113231. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113232. */
  113233. freeActiveMeshes(): void;
  113234. /**
  113235. * Clear the info related to rendering groups preventing retention points during dispose.
  113236. */
  113237. freeRenderingGroups(): void;
  113238. /** @hidden */
  113239. _isInIntermediateRendering(): boolean;
  113240. /**
  113241. * Lambda returning the list of potentially active meshes.
  113242. */
  113243. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113244. /**
  113245. * Lambda returning the list of potentially active sub meshes.
  113246. */
  113247. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113248. /**
  113249. * Lambda returning the list of potentially intersecting sub meshes.
  113250. */
  113251. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113252. /**
  113253. * Lambda returning the list of potentially colliding sub meshes.
  113254. */
  113255. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113256. private _activeMeshesFrozen;
  113257. private _skipEvaluateActiveMeshesCompletely;
  113258. /**
  113259. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113260. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113261. * @returns the current scene
  113262. */
  113263. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113264. /**
  113265. * Use this function to restart evaluating active meshes on every frame
  113266. * @returns the current scene
  113267. */
  113268. unfreezeActiveMeshes(): Scene;
  113269. private _evaluateActiveMeshes;
  113270. private _activeMesh;
  113271. /**
  113272. * Update the transform matrix to update from the current active camera
  113273. * @param force defines a boolean used to force the update even if cache is up to date
  113274. */
  113275. updateTransformMatrix(force?: boolean): void;
  113276. private _bindFrameBuffer;
  113277. /** @hidden */
  113278. _allowPostProcessClearColor: boolean;
  113279. /** @hidden */
  113280. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113281. private _processSubCameras;
  113282. private _checkIntersections;
  113283. /** @hidden */
  113284. _advancePhysicsEngineStep(step: number): void;
  113285. /**
  113286. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113287. */
  113288. getDeterministicFrameTime: () => number;
  113289. /** @hidden */
  113290. _animate(): void;
  113291. /** Execute all animations (for a frame) */
  113292. animate(): void;
  113293. /**
  113294. * Render the scene
  113295. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113296. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113297. */
  113298. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113299. /**
  113300. * Freeze all materials
  113301. * A frozen material will not be updatable but should be faster to render
  113302. */
  113303. freezeMaterials(): void;
  113304. /**
  113305. * Unfreeze all materials
  113306. * A frozen material will not be updatable but should be faster to render
  113307. */
  113308. unfreezeMaterials(): void;
  113309. /**
  113310. * Releases all held ressources
  113311. */
  113312. dispose(): void;
  113313. /**
  113314. * Gets if the scene is already disposed
  113315. */
  113316. get isDisposed(): boolean;
  113317. /**
  113318. * Call this function to reduce memory footprint of the scene.
  113319. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113320. */
  113321. clearCachedVertexData(): void;
  113322. /**
  113323. * This function will remove the local cached buffer data from texture.
  113324. * It will save memory but will prevent the texture from being rebuilt
  113325. */
  113326. cleanCachedTextureBuffer(): void;
  113327. /**
  113328. * Get the world extend vectors with an optional filter
  113329. *
  113330. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113331. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113332. */
  113333. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113334. min: Vector3;
  113335. max: Vector3;
  113336. };
  113337. /**
  113338. * Creates a ray that can be used to pick in the scene
  113339. * @param x defines the x coordinate of the origin (on-screen)
  113340. * @param y defines the y coordinate of the origin (on-screen)
  113341. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113342. * @param camera defines the camera to use for the picking
  113343. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113344. * @returns a Ray
  113345. */
  113346. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113347. /**
  113348. * Creates a ray that can be used to pick in the scene
  113349. * @param x defines the x coordinate of the origin (on-screen)
  113350. * @param y defines the y coordinate of the origin (on-screen)
  113351. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113352. * @param result defines the ray where to store the picking ray
  113353. * @param camera defines the camera to use for the picking
  113354. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113355. * @returns the current scene
  113356. */
  113357. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113358. /**
  113359. * Creates a ray that can be used to pick in the scene
  113360. * @param x defines the x coordinate of the origin (on-screen)
  113361. * @param y defines the y coordinate of the origin (on-screen)
  113362. * @param camera defines the camera to use for the picking
  113363. * @returns a Ray
  113364. */
  113365. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113366. /**
  113367. * Creates a ray that can be used to pick in the scene
  113368. * @param x defines the x coordinate of the origin (on-screen)
  113369. * @param y defines the y coordinate of the origin (on-screen)
  113370. * @param result defines the ray where to store the picking ray
  113371. * @param camera defines the camera to use for the picking
  113372. * @returns the current scene
  113373. */
  113374. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113375. /** Launch a ray to try to pick a mesh in the scene
  113376. * @param x position on screen
  113377. * @param y position on screen
  113378. * @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
  113379. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113380. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113382. * @returns a PickingInfo
  113383. */
  113384. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113385. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113386. * @param x position on screen
  113387. * @param y position on screen
  113388. * @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
  113389. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113390. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113391. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  113392. */
  113393. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113394. /** Use the given ray to pick a mesh in the scene
  113395. * @param ray The ray to use to pick meshes
  113396. * @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
  113397. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113398. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113399. * @returns a PickingInfo
  113400. */
  113401. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113402. /**
  113403. * Launch a ray to try to pick a mesh in the scene
  113404. * @param x X position on screen
  113405. * @param y Y position on screen
  113406. * @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
  113407. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113408. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113409. * @returns an array of PickingInfo
  113410. */
  113411. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113412. /**
  113413. * Launch a ray to try to pick a mesh in the scene
  113414. * @param ray Ray to use
  113415. * @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
  113416. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113417. * @returns an array of PickingInfo
  113418. */
  113419. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113420. /**
  113421. * Force the value of meshUnderPointer
  113422. * @param mesh defines the mesh to use
  113423. */
  113424. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113425. /**
  113426. * Gets the mesh under the pointer
  113427. * @returns a Mesh or null if no mesh is under the pointer
  113428. */
  113429. getPointerOverMesh(): Nullable<AbstractMesh>;
  113430. /** @hidden */
  113431. _rebuildGeometries(): void;
  113432. /** @hidden */
  113433. _rebuildTextures(): void;
  113434. private _getByTags;
  113435. /**
  113436. * Get a list of meshes by tags
  113437. * @param tagsQuery defines the tags query to use
  113438. * @param forEach defines a predicate used to filter results
  113439. * @returns an array of Mesh
  113440. */
  113441. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113442. /**
  113443. * Get a list of cameras by tags
  113444. * @param tagsQuery defines the tags query to use
  113445. * @param forEach defines a predicate used to filter results
  113446. * @returns an array of Camera
  113447. */
  113448. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113449. /**
  113450. * Get a list of lights by tags
  113451. * @param tagsQuery defines the tags query to use
  113452. * @param forEach defines a predicate used to filter results
  113453. * @returns an array of Light
  113454. */
  113455. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113456. /**
  113457. * Get a list of materials by tags
  113458. * @param tagsQuery defines the tags query to use
  113459. * @param forEach defines a predicate used to filter results
  113460. * @returns an array of Material
  113461. */
  113462. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113463. /**
  113464. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113465. * This allowed control for front to back rendering or reversly depending of the special needs.
  113466. *
  113467. * @param renderingGroupId The rendering group id corresponding to its index
  113468. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113469. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113470. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113471. */
  113472. 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;
  113473. /**
  113474. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113475. *
  113476. * @param renderingGroupId The rendering group id corresponding to its index
  113477. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113478. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113479. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113480. */
  113481. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113482. /**
  113483. * Gets the current auto clear configuration for one rendering group of the rendering
  113484. * manager.
  113485. * @param index the rendering group index to get the information for
  113486. * @returns The auto clear setup for the requested rendering group
  113487. */
  113488. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113489. private _blockMaterialDirtyMechanism;
  113490. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113491. get blockMaterialDirtyMechanism(): boolean;
  113492. set blockMaterialDirtyMechanism(value: boolean);
  113493. /**
  113494. * Will flag all materials as dirty to trigger new shader compilation
  113495. * @param flag defines the flag used to specify which material part must be marked as dirty
  113496. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113497. */
  113498. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113499. /** @hidden */
  113500. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  113501. /** @hidden */
  113502. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113503. /** @hidden */
  113504. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  113505. /** @hidden */
  113506. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113507. /** @hidden */
  113508. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113509. /** @hidden */
  113510. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113511. }
  113512. }
  113513. declare module BABYLON {
  113514. /**
  113515. * Set of assets to keep when moving a scene into an asset container.
  113516. */
  113517. export class KeepAssets extends AbstractScene {
  113518. }
  113519. /**
  113520. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113521. */
  113522. export class InstantiatedEntries {
  113523. /**
  113524. * List of new root nodes (eg. nodes with no parent)
  113525. */
  113526. rootNodes: TransformNode[];
  113527. /**
  113528. * List of new skeletons
  113529. */
  113530. skeletons: Skeleton[];
  113531. /**
  113532. * List of new animation groups
  113533. */
  113534. animationGroups: AnimationGroup[];
  113535. }
  113536. /**
  113537. * Container with a set of assets that can be added or removed from a scene.
  113538. */
  113539. export class AssetContainer extends AbstractScene {
  113540. private _wasAddedToScene;
  113541. /**
  113542. * The scene the AssetContainer belongs to.
  113543. */
  113544. scene: Scene;
  113545. /**
  113546. * Instantiates an AssetContainer.
  113547. * @param scene The scene the AssetContainer belongs to.
  113548. */
  113549. constructor(scene: Scene);
  113550. /**
  113551. * Instantiate or clone all meshes and add the new ones to the scene.
  113552. * Skeletons and animation groups will all be cloned
  113553. * @param nameFunction defines an optional function used to get new names for clones
  113554. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113555. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113556. */
  113557. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113558. /**
  113559. * Adds all the assets from the container to the scene.
  113560. */
  113561. addAllToScene(): void;
  113562. /**
  113563. * Removes all the assets in the container from the scene
  113564. */
  113565. removeAllFromScene(): void;
  113566. /**
  113567. * Disposes all the assets in the container
  113568. */
  113569. dispose(): void;
  113570. private _moveAssets;
  113571. /**
  113572. * Removes all the assets contained in the scene and adds them to the container.
  113573. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113574. */
  113575. moveAllFromScene(keepAssets?: KeepAssets): void;
  113576. /**
  113577. * 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.
  113578. * @returns the root mesh
  113579. */
  113580. createRootMesh(): Mesh;
  113581. /**
  113582. * Merge animations (direct and animation groups) from this asset container into a scene
  113583. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113584. * @param animatables set of animatables to retarget to a node from the scene
  113585. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113586. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113587. */
  113588. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113589. }
  113590. }
  113591. declare module BABYLON {
  113592. /**
  113593. * Defines how the parser contract is defined.
  113594. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113595. */
  113596. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113597. /**
  113598. * Defines how the individual parser contract is defined.
  113599. * These parser can parse an individual asset
  113600. */
  113601. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113602. /**
  113603. * Base class of the scene acting as a container for the different elements composing a scene.
  113604. * This class is dynamically extended by the different components of the scene increasing
  113605. * flexibility and reducing coupling
  113606. */
  113607. export abstract class AbstractScene {
  113608. /**
  113609. * Stores the list of available parsers in the application.
  113610. */
  113611. private static _BabylonFileParsers;
  113612. /**
  113613. * Stores the list of available individual parsers in the application.
  113614. */
  113615. private static _IndividualBabylonFileParsers;
  113616. /**
  113617. * Adds a parser in the list of available ones
  113618. * @param name Defines the name of the parser
  113619. * @param parser Defines the parser to add
  113620. */
  113621. static AddParser(name: string, parser: BabylonFileParser): void;
  113622. /**
  113623. * Gets a general parser from the list of avaialble ones
  113624. * @param name Defines the name of the parser
  113625. * @returns the requested parser or null
  113626. */
  113627. static GetParser(name: string): Nullable<BabylonFileParser>;
  113628. /**
  113629. * Adds n individual parser in the list of available ones
  113630. * @param name Defines the name of the parser
  113631. * @param parser Defines the parser to add
  113632. */
  113633. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113634. /**
  113635. * Gets an individual parser from the list of avaialble ones
  113636. * @param name Defines the name of the parser
  113637. * @returns the requested parser or null
  113638. */
  113639. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113640. /**
  113641. * Parser json data and populate both a scene and its associated container object
  113642. * @param jsonData Defines the data to parse
  113643. * @param scene Defines the scene to parse the data for
  113644. * @param container Defines the container attached to the parsing sequence
  113645. * @param rootUrl Defines the root url of the data
  113646. */
  113647. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113648. /**
  113649. * Gets the list of root nodes (ie. nodes with no parent)
  113650. */
  113651. rootNodes: Node[];
  113652. /** All of the cameras added to this scene
  113653. * @see http://doc.babylonjs.com/babylon101/cameras
  113654. */
  113655. cameras: Camera[];
  113656. /**
  113657. * All of the lights added to this scene
  113658. * @see http://doc.babylonjs.com/babylon101/lights
  113659. */
  113660. lights: Light[];
  113661. /**
  113662. * All of the (abstract) meshes added to this scene
  113663. */
  113664. meshes: AbstractMesh[];
  113665. /**
  113666. * The list of skeletons added to the scene
  113667. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113668. */
  113669. skeletons: Skeleton[];
  113670. /**
  113671. * All of the particle systems added to this scene
  113672. * @see http://doc.babylonjs.com/babylon101/particles
  113673. */
  113674. particleSystems: IParticleSystem[];
  113675. /**
  113676. * Gets a list of Animations associated with the scene
  113677. */
  113678. animations: Animation[];
  113679. /**
  113680. * All of the animation groups added to this scene
  113681. * @see http://doc.babylonjs.com/how_to/group
  113682. */
  113683. animationGroups: AnimationGroup[];
  113684. /**
  113685. * All of the multi-materials added to this scene
  113686. * @see http://doc.babylonjs.com/how_to/multi_materials
  113687. */
  113688. multiMaterials: MultiMaterial[];
  113689. /**
  113690. * All of the materials added to this scene
  113691. * In the context of a Scene, it is not supposed to be modified manually.
  113692. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113693. * Note also that the order of the Material within the array is not significant and might change.
  113694. * @see http://doc.babylonjs.com/babylon101/materials
  113695. */
  113696. materials: Material[];
  113697. /**
  113698. * The list of morph target managers added to the scene
  113699. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113700. */
  113701. morphTargetManagers: MorphTargetManager[];
  113702. /**
  113703. * The list of geometries used in the scene.
  113704. */
  113705. geometries: Geometry[];
  113706. /**
  113707. * All of the tranform nodes added to this scene
  113708. * In the context of a Scene, it is not supposed to be modified manually.
  113709. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113710. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113711. * @see http://doc.babylonjs.com/how_to/transformnode
  113712. */
  113713. transformNodes: TransformNode[];
  113714. /**
  113715. * ActionManagers available on the scene.
  113716. */
  113717. actionManagers: AbstractActionManager[];
  113718. /**
  113719. * Textures to keep.
  113720. */
  113721. textures: BaseTexture[];
  113722. /**
  113723. * Environment texture for the scene
  113724. */
  113725. environmentTexture: Nullable<BaseTexture>;
  113726. /**
  113727. * @returns all meshes, lights, cameras, transformNodes and bones
  113728. */
  113729. getNodes(): Array<Node>;
  113730. }
  113731. }
  113732. declare module BABYLON {
  113733. /**
  113734. * Interface used to define options for Sound class
  113735. */
  113736. export interface ISoundOptions {
  113737. /**
  113738. * Does the sound autoplay once loaded.
  113739. */
  113740. autoplay?: boolean;
  113741. /**
  113742. * Does the sound loop after it finishes playing once.
  113743. */
  113744. loop?: boolean;
  113745. /**
  113746. * Sound's volume
  113747. */
  113748. volume?: number;
  113749. /**
  113750. * Is it a spatial sound?
  113751. */
  113752. spatialSound?: boolean;
  113753. /**
  113754. * Maximum distance to hear that sound
  113755. */
  113756. maxDistance?: number;
  113757. /**
  113758. * Uses user defined attenuation function
  113759. */
  113760. useCustomAttenuation?: boolean;
  113761. /**
  113762. * Define the roll off factor of spatial sounds.
  113763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113764. */
  113765. rolloffFactor?: number;
  113766. /**
  113767. * Define the reference distance the sound should be heard perfectly.
  113768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113769. */
  113770. refDistance?: number;
  113771. /**
  113772. * Define the distance attenuation model the sound will follow.
  113773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113774. */
  113775. distanceModel?: string;
  113776. /**
  113777. * Defines the playback speed (1 by default)
  113778. */
  113779. playbackRate?: number;
  113780. /**
  113781. * Defines if the sound is from a streaming source
  113782. */
  113783. streaming?: boolean;
  113784. /**
  113785. * Defines an optional length (in seconds) inside the sound file
  113786. */
  113787. length?: number;
  113788. /**
  113789. * Defines an optional offset (in seconds) inside the sound file
  113790. */
  113791. offset?: number;
  113792. /**
  113793. * If true, URLs will not be required to state the audio file codec to use.
  113794. */
  113795. skipCodecCheck?: boolean;
  113796. }
  113797. /**
  113798. * Defines a sound that can be played in the application.
  113799. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113801. */
  113802. export class Sound {
  113803. /**
  113804. * The name of the sound in the scene.
  113805. */
  113806. name: string;
  113807. /**
  113808. * Does the sound autoplay once loaded.
  113809. */
  113810. autoplay: boolean;
  113811. /**
  113812. * Does the sound loop after it finishes playing once.
  113813. */
  113814. loop: boolean;
  113815. /**
  113816. * Does the sound use a custom attenuation curve to simulate the falloff
  113817. * happening when the source gets further away from the camera.
  113818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113819. */
  113820. useCustomAttenuation: boolean;
  113821. /**
  113822. * The sound track id this sound belongs to.
  113823. */
  113824. soundTrackId: number;
  113825. /**
  113826. * Is this sound currently played.
  113827. */
  113828. isPlaying: boolean;
  113829. /**
  113830. * Is this sound currently paused.
  113831. */
  113832. isPaused: boolean;
  113833. /**
  113834. * Does this sound enables spatial sound.
  113835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113836. */
  113837. spatialSound: boolean;
  113838. /**
  113839. * Define the reference distance the sound should be heard perfectly.
  113840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113841. */
  113842. refDistance: number;
  113843. /**
  113844. * Define the roll off factor of spatial sounds.
  113845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113846. */
  113847. rolloffFactor: number;
  113848. /**
  113849. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113851. */
  113852. maxDistance: number;
  113853. /**
  113854. * Define the distance attenuation model the sound will follow.
  113855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113856. */
  113857. distanceModel: string;
  113858. /**
  113859. * @hidden
  113860. * Back Compat
  113861. **/
  113862. onended: () => any;
  113863. /**
  113864. * Observable event when the current playing sound finishes.
  113865. */
  113866. onEndedObservable: Observable<Sound>;
  113867. private _panningModel;
  113868. private _playbackRate;
  113869. private _streaming;
  113870. private _startTime;
  113871. private _startOffset;
  113872. private _position;
  113873. /** @hidden */
  113874. _positionInEmitterSpace: boolean;
  113875. private _localDirection;
  113876. private _volume;
  113877. private _isReadyToPlay;
  113878. private _isDirectional;
  113879. private _readyToPlayCallback;
  113880. private _audioBuffer;
  113881. private _soundSource;
  113882. private _streamingSource;
  113883. private _soundPanner;
  113884. private _soundGain;
  113885. private _inputAudioNode;
  113886. private _outputAudioNode;
  113887. private _coneInnerAngle;
  113888. private _coneOuterAngle;
  113889. private _coneOuterGain;
  113890. private _scene;
  113891. private _connectedTransformNode;
  113892. private _customAttenuationFunction;
  113893. private _registerFunc;
  113894. private _isOutputConnected;
  113895. private _htmlAudioElement;
  113896. private _urlType;
  113897. private _length?;
  113898. private _offset?;
  113899. /** @hidden */
  113900. static _SceneComponentInitialization: (scene: Scene) => void;
  113901. /**
  113902. * Create a sound and attach it to a scene
  113903. * @param name Name of your sound
  113904. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113905. * @param scene defines the scene the sound belongs to
  113906. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113907. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113908. */
  113909. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113910. /**
  113911. * Release the sound and its associated resources
  113912. */
  113913. dispose(): void;
  113914. /**
  113915. * Gets if the sounds is ready to be played or not.
  113916. * @returns true if ready, otherwise false
  113917. */
  113918. isReady(): boolean;
  113919. private _soundLoaded;
  113920. /**
  113921. * Sets the data of the sound from an audiobuffer
  113922. * @param audioBuffer The audioBuffer containing the data
  113923. */
  113924. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113925. /**
  113926. * Updates the current sounds options such as maxdistance, loop...
  113927. * @param options A JSON object containing values named as the object properties
  113928. */
  113929. updateOptions(options: ISoundOptions): void;
  113930. private _createSpatialParameters;
  113931. private _updateSpatialParameters;
  113932. /**
  113933. * Switch the panning model to HRTF:
  113934. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113936. */
  113937. switchPanningModelToHRTF(): void;
  113938. /**
  113939. * Switch the panning model to Equal Power:
  113940. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113942. */
  113943. switchPanningModelToEqualPower(): void;
  113944. private _switchPanningModel;
  113945. /**
  113946. * Connect this sound to a sound track audio node like gain...
  113947. * @param soundTrackAudioNode the sound track audio node to connect to
  113948. */
  113949. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  113950. /**
  113951. * Transform this sound into a directional source
  113952. * @param coneInnerAngle Size of the inner cone in degree
  113953. * @param coneOuterAngle Size of the outer cone in degree
  113954. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  113955. */
  113956. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  113957. /**
  113958. * Gets or sets the inner angle for the directional cone.
  113959. */
  113960. get directionalConeInnerAngle(): number;
  113961. /**
  113962. * Gets or sets the inner angle for the directional cone.
  113963. */
  113964. set directionalConeInnerAngle(value: number);
  113965. /**
  113966. * Gets or sets the outer angle for the directional cone.
  113967. */
  113968. get directionalConeOuterAngle(): number;
  113969. /**
  113970. * Gets or sets the outer angle for the directional cone.
  113971. */
  113972. set directionalConeOuterAngle(value: number);
  113973. /**
  113974. * Sets the position of the emitter if spatial sound is enabled
  113975. * @param newPosition Defines the new posisiton
  113976. */
  113977. setPosition(newPosition: Vector3): void;
  113978. /**
  113979. * Sets the local direction of the emitter if spatial sound is enabled
  113980. * @param newLocalDirection Defines the new local direction
  113981. */
  113982. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  113983. private _updateDirection;
  113984. /** @hidden */
  113985. updateDistanceFromListener(): void;
  113986. /**
  113987. * Sets a new custom attenuation function for the sound.
  113988. * @param callback Defines the function used for the attenuation
  113989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113990. */
  113991. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  113992. /**
  113993. * Play the sound
  113994. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  113995. * @param offset (optional) Start the sound at a specific time in seconds
  113996. * @param length (optional) Sound duration (in seconds)
  113997. */
  113998. play(time?: number, offset?: number, length?: number): void;
  113999. private _onended;
  114000. /**
  114001. * Stop the sound
  114002. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  114003. */
  114004. stop(time?: number): void;
  114005. /**
  114006. * Put the sound in pause
  114007. */
  114008. pause(): void;
  114009. /**
  114010. * Sets a dedicated volume for this sounds
  114011. * @param newVolume Define the new volume of the sound
  114012. * @param time Define time for gradual change to new volume
  114013. */
  114014. setVolume(newVolume: number, time?: number): void;
  114015. /**
  114016. * Set the sound play back rate
  114017. * @param newPlaybackRate Define the playback rate the sound should be played at
  114018. */
  114019. setPlaybackRate(newPlaybackRate: number): void;
  114020. /**
  114021. * Gets the volume of the sound.
  114022. * @returns the volume of the sound
  114023. */
  114024. getVolume(): number;
  114025. /**
  114026. * Attach the sound to a dedicated mesh
  114027. * @param transformNode The transform node to connect the sound with
  114028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114029. */
  114030. attachToMesh(transformNode: TransformNode): void;
  114031. /**
  114032. * Detach the sound from the previously attached mesh
  114033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  114034. */
  114035. detachFromMesh(): void;
  114036. private _onRegisterAfterWorldMatrixUpdate;
  114037. /**
  114038. * Clone the current sound in the scene.
  114039. * @returns the new sound clone
  114040. */
  114041. clone(): Nullable<Sound>;
  114042. /**
  114043. * Gets the current underlying audio buffer containing the data
  114044. * @returns the audio buffer
  114045. */
  114046. getAudioBuffer(): Nullable<AudioBuffer>;
  114047. /**
  114048. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  114049. * @returns the source node
  114050. */
  114051. getSoundSource(): Nullable<AudioBufferSourceNode>;
  114052. /**
  114053. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  114054. * @returns the gain node
  114055. */
  114056. getSoundGain(): Nullable<GainNode>;
  114057. /**
  114058. * Serializes the Sound in a JSON representation
  114059. * @returns the JSON representation of the sound
  114060. */
  114061. serialize(): any;
  114062. /**
  114063. * Parse a JSON representation of a sound to innstantiate in a given scene
  114064. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  114065. * @param scene Define the scene the new parsed sound should be created in
  114066. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  114067. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  114068. * @returns the newly parsed sound
  114069. */
  114070. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  114071. }
  114072. }
  114073. declare module BABYLON {
  114074. /**
  114075. * This defines an action helpful to play a defined sound on a triggered action.
  114076. */
  114077. export class PlaySoundAction extends Action {
  114078. private _sound;
  114079. /**
  114080. * Instantiate the action
  114081. * @param triggerOptions defines the trigger options
  114082. * @param sound defines the sound to play
  114083. * @param condition defines the trigger related conditions
  114084. */
  114085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114086. /** @hidden */
  114087. _prepare(): void;
  114088. /**
  114089. * Execute the action and play the sound.
  114090. */
  114091. execute(): void;
  114092. /**
  114093. * Serializes the actions and its related information.
  114094. * @param parent defines the object to serialize in
  114095. * @returns the serialized object
  114096. */
  114097. serialize(parent: any): any;
  114098. }
  114099. /**
  114100. * This defines an action helpful to stop a defined sound on a triggered action.
  114101. */
  114102. export class StopSoundAction extends Action {
  114103. private _sound;
  114104. /**
  114105. * Instantiate the action
  114106. * @param triggerOptions defines the trigger options
  114107. * @param sound defines the sound to stop
  114108. * @param condition defines the trigger related conditions
  114109. */
  114110. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  114111. /** @hidden */
  114112. _prepare(): void;
  114113. /**
  114114. * Execute the action and stop the sound.
  114115. */
  114116. execute(): void;
  114117. /**
  114118. * Serializes the actions and its related information.
  114119. * @param parent defines the object to serialize in
  114120. * @returns the serialized object
  114121. */
  114122. serialize(parent: any): any;
  114123. }
  114124. }
  114125. declare module BABYLON {
  114126. /**
  114127. * This defines an action responsible to change the value of a property
  114128. * by interpolating between its current value and the newly set one once triggered.
  114129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  114130. */
  114131. export class InterpolateValueAction extends Action {
  114132. /**
  114133. * Defines the path of the property where the value should be interpolated
  114134. */
  114135. propertyPath: string;
  114136. /**
  114137. * Defines the target value at the end of the interpolation.
  114138. */
  114139. value: any;
  114140. /**
  114141. * Defines the time it will take for the property to interpolate to the value.
  114142. */
  114143. duration: number;
  114144. /**
  114145. * Defines if the other scene animations should be stopped when the action has been triggered
  114146. */
  114147. stopOtherAnimations?: boolean;
  114148. /**
  114149. * Defines a callback raised once the interpolation animation has been done.
  114150. */
  114151. onInterpolationDone?: () => void;
  114152. /**
  114153. * Observable triggered once the interpolation animation has been done.
  114154. */
  114155. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  114156. private _target;
  114157. private _effectiveTarget;
  114158. private _property;
  114159. /**
  114160. * Instantiate the action
  114161. * @param triggerOptions defines the trigger options
  114162. * @param target defines the object containing the value to interpolate
  114163. * @param propertyPath defines the path to the property in the target object
  114164. * @param value defines the target value at the end of the interpolation
  114165. * @param duration deines the time it will take for the property to interpolate to the value.
  114166. * @param condition defines the trigger related conditions
  114167. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  114168. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  114169. */
  114170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  114171. /** @hidden */
  114172. _prepare(): void;
  114173. /**
  114174. * Execute the action starts the value interpolation.
  114175. */
  114176. execute(): void;
  114177. /**
  114178. * Serializes the actions and its related information.
  114179. * @param parent defines the object to serialize in
  114180. * @returns the serialized object
  114181. */
  114182. serialize(parent: any): any;
  114183. }
  114184. }
  114185. declare module BABYLON {
  114186. /**
  114187. * Options allowed during the creation of a sound track.
  114188. */
  114189. export interface ISoundTrackOptions {
  114190. /**
  114191. * The volume the sound track should take during creation
  114192. */
  114193. volume?: number;
  114194. /**
  114195. * Define if the sound track is the main sound track of the scene
  114196. */
  114197. mainTrack?: boolean;
  114198. }
  114199. /**
  114200. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  114201. * It will be also used in a future release to apply effects on a specific track.
  114202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114203. */
  114204. export class SoundTrack {
  114205. /**
  114206. * The unique identifier of the sound track in the scene.
  114207. */
  114208. id: number;
  114209. /**
  114210. * The list of sounds included in the sound track.
  114211. */
  114212. soundCollection: Array<Sound>;
  114213. private _outputAudioNode;
  114214. private _scene;
  114215. private _connectedAnalyser;
  114216. private _options;
  114217. private _isInitialized;
  114218. /**
  114219. * Creates a new sound track.
  114220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114221. * @param scene Define the scene the sound track belongs to
  114222. * @param options
  114223. */
  114224. constructor(scene: Scene, options?: ISoundTrackOptions);
  114225. private _initializeSoundTrackAudioGraph;
  114226. /**
  114227. * Release the sound track and its associated resources
  114228. */
  114229. dispose(): void;
  114230. /**
  114231. * Adds a sound to this sound track
  114232. * @param sound define the cound to add
  114233. * @ignoreNaming
  114234. */
  114235. AddSound(sound: Sound): void;
  114236. /**
  114237. * Removes a sound to this sound track
  114238. * @param sound define the cound to remove
  114239. * @ignoreNaming
  114240. */
  114241. RemoveSound(sound: Sound): void;
  114242. /**
  114243. * Set a global volume for the full sound track.
  114244. * @param newVolume Define the new volume of the sound track
  114245. */
  114246. setVolume(newVolume: number): void;
  114247. /**
  114248. * Switch the panning model to HRTF:
  114249. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114251. */
  114252. switchPanningModelToHRTF(): void;
  114253. /**
  114254. * Switch the panning model to Equal Power:
  114255. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114257. */
  114258. switchPanningModelToEqualPower(): void;
  114259. /**
  114260. * Connect the sound track to an audio analyser allowing some amazing
  114261. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114263. * @param analyser The analyser to connect to the engine
  114264. */
  114265. connectToAnalyser(analyser: Analyser): void;
  114266. }
  114267. }
  114268. declare module BABYLON {
  114269. interface AbstractScene {
  114270. /**
  114271. * The list of sounds used in the scene.
  114272. */
  114273. sounds: Nullable<Array<Sound>>;
  114274. }
  114275. interface Scene {
  114276. /**
  114277. * @hidden
  114278. * Backing field
  114279. */
  114280. _mainSoundTrack: SoundTrack;
  114281. /**
  114282. * The main sound track played by the scene.
  114283. * It cotains your primary collection of sounds.
  114284. */
  114285. mainSoundTrack: SoundTrack;
  114286. /**
  114287. * The list of sound tracks added to the scene
  114288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114289. */
  114290. soundTracks: Nullable<Array<SoundTrack>>;
  114291. /**
  114292. * Gets a sound using a given name
  114293. * @param name defines the name to search for
  114294. * @return the found sound or null if not found at all.
  114295. */
  114296. getSoundByName(name: string): Nullable<Sound>;
  114297. /**
  114298. * Gets or sets if audio support is enabled
  114299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114300. */
  114301. audioEnabled: boolean;
  114302. /**
  114303. * Gets or sets if audio will be output to headphones
  114304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114305. */
  114306. headphone: boolean;
  114307. /**
  114308. * Gets or sets custom audio listener position provider
  114309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114310. */
  114311. audioListenerPositionProvider: Nullable<() => Vector3>;
  114312. /**
  114313. * Gets or sets a refresh rate when using 3D audio positioning
  114314. */
  114315. audioPositioningRefreshRate: number;
  114316. }
  114317. /**
  114318. * Defines the sound scene component responsible to manage any sounds
  114319. * in a given scene.
  114320. */
  114321. export class AudioSceneComponent implements ISceneSerializableComponent {
  114322. /**
  114323. * The component name helpfull to identify the component in the list of scene components.
  114324. */
  114325. readonly name: string;
  114326. /**
  114327. * The scene the component belongs to.
  114328. */
  114329. scene: Scene;
  114330. private _audioEnabled;
  114331. /**
  114332. * Gets whether audio is enabled or not.
  114333. * Please use related enable/disable method to switch state.
  114334. */
  114335. get audioEnabled(): boolean;
  114336. private _headphone;
  114337. /**
  114338. * Gets whether audio is outputing to headphone or not.
  114339. * Please use the according Switch methods to change output.
  114340. */
  114341. get headphone(): boolean;
  114342. /**
  114343. * Gets or sets a refresh rate when using 3D audio positioning
  114344. */
  114345. audioPositioningRefreshRate: number;
  114346. private _audioListenerPositionProvider;
  114347. /**
  114348. * Gets the current audio listener position provider
  114349. */
  114350. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114351. /**
  114352. * Sets a custom listener position for all sounds in the scene
  114353. * By default, this is the position of the first active camera
  114354. */
  114355. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114356. /**
  114357. * Creates a new instance of the component for the given scene
  114358. * @param scene Defines the scene to register the component in
  114359. */
  114360. constructor(scene: Scene);
  114361. /**
  114362. * Registers the component in a given scene
  114363. */
  114364. register(): void;
  114365. /**
  114366. * Rebuilds the elements related to this component in case of
  114367. * context lost for instance.
  114368. */
  114369. rebuild(): void;
  114370. /**
  114371. * Serializes the component data to the specified json object
  114372. * @param serializationObject The object to serialize to
  114373. */
  114374. serialize(serializationObject: any): void;
  114375. /**
  114376. * Adds all the elements from the container to the scene
  114377. * @param container the container holding the elements
  114378. */
  114379. addFromContainer(container: AbstractScene): void;
  114380. /**
  114381. * Removes all the elements in the container from the scene
  114382. * @param container contains the elements to remove
  114383. * @param dispose if the removed element should be disposed (default: false)
  114384. */
  114385. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114386. /**
  114387. * Disposes the component and the associated ressources.
  114388. */
  114389. dispose(): void;
  114390. /**
  114391. * Disables audio in the associated scene.
  114392. */
  114393. disableAudio(): void;
  114394. /**
  114395. * Enables audio in the associated scene.
  114396. */
  114397. enableAudio(): void;
  114398. /**
  114399. * Switch audio to headphone output.
  114400. */
  114401. switchAudioModeForHeadphones(): void;
  114402. /**
  114403. * Switch audio to normal speakers.
  114404. */
  114405. switchAudioModeForNormalSpeakers(): void;
  114406. private _cachedCameraDirection;
  114407. private _cachedCameraPosition;
  114408. private _lastCheck;
  114409. private _afterRender;
  114410. }
  114411. }
  114412. declare module BABYLON {
  114413. /**
  114414. * Wraps one or more Sound objects and selects one with random weight for playback.
  114415. */
  114416. export class WeightedSound {
  114417. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114418. loop: boolean;
  114419. private _coneInnerAngle;
  114420. private _coneOuterAngle;
  114421. private _volume;
  114422. /** A Sound is currently playing. */
  114423. isPlaying: boolean;
  114424. /** A Sound is currently paused. */
  114425. isPaused: boolean;
  114426. private _sounds;
  114427. private _weights;
  114428. private _currentIndex?;
  114429. /**
  114430. * Creates a new WeightedSound from the list of sounds given.
  114431. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114432. * @param sounds Array of Sounds that will be selected from.
  114433. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114434. */
  114435. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114436. /**
  114437. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114438. */
  114439. get directionalConeInnerAngle(): number;
  114440. /**
  114441. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114442. */
  114443. set directionalConeInnerAngle(value: number);
  114444. /**
  114445. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114446. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114447. */
  114448. get directionalConeOuterAngle(): number;
  114449. /**
  114450. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114451. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114452. */
  114453. set directionalConeOuterAngle(value: number);
  114454. /**
  114455. * Playback volume.
  114456. */
  114457. get volume(): number;
  114458. /**
  114459. * Playback volume.
  114460. */
  114461. set volume(value: number);
  114462. private _onended;
  114463. /**
  114464. * Suspend playback
  114465. */
  114466. pause(): void;
  114467. /**
  114468. * Stop playback
  114469. */
  114470. stop(): void;
  114471. /**
  114472. * Start playback.
  114473. * @param startOffset Position the clip head at a specific time in seconds.
  114474. */
  114475. play(startOffset?: number): void;
  114476. }
  114477. }
  114478. declare module BABYLON {
  114479. /**
  114480. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114482. */
  114483. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114484. /**
  114485. * Gets the name of the behavior.
  114486. */
  114487. get name(): string;
  114488. /**
  114489. * The easing function used by animations
  114490. */
  114491. static EasingFunction: BackEase;
  114492. /**
  114493. * The easing mode used by animations
  114494. */
  114495. static EasingMode: number;
  114496. /**
  114497. * The duration of the animation, in milliseconds
  114498. */
  114499. transitionDuration: number;
  114500. /**
  114501. * Length of the distance animated by the transition when lower radius is reached
  114502. */
  114503. lowerRadiusTransitionRange: number;
  114504. /**
  114505. * Length of the distance animated by the transition when upper radius is reached
  114506. */
  114507. upperRadiusTransitionRange: number;
  114508. private _autoTransitionRange;
  114509. /**
  114510. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114511. */
  114512. get autoTransitionRange(): boolean;
  114513. /**
  114514. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114515. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114516. */
  114517. set autoTransitionRange(value: boolean);
  114518. private _attachedCamera;
  114519. private _onAfterCheckInputsObserver;
  114520. private _onMeshTargetChangedObserver;
  114521. /**
  114522. * Initializes the behavior.
  114523. */
  114524. init(): void;
  114525. /**
  114526. * Attaches the behavior to its arc rotate camera.
  114527. * @param camera Defines the camera to attach the behavior to
  114528. */
  114529. attach(camera: ArcRotateCamera): void;
  114530. /**
  114531. * Detaches the behavior from its current arc rotate camera.
  114532. */
  114533. detach(): void;
  114534. private _radiusIsAnimating;
  114535. private _radiusBounceTransition;
  114536. private _animatables;
  114537. private _cachedWheelPrecision;
  114538. /**
  114539. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114540. * @param radiusLimit The limit to check against.
  114541. * @return Bool to indicate if at limit.
  114542. */
  114543. private _isRadiusAtLimit;
  114544. /**
  114545. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114546. * @param radiusDelta The delta by which to animate to. Can be negative.
  114547. */
  114548. private _applyBoundRadiusAnimation;
  114549. /**
  114550. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114551. */
  114552. protected _clearAnimationLocks(): void;
  114553. /**
  114554. * Stops and removes all animations that have been applied to the camera
  114555. */
  114556. stopAllAnimations(): void;
  114557. }
  114558. }
  114559. declare module BABYLON {
  114560. /**
  114561. * 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.
  114562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114563. */
  114564. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114565. /**
  114566. * Gets the name of the behavior.
  114567. */
  114568. get name(): string;
  114569. private _mode;
  114570. private _radiusScale;
  114571. private _positionScale;
  114572. private _defaultElevation;
  114573. private _elevationReturnTime;
  114574. private _elevationReturnWaitTime;
  114575. private _zoomStopsAnimation;
  114576. private _framingTime;
  114577. /**
  114578. * The easing function used by animations
  114579. */
  114580. static EasingFunction: ExponentialEase;
  114581. /**
  114582. * The easing mode used by animations
  114583. */
  114584. static EasingMode: number;
  114585. /**
  114586. * Sets the current mode used by the behavior
  114587. */
  114588. set mode(mode: number);
  114589. /**
  114590. * Gets current mode used by the behavior.
  114591. */
  114592. get mode(): number;
  114593. /**
  114594. * Sets the scale applied to the radius (1 by default)
  114595. */
  114596. set radiusScale(radius: number);
  114597. /**
  114598. * Gets the scale applied to the radius
  114599. */
  114600. get radiusScale(): number;
  114601. /**
  114602. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114603. */
  114604. set positionScale(scale: number);
  114605. /**
  114606. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114607. */
  114608. get positionScale(): number;
  114609. /**
  114610. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114611. * behaviour is triggered, in radians.
  114612. */
  114613. set defaultElevation(elevation: number);
  114614. /**
  114615. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114616. * behaviour is triggered, in radians.
  114617. */
  114618. get defaultElevation(): number;
  114619. /**
  114620. * Sets the time (in milliseconds) taken to return to the default beta position.
  114621. * Negative value indicates camera should not return to default.
  114622. */
  114623. set elevationReturnTime(speed: number);
  114624. /**
  114625. * Gets the time (in milliseconds) taken to return to the default beta position.
  114626. * Negative value indicates camera should not return to default.
  114627. */
  114628. get elevationReturnTime(): number;
  114629. /**
  114630. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114631. */
  114632. set elevationReturnWaitTime(time: number);
  114633. /**
  114634. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114635. */
  114636. get elevationReturnWaitTime(): number;
  114637. /**
  114638. * Sets the flag that indicates if user zooming should stop animation.
  114639. */
  114640. set zoomStopsAnimation(flag: boolean);
  114641. /**
  114642. * Gets the flag that indicates if user zooming should stop animation.
  114643. */
  114644. get zoomStopsAnimation(): boolean;
  114645. /**
  114646. * Sets the transition time when framing the mesh, in milliseconds
  114647. */
  114648. set framingTime(time: number);
  114649. /**
  114650. * Gets the transition time when framing the mesh, in milliseconds
  114651. */
  114652. get framingTime(): number;
  114653. /**
  114654. * Define if the behavior should automatically change the configured
  114655. * camera limits and sensibilities.
  114656. */
  114657. autoCorrectCameraLimitsAndSensibility: boolean;
  114658. private _onPrePointerObservableObserver;
  114659. private _onAfterCheckInputsObserver;
  114660. private _onMeshTargetChangedObserver;
  114661. private _attachedCamera;
  114662. private _isPointerDown;
  114663. private _lastInteractionTime;
  114664. /**
  114665. * Initializes the behavior.
  114666. */
  114667. init(): void;
  114668. /**
  114669. * Attaches the behavior to its arc rotate camera.
  114670. * @param camera Defines the camera to attach the behavior to
  114671. */
  114672. attach(camera: ArcRotateCamera): void;
  114673. /**
  114674. * Detaches the behavior from its current arc rotate camera.
  114675. */
  114676. detach(): void;
  114677. private _animatables;
  114678. private _betaIsAnimating;
  114679. private _betaTransition;
  114680. private _radiusTransition;
  114681. private _vectorTransition;
  114682. /**
  114683. * Targets the given mesh and updates zoom level accordingly.
  114684. * @param mesh The mesh to target.
  114685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114687. */
  114688. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114689. /**
  114690. * Targets the given mesh with its children and updates zoom level accordingly.
  114691. * @param mesh The mesh to target.
  114692. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114693. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114694. */
  114695. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114696. /**
  114697. * Targets the given meshes with their children and updates zoom level accordingly.
  114698. * @param meshes The mesh to target.
  114699. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114700. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114701. */
  114702. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114703. /**
  114704. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114705. * @param minimumWorld Determines the smaller position of the bounding box extend
  114706. * @param maximumWorld Determines the bigger position of the bounding box extend
  114707. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114708. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114709. */
  114710. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114711. /**
  114712. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114713. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114714. * frustum width.
  114715. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114716. * to fully enclose the mesh in the viewing frustum.
  114717. */
  114718. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114719. /**
  114720. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114721. * is automatically returned to its default position (expected to be above ground plane).
  114722. */
  114723. private _maintainCameraAboveGround;
  114724. /**
  114725. * Returns the frustum slope based on the canvas ratio and camera FOV
  114726. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114727. */
  114728. private _getFrustumSlope;
  114729. /**
  114730. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114731. */
  114732. private _clearAnimationLocks;
  114733. /**
  114734. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114735. */
  114736. private _applyUserInteraction;
  114737. /**
  114738. * Stops and removes all animations that have been applied to the camera
  114739. */
  114740. stopAllAnimations(): void;
  114741. /**
  114742. * Gets a value indicating if the user is moving the camera
  114743. */
  114744. get isUserIsMoving(): boolean;
  114745. /**
  114746. * The camera can move all the way towards the mesh.
  114747. */
  114748. static IgnoreBoundsSizeMode: number;
  114749. /**
  114750. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114751. */
  114752. static FitFrustumSidesMode: number;
  114753. }
  114754. }
  114755. declare module BABYLON {
  114756. /**
  114757. * Base class for Camera Pointer Inputs.
  114758. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114759. * for example usage.
  114760. */
  114761. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114762. /**
  114763. * Defines the camera the input is attached to.
  114764. */
  114765. abstract camera: Camera;
  114766. /**
  114767. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114768. */
  114769. protected _altKey: boolean;
  114770. protected _ctrlKey: boolean;
  114771. protected _metaKey: boolean;
  114772. protected _shiftKey: boolean;
  114773. /**
  114774. * Which mouse buttons were pressed at time of last mouse event.
  114775. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114776. */
  114777. protected _buttonsPressed: number;
  114778. /**
  114779. * Defines the buttons associated with the input to handle camera move.
  114780. */
  114781. buttons: number[];
  114782. /**
  114783. * Attach the input controls to a specific dom element to get the input from.
  114784. * @param element Defines the element the controls should be listened from
  114785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114786. */
  114787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114788. /**
  114789. * Detach the current controls from the specified dom element.
  114790. * @param element Defines the element to stop listening the inputs from
  114791. */
  114792. detachControl(element: Nullable<HTMLElement>): void;
  114793. /**
  114794. * Gets the class name of the current input.
  114795. * @returns the class name
  114796. */
  114797. getClassName(): string;
  114798. /**
  114799. * Get the friendly name associated with the input class.
  114800. * @returns the input friendly name
  114801. */
  114802. getSimpleName(): string;
  114803. /**
  114804. * Called on pointer POINTERDOUBLETAP event.
  114805. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114806. */
  114807. protected onDoubleTap(type: string): void;
  114808. /**
  114809. * Called on pointer POINTERMOVE event if only a single touch is active.
  114810. * Override this method to provide functionality.
  114811. */
  114812. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114813. /**
  114814. * Called on pointer POINTERMOVE event if multiple touches are active.
  114815. * Override this method to provide functionality.
  114816. */
  114817. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114818. /**
  114819. * Called on JS contextmenu event.
  114820. * Override this method to provide functionality.
  114821. */
  114822. protected onContextMenu(evt: PointerEvent): void;
  114823. /**
  114824. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114825. * press.
  114826. * Override this method to provide functionality.
  114827. */
  114828. protected onButtonDown(evt: PointerEvent): void;
  114829. /**
  114830. * Called each time a new POINTERUP event occurs. Ie, for each button
  114831. * release.
  114832. * Override this method to provide functionality.
  114833. */
  114834. protected onButtonUp(evt: PointerEvent): void;
  114835. /**
  114836. * Called when window becomes inactive.
  114837. * Override this method to provide functionality.
  114838. */
  114839. protected onLostFocus(): void;
  114840. private _pointerInput;
  114841. private _observer;
  114842. private _onLostFocus;
  114843. private pointA;
  114844. private pointB;
  114845. }
  114846. }
  114847. declare module BABYLON {
  114848. /**
  114849. * Manage the pointers inputs to control an arc rotate camera.
  114850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114851. */
  114852. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114853. /**
  114854. * Defines the camera the input is attached to.
  114855. */
  114856. camera: ArcRotateCamera;
  114857. /**
  114858. * Gets the class name of the current input.
  114859. * @returns the class name
  114860. */
  114861. getClassName(): string;
  114862. /**
  114863. * Defines the buttons associated with the input to handle camera move.
  114864. */
  114865. buttons: number[];
  114866. /**
  114867. * Defines the pointer angular sensibility along the X axis or how fast is
  114868. * the camera rotating.
  114869. */
  114870. angularSensibilityX: number;
  114871. /**
  114872. * Defines the pointer angular sensibility along the Y axis or how fast is
  114873. * the camera rotating.
  114874. */
  114875. angularSensibilityY: number;
  114876. /**
  114877. * Defines the pointer pinch precision or how fast is the camera zooming.
  114878. */
  114879. pinchPrecision: number;
  114880. /**
  114881. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114882. * from 0.
  114883. * It defines the percentage of current camera.radius to use as delta when
  114884. * pinch zoom is used.
  114885. */
  114886. pinchDeltaPercentage: number;
  114887. /**
  114888. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114889. * that any object in the plane at the camera's target point will scale
  114890. * perfectly with finger motion.
  114891. * Overrides pinchDeltaPercentage and pinchPrecision.
  114892. */
  114893. useNaturalPinchZoom: boolean;
  114894. /**
  114895. * Defines the pointer panning sensibility or how fast is the camera moving.
  114896. */
  114897. panningSensibility: number;
  114898. /**
  114899. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114900. */
  114901. multiTouchPanning: boolean;
  114902. /**
  114903. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114904. * zoom (pinch) through multitouch.
  114905. */
  114906. multiTouchPanAndZoom: boolean;
  114907. /**
  114908. * Revers pinch action direction.
  114909. */
  114910. pinchInwards: boolean;
  114911. private _isPanClick;
  114912. private _twoFingerActivityCount;
  114913. private _isPinching;
  114914. /**
  114915. * Called on pointer POINTERMOVE event if only a single touch is active.
  114916. */
  114917. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114918. /**
  114919. * Called on pointer POINTERDOUBLETAP event.
  114920. */
  114921. protected onDoubleTap(type: string): void;
  114922. /**
  114923. * Called on pointer POINTERMOVE event if multiple touches are active.
  114924. */
  114925. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114926. /**
  114927. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114928. * press.
  114929. */
  114930. protected onButtonDown(evt: PointerEvent): void;
  114931. /**
  114932. * Called each time a new POINTERUP event occurs. Ie, for each button
  114933. * release.
  114934. */
  114935. protected onButtonUp(evt: PointerEvent): void;
  114936. /**
  114937. * Called when window becomes inactive.
  114938. */
  114939. protected onLostFocus(): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  114945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114946. */
  114947. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  114948. /**
  114949. * Defines the camera the input is attached to.
  114950. */
  114951. camera: ArcRotateCamera;
  114952. /**
  114953. * Defines the list of key codes associated with the up action (increase alpha)
  114954. */
  114955. keysUp: number[];
  114956. /**
  114957. * Defines the list of key codes associated with the down action (decrease alpha)
  114958. */
  114959. keysDown: number[];
  114960. /**
  114961. * Defines the list of key codes associated with the left action (increase beta)
  114962. */
  114963. keysLeft: number[];
  114964. /**
  114965. * Defines the list of key codes associated with the right action (decrease beta)
  114966. */
  114967. keysRight: number[];
  114968. /**
  114969. * Defines the list of key codes associated with the reset action.
  114970. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  114971. */
  114972. keysReset: number[];
  114973. /**
  114974. * Defines the panning sensibility of the inputs.
  114975. * (How fast is the camera panning)
  114976. */
  114977. panningSensibility: number;
  114978. /**
  114979. * Defines the zooming sensibility of the inputs.
  114980. * (How fast is the camera zooming)
  114981. */
  114982. zoomingSensibility: number;
  114983. /**
  114984. * Defines whether maintaining the alt key down switch the movement mode from
  114985. * orientation to zoom.
  114986. */
  114987. useAltToZoom: boolean;
  114988. /**
  114989. * Rotation speed of the camera
  114990. */
  114991. angularSpeed: number;
  114992. private _keys;
  114993. private _ctrlPressed;
  114994. private _altPressed;
  114995. private _onCanvasBlurObserver;
  114996. private _onKeyboardObserver;
  114997. private _engine;
  114998. private _scene;
  114999. /**
  115000. * Attach the input controls to a specific dom element to get the input from.
  115001. * @param element Defines the element the controls should be listened from
  115002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115003. */
  115004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115005. /**
  115006. * Detach the current controls from the specified dom element.
  115007. * @param element Defines the element to stop listening the inputs from
  115008. */
  115009. detachControl(element: Nullable<HTMLElement>): void;
  115010. /**
  115011. * Update the current camera state depending on the inputs that have been used this frame.
  115012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115013. */
  115014. checkInputs(): void;
  115015. /**
  115016. * Gets the class name of the current intput.
  115017. * @returns the class name
  115018. */
  115019. getClassName(): string;
  115020. /**
  115021. * Get the friendly name associated with the input class.
  115022. * @returns the input friendly name
  115023. */
  115024. getSimpleName(): string;
  115025. }
  115026. }
  115027. declare module BABYLON {
  115028. /**
  115029. * Manage the mouse wheel inputs to control an arc rotate camera.
  115030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115031. */
  115032. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  115033. /**
  115034. * Defines the camera the input is attached to.
  115035. */
  115036. camera: ArcRotateCamera;
  115037. /**
  115038. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115039. */
  115040. wheelPrecision: number;
  115041. /**
  115042. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  115043. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  115044. */
  115045. wheelDeltaPercentage: number;
  115046. private _wheel;
  115047. private _observer;
  115048. private computeDeltaFromMouseWheelLegacyEvent;
  115049. /**
  115050. * Attach the input controls to a specific dom element to get the input from.
  115051. * @param element Defines the element the controls should be listened from
  115052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115053. */
  115054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115055. /**
  115056. * Detach the current controls from the specified dom element.
  115057. * @param element Defines the element to stop listening the inputs from
  115058. */
  115059. detachControl(element: Nullable<HTMLElement>): void;
  115060. /**
  115061. * Gets the class name of the current intput.
  115062. * @returns the class name
  115063. */
  115064. getClassName(): string;
  115065. /**
  115066. * Get the friendly name associated with the input class.
  115067. * @returns the input friendly name
  115068. */
  115069. getSimpleName(): string;
  115070. }
  115071. }
  115072. declare module BABYLON {
  115073. /**
  115074. * Default Inputs manager for the ArcRotateCamera.
  115075. * It groups all the default supported inputs for ease of use.
  115076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115077. */
  115078. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  115079. /**
  115080. * Instantiates a new ArcRotateCameraInputsManager.
  115081. * @param camera Defines the camera the inputs belong to
  115082. */
  115083. constructor(camera: ArcRotateCamera);
  115084. /**
  115085. * Add mouse wheel input support to the input manager.
  115086. * @returns the current input manager
  115087. */
  115088. addMouseWheel(): ArcRotateCameraInputsManager;
  115089. /**
  115090. * Add pointers input support to the input manager.
  115091. * @returns the current input manager
  115092. */
  115093. addPointers(): ArcRotateCameraInputsManager;
  115094. /**
  115095. * Add keyboard input support to the input manager.
  115096. * @returns the current input manager
  115097. */
  115098. addKeyboard(): ArcRotateCameraInputsManager;
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * This represents an orbital type of camera.
  115104. *
  115105. * 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.
  115106. * 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.
  115107. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  115108. */
  115109. export class ArcRotateCamera extends TargetCamera {
  115110. /**
  115111. * Defines the rotation angle of the camera along the longitudinal axis.
  115112. */
  115113. alpha: number;
  115114. /**
  115115. * Defines the rotation angle of the camera along the latitudinal axis.
  115116. */
  115117. beta: number;
  115118. /**
  115119. * Defines the radius of the camera from it s target point.
  115120. */
  115121. radius: number;
  115122. protected _target: Vector3;
  115123. protected _targetHost: Nullable<AbstractMesh>;
  115124. /**
  115125. * Defines the target point of the camera.
  115126. * The camera looks towards it form the radius distance.
  115127. */
  115128. get target(): Vector3;
  115129. set target(value: Vector3);
  115130. /**
  115131. * Define the current local position of the camera in the scene
  115132. */
  115133. get position(): Vector3;
  115134. set position(newPosition: Vector3);
  115135. protected _upVector: Vector3;
  115136. protected _upToYMatrix: Matrix;
  115137. protected _YToUpMatrix: Matrix;
  115138. /**
  115139. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  115140. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  115141. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  115142. */
  115143. set upVector(vec: Vector3);
  115144. get upVector(): Vector3;
  115145. /**
  115146. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  115147. */
  115148. setMatUp(): void;
  115149. /**
  115150. * Current inertia value on the longitudinal axis.
  115151. * The bigger this number the longer it will take for the camera to stop.
  115152. */
  115153. inertialAlphaOffset: number;
  115154. /**
  115155. * Current inertia value on the latitudinal axis.
  115156. * The bigger this number the longer it will take for the camera to stop.
  115157. */
  115158. inertialBetaOffset: number;
  115159. /**
  115160. * Current inertia value on the radius axis.
  115161. * The bigger this number the longer it will take for the camera to stop.
  115162. */
  115163. inertialRadiusOffset: number;
  115164. /**
  115165. * Minimum allowed angle on the longitudinal axis.
  115166. * This can help limiting how the Camera is able to move in the scene.
  115167. */
  115168. lowerAlphaLimit: Nullable<number>;
  115169. /**
  115170. * Maximum allowed angle on the longitudinal axis.
  115171. * This can help limiting how the Camera is able to move in the scene.
  115172. */
  115173. upperAlphaLimit: Nullable<number>;
  115174. /**
  115175. * Minimum allowed angle on the latitudinal axis.
  115176. * This can help limiting how the Camera is able to move in the scene.
  115177. */
  115178. lowerBetaLimit: number;
  115179. /**
  115180. * Maximum allowed angle on the latitudinal axis.
  115181. * This can help limiting how the Camera is able to move in the scene.
  115182. */
  115183. upperBetaLimit: number;
  115184. /**
  115185. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  115186. * This can help limiting how the Camera is able to move in the scene.
  115187. */
  115188. lowerRadiusLimit: Nullable<number>;
  115189. /**
  115190. * Maximum allowed distance of the camera to the target (The camera can not get further).
  115191. * This can help limiting how the Camera is able to move in the scene.
  115192. */
  115193. upperRadiusLimit: Nullable<number>;
  115194. /**
  115195. * Defines the current inertia value used during panning of the camera along the X axis.
  115196. */
  115197. inertialPanningX: number;
  115198. /**
  115199. * Defines the current inertia value used during panning of the camera along the Y axis.
  115200. */
  115201. inertialPanningY: number;
  115202. /**
  115203. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  115204. * Basically if your fingers moves away from more than this distance you will be considered
  115205. * in pinch mode.
  115206. */
  115207. pinchToPanMaxDistance: number;
  115208. /**
  115209. * Defines the maximum distance the camera can pan.
  115210. * This could help keeping the cammera always in your scene.
  115211. */
  115212. panningDistanceLimit: Nullable<number>;
  115213. /**
  115214. * Defines the target of the camera before paning.
  115215. */
  115216. panningOriginTarget: Vector3;
  115217. /**
  115218. * Defines the value of the inertia used during panning.
  115219. * 0 would mean stop inertia and one would mean no decelleration at all.
  115220. */
  115221. panningInertia: number;
  115222. /**
  115223. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115224. */
  115225. get angularSensibilityX(): number;
  115226. set angularSensibilityX(value: number);
  115227. /**
  115228. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115229. */
  115230. get angularSensibilityY(): number;
  115231. set angularSensibilityY(value: number);
  115232. /**
  115233. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115234. */
  115235. get pinchPrecision(): number;
  115236. set pinchPrecision(value: number);
  115237. /**
  115238. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115239. * It will be used instead of pinchDeltaPrecision if different from 0.
  115240. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115241. */
  115242. get pinchDeltaPercentage(): number;
  115243. set pinchDeltaPercentage(value: number);
  115244. /**
  115245. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115246. * and pinch delta percentage.
  115247. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115248. * that any object in the plane at the camera's target point will scale
  115249. * perfectly with finger motion.
  115250. */
  115251. get useNaturalPinchZoom(): boolean;
  115252. set useNaturalPinchZoom(value: boolean);
  115253. /**
  115254. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115255. */
  115256. get panningSensibility(): number;
  115257. set panningSensibility(value: number);
  115258. /**
  115259. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115260. */
  115261. get keysUp(): number[];
  115262. set keysUp(value: number[]);
  115263. /**
  115264. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115265. */
  115266. get keysDown(): number[];
  115267. set keysDown(value: number[]);
  115268. /**
  115269. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115270. */
  115271. get keysLeft(): number[];
  115272. set keysLeft(value: number[]);
  115273. /**
  115274. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115275. */
  115276. get keysRight(): number[];
  115277. set keysRight(value: number[]);
  115278. /**
  115279. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115280. */
  115281. get wheelPrecision(): number;
  115282. set wheelPrecision(value: number);
  115283. /**
  115284. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115285. * It will be used instead of pinchDeltaPrecision if different from 0.
  115286. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115287. */
  115288. get wheelDeltaPercentage(): number;
  115289. set wheelDeltaPercentage(value: number);
  115290. /**
  115291. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115292. */
  115293. zoomOnFactor: number;
  115294. /**
  115295. * Defines a screen offset for the camera position.
  115296. */
  115297. targetScreenOffset: Vector2;
  115298. /**
  115299. * Allows the camera to be completely reversed.
  115300. * If false the camera can not arrive upside down.
  115301. */
  115302. allowUpsideDown: boolean;
  115303. /**
  115304. * Define if double tap/click is used to restore the previously saved state of the camera.
  115305. */
  115306. useInputToRestoreState: boolean;
  115307. /** @hidden */
  115308. _viewMatrix: Matrix;
  115309. /** @hidden */
  115310. _useCtrlForPanning: boolean;
  115311. /** @hidden */
  115312. _panningMouseButton: number;
  115313. /**
  115314. * Defines the input associated to the camera.
  115315. */
  115316. inputs: ArcRotateCameraInputsManager;
  115317. /** @hidden */
  115318. _reset: () => void;
  115319. /**
  115320. * Defines the allowed panning axis.
  115321. */
  115322. panningAxis: Vector3;
  115323. protected _localDirection: Vector3;
  115324. protected _transformedDirection: Vector3;
  115325. private _bouncingBehavior;
  115326. /**
  115327. * Gets the bouncing behavior of the camera if it has been enabled.
  115328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115329. */
  115330. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115331. /**
  115332. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115334. */
  115335. get useBouncingBehavior(): boolean;
  115336. set useBouncingBehavior(value: boolean);
  115337. private _framingBehavior;
  115338. /**
  115339. * Gets the framing behavior of the camera if it has been enabled.
  115340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115341. */
  115342. get framingBehavior(): Nullable<FramingBehavior>;
  115343. /**
  115344. * Defines if the framing behavior of the camera is enabled on the camera.
  115345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115346. */
  115347. get useFramingBehavior(): boolean;
  115348. set useFramingBehavior(value: boolean);
  115349. private _autoRotationBehavior;
  115350. /**
  115351. * Gets the auto rotation behavior of the camera if it has been enabled.
  115352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115353. */
  115354. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115355. /**
  115356. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115357. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115358. */
  115359. get useAutoRotationBehavior(): boolean;
  115360. set useAutoRotationBehavior(value: boolean);
  115361. /**
  115362. * Observable triggered when the mesh target has been changed on the camera.
  115363. */
  115364. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115365. /**
  115366. * Event raised when the camera is colliding with a mesh.
  115367. */
  115368. onCollide: (collidedMesh: AbstractMesh) => void;
  115369. /**
  115370. * Defines whether the camera should check collision with the objects oh the scene.
  115371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115372. */
  115373. checkCollisions: boolean;
  115374. /**
  115375. * Defines the collision radius of the camera.
  115376. * This simulates a sphere around the camera.
  115377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115378. */
  115379. collisionRadius: Vector3;
  115380. protected _collider: Collider;
  115381. protected _previousPosition: Vector3;
  115382. protected _collisionVelocity: Vector3;
  115383. protected _newPosition: Vector3;
  115384. protected _previousAlpha: number;
  115385. protected _previousBeta: number;
  115386. protected _previousRadius: number;
  115387. protected _collisionTriggered: boolean;
  115388. protected _targetBoundingCenter: Nullable<Vector3>;
  115389. private _computationVector;
  115390. /**
  115391. * Instantiates a new ArcRotateCamera in a given scene
  115392. * @param name Defines the name of the camera
  115393. * @param alpha Defines the camera rotation along the logitudinal axis
  115394. * @param beta Defines the camera rotation along the latitudinal axis
  115395. * @param radius Defines the camera distance from its target
  115396. * @param target Defines the camera target
  115397. * @param scene Defines the scene the camera belongs to
  115398. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115399. */
  115400. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115401. /** @hidden */
  115402. _initCache(): void;
  115403. /** @hidden */
  115404. _updateCache(ignoreParentClass?: boolean): void;
  115405. protected _getTargetPosition(): Vector3;
  115406. private _storedAlpha;
  115407. private _storedBeta;
  115408. private _storedRadius;
  115409. private _storedTarget;
  115410. private _storedTargetScreenOffset;
  115411. /**
  115412. * Stores the current state of the camera (alpha, beta, radius and target)
  115413. * @returns the camera itself
  115414. */
  115415. storeState(): Camera;
  115416. /**
  115417. * @hidden
  115418. * Restored camera state. You must call storeState() first
  115419. */
  115420. _restoreStateValues(): boolean;
  115421. /** @hidden */
  115422. _isSynchronizedViewMatrix(): boolean;
  115423. /**
  115424. * Attached controls to the current camera.
  115425. * @param element Defines the element the controls should be listened from
  115426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115427. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115428. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115429. */
  115430. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115431. /**
  115432. * Detach the current controls from the camera.
  115433. * The camera will stop reacting to inputs.
  115434. * @param element Defines the element to stop listening the inputs from
  115435. */
  115436. detachControl(element: HTMLElement): void;
  115437. /** @hidden */
  115438. _checkInputs(): void;
  115439. protected _checkLimits(): void;
  115440. /**
  115441. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115442. */
  115443. rebuildAnglesAndRadius(): void;
  115444. /**
  115445. * Use a position to define the current camera related information like alpha, beta and radius
  115446. * @param position Defines the position to set the camera at
  115447. */
  115448. setPosition(position: Vector3): void;
  115449. /**
  115450. * Defines the target the camera should look at.
  115451. * This will automatically adapt alpha beta and radius to fit within the new target.
  115452. * @param target Defines the new target as a Vector or a mesh
  115453. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115454. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115455. */
  115456. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115457. /** @hidden */
  115458. _getViewMatrix(): Matrix;
  115459. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115460. /**
  115461. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115462. * @param meshes Defines the mesh to zoom on
  115463. * @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)
  115464. */
  115465. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115466. /**
  115467. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115468. * The target will be changed but the radius
  115469. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115470. * @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)
  115471. */
  115472. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115473. min: Vector3;
  115474. max: Vector3;
  115475. distance: number;
  115476. }, doNotUpdateMaxZ?: boolean): void;
  115477. /**
  115478. * @override
  115479. * Override Camera.createRigCamera
  115480. */
  115481. createRigCamera(name: string, cameraIndex: number): Camera;
  115482. /**
  115483. * @hidden
  115484. * @override
  115485. * Override Camera._updateRigCameras
  115486. */
  115487. _updateRigCameras(): void;
  115488. /**
  115489. * Destroy the camera and release the current resources hold by it.
  115490. */
  115491. dispose(): void;
  115492. /**
  115493. * Gets the current object class name.
  115494. * @return the class name
  115495. */
  115496. getClassName(): string;
  115497. }
  115498. }
  115499. declare module BABYLON {
  115500. /**
  115501. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115502. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115503. */
  115504. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115505. /**
  115506. * Gets the name of the behavior.
  115507. */
  115508. get name(): string;
  115509. private _zoomStopsAnimation;
  115510. private _idleRotationSpeed;
  115511. private _idleRotationWaitTime;
  115512. private _idleRotationSpinupTime;
  115513. /**
  115514. * Sets the flag that indicates if user zooming should stop animation.
  115515. */
  115516. set zoomStopsAnimation(flag: boolean);
  115517. /**
  115518. * Gets the flag that indicates if user zooming should stop animation.
  115519. */
  115520. get zoomStopsAnimation(): boolean;
  115521. /**
  115522. * Sets the default speed at which the camera rotates around the model.
  115523. */
  115524. set idleRotationSpeed(speed: number);
  115525. /**
  115526. * Gets the default speed at which the camera rotates around the model.
  115527. */
  115528. get idleRotationSpeed(): number;
  115529. /**
  115530. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115531. */
  115532. set idleRotationWaitTime(time: number);
  115533. /**
  115534. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115535. */
  115536. get idleRotationWaitTime(): number;
  115537. /**
  115538. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115539. */
  115540. set idleRotationSpinupTime(time: number);
  115541. /**
  115542. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115543. */
  115544. get idleRotationSpinupTime(): number;
  115545. /**
  115546. * Gets a value indicating if the camera is currently rotating because of this behavior
  115547. */
  115548. get rotationInProgress(): boolean;
  115549. private _onPrePointerObservableObserver;
  115550. private _onAfterCheckInputsObserver;
  115551. private _attachedCamera;
  115552. private _isPointerDown;
  115553. private _lastFrameTime;
  115554. private _lastInteractionTime;
  115555. private _cameraRotationSpeed;
  115556. /**
  115557. * Initializes the behavior.
  115558. */
  115559. init(): void;
  115560. /**
  115561. * Attaches the behavior to its arc rotate camera.
  115562. * @param camera Defines the camera to attach the behavior to
  115563. */
  115564. attach(camera: ArcRotateCamera): void;
  115565. /**
  115566. * Detaches the behavior from its current arc rotate camera.
  115567. */
  115568. detach(): void;
  115569. /**
  115570. * Returns true if user is scrolling.
  115571. * @return true if user is scrolling.
  115572. */
  115573. private _userIsZooming;
  115574. private _lastFrameRadius;
  115575. private _shouldAnimationStopForInteraction;
  115576. /**
  115577. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115578. */
  115579. private _applyUserInteraction;
  115580. private _userIsMoving;
  115581. }
  115582. }
  115583. declare module BABYLON {
  115584. /**
  115585. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115586. */
  115587. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115588. private ui;
  115589. /**
  115590. * The name of the behavior
  115591. */
  115592. name: string;
  115593. /**
  115594. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115595. */
  115596. distanceAwayFromFace: number;
  115597. /**
  115598. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115599. */
  115600. distanceAwayFromBottomOfFace: number;
  115601. private _faceVectors;
  115602. private _target;
  115603. private _scene;
  115604. private _onRenderObserver;
  115605. private _tmpMatrix;
  115606. private _tmpVector;
  115607. /**
  115608. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115609. * @param ui The transform node that should be attched to the mesh
  115610. */
  115611. constructor(ui: TransformNode);
  115612. /**
  115613. * Initializes the behavior
  115614. */
  115615. init(): void;
  115616. private _closestFace;
  115617. private _zeroVector;
  115618. private _lookAtTmpMatrix;
  115619. private _lookAtToRef;
  115620. /**
  115621. * Attaches the AttachToBoxBehavior to the passed in mesh
  115622. * @param target The mesh that the specified node will be attached to
  115623. */
  115624. attach(target: Mesh): void;
  115625. /**
  115626. * Detaches the behavior from the mesh
  115627. */
  115628. detach(): void;
  115629. }
  115630. }
  115631. declare module BABYLON {
  115632. /**
  115633. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115634. */
  115635. export class FadeInOutBehavior implements Behavior<Mesh> {
  115636. /**
  115637. * Time in milliseconds to delay before fading in (Default: 0)
  115638. */
  115639. delay: number;
  115640. /**
  115641. * Time in milliseconds for the mesh to fade in (Default: 300)
  115642. */
  115643. fadeInTime: number;
  115644. private _millisecondsPerFrame;
  115645. private _hovered;
  115646. private _hoverValue;
  115647. private _ownerNode;
  115648. /**
  115649. * Instatiates the FadeInOutBehavior
  115650. */
  115651. constructor();
  115652. /**
  115653. * The name of the behavior
  115654. */
  115655. get name(): string;
  115656. /**
  115657. * Initializes the behavior
  115658. */
  115659. init(): void;
  115660. /**
  115661. * Attaches the fade behavior on the passed in mesh
  115662. * @param ownerNode The mesh that will be faded in/out once attached
  115663. */
  115664. attach(ownerNode: Mesh): void;
  115665. /**
  115666. * Detaches the behavior from the mesh
  115667. */
  115668. detach(): void;
  115669. /**
  115670. * Triggers the mesh to begin fading in or out
  115671. * @param value if the object should fade in or out (true to fade in)
  115672. */
  115673. fadeIn(value: boolean): void;
  115674. private _update;
  115675. private _setAllVisibility;
  115676. }
  115677. }
  115678. declare module BABYLON {
  115679. /**
  115680. * Class containing a set of static utilities functions for managing Pivots
  115681. * @hidden
  115682. */
  115683. export class PivotTools {
  115684. private static _PivotCached;
  115685. private static _OldPivotPoint;
  115686. private static _PivotTranslation;
  115687. private static _PivotTmpVector;
  115688. /** @hidden */
  115689. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115690. /** @hidden */
  115691. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115692. }
  115693. }
  115694. declare module BABYLON {
  115695. /**
  115696. * Class containing static functions to help procedurally build meshes
  115697. */
  115698. export class PlaneBuilder {
  115699. /**
  115700. * Creates a plane mesh
  115701. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115702. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115703. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115707. * @param name defines the name of the mesh
  115708. * @param options defines the options used to create the mesh
  115709. * @param scene defines the hosting scene
  115710. * @returns the plane mesh
  115711. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115712. */
  115713. static CreatePlane(name: string, options: {
  115714. size?: number;
  115715. width?: number;
  115716. height?: number;
  115717. sideOrientation?: number;
  115718. frontUVs?: Vector4;
  115719. backUVs?: Vector4;
  115720. updatable?: boolean;
  115721. sourcePlane?: Plane;
  115722. }, scene?: Nullable<Scene>): Mesh;
  115723. }
  115724. }
  115725. declare module BABYLON {
  115726. /**
  115727. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115728. */
  115729. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115730. private static _AnyMouseID;
  115731. /**
  115732. * Abstract mesh the behavior is set on
  115733. */
  115734. attachedNode: AbstractMesh;
  115735. private _dragPlane;
  115736. private _scene;
  115737. private _pointerObserver;
  115738. private _beforeRenderObserver;
  115739. private static _planeScene;
  115740. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115741. /**
  115742. * 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)
  115743. */
  115744. maxDragAngle: number;
  115745. /**
  115746. * @hidden
  115747. */
  115748. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115749. /**
  115750. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115751. */
  115752. currentDraggingPointerID: number;
  115753. /**
  115754. * The last position where the pointer hit the drag plane in world space
  115755. */
  115756. lastDragPosition: Vector3;
  115757. /**
  115758. * If the behavior is currently in a dragging state
  115759. */
  115760. dragging: boolean;
  115761. /**
  115762. * 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)
  115763. */
  115764. dragDeltaRatio: number;
  115765. /**
  115766. * If the drag plane orientation should be updated during the dragging (Default: true)
  115767. */
  115768. updateDragPlane: boolean;
  115769. private _debugMode;
  115770. private _moving;
  115771. /**
  115772. * Fires each time the attached mesh is dragged with the pointer
  115773. * * delta between last drag position and current drag position in world space
  115774. * * dragDistance along the drag axis
  115775. * * dragPlaneNormal normal of the current drag plane used during the drag
  115776. * * dragPlanePoint in world space where the drag intersects the drag plane
  115777. */
  115778. onDragObservable: Observable<{
  115779. delta: Vector3;
  115780. dragPlanePoint: Vector3;
  115781. dragPlaneNormal: Vector3;
  115782. dragDistance: number;
  115783. pointerId: number;
  115784. }>;
  115785. /**
  115786. * Fires each time a drag begins (eg. mouse down on mesh)
  115787. */
  115788. onDragStartObservable: Observable<{
  115789. dragPlanePoint: Vector3;
  115790. pointerId: number;
  115791. }>;
  115792. /**
  115793. * Fires each time a drag ends (eg. mouse release after drag)
  115794. */
  115795. onDragEndObservable: Observable<{
  115796. dragPlanePoint: Vector3;
  115797. pointerId: number;
  115798. }>;
  115799. /**
  115800. * If the attached mesh should be moved when dragged
  115801. */
  115802. moveAttached: boolean;
  115803. /**
  115804. * If the drag behavior will react to drag events (Default: true)
  115805. */
  115806. enabled: boolean;
  115807. /**
  115808. * If pointer events should start and release the drag (Default: true)
  115809. */
  115810. startAndReleaseDragOnPointerEvents: boolean;
  115811. /**
  115812. * If camera controls should be detached during the drag
  115813. */
  115814. detachCameraControls: boolean;
  115815. /**
  115816. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115817. */
  115818. useObjectOrientationForDragging: boolean;
  115819. private _options;
  115820. /**
  115821. * Gets the options used by the behavior
  115822. */
  115823. get options(): {
  115824. dragAxis?: Vector3;
  115825. dragPlaneNormal?: Vector3;
  115826. };
  115827. /**
  115828. * Sets the options used by the behavior
  115829. */
  115830. set options(options: {
  115831. dragAxis?: Vector3;
  115832. dragPlaneNormal?: Vector3;
  115833. });
  115834. /**
  115835. * Creates a pointer drag behavior that can be attached to a mesh
  115836. * @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)
  115837. */
  115838. constructor(options?: {
  115839. dragAxis?: Vector3;
  115840. dragPlaneNormal?: Vector3;
  115841. });
  115842. /**
  115843. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115844. */
  115845. validateDrag: (targetPosition: Vector3) => boolean;
  115846. /**
  115847. * The name of the behavior
  115848. */
  115849. get name(): string;
  115850. /**
  115851. * Initializes the behavior
  115852. */
  115853. init(): void;
  115854. private _tmpVector;
  115855. private _alternatePickedPoint;
  115856. private _worldDragAxis;
  115857. private _targetPosition;
  115858. private _attachedElement;
  115859. /**
  115860. * Attaches the drag behavior the passed in mesh
  115861. * @param ownerNode The mesh that will be dragged around once attached
  115862. * @param predicate Predicate to use for pick filtering
  115863. */
  115864. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115865. /**
  115866. * Force relase the drag action by code.
  115867. */
  115868. releaseDrag(): void;
  115869. private _startDragRay;
  115870. private _lastPointerRay;
  115871. /**
  115872. * Simulates the start of a pointer drag event on the behavior
  115873. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115874. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115875. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115876. */
  115877. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115878. private _startDrag;
  115879. private _dragDelta;
  115880. private _moveDrag;
  115881. private _pickWithRayOnDragPlane;
  115882. private _pointA;
  115883. private _pointB;
  115884. private _pointC;
  115885. private _lineA;
  115886. private _lineB;
  115887. private _localAxis;
  115888. private _lookAt;
  115889. private _updateDragPlanePosition;
  115890. /**
  115891. * Detaches the behavior from the mesh
  115892. */
  115893. detach(): void;
  115894. }
  115895. }
  115896. declare module BABYLON {
  115897. /**
  115898. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115899. */
  115900. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115901. private _dragBehaviorA;
  115902. private _dragBehaviorB;
  115903. private _startDistance;
  115904. private _initialScale;
  115905. private _targetScale;
  115906. private _ownerNode;
  115907. private _sceneRenderObserver;
  115908. /**
  115909. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115910. */
  115911. constructor();
  115912. /**
  115913. * The name of the behavior
  115914. */
  115915. get name(): string;
  115916. /**
  115917. * Initializes the behavior
  115918. */
  115919. init(): void;
  115920. private _getCurrentDistance;
  115921. /**
  115922. * Attaches the scale behavior the passed in mesh
  115923. * @param ownerNode The mesh that will be scaled around once attached
  115924. */
  115925. attach(ownerNode: Mesh): void;
  115926. /**
  115927. * Detaches the behavior from the mesh
  115928. */
  115929. detach(): void;
  115930. }
  115931. }
  115932. declare module BABYLON {
  115933. /**
  115934. * 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
  115935. */
  115936. export class SixDofDragBehavior implements Behavior<Mesh> {
  115937. private static _virtualScene;
  115938. private _ownerNode;
  115939. private _sceneRenderObserver;
  115940. private _scene;
  115941. private _targetPosition;
  115942. private _virtualOriginMesh;
  115943. private _virtualDragMesh;
  115944. private _pointerObserver;
  115945. private _moving;
  115946. private _startingOrientation;
  115947. private _attachedElement;
  115948. /**
  115949. * 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)
  115950. */
  115951. private zDragFactor;
  115952. /**
  115953. * If the object should rotate to face the drag origin
  115954. */
  115955. rotateDraggedObject: boolean;
  115956. /**
  115957. * If the behavior is currently in a dragging state
  115958. */
  115959. dragging: boolean;
  115960. /**
  115961. * 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)
  115962. */
  115963. dragDeltaRatio: number;
  115964. /**
  115965. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115966. */
  115967. currentDraggingPointerID: number;
  115968. /**
  115969. * If camera controls should be detached during the drag
  115970. */
  115971. detachCameraControls: boolean;
  115972. /**
  115973. * Fires each time a drag starts
  115974. */
  115975. onDragStartObservable: Observable<{}>;
  115976. /**
  115977. * Fires each time a drag ends (eg. mouse release after drag)
  115978. */
  115979. onDragEndObservable: Observable<{}>;
  115980. /**
  115981. * 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
  115982. */
  115983. constructor();
  115984. /**
  115985. * The name of the behavior
  115986. */
  115987. get name(): string;
  115988. /**
  115989. * Initializes the behavior
  115990. */
  115991. init(): void;
  115992. /**
  115993. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  115994. */
  115995. private get _pointerCamera();
  115996. /**
  115997. * Attaches the scale behavior the passed in mesh
  115998. * @param ownerNode The mesh that will be scaled around once attached
  115999. */
  116000. attach(ownerNode: Mesh): void;
  116001. /**
  116002. * Detaches the behavior from the mesh
  116003. */
  116004. detach(): void;
  116005. }
  116006. }
  116007. declare module BABYLON {
  116008. /**
  116009. * Class used to apply inverse kinematics to bones
  116010. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  116011. */
  116012. export class BoneIKController {
  116013. private static _tmpVecs;
  116014. private static _tmpQuat;
  116015. private static _tmpMats;
  116016. /**
  116017. * Gets or sets the target mesh
  116018. */
  116019. targetMesh: AbstractMesh;
  116020. /** Gets or sets the mesh used as pole */
  116021. poleTargetMesh: AbstractMesh;
  116022. /**
  116023. * Gets or sets the bone used as pole
  116024. */
  116025. poleTargetBone: Nullable<Bone>;
  116026. /**
  116027. * Gets or sets the target position
  116028. */
  116029. targetPosition: Vector3;
  116030. /**
  116031. * Gets or sets the pole target position
  116032. */
  116033. poleTargetPosition: Vector3;
  116034. /**
  116035. * Gets or sets the pole target local offset
  116036. */
  116037. poleTargetLocalOffset: Vector3;
  116038. /**
  116039. * Gets or sets the pole angle
  116040. */
  116041. poleAngle: number;
  116042. /**
  116043. * Gets or sets the mesh associated with the controller
  116044. */
  116045. mesh: AbstractMesh;
  116046. /**
  116047. * 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)
  116048. */
  116049. slerpAmount: number;
  116050. private _bone1Quat;
  116051. private _bone1Mat;
  116052. private _bone2Ang;
  116053. private _bone1;
  116054. private _bone2;
  116055. private _bone1Length;
  116056. private _bone2Length;
  116057. private _maxAngle;
  116058. private _maxReach;
  116059. private _rightHandedSystem;
  116060. private _bendAxis;
  116061. private _slerping;
  116062. private _adjustRoll;
  116063. /**
  116064. * Gets or sets maximum allowed angle
  116065. */
  116066. get maxAngle(): number;
  116067. set maxAngle(value: number);
  116068. /**
  116069. * Creates a new BoneIKController
  116070. * @param mesh defines the mesh to control
  116071. * @param bone defines the bone to control
  116072. * @param options defines options to set up the controller
  116073. */
  116074. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  116075. targetMesh?: AbstractMesh;
  116076. poleTargetMesh?: AbstractMesh;
  116077. poleTargetBone?: Bone;
  116078. poleTargetLocalOffset?: Vector3;
  116079. poleAngle?: number;
  116080. bendAxis?: Vector3;
  116081. maxAngle?: number;
  116082. slerpAmount?: number;
  116083. });
  116084. private _setMaxAngle;
  116085. /**
  116086. * Force the controller to update the bones
  116087. */
  116088. update(): void;
  116089. }
  116090. }
  116091. declare module BABYLON {
  116092. /**
  116093. * Class used to make a bone look toward a point in space
  116094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  116095. */
  116096. export class BoneLookController {
  116097. private static _tmpVecs;
  116098. private static _tmpQuat;
  116099. private static _tmpMats;
  116100. /**
  116101. * The target Vector3 that the bone will look at
  116102. */
  116103. target: Vector3;
  116104. /**
  116105. * The mesh that the bone is attached to
  116106. */
  116107. mesh: AbstractMesh;
  116108. /**
  116109. * The bone that will be looking to the target
  116110. */
  116111. bone: Bone;
  116112. /**
  116113. * The up axis of the coordinate system that is used when the bone is rotated
  116114. */
  116115. upAxis: Vector3;
  116116. /**
  116117. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  116118. */
  116119. upAxisSpace: Space;
  116120. /**
  116121. * Used to make an adjustment to the yaw of the bone
  116122. */
  116123. adjustYaw: number;
  116124. /**
  116125. * Used to make an adjustment to the pitch of the bone
  116126. */
  116127. adjustPitch: number;
  116128. /**
  116129. * Used to make an adjustment to the roll of the bone
  116130. */
  116131. adjustRoll: number;
  116132. /**
  116133. * 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)
  116134. */
  116135. slerpAmount: number;
  116136. private _minYaw;
  116137. private _maxYaw;
  116138. private _minPitch;
  116139. private _maxPitch;
  116140. private _minYawSin;
  116141. private _minYawCos;
  116142. private _maxYawSin;
  116143. private _maxYawCos;
  116144. private _midYawConstraint;
  116145. private _minPitchTan;
  116146. private _maxPitchTan;
  116147. private _boneQuat;
  116148. private _slerping;
  116149. private _transformYawPitch;
  116150. private _transformYawPitchInv;
  116151. private _firstFrameSkipped;
  116152. private _yawRange;
  116153. private _fowardAxis;
  116154. /**
  116155. * Gets or sets the minimum yaw angle that the bone can look to
  116156. */
  116157. get minYaw(): number;
  116158. set minYaw(value: number);
  116159. /**
  116160. * Gets or sets the maximum yaw angle that the bone can look to
  116161. */
  116162. get maxYaw(): number;
  116163. set maxYaw(value: number);
  116164. /**
  116165. * Gets or sets the minimum pitch angle that the bone can look to
  116166. */
  116167. get minPitch(): number;
  116168. set minPitch(value: number);
  116169. /**
  116170. * Gets or sets the maximum pitch angle that the bone can look to
  116171. */
  116172. get maxPitch(): number;
  116173. set maxPitch(value: number);
  116174. /**
  116175. * Create a BoneLookController
  116176. * @param mesh the mesh that the bone belongs to
  116177. * @param bone the bone that will be looking to the target
  116178. * @param target the target Vector3 to look at
  116179. * @param options optional settings:
  116180. * * maxYaw: the maximum angle the bone will yaw to
  116181. * * minYaw: the minimum angle the bone will yaw to
  116182. * * maxPitch: the maximum angle the bone will pitch to
  116183. * * minPitch: the minimum angle the bone will yaw to
  116184. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  116185. * * upAxis: the up axis of the coordinate system
  116186. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  116187. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  116188. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  116189. * * adjustYaw: used to make an adjustment to the yaw of the bone
  116190. * * adjustPitch: used to make an adjustment to the pitch of the bone
  116191. * * adjustRoll: used to make an adjustment to the roll of the bone
  116192. **/
  116193. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  116194. maxYaw?: number;
  116195. minYaw?: number;
  116196. maxPitch?: number;
  116197. minPitch?: number;
  116198. slerpAmount?: number;
  116199. upAxis?: Vector3;
  116200. upAxisSpace?: Space;
  116201. yawAxis?: Vector3;
  116202. pitchAxis?: Vector3;
  116203. adjustYaw?: number;
  116204. adjustPitch?: number;
  116205. adjustRoll?: number;
  116206. });
  116207. /**
  116208. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  116209. */
  116210. update(): void;
  116211. private _getAngleDiff;
  116212. private _getAngleBetween;
  116213. private _isAngleBetween;
  116214. }
  116215. }
  116216. declare module BABYLON {
  116217. /**
  116218. * Manage the gamepad inputs to control an arc rotate camera.
  116219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116220. */
  116221. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116222. /**
  116223. * Defines the camera the input is attached to.
  116224. */
  116225. camera: ArcRotateCamera;
  116226. /**
  116227. * Defines the gamepad the input is gathering event from.
  116228. */
  116229. gamepad: Nullable<Gamepad>;
  116230. /**
  116231. * Defines the gamepad rotation sensiblity.
  116232. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116233. */
  116234. gamepadRotationSensibility: number;
  116235. /**
  116236. * Defines the gamepad move sensiblity.
  116237. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116238. */
  116239. gamepadMoveSensibility: number;
  116240. private _yAxisScale;
  116241. /**
  116242. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116243. */
  116244. get invertYAxis(): boolean;
  116245. set invertYAxis(value: boolean);
  116246. private _onGamepadConnectedObserver;
  116247. private _onGamepadDisconnectedObserver;
  116248. /**
  116249. * Attach the input controls to a specific dom element to get the input from.
  116250. * @param element Defines the element the controls should be listened from
  116251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116252. */
  116253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116254. /**
  116255. * Detach the current controls from the specified dom element.
  116256. * @param element Defines the element to stop listening the inputs from
  116257. */
  116258. detachControl(element: Nullable<HTMLElement>): void;
  116259. /**
  116260. * Update the current camera state depending on the inputs that have been used this frame.
  116261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116262. */
  116263. checkInputs(): void;
  116264. /**
  116265. * Gets the class name of the current intput.
  116266. * @returns the class name
  116267. */
  116268. getClassName(): string;
  116269. /**
  116270. * Get the friendly name associated with the input class.
  116271. * @returns the input friendly name
  116272. */
  116273. getSimpleName(): string;
  116274. }
  116275. }
  116276. declare module BABYLON {
  116277. interface ArcRotateCameraInputsManager {
  116278. /**
  116279. * Add orientation input support to the input manager.
  116280. * @returns the current input manager
  116281. */
  116282. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116283. }
  116284. /**
  116285. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116287. */
  116288. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116289. /**
  116290. * Defines the camera the input is attached to.
  116291. */
  116292. camera: ArcRotateCamera;
  116293. /**
  116294. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116295. */
  116296. alphaCorrection: number;
  116297. /**
  116298. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116299. */
  116300. gammaCorrection: number;
  116301. private _alpha;
  116302. private _gamma;
  116303. private _dirty;
  116304. private _deviceOrientationHandler;
  116305. /**
  116306. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116307. */
  116308. constructor();
  116309. /**
  116310. * Attach the input controls to a specific dom element to get the input from.
  116311. * @param element Defines the element the controls should be listened from
  116312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116313. */
  116314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116315. /** @hidden */
  116316. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116317. /**
  116318. * Update the current camera state depending on the inputs that have been used this frame.
  116319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116320. */
  116321. checkInputs(): void;
  116322. /**
  116323. * Detach the current controls from the specified dom element.
  116324. * @param element Defines the element to stop listening the inputs from
  116325. */
  116326. detachControl(element: Nullable<HTMLElement>): void;
  116327. /**
  116328. * Gets the class name of the current intput.
  116329. * @returns the class name
  116330. */
  116331. getClassName(): string;
  116332. /**
  116333. * Get the friendly name associated with the input class.
  116334. * @returns the input friendly name
  116335. */
  116336. getSimpleName(): string;
  116337. }
  116338. }
  116339. declare module BABYLON {
  116340. /**
  116341. * Listen to mouse events to control the camera.
  116342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116343. */
  116344. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116345. /**
  116346. * Defines the camera the input is attached to.
  116347. */
  116348. camera: FlyCamera;
  116349. /**
  116350. * Defines if touch is enabled. (Default is true.)
  116351. */
  116352. touchEnabled: boolean;
  116353. /**
  116354. * Defines the buttons associated with the input to handle camera rotation.
  116355. */
  116356. buttons: number[];
  116357. /**
  116358. * Assign buttons for Yaw control.
  116359. */
  116360. buttonsYaw: number[];
  116361. /**
  116362. * Assign buttons for Pitch control.
  116363. */
  116364. buttonsPitch: number[];
  116365. /**
  116366. * Assign buttons for Roll control.
  116367. */
  116368. buttonsRoll: number[];
  116369. /**
  116370. * Detect if any button is being pressed while mouse is moved.
  116371. * -1 = Mouse locked.
  116372. * 0 = Left button.
  116373. * 1 = Middle Button.
  116374. * 2 = Right Button.
  116375. */
  116376. activeButton: number;
  116377. /**
  116378. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116379. * Higher values reduce its sensitivity.
  116380. */
  116381. angularSensibility: number;
  116382. private _mousemoveCallback;
  116383. private _observer;
  116384. private _rollObserver;
  116385. private previousPosition;
  116386. private noPreventDefault;
  116387. private element;
  116388. /**
  116389. * Listen to mouse events to control the camera.
  116390. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116392. */
  116393. constructor(touchEnabled?: boolean);
  116394. /**
  116395. * Attach the mouse control to the HTML DOM element.
  116396. * @param element Defines the element that listens to the input events.
  116397. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116398. */
  116399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116400. /**
  116401. * Detach the current controls from the specified dom element.
  116402. * @param element Defines the element to stop listening the inputs from
  116403. */
  116404. detachControl(element: Nullable<HTMLElement>): void;
  116405. /**
  116406. * Gets the class name of the current input.
  116407. * @returns the class name.
  116408. */
  116409. getClassName(): string;
  116410. /**
  116411. * Get the friendly name associated with the input class.
  116412. * @returns the input's friendly name.
  116413. */
  116414. getSimpleName(): string;
  116415. private _pointerInput;
  116416. private _onMouseMove;
  116417. /**
  116418. * Rotate camera by mouse offset.
  116419. */
  116420. private rotateCamera;
  116421. }
  116422. }
  116423. declare module BABYLON {
  116424. /**
  116425. * Default Inputs manager for the FlyCamera.
  116426. * It groups all the default supported inputs for ease of use.
  116427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116428. */
  116429. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116430. /**
  116431. * Instantiates a new FlyCameraInputsManager.
  116432. * @param camera Defines the camera the inputs belong to.
  116433. */
  116434. constructor(camera: FlyCamera);
  116435. /**
  116436. * Add keyboard input support to the input manager.
  116437. * @returns the new FlyCameraKeyboardMoveInput().
  116438. */
  116439. addKeyboard(): FlyCameraInputsManager;
  116440. /**
  116441. * Add mouse input support to the input manager.
  116442. * @param touchEnabled Enable touch screen support.
  116443. * @returns the new FlyCameraMouseInput().
  116444. */
  116445. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116446. }
  116447. }
  116448. declare module BABYLON {
  116449. /**
  116450. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116451. * such as in a 3D Space Shooter or a Flight Simulator.
  116452. */
  116453. export class FlyCamera extends TargetCamera {
  116454. /**
  116455. * Define the collision ellipsoid of the camera.
  116456. * This is helpful for simulating a camera body, like a player's body.
  116457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116458. */
  116459. ellipsoid: Vector3;
  116460. /**
  116461. * Define an offset for the position of the ellipsoid around the camera.
  116462. * This can be helpful if the camera is attached away from the player's body center,
  116463. * such as at its head.
  116464. */
  116465. ellipsoidOffset: Vector3;
  116466. /**
  116467. * Enable or disable collisions of the camera with the rest of the scene objects.
  116468. */
  116469. checkCollisions: boolean;
  116470. /**
  116471. * Enable or disable gravity on the camera.
  116472. */
  116473. applyGravity: boolean;
  116474. /**
  116475. * Define the current direction the camera is moving to.
  116476. */
  116477. cameraDirection: Vector3;
  116478. /**
  116479. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116480. * This overrides and empties cameraRotation.
  116481. */
  116482. rotationQuaternion: Quaternion;
  116483. /**
  116484. * Track Roll to maintain the wanted Rolling when looking around.
  116485. */
  116486. _trackRoll: number;
  116487. /**
  116488. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116489. */
  116490. rollCorrect: number;
  116491. /**
  116492. * Mimic a banked turn, Rolling the camera when Yawing.
  116493. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116494. */
  116495. bankedTurn: boolean;
  116496. /**
  116497. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116498. */
  116499. bankedTurnLimit: number;
  116500. /**
  116501. * Value of 0 disables the banked Roll.
  116502. * Value of 1 is equal to the Yaw angle in radians.
  116503. */
  116504. bankedTurnMultiplier: number;
  116505. /**
  116506. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116507. */
  116508. inputs: FlyCameraInputsManager;
  116509. /**
  116510. * Gets the input sensibility for mouse input.
  116511. * Higher values reduce sensitivity.
  116512. */
  116513. get angularSensibility(): number;
  116514. /**
  116515. * Sets the input sensibility for a mouse input.
  116516. * Higher values reduce sensitivity.
  116517. */
  116518. set angularSensibility(value: number);
  116519. /**
  116520. * Get the keys for camera movement forward.
  116521. */
  116522. get keysForward(): number[];
  116523. /**
  116524. * Set the keys for camera movement forward.
  116525. */
  116526. set keysForward(value: number[]);
  116527. /**
  116528. * Get the keys for camera movement backward.
  116529. */
  116530. get keysBackward(): number[];
  116531. set keysBackward(value: number[]);
  116532. /**
  116533. * Get the keys for camera movement up.
  116534. */
  116535. get keysUp(): number[];
  116536. /**
  116537. * Set the keys for camera movement up.
  116538. */
  116539. set keysUp(value: number[]);
  116540. /**
  116541. * Get the keys for camera movement down.
  116542. */
  116543. get keysDown(): number[];
  116544. /**
  116545. * Set the keys for camera movement down.
  116546. */
  116547. set keysDown(value: number[]);
  116548. /**
  116549. * Get the keys for camera movement left.
  116550. */
  116551. get keysLeft(): number[];
  116552. /**
  116553. * Set the keys for camera movement left.
  116554. */
  116555. set keysLeft(value: number[]);
  116556. /**
  116557. * Set the keys for camera movement right.
  116558. */
  116559. get keysRight(): number[];
  116560. /**
  116561. * Set the keys for camera movement right.
  116562. */
  116563. set keysRight(value: number[]);
  116564. /**
  116565. * Event raised when the camera collides with a mesh in the scene.
  116566. */
  116567. onCollide: (collidedMesh: AbstractMesh) => void;
  116568. private _collider;
  116569. private _needMoveForGravity;
  116570. private _oldPosition;
  116571. private _diffPosition;
  116572. private _newPosition;
  116573. /** @hidden */
  116574. _localDirection: Vector3;
  116575. /** @hidden */
  116576. _transformedDirection: Vector3;
  116577. /**
  116578. * Instantiates a FlyCamera.
  116579. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116580. * such as in a 3D Space Shooter or a Flight Simulator.
  116581. * @param name Define the name of the camera in the scene.
  116582. * @param position Define the starting position of the camera in the scene.
  116583. * @param scene Define the scene the camera belongs to.
  116584. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116585. */
  116586. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116587. /**
  116588. * Attach a control to the HTML DOM element.
  116589. * @param element Defines the element that listens to the input events.
  116590. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116591. */
  116592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116593. /**
  116594. * Detach a control from the HTML DOM element.
  116595. * The camera will stop reacting to that input.
  116596. * @param element Defines the element that listens to the input events.
  116597. */
  116598. detachControl(element: HTMLElement): void;
  116599. private _collisionMask;
  116600. /**
  116601. * Get the mask that the camera ignores in collision events.
  116602. */
  116603. get collisionMask(): number;
  116604. /**
  116605. * Set the mask that the camera ignores in collision events.
  116606. */
  116607. set collisionMask(mask: number);
  116608. /** @hidden */
  116609. _collideWithWorld(displacement: Vector3): void;
  116610. /** @hidden */
  116611. private _onCollisionPositionChange;
  116612. /** @hidden */
  116613. _checkInputs(): void;
  116614. /** @hidden */
  116615. _decideIfNeedsToMove(): boolean;
  116616. /** @hidden */
  116617. _updatePosition(): void;
  116618. /**
  116619. * Restore the Roll to its target value at the rate specified.
  116620. * @param rate - Higher means slower restoring.
  116621. * @hidden
  116622. */
  116623. restoreRoll(rate: number): void;
  116624. /**
  116625. * Destroy the camera and release the current resources held by it.
  116626. */
  116627. dispose(): void;
  116628. /**
  116629. * Get the current object class name.
  116630. * @returns the class name.
  116631. */
  116632. getClassName(): string;
  116633. }
  116634. }
  116635. declare module BABYLON {
  116636. /**
  116637. * Listen to keyboard events to control the camera.
  116638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116639. */
  116640. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116641. /**
  116642. * Defines the camera the input is attached to.
  116643. */
  116644. camera: FlyCamera;
  116645. /**
  116646. * The list of keyboard keys used to control the forward move of the camera.
  116647. */
  116648. keysForward: number[];
  116649. /**
  116650. * The list of keyboard keys used to control the backward move of the camera.
  116651. */
  116652. keysBackward: number[];
  116653. /**
  116654. * The list of keyboard keys used to control the forward move of the camera.
  116655. */
  116656. keysUp: number[];
  116657. /**
  116658. * The list of keyboard keys used to control the backward move of the camera.
  116659. */
  116660. keysDown: number[];
  116661. /**
  116662. * The list of keyboard keys used to control the right strafe move of the camera.
  116663. */
  116664. keysRight: number[];
  116665. /**
  116666. * The list of keyboard keys used to control the left strafe move of the camera.
  116667. */
  116668. keysLeft: number[];
  116669. private _keys;
  116670. private _onCanvasBlurObserver;
  116671. private _onKeyboardObserver;
  116672. private _engine;
  116673. private _scene;
  116674. /**
  116675. * Attach the input controls to a specific dom element to get the input from.
  116676. * @param element Defines the element the controls should be listened from
  116677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116678. */
  116679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116680. /**
  116681. * Detach the current controls from the specified dom element.
  116682. * @param element Defines the element to stop listening the inputs from
  116683. */
  116684. detachControl(element: Nullable<HTMLElement>): void;
  116685. /**
  116686. * Gets the class name of the current intput.
  116687. * @returns the class name
  116688. */
  116689. getClassName(): string;
  116690. /** @hidden */
  116691. _onLostFocus(e: FocusEvent): void;
  116692. /**
  116693. * Get the friendly name associated with the input class.
  116694. * @returns the input friendly name
  116695. */
  116696. getSimpleName(): string;
  116697. /**
  116698. * Update the current camera state depending on the inputs that have been used this frame.
  116699. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116700. */
  116701. checkInputs(): void;
  116702. }
  116703. }
  116704. declare module BABYLON {
  116705. /**
  116706. * Manage the mouse wheel inputs to control a follow camera.
  116707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116708. */
  116709. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116710. /**
  116711. * Defines the camera the input is attached to.
  116712. */
  116713. camera: FollowCamera;
  116714. /**
  116715. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116716. */
  116717. axisControlRadius: boolean;
  116718. /**
  116719. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116720. */
  116721. axisControlHeight: boolean;
  116722. /**
  116723. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116724. */
  116725. axisControlRotation: boolean;
  116726. /**
  116727. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116728. * relation to mouseWheel events.
  116729. */
  116730. wheelPrecision: number;
  116731. /**
  116732. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116733. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116734. */
  116735. wheelDeltaPercentage: number;
  116736. private _wheel;
  116737. private _observer;
  116738. /**
  116739. * Attach the input controls to a specific dom element to get the input from.
  116740. * @param element Defines the element the controls should be listened from
  116741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116742. */
  116743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116744. /**
  116745. * Detach the current controls from the specified dom element.
  116746. * @param element Defines the element to stop listening the inputs from
  116747. */
  116748. detachControl(element: Nullable<HTMLElement>): void;
  116749. /**
  116750. * Gets the class name of the current intput.
  116751. * @returns the class name
  116752. */
  116753. getClassName(): string;
  116754. /**
  116755. * Get the friendly name associated with the input class.
  116756. * @returns the input friendly name
  116757. */
  116758. getSimpleName(): string;
  116759. }
  116760. }
  116761. declare module BABYLON {
  116762. /**
  116763. * Manage the pointers inputs to control an follow camera.
  116764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116765. */
  116766. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116767. /**
  116768. * Defines the camera the input is attached to.
  116769. */
  116770. camera: FollowCamera;
  116771. /**
  116772. * Gets the class name of the current input.
  116773. * @returns the class name
  116774. */
  116775. getClassName(): string;
  116776. /**
  116777. * Defines the pointer angular sensibility along the X axis or how fast is
  116778. * the camera rotating.
  116779. * A negative number will reverse the axis direction.
  116780. */
  116781. angularSensibilityX: number;
  116782. /**
  116783. * Defines the pointer angular sensibility along the Y axis or how fast is
  116784. * the camera rotating.
  116785. * A negative number will reverse the axis direction.
  116786. */
  116787. angularSensibilityY: number;
  116788. /**
  116789. * Defines the pointer pinch precision or how fast is the camera zooming.
  116790. * A negative number will reverse the axis direction.
  116791. */
  116792. pinchPrecision: number;
  116793. /**
  116794. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116795. * from 0.
  116796. * It defines the percentage of current camera.radius to use as delta when
  116797. * pinch zoom is used.
  116798. */
  116799. pinchDeltaPercentage: number;
  116800. /**
  116801. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116802. */
  116803. axisXControlRadius: boolean;
  116804. /**
  116805. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116806. */
  116807. axisXControlHeight: boolean;
  116808. /**
  116809. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116810. */
  116811. axisXControlRotation: boolean;
  116812. /**
  116813. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116814. */
  116815. axisYControlRadius: boolean;
  116816. /**
  116817. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116818. */
  116819. axisYControlHeight: boolean;
  116820. /**
  116821. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116822. */
  116823. axisYControlRotation: boolean;
  116824. /**
  116825. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116826. */
  116827. axisPinchControlRadius: boolean;
  116828. /**
  116829. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116830. */
  116831. axisPinchControlHeight: boolean;
  116832. /**
  116833. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116834. */
  116835. axisPinchControlRotation: boolean;
  116836. /**
  116837. * Log error messages if basic misconfiguration has occurred.
  116838. */
  116839. warningEnable: boolean;
  116840. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116841. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116842. private _warningCounter;
  116843. private _warning;
  116844. }
  116845. }
  116846. declare module BABYLON {
  116847. /**
  116848. * Default Inputs manager for the FollowCamera.
  116849. * It groups all the default supported inputs for ease of use.
  116850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116851. */
  116852. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116853. /**
  116854. * Instantiates a new FollowCameraInputsManager.
  116855. * @param camera Defines the camera the inputs belong to
  116856. */
  116857. constructor(camera: FollowCamera);
  116858. /**
  116859. * Add keyboard input support to the input manager.
  116860. * @returns the current input manager
  116861. */
  116862. addKeyboard(): FollowCameraInputsManager;
  116863. /**
  116864. * Add mouse wheel input support to the input manager.
  116865. * @returns the current input manager
  116866. */
  116867. addMouseWheel(): FollowCameraInputsManager;
  116868. /**
  116869. * Add pointers input support to the input manager.
  116870. * @returns the current input manager
  116871. */
  116872. addPointers(): FollowCameraInputsManager;
  116873. /**
  116874. * Add orientation input support to the input manager.
  116875. * @returns the current input manager
  116876. */
  116877. addVRDeviceOrientation(): FollowCameraInputsManager;
  116878. }
  116879. }
  116880. declare module BABYLON {
  116881. /**
  116882. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116883. * an arc rotate version arcFollowCamera are available.
  116884. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116885. */
  116886. export class FollowCamera extends TargetCamera {
  116887. /**
  116888. * Distance the follow camera should follow an object at
  116889. */
  116890. radius: number;
  116891. /**
  116892. * Minimum allowed distance of the camera to the axis of rotation
  116893. * (The camera can not get closer).
  116894. * This can help limiting how the Camera is able to move in the scene.
  116895. */
  116896. lowerRadiusLimit: Nullable<number>;
  116897. /**
  116898. * Maximum allowed distance of the camera to the axis of rotation
  116899. * (The camera can not get further).
  116900. * This can help limiting how the Camera is able to move in the scene.
  116901. */
  116902. upperRadiusLimit: Nullable<number>;
  116903. /**
  116904. * Define a rotation offset between the camera and the object it follows
  116905. */
  116906. rotationOffset: number;
  116907. /**
  116908. * Minimum allowed angle to camera position relative to target object.
  116909. * This can help limiting how the Camera is able to move in the scene.
  116910. */
  116911. lowerRotationOffsetLimit: Nullable<number>;
  116912. /**
  116913. * Maximum allowed angle to camera position relative to target object.
  116914. * This can help limiting how the Camera is able to move in the scene.
  116915. */
  116916. upperRotationOffsetLimit: Nullable<number>;
  116917. /**
  116918. * Define a height offset between the camera and the object it follows.
  116919. * It can help following an object from the top (like a car chaing a plane)
  116920. */
  116921. heightOffset: number;
  116922. /**
  116923. * Minimum allowed height of camera position relative to target object.
  116924. * This can help limiting how the Camera is able to move in the scene.
  116925. */
  116926. lowerHeightOffsetLimit: Nullable<number>;
  116927. /**
  116928. * Maximum allowed height of camera position relative to target object.
  116929. * This can help limiting how the Camera is able to move in the scene.
  116930. */
  116931. upperHeightOffsetLimit: Nullable<number>;
  116932. /**
  116933. * Define how fast the camera can accelerate to follow it s target.
  116934. */
  116935. cameraAcceleration: number;
  116936. /**
  116937. * Define the speed limit of the camera following an object.
  116938. */
  116939. maxCameraSpeed: number;
  116940. /**
  116941. * Define the target of the camera.
  116942. */
  116943. lockedTarget: Nullable<AbstractMesh>;
  116944. /**
  116945. * Defines the input associated with the camera.
  116946. */
  116947. inputs: FollowCameraInputsManager;
  116948. /**
  116949. * Instantiates the follow camera.
  116950. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116951. * @param name Define the name of the camera in the scene
  116952. * @param position Define the position of the camera
  116953. * @param scene Define the scene the camera belong to
  116954. * @param lockedTarget Define the target of the camera
  116955. */
  116956. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  116957. private _follow;
  116958. /**
  116959. * Attached controls to the current camera.
  116960. * @param element Defines the element the controls should be listened from
  116961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116962. */
  116963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116964. /**
  116965. * Detach the current controls from the camera.
  116966. * The camera will stop reacting to inputs.
  116967. * @param element Defines the element to stop listening the inputs from
  116968. */
  116969. detachControl(element: HTMLElement): void;
  116970. /** @hidden */
  116971. _checkInputs(): void;
  116972. private _checkLimits;
  116973. /**
  116974. * Gets the camera class name.
  116975. * @returns the class name
  116976. */
  116977. getClassName(): string;
  116978. }
  116979. /**
  116980. * Arc Rotate version of the follow camera.
  116981. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  116982. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116983. */
  116984. export class ArcFollowCamera extends TargetCamera {
  116985. /** The longitudinal angle of the camera */
  116986. alpha: number;
  116987. /** The latitudinal angle of the camera */
  116988. beta: number;
  116989. /** The radius of the camera from its target */
  116990. radius: number;
  116991. /** Define the camera target (the messh it should follow) */
  116992. target: Nullable<AbstractMesh>;
  116993. private _cartesianCoordinates;
  116994. /**
  116995. * Instantiates a new ArcFollowCamera
  116996. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116997. * @param name Define the name of the camera
  116998. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  116999. * @param beta Define the rotation angle of the camera around the elevation axis
  117000. * @param radius Define the radius of the camera from its target point
  117001. * @param target Define the target of the camera
  117002. * @param scene Define the scene the camera belongs to
  117003. */
  117004. constructor(name: string,
  117005. /** The longitudinal angle of the camera */
  117006. alpha: number,
  117007. /** The latitudinal angle of the camera */
  117008. beta: number,
  117009. /** The radius of the camera from its target */
  117010. radius: number,
  117011. /** Define the camera target (the messh it should follow) */
  117012. target: Nullable<AbstractMesh>, scene: Scene);
  117013. private _follow;
  117014. /** @hidden */
  117015. _checkInputs(): void;
  117016. /**
  117017. * Returns the class name of the object.
  117018. * It is mostly used internally for serialization purposes.
  117019. */
  117020. getClassName(): string;
  117021. }
  117022. }
  117023. declare module BABYLON {
  117024. /**
  117025. * Manage the keyboard inputs to control the movement of a follow camera.
  117026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117027. */
  117028. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  117029. /**
  117030. * Defines the camera the input is attached to.
  117031. */
  117032. camera: FollowCamera;
  117033. /**
  117034. * Defines the list of key codes associated with the up action (increase heightOffset)
  117035. */
  117036. keysHeightOffsetIncr: number[];
  117037. /**
  117038. * Defines the list of key codes associated with the down action (decrease heightOffset)
  117039. */
  117040. keysHeightOffsetDecr: number[];
  117041. /**
  117042. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  117043. */
  117044. keysHeightOffsetModifierAlt: boolean;
  117045. /**
  117046. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  117047. */
  117048. keysHeightOffsetModifierCtrl: boolean;
  117049. /**
  117050. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  117051. */
  117052. keysHeightOffsetModifierShift: boolean;
  117053. /**
  117054. * Defines the list of key codes associated with the left action (increase rotationOffset)
  117055. */
  117056. keysRotationOffsetIncr: number[];
  117057. /**
  117058. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  117059. */
  117060. keysRotationOffsetDecr: number[];
  117061. /**
  117062. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  117063. */
  117064. keysRotationOffsetModifierAlt: boolean;
  117065. /**
  117066. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  117067. */
  117068. keysRotationOffsetModifierCtrl: boolean;
  117069. /**
  117070. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  117071. */
  117072. keysRotationOffsetModifierShift: boolean;
  117073. /**
  117074. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  117075. */
  117076. keysRadiusIncr: number[];
  117077. /**
  117078. * Defines the list of key codes associated with the zoom-out action (increase radius)
  117079. */
  117080. keysRadiusDecr: number[];
  117081. /**
  117082. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  117083. */
  117084. keysRadiusModifierAlt: boolean;
  117085. /**
  117086. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  117087. */
  117088. keysRadiusModifierCtrl: boolean;
  117089. /**
  117090. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  117091. */
  117092. keysRadiusModifierShift: boolean;
  117093. /**
  117094. * Defines the rate of change of heightOffset.
  117095. */
  117096. heightSensibility: number;
  117097. /**
  117098. * Defines the rate of change of rotationOffset.
  117099. */
  117100. rotationSensibility: number;
  117101. /**
  117102. * Defines the rate of change of radius.
  117103. */
  117104. radiusSensibility: number;
  117105. private _keys;
  117106. private _ctrlPressed;
  117107. private _altPressed;
  117108. private _shiftPressed;
  117109. private _onCanvasBlurObserver;
  117110. private _onKeyboardObserver;
  117111. private _engine;
  117112. private _scene;
  117113. /**
  117114. * Attach the input controls to a specific dom element to get the input from.
  117115. * @param element Defines the element the controls should be listened from
  117116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117117. */
  117118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117119. /**
  117120. * Detach the current controls from the specified dom element.
  117121. * @param element Defines the element to stop listening the inputs from
  117122. */
  117123. detachControl(element: Nullable<HTMLElement>): void;
  117124. /**
  117125. * Update the current camera state depending on the inputs that have been used this frame.
  117126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117127. */
  117128. checkInputs(): void;
  117129. /**
  117130. * Gets the class name of the current input.
  117131. * @returns the class name
  117132. */
  117133. getClassName(): string;
  117134. /**
  117135. * Get the friendly name associated with the input class.
  117136. * @returns the input friendly name
  117137. */
  117138. getSimpleName(): string;
  117139. /**
  117140. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117141. * allow modification of the heightOffset value.
  117142. */
  117143. private _modifierHeightOffset;
  117144. /**
  117145. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117146. * allow modification of the rotationOffset value.
  117147. */
  117148. private _modifierRotationOffset;
  117149. /**
  117150. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  117151. * allow modification of the radius value.
  117152. */
  117153. private _modifierRadius;
  117154. }
  117155. }
  117156. declare module BABYLON {
  117157. interface FreeCameraInputsManager {
  117158. /**
  117159. * @hidden
  117160. */
  117161. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  117162. /**
  117163. * Add orientation input support to the input manager.
  117164. * @returns the current input manager
  117165. */
  117166. addDeviceOrientation(): FreeCameraInputsManager;
  117167. }
  117168. /**
  117169. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  117170. * Screen rotation is taken into account.
  117171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117172. */
  117173. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  117174. private _camera;
  117175. private _screenOrientationAngle;
  117176. private _constantTranform;
  117177. private _screenQuaternion;
  117178. private _alpha;
  117179. private _beta;
  117180. private _gamma;
  117181. /**
  117182. * Can be used to detect if a device orientation sensor is available on a device
  117183. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  117184. * @returns a promise that will resolve on orientation change
  117185. */
  117186. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  117187. /**
  117188. * @hidden
  117189. */
  117190. _onDeviceOrientationChangedObservable: Observable<void>;
  117191. /**
  117192. * Instantiates a new input
  117193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117194. */
  117195. constructor();
  117196. /**
  117197. * Define the camera controlled by the input.
  117198. */
  117199. get camera(): FreeCamera;
  117200. set camera(camera: FreeCamera);
  117201. /**
  117202. * Attach the input controls to a specific dom element to get the input from.
  117203. * @param element Defines the element the controls should be listened from
  117204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117205. */
  117206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117207. private _orientationChanged;
  117208. private _deviceOrientation;
  117209. /**
  117210. * Detach the current controls from the specified dom element.
  117211. * @param element Defines the element to stop listening the inputs from
  117212. */
  117213. detachControl(element: Nullable<HTMLElement>): void;
  117214. /**
  117215. * Update the current camera state depending on the inputs that have been used this frame.
  117216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117217. */
  117218. checkInputs(): void;
  117219. /**
  117220. * Gets the class name of the current intput.
  117221. * @returns the class name
  117222. */
  117223. getClassName(): string;
  117224. /**
  117225. * Get the friendly name associated with the input class.
  117226. * @returns the input friendly name
  117227. */
  117228. getSimpleName(): string;
  117229. }
  117230. }
  117231. declare module BABYLON {
  117232. /**
  117233. * Manage the gamepad inputs to control a free camera.
  117234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117235. */
  117236. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117237. /**
  117238. * Define the camera the input is attached to.
  117239. */
  117240. camera: FreeCamera;
  117241. /**
  117242. * Define the Gamepad controlling the input
  117243. */
  117244. gamepad: Nullable<Gamepad>;
  117245. /**
  117246. * Defines the gamepad rotation sensiblity.
  117247. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117248. */
  117249. gamepadAngularSensibility: number;
  117250. /**
  117251. * Defines the gamepad move sensiblity.
  117252. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117253. */
  117254. gamepadMoveSensibility: number;
  117255. private _yAxisScale;
  117256. /**
  117257. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117258. */
  117259. get invertYAxis(): boolean;
  117260. set invertYAxis(value: boolean);
  117261. private _onGamepadConnectedObserver;
  117262. private _onGamepadDisconnectedObserver;
  117263. private _cameraTransform;
  117264. private _deltaTransform;
  117265. private _vector3;
  117266. private _vector2;
  117267. /**
  117268. * Attach the input controls to a specific dom element to get the input from.
  117269. * @param element Defines the element the controls should be listened from
  117270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117271. */
  117272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117273. /**
  117274. * Detach the current controls from the specified dom element.
  117275. * @param element Defines the element to stop listening the inputs from
  117276. */
  117277. detachControl(element: Nullable<HTMLElement>): void;
  117278. /**
  117279. * Update the current camera state depending on the inputs that have been used this frame.
  117280. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117281. */
  117282. checkInputs(): void;
  117283. /**
  117284. * Gets the class name of the current intput.
  117285. * @returns the class name
  117286. */
  117287. getClassName(): string;
  117288. /**
  117289. * Get the friendly name associated with the input class.
  117290. * @returns the input friendly name
  117291. */
  117292. getSimpleName(): string;
  117293. }
  117294. }
  117295. declare module BABYLON {
  117296. /**
  117297. * Defines the potential axis of a Joystick
  117298. */
  117299. export enum JoystickAxis {
  117300. /** X axis */
  117301. X = 0,
  117302. /** Y axis */
  117303. Y = 1,
  117304. /** Z axis */
  117305. Z = 2
  117306. }
  117307. /**
  117308. * Class used to define virtual joystick (used in touch mode)
  117309. */
  117310. export class VirtualJoystick {
  117311. /**
  117312. * Gets or sets a boolean indicating that left and right values must be inverted
  117313. */
  117314. reverseLeftRight: boolean;
  117315. /**
  117316. * Gets or sets a boolean indicating that up and down values must be inverted
  117317. */
  117318. reverseUpDown: boolean;
  117319. /**
  117320. * Gets the offset value for the position (ie. the change of the position value)
  117321. */
  117322. deltaPosition: Vector3;
  117323. /**
  117324. * Gets a boolean indicating if the virtual joystick was pressed
  117325. */
  117326. pressed: boolean;
  117327. /**
  117328. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117329. */
  117330. static Canvas: Nullable<HTMLCanvasElement>;
  117331. private static _globalJoystickIndex;
  117332. private static vjCanvasContext;
  117333. private static vjCanvasWidth;
  117334. private static vjCanvasHeight;
  117335. private static halfWidth;
  117336. private _action;
  117337. private _axisTargetedByLeftAndRight;
  117338. private _axisTargetedByUpAndDown;
  117339. private _joystickSensibility;
  117340. private _inversedSensibility;
  117341. private _joystickPointerID;
  117342. private _joystickColor;
  117343. private _joystickPointerPos;
  117344. private _joystickPreviousPointerPos;
  117345. private _joystickPointerStartPos;
  117346. private _deltaJoystickVector;
  117347. private _leftJoystick;
  117348. private _touches;
  117349. private _onPointerDownHandlerRef;
  117350. private _onPointerMoveHandlerRef;
  117351. private _onPointerUpHandlerRef;
  117352. private _onResize;
  117353. /**
  117354. * Creates a new virtual joystick
  117355. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117356. */
  117357. constructor(leftJoystick?: boolean);
  117358. /**
  117359. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117360. * @param newJoystickSensibility defines the new sensibility
  117361. */
  117362. setJoystickSensibility(newJoystickSensibility: number): void;
  117363. private _onPointerDown;
  117364. private _onPointerMove;
  117365. private _onPointerUp;
  117366. /**
  117367. * Change the color of the virtual joystick
  117368. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117369. */
  117370. setJoystickColor(newColor: string): void;
  117371. /**
  117372. * Defines a callback to call when the joystick is touched
  117373. * @param action defines the callback
  117374. */
  117375. setActionOnTouch(action: () => any): void;
  117376. /**
  117377. * Defines which axis you'd like to control for left & right
  117378. * @param axis defines the axis to use
  117379. */
  117380. setAxisForLeftRight(axis: JoystickAxis): void;
  117381. /**
  117382. * Defines which axis you'd like to control for up & down
  117383. * @param axis defines the axis to use
  117384. */
  117385. setAxisForUpDown(axis: JoystickAxis): void;
  117386. private _drawVirtualJoystick;
  117387. /**
  117388. * Release internal HTML canvas
  117389. */
  117390. releaseCanvas(): void;
  117391. }
  117392. }
  117393. declare module BABYLON {
  117394. interface FreeCameraInputsManager {
  117395. /**
  117396. * Add virtual joystick input support to the input manager.
  117397. * @returns the current input manager
  117398. */
  117399. addVirtualJoystick(): FreeCameraInputsManager;
  117400. }
  117401. /**
  117402. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117404. */
  117405. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117406. /**
  117407. * Defines the camera the input is attached to.
  117408. */
  117409. camera: FreeCamera;
  117410. private _leftjoystick;
  117411. private _rightjoystick;
  117412. /**
  117413. * Gets the left stick of the virtual joystick.
  117414. * @returns The virtual Joystick
  117415. */
  117416. getLeftJoystick(): VirtualJoystick;
  117417. /**
  117418. * Gets the right stick of the virtual joystick.
  117419. * @returns The virtual Joystick
  117420. */
  117421. getRightJoystick(): VirtualJoystick;
  117422. /**
  117423. * Update the current camera state depending on the inputs that have been used this frame.
  117424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117425. */
  117426. checkInputs(): void;
  117427. /**
  117428. * Attach the input controls to a specific dom element to get the input from.
  117429. * @param element Defines the element the controls should be listened from
  117430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117431. */
  117432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117433. /**
  117434. * Detach the current controls from the specified dom element.
  117435. * @param element Defines the element to stop listening the inputs from
  117436. */
  117437. detachControl(element: Nullable<HTMLElement>): void;
  117438. /**
  117439. * Gets the class name of the current intput.
  117440. * @returns the class name
  117441. */
  117442. getClassName(): string;
  117443. /**
  117444. * Get the friendly name associated with the input class.
  117445. * @returns the input friendly name
  117446. */
  117447. getSimpleName(): string;
  117448. }
  117449. }
  117450. declare module BABYLON {
  117451. /**
  117452. * This represents a FPS type of camera controlled by touch.
  117453. * This is like a universal camera minus the Gamepad controls.
  117454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117455. */
  117456. export class TouchCamera extends FreeCamera {
  117457. /**
  117458. * Defines the touch sensibility for rotation.
  117459. * The higher the faster.
  117460. */
  117461. get touchAngularSensibility(): number;
  117462. set touchAngularSensibility(value: number);
  117463. /**
  117464. * Defines the touch sensibility for move.
  117465. * The higher the faster.
  117466. */
  117467. get touchMoveSensibility(): number;
  117468. set touchMoveSensibility(value: number);
  117469. /**
  117470. * Instantiates a new touch camera.
  117471. * This represents a FPS type of camera controlled by touch.
  117472. * This is like a universal camera minus the Gamepad controls.
  117473. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117474. * @param name Define the name of the camera in the scene
  117475. * @param position Define the start position of the camera in the scene
  117476. * @param scene Define the scene the camera belongs to
  117477. */
  117478. constructor(name: string, position: Vector3, scene: Scene);
  117479. /**
  117480. * Gets the current object class name.
  117481. * @return the class name
  117482. */
  117483. getClassName(): string;
  117484. /** @hidden */
  117485. _setupInputs(): void;
  117486. }
  117487. }
  117488. declare module BABYLON {
  117489. /**
  117490. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117491. * being tilted forward or back and left or right.
  117492. */
  117493. export class DeviceOrientationCamera extends FreeCamera {
  117494. private _initialQuaternion;
  117495. private _quaternionCache;
  117496. private _tmpDragQuaternion;
  117497. private _disablePointerInputWhenUsingDeviceOrientation;
  117498. /**
  117499. * Creates a new device orientation camera
  117500. * @param name The name of the camera
  117501. * @param position The start position camera
  117502. * @param scene The scene the camera belongs to
  117503. */
  117504. constructor(name: string, position: Vector3, scene: Scene);
  117505. /**
  117506. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117507. */
  117508. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117509. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117510. private _dragFactor;
  117511. /**
  117512. * Enabled turning on the y axis when the orientation sensor is active
  117513. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117514. */
  117515. enableHorizontalDragging(dragFactor?: number): void;
  117516. /**
  117517. * Gets the current instance class name ("DeviceOrientationCamera").
  117518. * This helps avoiding instanceof at run time.
  117519. * @returns the class name
  117520. */
  117521. getClassName(): string;
  117522. /**
  117523. * @hidden
  117524. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117525. */
  117526. _checkInputs(): void;
  117527. /**
  117528. * Reset the camera to its default orientation on the specified axis only.
  117529. * @param axis The axis to reset
  117530. */
  117531. resetToCurrentRotation(axis?: Axis): void;
  117532. }
  117533. }
  117534. declare module BABYLON {
  117535. /**
  117536. * Defines supported buttons for XBox360 compatible gamepads
  117537. */
  117538. export enum Xbox360Button {
  117539. /** A */
  117540. A = 0,
  117541. /** B */
  117542. B = 1,
  117543. /** X */
  117544. X = 2,
  117545. /** Y */
  117546. Y = 3,
  117547. /** Left button */
  117548. LB = 4,
  117549. /** Right button */
  117550. RB = 5,
  117551. /** Back */
  117552. Back = 8,
  117553. /** Start */
  117554. Start = 9,
  117555. /** Left stick */
  117556. LeftStick = 10,
  117557. /** Right stick */
  117558. RightStick = 11
  117559. }
  117560. /** Defines values for XBox360 DPad */
  117561. export enum Xbox360Dpad {
  117562. /** Up */
  117563. Up = 12,
  117564. /** Down */
  117565. Down = 13,
  117566. /** Left */
  117567. Left = 14,
  117568. /** Right */
  117569. Right = 15
  117570. }
  117571. /**
  117572. * Defines a XBox360 gamepad
  117573. */
  117574. export class Xbox360Pad extends Gamepad {
  117575. private _leftTrigger;
  117576. private _rightTrigger;
  117577. private _onlefttriggerchanged;
  117578. private _onrighttriggerchanged;
  117579. private _onbuttondown;
  117580. private _onbuttonup;
  117581. private _ondpaddown;
  117582. private _ondpadup;
  117583. /** Observable raised when a button is pressed */
  117584. onButtonDownObservable: Observable<Xbox360Button>;
  117585. /** Observable raised when a button is released */
  117586. onButtonUpObservable: Observable<Xbox360Button>;
  117587. /** Observable raised when a pad is pressed */
  117588. onPadDownObservable: Observable<Xbox360Dpad>;
  117589. /** Observable raised when a pad is released */
  117590. onPadUpObservable: Observable<Xbox360Dpad>;
  117591. private _buttonA;
  117592. private _buttonB;
  117593. private _buttonX;
  117594. private _buttonY;
  117595. private _buttonBack;
  117596. private _buttonStart;
  117597. private _buttonLB;
  117598. private _buttonRB;
  117599. private _buttonLeftStick;
  117600. private _buttonRightStick;
  117601. private _dPadUp;
  117602. private _dPadDown;
  117603. private _dPadLeft;
  117604. private _dPadRight;
  117605. private _isXboxOnePad;
  117606. /**
  117607. * Creates a new XBox360 gamepad object
  117608. * @param id defines the id of this gamepad
  117609. * @param index defines its index
  117610. * @param gamepad defines the internal HTML gamepad object
  117611. * @param xboxOne defines if it is a XBox One gamepad
  117612. */
  117613. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117614. /**
  117615. * Defines the callback to call when left trigger is pressed
  117616. * @param callback defines the callback to use
  117617. */
  117618. onlefttriggerchanged(callback: (value: number) => void): void;
  117619. /**
  117620. * Defines the callback to call when right trigger is pressed
  117621. * @param callback defines the callback to use
  117622. */
  117623. onrighttriggerchanged(callback: (value: number) => void): void;
  117624. /**
  117625. * Gets the left trigger value
  117626. */
  117627. get leftTrigger(): number;
  117628. /**
  117629. * Sets the left trigger value
  117630. */
  117631. set leftTrigger(newValue: number);
  117632. /**
  117633. * Gets the right trigger value
  117634. */
  117635. get rightTrigger(): number;
  117636. /**
  117637. * Sets the right trigger value
  117638. */
  117639. set rightTrigger(newValue: number);
  117640. /**
  117641. * Defines the callback to call when a button is pressed
  117642. * @param callback defines the callback to use
  117643. */
  117644. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117645. /**
  117646. * Defines the callback to call when a button is released
  117647. * @param callback defines the callback to use
  117648. */
  117649. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117650. /**
  117651. * Defines the callback to call when a pad is pressed
  117652. * @param callback defines the callback to use
  117653. */
  117654. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117655. /**
  117656. * Defines the callback to call when a pad is released
  117657. * @param callback defines the callback to use
  117658. */
  117659. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117660. private _setButtonValue;
  117661. private _setDPadValue;
  117662. /**
  117663. * Gets the value of the `A` button
  117664. */
  117665. get buttonA(): number;
  117666. /**
  117667. * Sets the value of the `A` button
  117668. */
  117669. set buttonA(value: number);
  117670. /**
  117671. * Gets the value of the `B` button
  117672. */
  117673. get buttonB(): number;
  117674. /**
  117675. * Sets the value of the `B` button
  117676. */
  117677. set buttonB(value: number);
  117678. /**
  117679. * Gets the value of the `X` button
  117680. */
  117681. get buttonX(): number;
  117682. /**
  117683. * Sets the value of the `X` button
  117684. */
  117685. set buttonX(value: number);
  117686. /**
  117687. * Gets the value of the `Y` button
  117688. */
  117689. get buttonY(): number;
  117690. /**
  117691. * Sets the value of the `Y` button
  117692. */
  117693. set buttonY(value: number);
  117694. /**
  117695. * Gets the value of the `Start` button
  117696. */
  117697. get buttonStart(): number;
  117698. /**
  117699. * Sets the value of the `Start` button
  117700. */
  117701. set buttonStart(value: number);
  117702. /**
  117703. * Gets the value of the `Back` button
  117704. */
  117705. get buttonBack(): number;
  117706. /**
  117707. * Sets the value of the `Back` button
  117708. */
  117709. set buttonBack(value: number);
  117710. /**
  117711. * Gets the value of the `Left` button
  117712. */
  117713. get buttonLB(): number;
  117714. /**
  117715. * Sets the value of the `Left` button
  117716. */
  117717. set buttonLB(value: number);
  117718. /**
  117719. * Gets the value of the `Right` button
  117720. */
  117721. get buttonRB(): number;
  117722. /**
  117723. * Sets the value of the `Right` button
  117724. */
  117725. set buttonRB(value: number);
  117726. /**
  117727. * Gets the value of the Left joystick
  117728. */
  117729. get buttonLeftStick(): number;
  117730. /**
  117731. * Sets the value of the Left joystick
  117732. */
  117733. set buttonLeftStick(value: number);
  117734. /**
  117735. * Gets the value of the Right joystick
  117736. */
  117737. get buttonRightStick(): number;
  117738. /**
  117739. * Sets the value of the Right joystick
  117740. */
  117741. set buttonRightStick(value: number);
  117742. /**
  117743. * Gets the value of D-pad up
  117744. */
  117745. get dPadUp(): number;
  117746. /**
  117747. * Sets the value of D-pad up
  117748. */
  117749. set dPadUp(value: number);
  117750. /**
  117751. * Gets the value of D-pad down
  117752. */
  117753. get dPadDown(): number;
  117754. /**
  117755. * Sets the value of D-pad down
  117756. */
  117757. set dPadDown(value: number);
  117758. /**
  117759. * Gets the value of D-pad left
  117760. */
  117761. get dPadLeft(): number;
  117762. /**
  117763. * Sets the value of D-pad left
  117764. */
  117765. set dPadLeft(value: number);
  117766. /**
  117767. * Gets the value of D-pad right
  117768. */
  117769. get dPadRight(): number;
  117770. /**
  117771. * Sets the value of D-pad right
  117772. */
  117773. set dPadRight(value: number);
  117774. /**
  117775. * Force the gamepad to synchronize with device values
  117776. */
  117777. update(): void;
  117778. /**
  117779. * Disposes the gamepad
  117780. */
  117781. dispose(): void;
  117782. }
  117783. }
  117784. declare module BABYLON {
  117785. /**
  117786. * Defines supported buttons for DualShock compatible gamepads
  117787. */
  117788. export enum DualShockButton {
  117789. /** Cross */
  117790. Cross = 0,
  117791. /** Circle */
  117792. Circle = 1,
  117793. /** Square */
  117794. Square = 2,
  117795. /** Triangle */
  117796. Triangle = 3,
  117797. /** L1 */
  117798. L1 = 4,
  117799. /** R1 */
  117800. R1 = 5,
  117801. /** Share */
  117802. Share = 8,
  117803. /** Options */
  117804. Options = 9,
  117805. /** Left stick */
  117806. LeftStick = 10,
  117807. /** Right stick */
  117808. RightStick = 11
  117809. }
  117810. /** Defines values for DualShock DPad */
  117811. export enum DualShockDpad {
  117812. /** Up */
  117813. Up = 12,
  117814. /** Down */
  117815. Down = 13,
  117816. /** Left */
  117817. Left = 14,
  117818. /** Right */
  117819. Right = 15
  117820. }
  117821. /**
  117822. * Defines a DualShock gamepad
  117823. */
  117824. export class DualShockPad extends Gamepad {
  117825. private _leftTrigger;
  117826. private _rightTrigger;
  117827. private _onlefttriggerchanged;
  117828. private _onrighttriggerchanged;
  117829. private _onbuttondown;
  117830. private _onbuttonup;
  117831. private _ondpaddown;
  117832. private _ondpadup;
  117833. /** Observable raised when a button is pressed */
  117834. onButtonDownObservable: Observable<DualShockButton>;
  117835. /** Observable raised when a button is released */
  117836. onButtonUpObservable: Observable<DualShockButton>;
  117837. /** Observable raised when a pad is pressed */
  117838. onPadDownObservable: Observable<DualShockDpad>;
  117839. /** Observable raised when a pad is released */
  117840. onPadUpObservable: Observable<DualShockDpad>;
  117841. private _buttonCross;
  117842. private _buttonCircle;
  117843. private _buttonSquare;
  117844. private _buttonTriangle;
  117845. private _buttonShare;
  117846. private _buttonOptions;
  117847. private _buttonL1;
  117848. private _buttonR1;
  117849. private _buttonLeftStick;
  117850. private _buttonRightStick;
  117851. private _dPadUp;
  117852. private _dPadDown;
  117853. private _dPadLeft;
  117854. private _dPadRight;
  117855. /**
  117856. * Creates a new DualShock gamepad object
  117857. * @param id defines the id of this gamepad
  117858. * @param index defines its index
  117859. * @param gamepad defines the internal HTML gamepad object
  117860. */
  117861. constructor(id: string, index: number, gamepad: any);
  117862. /**
  117863. * Defines the callback to call when left trigger is pressed
  117864. * @param callback defines the callback to use
  117865. */
  117866. onlefttriggerchanged(callback: (value: number) => void): void;
  117867. /**
  117868. * Defines the callback to call when right trigger is pressed
  117869. * @param callback defines the callback to use
  117870. */
  117871. onrighttriggerchanged(callback: (value: number) => void): void;
  117872. /**
  117873. * Gets the left trigger value
  117874. */
  117875. get leftTrigger(): number;
  117876. /**
  117877. * Sets the left trigger value
  117878. */
  117879. set leftTrigger(newValue: number);
  117880. /**
  117881. * Gets the right trigger value
  117882. */
  117883. get rightTrigger(): number;
  117884. /**
  117885. * Sets the right trigger value
  117886. */
  117887. set rightTrigger(newValue: number);
  117888. /**
  117889. * Defines the callback to call when a button is pressed
  117890. * @param callback defines the callback to use
  117891. */
  117892. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117893. /**
  117894. * Defines the callback to call when a button is released
  117895. * @param callback defines the callback to use
  117896. */
  117897. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117898. /**
  117899. * Defines the callback to call when a pad is pressed
  117900. * @param callback defines the callback to use
  117901. */
  117902. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117903. /**
  117904. * Defines the callback to call when a pad is released
  117905. * @param callback defines the callback to use
  117906. */
  117907. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117908. private _setButtonValue;
  117909. private _setDPadValue;
  117910. /**
  117911. * Gets the value of the `Cross` button
  117912. */
  117913. get buttonCross(): number;
  117914. /**
  117915. * Sets the value of the `Cross` button
  117916. */
  117917. set buttonCross(value: number);
  117918. /**
  117919. * Gets the value of the `Circle` button
  117920. */
  117921. get buttonCircle(): number;
  117922. /**
  117923. * Sets the value of the `Circle` button
  117924. */
  117925. set buttonCircle(value: number);
  117926. /**
  117927. * Gets the value of the `Square` button
  117928. */
  117929. get buttonSquare(): number;
  117930. /**
  117931. * Sets the value of the `Square` button
  117932. */
  117933. set buttonSquare(value: number);
  117934. /**
  117935. * Gets the value of the `Triangle` button
  117936. */
  117937. get buttonTriangle(): number;
  117938. /**
  117939. * Sets the value of the `Triangle` button
  117940. */
  117941. set buttonTriangle(value: number);
  117942. /**
  117943. * Gets the value of the `Options` button
  117944. */
  117945. get buttonOptions(): number;
  117946. /**
  117947. * Sets the value of the `Options` button
  117948. */
  117949. set buttonOptions(value: number);
  117950. /**
  117951. * Gets the value of the `Share` button
  117952. */
  117953. get buttonShare(): number;
  117954. /**
  117955. * Sets the value of the `Share` button
  117956. */
  117957. set buttonShare(value: number);
  117958. /**
  117959. * Gets the value of the `L1` button
  117960. */
  117961. get buttonL1(): number;
  117962. /**
  117963. * Sets the value of the `L1` button
  117964. */
  117965. set buttonL1(value: number);
  117966. /**
  117967. * Gets the value of the `R1` button
  117968. */
  117969. get buttonR1(): number;
  117970. /**
  117971. * Sets the value of the `R1` button
  117972. */
  117973. set buttonR1(value: number);
  117974. /**
  117975. * Gets the value of the Left joystick
  117976. */
  117977. get buttonLeftStick(): number;
  117978. /**
  117979. * Sets the value of the Left joystick
  117980. */
  117981. set buttonLeftStick(value: number);
  117982. /**
  117983. * Gets the value of the Right joystick
  117984. */
  117985. get buttonRightStick(): number;
  117986. /**
  117987. * Sets the value of the Right joystick
  117988. */
  117989. set buttonRightStick(value: number);
  117990. /**
  117991. * Gets the value of D-pad up
  117992. */
  117993. get dPadUp(): number;
  117994. /**
  117995. * Sets the value of D-pad up
  117996. */
  117997. set dPadUp(value: number);
  117998. /**
  117999. * Gets the value of D-pad down
  118000. */
  118001. get dPadDown(): number;
  118002. /**
  118003. * Sets the value of D-pad down
  118004. */
  118005. set dPadDown(value: number);
  118006. /**
  118007. * Gets the value of D-pad left
  118008. */
  118009. get dPadLeft(): number;
  118010. /**
  118011. * Sets the value of D-pad left
  118012. */
  118013. set dPadLeft(value: number);
  118014. /**
  118015. * Gets the value of D-pad right
  118016. */
  118017. get dPadRight(): number;
  118018. /**
  118019. * Sets the value of D-pad right
  118020. */
  118021. set dPadRight(value: number);
  118022. /**
  118023. * Force the gamepad to synchronize with device values
  118024. */
  118025. update(): void;
  118026. /**
  118027. * Disposes the gamepad
  118028. */
  118029. dispose(): void;
  118030. }
  118031. }
  118032. declare module BABYLON {
  118033. /**
  118034. * Manager for handling gamepads
  118035. */
  118036. export class GamepadManager {
  118037. private _scene?;
  118038. private _babylonGamepads;
  118039. private _oneGamepadConnected;
  118040. /** @hidden */
  118041. _isMonitoring: boolean;
  118042. private _gamepadEventSupported;
  118043. private _gamepadSupport?;
  118044. /**
  118045. * observable to be triggered when the gamepad controller has been connected
  118046. */
  118047. onGamepadConnectedObservable: Observable<Gamepad>;
  118048. /**
  118049. * observable to be triggered when the gamepad controller has been disconnected
  118050. */
  118051. onGamepadDisconnectedObservable: Observable<Gamepad>;
  118052. private _onGamepadConnectedEvent;
  118053. private _onGamepadDisconnectedEvent;
  118054. /**
  118055. * Initializes the gamepad manager
  118056. * @param _scene BabylonJS scene
  118057. */
  118058. constructor(_scene?: Scene | undefined);
  118059. /**
  118060. * The gamepads in the game pad manager
  118061. */
  118062. get gamepads(): Gamepad[];
  118063. /**
  118064. * Get the gamepad controllers based on type
  118065. * @param type The type of gamepad controller
  118066. * @returns Nullable gamepad
  118067. */
  118068. getGamepadByType(type?: number): Nullable<Gamepad>;
  118069. /**
  118070. * Disposes the gamepad manager
  118071. */
  118072. dispose(): void;
  118073. private _addNewGamepad;
  118074. private _startMonitoringGamepads;
  118075. private _stopMonitoringGamepads;
  118076. /** @hidden */
  118077. _checkGamepadsStatus(): void;
  118078. private _updateGamepadObjects;
  118079. }
  118080. }
  118081. declare module BABYLON {
  118082. interface Scene {
  118083. /** @hidden */
  118084. _gamepadManager: Nullable<GamepadManager>;
  118085. /**
  118086. * Gets the gamepad manager associated with the scene
  118087. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  118088. */
  118089. gamepadManager: GamepadManager;
  118090. }
  118091. /**
  118092. * Interface representing a free camera inputs manager
  118093. */
  118094. interface FreeCameraInputsManager {
  118095. /**
  118096. * Adds gamepad input support to the FreeCameraInputsManager.
  118097. * @returns the FreeCameraInputsManager
  118098. */
  118099. addGamepad(): FreeCameraInputsManager;
  118100. }
  118101. /**
  118102. * Interface representing an arc rotate camera inputs manager
  118103. */
  118104. interface ArcRotateCameraInputsManager {
  118105. /**
  118106. * Adds gamepad input support to the ArcRotateCamera InputManager.
  118107. * @returns the camera inputs manager
  118108. */
  118109. addGamepad(): ArcRotateCameraInputsManager;
  118110. }
  118111. /**
  118112. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  118113. */
  118114. export class GamepadSystemSceneComponent implements ISceneComponent {
  118115. /**
  118116. * The component name helpfull to identify the component in the list of scene components.
  118117. */
  118118. readonly name: string;
  118119. /**
  118120. * The scene the component belongs to.
  118121. */
  118122. scene: Scene;
  118123. /**
  118124. * Creates a new instance of the component for the given scene
  118125. * @param scene Defines the scene to register the component in
  118126. */
  118127. constructor(scene: Scene);
  118128. /**
  118129. * Registers the component in a given scene
  118130. */
  118131. register(): void;
  118132. /**
  118133. * Rebuilds the elements related to this component in case of
  118134. * context lost for instance.
  118135. */
  118136. rebuild(): void;
  118137. /**
  118138. * Disposes the component and the associated ressources
  118139. */
  118140. dispose(): void;
  118141. private _beforeCameraUpdate;
  118142. }
  118143. }
  118144. declare module BABYLON {
  118145. /**
  118146. * 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,
  118147. * which still works and will still be found in many Playgrounds.
  118148. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118149. */
  118150. export class UniversalCamera extends TouchCamera {
  118151. /**
  118152. * Defines the gamepad rotation sensiblity.
  118153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  118154. */
  118155. get gamepadAngularSensibility(): number;
  118156. set gamepadAngularSensibility(value: number);
  118157. /**
  118158. * Defines the gamepad move sensiblity.
  118159. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  118160. */
  118161. get gamepadMoveSensibility(): number;
  118162. set gamepadMoveSensibility(value: number);
  118163. /**
  118164. * 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,
  118165. * which still works and will still be found in many Playgrounds.
  118166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118167. * @param name Define the name of the camera in the scene
  118168. * @param position Define the start position of the camera in the scene
  118169. * @param scene Define the scene the camera belongs to
  118170. */
  118171. constructor(name: string, position: Vector3, scene: Scene);
  118172. /**
  118173. * Gets the current object class name.
  118174. * @return the class name
  118175. */
  118176. getClassName(): string;
  118177. }
  118178. }
  118179. declare module BABYLON {
  118180. /**
  118181. * This represents a FPS type of camera. This is only here for back compat purpose.
  118182. * Please use the UniversalCamera instead as both are identical.
  118183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118184. */
  118185. export class GamepadCamera extends UniversalCamera {
  118186. /**
  118187. * Instantiates a new Gamepad Camera
  118188. * This represents a FPS type of camera. This is only here for back compat purpose.
  118189. * Please use the UniversalCamera instead as both are identical.
  118190. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  118191. * @param name Define the name of the camera in the scene
  118192. * @param position Define the start position of the camera in the scene
  118193. * @param scene Define the scene the camera belongs to
  118194. */
  118195. constructor(name: string, position: Vector3, scene: Scene);
  118196. /**
  118197. * Gets the current object class name.
  118198. * @return the class name
  118199. */
  118200. getClassName(): string;
  118201. }
  118202. }
  118203. declare module BABYLON {
  118204. /** @hidden */
  118205. export var passPixelShader: {
  118206. name: string;
  118207. shader: string;
  118208. };
  118209. }
  118210. declare module BABYLON {
  118211. /** @hidden */
  118212. export var passCubePixelShader: {
  118213. name: string;
  118214. shader: string;
  118215. };
  118216. }
  118217. declare module BABYLON {
  118218. /**
  118219. * PassPostProcess which produces an output the same as it's input
  118220. */
  118221. export class PassPostProcess extends PostProcess {
  118222. /**
  118223. * Creates the PassPostProcess
  118224. * @param name The name of the effect.
  118225. * @param options The required width/height ratio to downsize to before computing the render pass.
  118226. * @param camera The camera to apply the render pass to.
  118227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118228. * @param engine The engine which the post process will be applied. (default: current engine)
  118229. * @param reusable If the post process can be reused on the same frame. (default: false)
  118230. * @param textureType The type of texture to be used when performing the post processing.
  118231. * @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)
  118232. */
  118233. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118234. }
  118235. /**
  118236. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118237. */
  118238. export class PassCubePostProcess extends PostProcess {
  118239. private _face;
  118240. /**
  118241. * Gets or sets the cube face to display.
  118242. * * 0 is +X
  118243. * * 1 is -X
  118244. * * 2 is +Y
  118245. * * 3 is -Y
  118246. * * 4 is +Z
  118247. * * 5 is -Z
  118248. */
  118249. get face(): number;
  118250. set face(value: number);
  118251. /**
  118252. * Creates the PassCubePostProcess
  118253. * @param name The name of the effect.
  118254. * @param options The required width/height ratio to downsize to before computing the render pass.
  118255. * @param camera The camera to apply the render pass to.
  118256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118257. * @param engine The engine which the post process will be applied. (default: current engine)
  118258. * @param reusable If the post process can be reused on the same frame. (default: false)
  118259. * @param textureType The type of texture to be used when performing the post processing.
  118260. * @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)
  118261. */
  118262. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118263. }
  118264. }
  118265. declare module BABYLON {
  118266. /** @hidden */
  118267. export var anaglyphPixelShader: {
  118268. name: string;
  118269. shader: string;
  118270. };
  118271. }
  118272. declare module BABYLON {
  118273. /**
  118274. * Postprocess used to generate anaglyphic rendering
  118275. */
  118276. export class AnaglyphPostProcess extends PostProcess {
  118277. private _passedProcess;
  118278. /**
  118279. * Creates a new AnaglyphPostProcess
  118280. * @param name defines postprocess name
  118281. * @param options defines creation options or target ratio scale
  118282. * @param rigCameras defines cameras using this postprocess
  118283. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118284. * @param engine defines hosting engine
  118285. * @param reusable defines if the postprocess will be reused multiple times per frame
  118286. */
  118287. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118288. }
  118289. }
  118290. declare module BABYLON {
  118291. /**
  118292. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118293. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118294. */
  118295. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118296. /**
  118297. * Creates a new AnaglyphArcRotateCamera
  118298. * @param name defines camera name
  118299. * @param alpha defines alpha angle (in radians)
  118300. * @param beta defines beta angle (in radians)
  118301. * @param radius defines radius
  118302. * @param target defines camera target
  118303. * @param interaxialDistance defines distance between each color axis
  118304. * @param scene defines the hosting scene
  118305. */
  118306. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118307. /**
  118308. * Gets camera class name
  118309. * @returns AnaglyphArcRotateCamera
  118310. */
  118311. getClassName(): string;
  118312. }
  118313. }
  118314. declare module BABYLON {
  118315. /**
  118316. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118317. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118318. */
  118319. export class AnaglyphFreeCamera extends FreeCamera {
  118320. /**
  118321. * Creates a new AnaglyphFreeCamera
  118322. * @param name defines camera name
  118323. * @param position defines initial position
  118324. * @param interaxialDistance defines distance between each color axis
  118325. * @param scene defines the hosting scene
  118326. */
  118327. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118328. /**
  118329. * Gets camera class name
  118330. * @returns AnaglyphFreeCamera
  118331. */
  118332. getClassName(): string;
  118333. }
  118334. }
  118335. declare module BABYLON {
  118336. /**
  118337. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118338. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118339. */
  118340. export class AnaglyphGamepadCamera extends GamepadCamera {
  118341. /**
  118342. * Creates a new AnaglyphGamepadCamera
  118343. * @param name defines camera name
  118344. * @param position defines initial position
  118345. * @param interaxialDistance defines distance between each color axis
  118346. * @param scene defines the hosting scene
  118347. */
  118348. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118349. /**
  118350. * Gets camera class name
  118351. * @returns AnaglyphGamepadCamera
  118352. */
  118353. getClassName(): string;
  118354. }
  118355. }
  118356. declare module BABYLON {
  118357. /**
  118358. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118359. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118360. */
  118361. export class AnaglyphUniversalCamera extends UniversalCamera {
  118362. /**
  118363. * Creates a new AnaglyphUniversalCamera
  118364. * @param name defines camera name
  118365. * @param position defines initial position
  118366. * @param interaxialDistance defines distance between each color axis
  118367. * @param scene defines the hosting scene
  118368. */
  118369. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118370. /**
  118371. * Gets camera class name
  118372. * @returns AnaglyphUniversalCamera
  118373. */
  118374. getClassName(): string;
  118375. }
  118376. }
  118377. declare module BABYLON {
  118378. /**
  118379. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118380. * @see http://doc.babylonjs.com/features/cameras
  118381. */
  118382. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118383. /**
  118384. * Creates a new StereoscopicArcRotateCamera
  118385. * @param name defines camera name
  118386. * @param alpha defines alpha angle (in radians)
  118387. * @param beta defines beta angle (in radians)
  118388. * @param radius defines radius
  118389. * @param target defines camera target
  118390. * @param interaxialDistance defines distance between each color axis
  118391. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118392. * @param scene defines the hosting scene
  118393. */
  118394. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118395. /**
  118396. * Gets camera class name
  118397. * @returns StereoscopicArcRotateCamera
  118398. */
  118399. getClassName(): string;
  118400. }
  118401. }
  118402. declare module BABYLON {
  118403. /**
  118404. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118405. * @see http://doc.babylonjs.com/features/cameras
  118406. */
  118407. export class StereoscopicFreeCamera extends FreeCamera {
  118408. /**
  118409. * Creates a new StereoscopicFreeCamera
  118410. * @param name defines camera name
  118411. * @param position defines initial position
  118412. * @param interaxialDistance defines distance between each color axis
  118413. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118414. * @param scene defines the hosting scene
  118415. */
  118416. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118417. /**
  118418. * Gets camera class name
  118419. * @returns StereoscopicFreeCamera
  118420. */
  118421. getClassName(): string;
  118422. }
  118423. }
  118424. declare module BABYLON {
  118425. /**
  118426. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118427. * @see http://doc.babylonjs.com/features/cameras
  118428. */
  118429. export class StereoscopicGamepadCamera extends GamepadCamera {
  118430. /**
  118431. * Creates a new StereoscopicGamepadCamera
  118432. * @param name defines camera name
  118433. * @param position defines initial position
  118434. * @param interaxialDistance defines distance between each color axis
  118435. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118436. * @param scene defines the hosting scene
  118437. */
  118438. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118439. /**
  118440. * Gets camera class name
  118441. * @returns StereoscopicGamepadCamera
  118442. */
  118443. getClassName(): string;
  118444. }
  118445. }
  118446. declare module BABYLON {
  118447. /**
  118448. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118449. * @see http://doc.babylonjs.com/features/cameras
  118450. */
  118451. export class StereoscopicUniversalCamera extends UniversalCamera {
  118452. /**
  118453. * Creates a new StereoscopicUniversalCamera
  118454. * @param name defines camera name
  118455. * @param position defines initial position
  118456. * @param interaxialDistance defines distance between each color axis
  118457. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118458. * @param scene defines the hosting scene
  118459. */
  118460. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118461. /**
  118462. * Gets camera class name
  118463. * @returns StereoscopicUniversalCamera
  118464. */
  118465. getClassName(): string;
  118466. }
  118467. }
  118468. declare module BABYLON {
  118469. /**
  118470. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118471. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118472. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118473. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118474. */
  118475. export class VirtualJoysticksCamera extends FreeCamera {
  118476. /**
  118477. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118478. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118479. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118480. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118481. * @param name Define the name of the camera in the scene
  118482. * @param position Define the start position of the camera in the scene
  118483. * @param scene Define the scene the camera belongs to
  118484. */
  118485. constructor(name: string, position: Vector3, scene: Scene);
  118486. /**
  118487. * Gets the current object class name.
  118488. * @return the class name
  118489. */
  118490. getClassName(): string;
  118491. }
  118492. }
  118493. declare module BABYLON {
  118494. /**
  118495. * This represents all the required metrics to create a VR camera.
  118496. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118497. */
  118498. export class VRCameraMetrics {
  118499. /**
  118500. * Define the horizontal resolution off the screen.
  118501. */
  118502. hResolution: number;
  118503. /**
  118504. * Define the vertical resolution off the screen.
  118505. */
  118506. vResolution: number;
  118507. /**
  118508. * Define the horizontal screen size.
  118509. */
  118510. hScreenSize: number;
  118511. /**
  118512. * Define the vertical screen size.
  118513. */
  118514. vScreenSize: number;
  118515. /**
  118516. * Define the vertical screen center position.
  118517. */
  118518. vScreenCenter: number;
  118519. /**
  118520. * Define the distance of the eyes to the screen.
  118521. */
  118522. eyeToScreenDistance: number;
  118523. /**
  118524. * Define the distance between both lenses
  118525. */
  118526. lensSeparationDistance: number;
  118527. /**
  118528. * Define the distance between both viewer's eyes.
  118529. */
  118530. interpupillaryDistance: number;
  118531. /**
  118532. * Define the distortion factor of the VR postprocess.
  118533. * Please, touch with care.
  118534. */
  118535. distortionK: number[];
  118536. /**
  118537. * Define the chromatic aberration correction factors for the VR post process.
  118538. */
  118539. chromaAbCorrection: number[];
  118540. /**
  118541. * Define the scale factor of the post process.
  118542. * The smaller the better but the slower.
  118543. */
  118544. postProcessScaleFactor: number;
  118545. /**
  118546. * Define an offset for the lens center.
  118547. */
  118548. lensCenterOffset: number;
  118549. /**
  118550. * Define if the current vr camera should compensate the distortion of the lense or not.
  118551. */
  118552. compensateDistortion: boolean;
  118553. /**
  118554. * Defines if multiview should be enabled when rendering (Default: false)
  118555. */
  118556. multiviewEnabled: boolean;
  118557. /**
  118558. * Gets the rendering aspect ratio based on the provided resolutions.
  118559. */
  118560. get aspectRatio(): number;
  118561. /**
  118562. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118563. */
  118564. get aspectRatioFov(): number;
  118565. /**
  118566. * @hidden
  118567. */
  118568. get leftHMatrix(): Matrix;
  118569. /**
  118570. * @hidden
  118571. */
  118572. get rightHMatrix(): Matrix;
  118573. /**
  118574. * @hidden
  118575. */
  118576. get leftPreViewMatrix(): Matrix;
  118577. /**
  118578. * @hidden
  118579. */
  118580. get rightPreViewMatrix(): Matrix;
  118581. /**
  118582. * Get the default VRMetrics based on the most generic setup.
  118583. * @returns the default vr metrics
  118584. */
  118585. static GetDefault(): VRCameraMetrics;
  118586. }
  118587. }
  118588. declare module BABYLON {
  118589. /** @hidden */
  118590. export var vrDistortionCorrectionPixelShader: {
  118591. name: string;
  118592. shader: string;
  118593. };
  118594. }
  118595. declare module BABYLON {
  118596. /**
  118597. * VRDistortionCorrectionPostProcess used for mobile VR
  118598. */
  118599. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118600. private _isRightEye;
  118601. private _distortionFactors;
  118602. private _postProcessScaleFactor;
  118603. private _lensCenterOffset;
  118604. private _scaleIn;
  118605. private _scaleFactor;
  118606. private _lensCenter;
  118607. /**
  118608. * Initializes the VRDistortionCorrectionPostProcess
  118609. * @param name The name of the effect.
  118610. * @param camera The camera to apply the render pass to.
  118611. * @param isRightEye If this is for the right eye distortion
  118612. * @param vrMetrics All the required metrics for the VR camera
  118613. */
  118614. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118615. }
  118616. }
  118617. declare module BABYLON {
  118618. /**
  118619. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118620. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118621. */
  118622. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118623. /**
  118624. * Creates a new VRDeviceOrientationArcRotateCamera
  118625. * @param name defines camera name
  118626. * @param alpha defines the camera rotation along the logitudinal axis
  118627. * @param beta defines the camera rotation along the latitudinal axis
  118628. * @param radius defines the camera distance from its target
  118629. * @param target defines the camera target
  118630. * @param scene defines the scene the camera belongs to
  118631. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118632. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118633. */
  118634. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118635. /**
  118636. * Gets camera class name
  118637. * @returns VRDeviceOrientationArcRotateCamera
  118638. */
  118639. getClassName(): string;
  118640. }
  118641. }
  118642. declare module BABYLON {
  118643. /**
  118644. * Camera used to simulate VR rendering (based on FreeCamera)
  118645. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118646. */
  118647. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118648. /**
  118649. * Creates a new VRDeviceOrientationFreeCamera
  118650. * @param name defines camera name
  118651. * @param position defines the start position of the camera
  118652. * @param scene defines the scene the camera belongs to
  118653. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118654. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118655. */
  118656. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118657. /**
  118658. * Gets camera class name
  118659. * @returns VRDeviceOrientationFreeCamera
  118660. */
  118661. getClassName(): string;
  118662. }
  118663. }
  118664. declare module BABYLON {
  118665. /**
  118666. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118667. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118668. */
  118669. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118670. /**
  118671. * Creates a new VRDeviceOrientationGamepadCamera
  118672. * @param name defines camera name
  118673. * @param position defines the start position of the camera
  118674. * @param scene defines the scene the camera belongs to
  118675. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118676. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118677. */
  118678. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118679. /**
  118680. * Gets camera class name
  118681. * @returns VRDeviceOrientationGamepadCamera
  118682. */
  118683. getClassName(): string;
  118684. }
  118685. }
  118686. declare module BABYLON {
  118687. /** @hidden */
  118688. export var imageProcessingPixelShader: {
  118689. name: string;
  118690. shader: string;
  118691. };
  118692. }
  118693. declare module BABYLON {
  118694. /**
  118695. * ImageProcessingPostProcess
  118696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118697. */
  118698. export class ImageProcessingPostProcess extends PostProcess {
  118699. /**
  118700. * Default configuration related to image processing available in the PBR Material.
  118701. */
  118702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118703. /**
  118704. * Gets the image processing configuration used either in this material.
  118705. */
  118706. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118707. /**
  118708. * Sets the Default image processing configuration used either in the this material.
  118709. *
  118710. * If sets to null, the scene one is in use.
  118711. */
  118712. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118713. /**
  118714. * Keep track of the image processing observer to allow dispose and replace.
  118715. */
  118716. private _imageProcessingObserver;
  118717. /**
  118718. * Attaches a new image processing configuration to the PBR Material.
  118719. * @param configuration
  118720. */
  118721. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118722. /**
  118723. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118724. */
  118725. get colorCurves(): Nullable<ColorCurves>;
  118726. /**
  118727. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118728. */
  118729. set colorCurves(value: Nullable<ColorCurves>);
  118730. /**
  118731. * Gets wether the color curves effect is enabled.
  118732. */
  118733. get colorCurvesEnabled(): boolean;
  118734. /**
  118735. * Sets wether the color curves effect is enabled.
  118736. */
  118737. set colorCurvesEnabled(value: boolean);
  118738. /**
  118739. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118740. */
  118741. get colorGradingTexture(): Nullable<BaseTexture>;
  118742. /**
  118743. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118744. */
  118745. set colorGradingTexture(value: Nullable<BaseTexture>);
  118746. /**
  118747. * Gets wether the color grading effect is enabled.
  118748. */
  118749. get colorGradingEnabled(): boolean;
  118750. /**
  118751. * Gets wether the color grading effect is enabled.
  118752. */
  118753. set colorGradingEnabled(value: boolean);
  118754. /**
  118755. * Gets exposure used in the effect.
  118756. */
  118757. get exposure(): number;
  118758. /**
  118759. * Sets exposure used in the effect.
  118760. */
  118761. set exposure(value: number);
  118762. /**
  118763. * Gets wether tonemapping is enabled or not.
  118764. */
  118765. get toneMappingEnabled(): boolean;
  118766. /**
  118767. * Sets wether tonemapping is enabled or not
  118768. */
  118769. set toneMappingEnabled(value: boolean);
  118770. /**
  118771. * Gets the type of tone mapping effect.
  118772. */
  118773. get toneMappingType(): number;
  118774. /**
  118775. * Sets the type of tone mapping effect.
  118776. */
  118777. set toneMappingType(value: number);
  118778. /**
  118779. * Gets contrast used in the effect.
  118780. */
  118781. get contrast(): number;
  118782. /**
  118783. * Sets contrast used in the effect.
  118784. */
  118785. set contrast(value: number);
  118786. /**
  118787. * Gets Vignette stretch size.
  118788. */
  118789. get vignetteStretch(): number;
  118790. /**
  118791. * Sets Vignette stretch size.
  118792. */
  118793. set vignetteStretch(value: number);
  118794. /**
  118795. * Gets Vignette centre X Offset.
  118796. */
  118797. get vignetteCentreX(): number;
  118798. /**
  118799. * Sets Vignette centre X Offset.
  118800. */
  118801. set vignetteCentreX(value: number);
  118802. /**
  118803. * Gets Vignette centre Y Offset.
  118804. */
  118805. get vignetteCentreY(): number;
  118806. /**
  118807. * Sets Vignette centre Y Offset.
  118808. */
  118809. set vignetteCentreY(value: number);
  118810. /**
  118811. * Gets Vignette weight or intensity of the vignette effect.
  118812. */
  118813. get vignetteWeight(): number;
  118814. /**
  118815. * Sets Vignette weight or intensity of the vignette effect.
  118816. */
  118817. set vignetteWeight(value: number);
  118818. /**
  118819. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118820. * if vignetteEnabled is set to true.
  118821. */
  118822. get vignetteColor(): Color4;
  118823. /**
  118824. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118825. * if vignetteEnabled is set to true.
  118826. */
  118827. set vignetteColor(value: Color4);
  118828. /**
  118829. * Gets Camera field of view used by the Vignette effect.
  118830. */
  118831. get vignetteCameraFov(): number;
  118832. /**
  118833. * Sets Camera field of view used by the Vignette effect.
  118834. */
  118835. set vignetteCameraFov(value: number);
  118836. /**
  118837. * Gets the vignette blend mode allowing different kind of effect.
  118838. */
  118839. get vignetteBlendMode(): number;
  118840. /**
  118841. * Sets the vignette blend mode allowing different kind of effect.
  118842. */
  118843. set vignetteBlendMode(value: number);
  118844. /**
  118845. * Gets wether the vignette effect is enabled.
  118846. */
  118847. get vignetteEnabled(): boolean;
  118848. /**
  118849. * Sets wether the vignette effect is enabled.
  118850. */
  118851. set vignetteEnabled(value: boolean);
  118852. private _fromLinearSpace;
  118853. /**
  118854. * Gets wether the input of the processing is in Gamma or Linear Space.
  118855. */
  118856. get fromLinearSpace(): boolean;
  118857. /**
  118858. * Sets wether the input of the processing is in Gamma or Linear Space.
  118859. */
  118860. set fromLinearSpace(value: boolean);
  118861. /**
  118862. * Defines cache preventing GC.
  118863. */
  118864. private _defines;
  118865. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118866. /**
  118867. * "ImageProcessingPostProcess"
  118868. * @returns "ImageProcessingPostProcess"
  118869. */
  118870. getClassName(): string;
  118871. protected _updateParameters(): void;
  118872. dispose(camera?: Camera): void;
  118873. }
  118874. }
  118875. declare module BABYLON {
  118876. /**
  118877. * Class containing static functions to help procedurally build meshes
  118878. */
  118879. export class GroundBuilder {
  118880. /**
  118881. * Creates a ground mesh
  118882. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118883. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118885. * @param name defines the name of the mesh
  118886. * @param options defines the options used to create the mesh
  118887. * @param scene defines the hosting scene
  118888. * @returns the ground mesh
  118889. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118890. */
  118891. static CreateGround(name: string, options: {
  118892. width?: number;
  118893. height?: number;
  118894. subdivisions?: number;
  118895. subdivisionsX?: number;
  118896. subdivisionsY?: number;
  118897. updatable?: boolean;
  118898. }, scene: any): Mesh;
  118899. /**
  118900. * Creates a tiled ground mesh
  118901. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118902. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118903. * * 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
  118904. * * 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
  118905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118906. * @param name defines the name of the mesh
  118907. * @param options defines the options used to create the mesh
  118908. * @param scene defines the hosting scene
  118909. * @returns the tiled ground mesh
  118910. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118911. */
  118912. static CreateTiledGround(name: string, options: {
  118913. xmin: number;
  118914. zmin: number;
  118915. xmax: number;
  118916. zmax: number;
  118917. subdivisions?: {
  118918. w: number;
  118919. h: number;
  118920. };
  118921. precision?: {
  118922. w: number;
  118923. h: number;
  118924. };
  118925. updatable?: boolean;
  118926. }, scene?: Nullable<Scene>): Mesh;
  118927. /**
  118928. * Creates a ground mesh from a height map
  118929. * * The parameter `url` sets the URL of the height map image resource.
  118930. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118931. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118932. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118933. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118934. * * 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.
  118935. * * 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).
  118936. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118938. * @param name defines the name of the mesh
  118939. * @param url defines the url to the height map
  118940. * @param options defines the options used to create the mesh
  118941. * @param scene defines the hosting scene
  118942. * @returns the ground mesh
  118943. * @see https://doc.babylonjs.com/babylon101/height_map
  118944. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118945. */
  118946. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118947. width?: number;
  118948. height?: number;
  118949. subdivisions?: number;
  118950. minHeight?: number;
  118951. maxHeight?: number;
  118952. colorFilter?: Color3;
  118953. alphaFilter?: number;
  118954. updatable?: boolean;
  118955. onReady?: (mesh: GroundMesh) => void;
  118956. }, scene?: Nullable<Scene>): GroundMesh;
  118957. }
  118958. }
  118959. declare module BABYLON {
  118960. /**
  118961. * Class containing static functions to help procedurally build meshes
  118962. */
  118963. export class TorusBuilder {
  118964. /**
  118965. * Creates a torus mesh
  118966. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118967. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118968. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118972. * @param name defines the name of the mesh
  118973. * @param options defines the options used to create the mesh
  118974. * @param scene defines the hosting scene
  118975. * @returns the torus mesh
  118976. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118977. */
  118978. static CreateTorus(name: string, options: {
  118979. diameter?: number;
  118980. thickness?: number;
  118981. tessellation?: number;
  118982. updatable?: boolean;
  118983. sideOrientation?: number;
  118984. frontUVs?: Vector4;
  118985. backUVs?: Vector4;
  118986. }, scene: any): Mesh;
  118987. }
  118988. }
  118989. declare module BABYLON {
  118990. /**
  118991. * Class containing static functions to help procedurally build meshes
  118992. */
  118993. export class CylinderBuilder {
  118994. /**
  118995. * Creates a cylinder or a cone mesh
  118996. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118997. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118998. * * 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.
  118999. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119000. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119001. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119002. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119003. * * 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).
  119004. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119005. * * 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).
  119006. * * 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
  119007. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119008. * * 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
  119009. * * 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.
  119010. * * If `enclose` is false, a ring surface is one element.
  119011. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119012. * * 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
  119013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119016. * @param name defines the name of the mesh
  119017. * @param options defines the options used to create the mesh
  119018. * @param scene defines the hosting scene
  119019. * @returns the cylinder mesh
  119020. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119021. */
  119022. static CreateCylinder(name: string, options: {
  119023. height?: number;
  119024. diameterTop?: number;
  119025. diameterBottom?: number;
  119026. diameter?: number;
  119027. tessellation?: number;
  119028. subdivisions?: number;
  119029. arc?: number;
  119030. faceColors?: Color4[];
  119031. faceUV?: Vector4[];
  119032. updatable?: boolean;
  119033. hasRings?: boolean;
  119034. enclose?: boolean;
  119035. cap?: number;
  119036. sideOrientation?: number;
  119037. frontUVs?: Vector4;
  119038. backUVs?: Vector4;
  119039. }, scene: any): Mesh;
  119040. }
  119041. }
  119042. declare module BABYLON {
  119043. /**
  119044. * States of the webXR experience
  119045. */
  119046. export enum WebXRState {
  119047. /**
  119048. * Transitioning to being in XR mode
  119049. */
  119050. ENTERING_XR = 0,
  119051. /**
  119052. * Transitioning to non XR mode
  119053. */
  119054. EXITING_XR = 1,
  119055. /**
  119056. * In XR mode and presenting
  119057. */
  119058. IN_XR = 2,
  119059. /**
  119060. * Not entered XR mode
  119061. */
  119062. NOT_IN_XR = 3
  119063. }
  119064. /**
  119065. * Abstraction of the XR render target
  119066. */
  119067. export interface WebXRRenderTarget extends IDisposable {
  119068. /**
  119069. * xrpresent context of the canvas which can be used to display/mirror xr content
  119070. */
  119071. canvasContext: WebGLRenderingContext;
  119072. /**
  119073. * xr layer for the canvas
  119074. */
  119075. xrLayer: Nullable<XRWebGLLayer>;
  119076. /**
  119077. * Initializes the xr layer for the session
  119078. * @param xrSession xr session
  119079. * @returns a promise that will resolve once the XR Layer has been created
  119080. */
  119081. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119082. }
  119083. }
  119084. declare module BABYLON {
  119085. /**
  119086. * COnfiguration object for WebXR output canvas
  119087. */
  119088. export class WebXRManagedOutputCanvasOptions {
  119089. /**
  119090. * An optional canvas in case you wish to create it yourself and provide it here.
  119091. * If not provided, a new canvas will be created
  119092. */
  119093. canvasElement?: HTMLCanvasElement;
  119094. /**
  119095. * Options for this XR Layer output
  119096. */
  119097. canvasOptions?: XRWebGLLayerOptions;
  119098. /**
  119099. * CSS styling for a newly created canvas (if not provided)
  119100. */
  119101. newCanvasCssStyle?: string;
  119102. /**
  119103. * Get the default values of the configuration object
  119104. * @returns default values of this configuration object
  119105. */
  119106. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  119107. }
  119108. /**
  119109. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  119110. */
  119111. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  119112. private _options;
  119113. private _canvas;
  119114. private _engine;
  119115. /**
  119116. * Rendering context of the canvas which can be used to display/mirror xr content
  119117. */
  119118. canvasContext: WebGLRenderingContext;
  119119. /**
  119120. * xr layer for the canvas
  119121. */
  119122. xrLayer: Nullable<XRWebGLLayer>;
  119123. /**
  119124. * Initializes the canvas to be added/removed upon entering/exiting xr
  119125. * @param _xrSessionManager The XR Session manager
  119126. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  119127. */
  119128. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  119129. /**
  119130. * Disposes of the object
  119131. */
  119132. dispose(): void;
  119133. /**
  119134. * Initializes the xr layer for the session
  119135. * @param xrSession xr session
  119136. * @returns a promise that will resolve once the XR Layer has been created
  119137. */
  119138. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  119139. private _addCanvas;
  119140. private _removeCanvas;
  119141. private _setManagedOutputCanvas;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /**
  119146. * Manages an XRSession to work with Babylon's engine
  119147. * @see https://doc.babylonjs.com/how_to/webxr
  119148. */
  119149. export class WebXRSessionManager implements IDisposable {
  119150. /** The scene which the session should be created for */
  119151. scene: Scene;
  119152. private _referenceSpace;
  119153. private _rttProvider;
  119154. private _sessionEnded;
  119155. private _xrNavigator;
  119156. private baseLayer;
  119157. /**
  119158. * The base reference space from which the session started. good if you want to reset your
  119159. * reference space
  119160. */
  119161. baseReferenceSpace: XRReferenceSpace;
  119162. /**
  119163. * Current XR frame
  119164. */
  119165. currentFrame: Nullable<XRFrame>;
  119166. /** WebXR timestamp updated every frame */
  119167. currentTimestamp: number;
  119168. /**
  119169. * Used just in case of a failure to initialize an immersive session.
  119170. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  119171. */
  119172. defaultHeightCompensation: number;
  119173. /**
  119174. * Fires every time a new xrFrame arrives which can be used to update the camera
  119175. */
  119176. onXRFrameObservable: Observable<XRFrame>;
  119177. /**
  119178. * Fires when the reference space changed
  119179. */
  119180. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  119181. /**
  119182. * Fires when the xr session is ended either by the device or manually done
  119183. */
  119184. onXRSessionEnded: Observable<any>;
  119185. /**
  119186. * Fires when the xr session is ended either by the device or manually done
  119187. */
  119188. onXRSessionInit: Observable<XRSession>;
  119189. /**
  119190. * Underlying xr session
  119191. */
  119192. session: XRSession;
  119193. /**
  119194. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  119195. * or get the offset the player is currently at.
  119196. */
  119197. viewerReferenceSpace: XRReferenceSpace;
  119198. /**
  119199. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  119200. * @param scene The scene which the session should be created for
  119201. */
  119202. constructor(
  119203. /** The scene which the session should be created for */
  119204. scene: Scene);
  119205. /**
  119206. * The current reference space used in this session. This reference space can constantly change!
  119207. * It is mainly used to offset the camera's position.
  119208. */
  119209. get referenceSpace(): XRReferenceSpace;
  119210. /**
  119211. * Set a new reference space and triggers the observable
  119212. */
  119213. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  119214. /**
  119215. * Disposes of the session manager
  119216. */
  119217. dispose(): void;
  119218. /**
  119219. * Stops the xrSession and restores the render loop
  119220. * @returns Promise which resolves after it exits XR
  119221. */
  119222. exitXRAsync(): Promise<void>;
  119223. /**
  119224. * Gets the correct render target texture to be rendered this frame for this eye
  119225. * @param eye the eye for which to get the render target
  119226. * @returns the render target for the specified eye
  119227. */
  119228. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119229. /**
  119230. * Creates a WebXRRenderTarget object for the XR session
  119231. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119232. * @param options optional options to provide when creating a new render target
  119233. * @returns a WebXR render target to which the session can render
  119234. */
  119235. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119236. /**
  119237. * Initializes the manager
  119238. * After initialization enterXR can be called to start an XR session
  119239. * @returns Promise which resolves after it is initialized
  119240. */
  119241. initializeAsync(): Promise<void>;
  119242. /**
  119243. * Initializes an xr session
  119244. * @param xrSessionMode mode to initialize
  119245. * @param xrSessionInit defines optional and required values to pass to the session builder
  119246. * @returns a promise which will resolve once the session has been initialized
  119247. */
  119248. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119249. /**
  119250. * Checks if a session would be supported for the creation options specified
  119251. * @param sessionMode session mode to check if supported eg. immersive-vr
  119252. * @returns A Promise that resolves to true if supported and false if not
  119253. */
  119254. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119255. /**
  119256. * Resets the reference space to the one started the session
  119257. */
  119258. resetReferenceSpace(): void;
  119259. /**
  119260. * Starts rendering to the xr layer
  119261. */
  119262. runXRRenderLoop(): void;
  119263. /**
  119264. * Sets the reference space on the xr session
  119265. * @param referenceSpaceType space to set
  119266. * @returns a promise that will resolve once the reference space has been set
  119267. */
  119268. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119269. /**
  119270. * Updates the render state of the session
  119271. * @param state state to set
  119272. * @returns a promise that resolves once the render state has been updated
  119273. */
  119274. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119275. /**
  119276. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119277. * @param sessionMode defines the session to test
  119278. * @returns a promise with boolean as final value
  119279. */
  119280. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119281. private _createRenderTargetTexture;
  119282. }
  119283. }
  119284. declare module BABYLON {
  119285. /**
  119286. * WebXR Camera which holds the views for the xrSession
  119287. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119288. */
  119289. export class WebXRCamera extends FreeCamera {
  119290. private _xrSessionManager;
  119291. private _firstFrame;
  119292. private _referenceQuaternion;
  119293. private _referencedPosition;
  119294. private _xrInvPositionCache;
  119295. private _xrInvQuaternionCache;
  119296. /**
  119297. * Should position compensation execute on first frame.
  119298. * This is used when copying the position from a native (non XR) camera
  119299. */
  119300. compensateOnFirstFrame: boolean;
  119301. /**
  119302. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119303. * @param name the name of the camera
  119304. * @param scene the scene to add the camera to
  119305. * @param _xrSessionManager a constructed xr session manager
  119306. */
  119307. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119308. /**
  119309. * Return the user's height, unrelated to the current ground.
  119310. * This will be the y position of this camera, when ground level is 0.
  119311. */
  119312. get realWorldHeight(): number;
  119313. /** @hidden */
  119314. _updateForDualEyeDebugging(): void;
  119315. /**
  119316. * Sets this camera's transformation based on a non-vr camera
  119317. * @param otherCamera the non-vr camera to copy the transformation from
  119318. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119319. */
  119320. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119321. /**
  119322. * Gets the current instance class name ("WebXRCamera").
  119323. * @returns the class name
  119324. */
  119325. getClassName(): string;
  119326. private _updateFromXRSession;
  119327. private _updateNumberOfRigCameras;
  119328. private _updateReferenceSpace;
  119329. private _updateReferenceSpaceOffset;
  119330. }
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Defining the interface required for a (webxr) feature
  119335. */
  119336. export interface IWebXRFeature extends IDisposable {
  119337. /**
  119338. * Is this feature attached
  119339. */
  119340. attached: boolean;
  119341. /**
  119342. * Should auto-attach be disabled?
  119343. */
  119344. disableAutoAttach: boolean;
  119345. /**
  119346. * Attach the feature to the session
  119347. * Will usually be called by the features manager
  119348. *
  119349. * @param force should attachment be forced (even when already attached)
  119350. * @returns true if successful.
  119351. */
  119352. attach(force?: boolean): boolean;
  119353. /**
  119354. * Detach the feature from the session
  119355. * Will usually be called by the features manager
  119356. *
  119357. * @returns true if successful.
  119358. */
  119359. detach(): boolean;
  119360. }
  119361. /**
  119362. * A list of the currently available features without referencing them
  119363. */
  119364. export class WebXRFeatureName {
  119365. /**
  119366. * The name of the anchor system feature
  119367. */
  119368. static ANCHOR_SYSTEM: string;
  119369. /**
  119370. * The name of the background remover feature
  119371. */
  119372. static BACKGROUND_REMOVER: string;
  119373. /**
  119374. * The name of the hit test feature
  119375. */
  119376. static HIT_TEST: string;
  119377. /**
  119378. * physics impostors for xr controllers feature
  119379. */
  119380. static PHYSICS_CONTROLLERS: string;
  119381. /**
  119382. * The name of the plane detection feature
  119383. */
  119384. static PLANE_DETECTION: string;
  119385. /**
  119386. * The name of the pointer selection feature
  119387. */
  119388. static POINTER_SELECTION: string;
  119389. /**
  119390. * The name of the teleportation feature
  119391. */
  119392. static TELEPORTATION: string;
  119393. }
  119394. /**
  119395. * Defining the constructor of a feature. Used to register the modules.
  119396. */
  119397. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119398. /**
  119399. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119400. * It is mainly used in AR sessions.
  119401. *
  119402. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119403. */
  119404. export class WebXRFeaturesManager implements IDisposable {
  119405. private _xrSessionManager;
  119406. private static readonly _AvailableFeatures;
  119407. private _features;
  119408. /**
  119409. * constructs a new features manages.
  119410. *
  119411. * @param _xrSessionManager an instance of WebXRSessionManager
  119412. */
  119413. constructor(_xrSessionManager: WebXRSessionManager);
  119414. /**
  119415. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119416. * Mainly used internally.
  119417. *
  119418. * @param featureName the name of the feature to register
  119419. * @param constructorFunction the function used to construct the module
  119420. * @param version the (babylon) version of the module
  119421. * @param stable is that a stable version of this module
  119422. */
  119423. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119424. /**
  119425. * Returns a constructor of a specific feature.
  119426. *
  119427. * @param featureName the name of the feature to construct
  119428. * @param version the version of the feature to load
  119429. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119430. * @param options optional options provided to the module.
  119431. * @returns a function that, when called, will return a new instance of this feature
  119432. */
  119433. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119434. /**
  119435. * Can be used to return the list of features currently registered
  119436. *
  119437. * @returns an Array of available features
  119438. */
  119439. static GetAvailableFeatures(): string[];
  119440. /**
  119441. * Gets the versions available for a specific feature
  119442. * @param featureName the name of the feature
  119443. * @returns an array with the available versions
  119444. */
  119445. static GetAvailableVersions(featureName: string): string[];
  119446. /**
  119447. * Return the latest unstable version of this feature
  119448. * @param featureName the name of the feature to search
  119449. * @returns the version number. if not found will return -1
  119450. */
  119451. static GetLatestVersionOfFeature(featureName: string): number;
  119452. /**
  119453. * Return the latest stable version of this feature
  119454. * @param featureName the name of the feature to search
  119455. * @returns the version number. if not found will return -1
  119456. */
  119457. static GetStableVersionOfFeature(featureName: string): number;
  119458. /**
  119459. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119460. * Can be used during a session to start a feature
  119461. * @param featureName the name of feature to attach
  119462. */
  119463. attachFeature(featureName: string): void;
  119464. /**
  119465. * Can be used inside a session or when the session ends to detach a specific feature
  119466. * @param featureName the name of the feature to detach
  119467. */
  119468. detachFeature(featureName: string): void;
  119469. /**
  119470. * Used to disable an already-enabled feature
  119471. * The feature will be disposed and will be recreated once enabled.
  119472. * @param featureName the feature to disable
  119473. * @returns true if disable was successful
  119474. */
  119475. disableFeature(featureName: string | {
  119476. Name: string;
  119477. }): boolean;
  119478. /**
  119479. * dispose this features manager
  119480. */
  119481. dispose(): void;
  119482. /**
  119483. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  119484. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  119485. *
  119486. * @param featureName the name of the feature to load or the class of the feature
  119487. * @param version optional version to load. if not provided the latest version will be enabled
  119488. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119489. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119490. * @returns a new constructed feature or throws an error if feature not found.
  119491. */
  119492. enableFeature(featureName: string | {
  119493. Name: string;
  119494. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119495. /**
  119496. * get the implementation of an enabled feature.
  119497. * @param featureName the name of the feature to load
  119498. * @returns the feature class, if found
  119499. */
  119500. getEnabledFeature(featureName: string): IWebXRFeature;
  119501. /**
  119502. * Get the list of enabled features
  119503. * @returns an array of enabled features
  119504. */
  119505. getEnabledFeatures(): string[];
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119511. * @see https://doc.babylonjs.com/how_to/webxr
  119512. */
  119513. export class WebXRExperienceHelper implements IDisposable {
  119514. private scene;
  119515. private _nonVRCamera;
  119516. private _originalSceneAutoClear;
  119517. private _supported;
  119518. /**
  119519. * Camera used to render xr content
  119520. */
  119521. camera: WebXRCamera;
  119522. /** A features manager for this xr session */
  119523. featuresManager: WebXRFeaturesManager;
  119524. /**
  119525. * Observers registered here will be triggered after the camera's initial transformation is set
  119526. * This can be used to set a different ground level or an extra rotation.
  119527. *
  119528. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119529. * to the position set after this observable is done executing.
  119530. */
  119531. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119532. /**
  119533. * Fires when the state of the experience helper has changed
  119534. */
  119535. onStateChangedObservable: Observable<WebXRState>;
  119536. /** Session manager used to keep track of xr session */
  119537. sessionManager: WebXRSessionManager;
  119538. /**
  119539. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119540. */
  119541. state: WebXRState;
  119542. /**
  119543. * Creates a WebXRExperienceHelper
  119544. * @param scene The scene the helper should be created in
  119545. */
  119546. private constructor();
  119547. /**
  119548. * Creates the experience helper
  119549. * @param scene the scene to attach the experience helper to
  119550. * @returns a promise for the experience helper
  119551. */
  119552. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119553. /**
  119554. * Disposes of the experience helper
  119555. */
  119556. dispose(): void;
  119557. /**
  119558. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119559. * @param sessionMode options for the XR session
  119560. * @param referenceSpaceType frame of reference of the XR session
  119561. * @param renderTarget the output canvas that will be used to enter XR mode
  119562. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  119563. * @returns promise that resolves after xr mode has entered
  119564. */
  119565. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  119566. /**
  119567. * Exits XR mode and returns the scene to its original state
  119568. * @returns promise that resolves after xr mode has exited
  119569. */
  119570. exitXRAsync(): Promise<void>;
  119571. private _nonXRToXRCamera;
  119572. private _setState;
  119573. }
  119574. }
  119575. declare module BABYLON {
  119576. /**
  119577. * X-Y values for axes in WebXR
  119578. */
  119579. export interface IWebXRMotionControllerAxesValue {
  119580. /**
  119581. * The value of the x axis
  119582. */
  119583. x: number;
  119584. /**
  119585. * The value of the y-axis
  119586. */
  119587. y: number;
  119588. }
  119589. /**
  119590. * changed / previous values for the values of this component
  119591. */
  119592. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119593. /**
  119594. * current (this frame) value
  119595. */
  119596. current: T;
  119597. /**
  119598. * previous (last change) value
  119599. */
  119600. previous: T;
  119601. }
  119602. /**
  119603. * Represents changes in the component between current frame and last values recorded
  119604. */
  119605. export interface IWebXRMotionControllerComponentChanges {
  119606. /**
  119607. * will be populated with previous and current values if axes changed
  119608. */
  119609. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119610. /**
  119611. * will be populated with previous and current values if pressed changed
  119612. */
  119613. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119614. /**
  119615. * will be populated with previous and current values if touched changed
  119616. */
  119617. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119618. /**
  119619. * will be populated with previous and current values if value changed
  119620. */
  119621. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119622. }
  119623. /**
  119624. * This class represents a single component (for example button or thumbstick) of a motion controller
  119625. */
  119626. export class WebXRControllerComponent implements IDisposable {
  119627. /**
  119628. * the id of this component
  119629. */
  119630. id: string;
  119631. /**
  119632. * the type of the component
  119633. */
  119634. type: MotionControllerComponentType;
  119635. private _buttonIndex;
  119636. private _axesIndices;
  119637. private _axes;
  119638. private _changes;
  119639. private _currentValue;
  119640. private _hasChanges;
  119641. private _pressed;
  119642. private _touched;
  119643. /**
  119644. * button component type
  119645. */
  119646. static BUTTON_TYPE: MotionControllerComponentType;
  119647. /**
  119648. * squeeze component type
  119649. */
  119650. static SQUEEZE_TYPE: MotionControllerComponentType;
  119651. /**
  119652. * Thumbstick component type
  119653. */
  119654. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119655. /**
  119656. * Touchpad component type
  119657. */
  119658. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119659. /**
  119660. * trigger component type
  119661. */
  119662. static TRIGGER_TYPE: MotionControllerComponentType;
  119663. /**
  119664. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119665. * the axes data changes
  119666. */
  119667. onAxisValueChangedObservable: Observable<{
  119668. x: number;
  119669. y: number;
  119670. }>;
  119671. /**
  119672. * Observers registered here will be triggered when the state of a button changes
  119673. * State change is either pressed / touched / value
  119674. */
  119675. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119676. /**
  119677. * Creates a new component for a motion controller.
  119678. * It is created by the motion controller itself
  119679. *
  119680. * @param id the id of this component
  119681. * @param type the type of the component
  119682. * @param _buttonIndex index in the buttons array of the gamepad
  119683. * @param _axesIndices indices of the values in the axes array of the gamepad
  119684. */
  119685. constructor(
  119686. /**
  119687. * the id of this component
  119688. */
  119689. id: string,
  119690. /**
  119691. * the type of the component
  119692. */
  119693. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119694. /**
  119695. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119696. */
  119697. get axes(): IWebXRMotionControllerAxesValue;
  119698. /**
  119699. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119700. */
  119701. get changes(): IWebXRMotionControllerComponentChanges;
  119702. /**
  119703. * Return whether or not the component changed the last frame
  119704. */
  119705. get hasChanges(): boolean;
  119706. /**
  119707. * is the button currently pressed
  119708. */
  119709. get pressed(): boolean;
  119710. /**
  119711. * is the button currently touched
  119712. */
  119713. get touched(): boolean;
  119714. /**
  119715. * Get the current value of this component
  119716. */
  119717. get value(): number;
  119718. /**
  119719. * Dispose this component
  119720. */
  119721. dispose(): void;
  119722. /**
  119723. * Are there axes correlating to this component
  119724. * @return true is axes data is available
  119725. */
  119726. isAxes(): boolean;
  119727. /**
  119728. * Is this component a button (hence - pressable)
  119729. * @returns true if can be pressed
  119730. */
  119731. isButton(): boolean;
  119732. /**
  119733. * update this component using the gamepad object it is in. Called on every frame
  119734. * @param nativeController the native gamepad controller object
  119735. */
  119736. update(nativeController: IMinimalMotionControllerObject): void;
  119737. }
  119738. }
  119739. declare module BABYLON {
  119740. /**
  119741. * Class used to represent data loading progression
  119742. */
  119743. export class SceneLoaderProgressEvent {
  119744. /** defines if data length to load can be evaluated */
  119745. readonly lengthComputable: boolean;
  119746. /** defines the loaded data length */
  119747. readonly loaded: number;
  119748. /** defines the data length to load */
  119749. readonly total: number;
  119750. /**
  119751. * Create a new progress event
  119752. * @param lengthComputable defines if data length to load can be evaluated
  119753. * @param loaded defines the loaded data length
  119754. * @param total defines the data length to load
  119755. */
  119756. constructor(
  119757. /** defines if data length to load can be evaluated */
  119758. lengthComputable: boolean,
  119759. /** defines the loaded data length */
  119760. loaded: number,
  119761. /** defines the data length to load */
  119762. total: number);
  119763. /**
  119764. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119765. * @param event defines the source event
  119766. * @returns a new SceneLoaderProgressEvent
  119767. */
  119768. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119769. }
  119770. /**
  119771. * Interface used by SceneLoader plugins to define supported file extensions
  119772. */
  119773. export interface ISceneLoaderPluginExtensions {
  119774. /**
  119775. * Defines the list of supported extensions
  119776. */
  119777. [extension: string]: {
  119778. isBinary: boolean;
  119779. };
  119780. }
  119781. /**
  119782. * Interface used by SceneLoader plugin factory
  119783. */
  119784. export interface ISceneLoaderPluginFactory {
  119785. /**
  119786. * Defines the name of the factory
  119787. */
  119788. name: string;
  119789. /**
  119790. * Function called to create a new plugin
  119791. * @return the new plugin
  119792. */
  119793. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119794. /**
  119795. * The callback that returns true if the data can be directly loaded.
  119796. * @param data string containing the file data
  119797. * @returns if the data can be loaded directly
  119798. */
  119799. canDirectLoad?(data: string): boolean;
  119800. }
  119801. /**
  119802. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119803. */
  119804. export interface ISceneLoaderPluginBase {
  119805. /**
  119806. * The friendly name of this plugin.
  119807. */
  119808. name: string;
  119809. /**
  119810. * The file extensions supported by this plugin.
  119811. */
  119812. extensions: string | ISceneLoaderPluginExtensions;
  119813. /**
  119814. * The callback called when loading from a url.
  119815. * @param scene scene loading this url
  119816. * @param url url to load
  119817. * @param onSuccess callback called when the file successfully loads
  119818. * @param onProgress callback called while file is loading (if the server supports this mode)
  119819. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119820. * @param onError callback called when the file fails to load
  119821. * @returns a file request object
  119822. */
  119823. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119824. /**
  119825. * The callback called when loading from a file object.
  119826. * @param scene scene loading this file
  119827. * @param file defines the file to load
  119828. * @param onSuccess defines the callback to call when data is loaded
  119829. * @param onProgress defines the callback to call during loading process
  119830. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119831. * @param onError defines the callback to call when an error occurs
  119832. * @returns a file request object
  119833. */
  119834. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119835. /**
  119836. * The callback that returns true if the data can be directly loaded.
  119837. * @param data string containing the file data
  119838. * @returns if the data can be loaded directly
  119839. */
  119840. canDirectLoad?(data: string): boolean;
  119841. /**
  119842. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119843. * @param scene scene loading this data
  119844. * @param data string containing the data
  119845. * @returns data to pass to the plugin
  119846. */
  119847. directLoad?(scene: Scene, data: string): any;
  119848. /**
  119849. * The callback that allows custom handling of the root url based on the response url.
  119850. * @param rootUrl the original root url
  119851. * @param responseURL the response url if available
  119852. * @returns the new root url
  119853. */
  119854. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119855. }
  119856. /**
  119857. * Interface used to define a SceneLoader plugin
  119858. */
  119859. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119860. /**
  119861. * Import meshes into a scene.
  119862. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119863. * @param scene The scene to import into
  119864. * @param data The data to import
  119865. * @param rootUrl The root url for scene and resources
  119866. * @param meshes The meshes array to import into
  119867. * @param particleSystems The particle systems array to import into
  119868. * @param skeletons The skeletons array to import into
  119869. * @param onError The callback when import fails
  119870. * @returns True if successful or false otherwise
  119871. */
  119872. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119873. /**
  119874. * Load into a scene.
  119875. * @param scene The scene to load into
  119876. * @param data The data to import
  119877. * @param rootUrl The root url for scene and resources
  119878. * @param onError The callback when import fails
  119879. * @returns True if successful or false otherwise
  119880. */
  119881. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119882. /**
  119883. * Load into an asset container.
  119884. * @param scene The scene to load into
  119885. * @param data The data to import
  119886. * @param rootUrl The root url for scene and resources
  119887. * @param onError The callback when import fails
  119888. * @returns The loaded asset container
  119889. */
  119890. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119891. }
  119892. /**
  119893. * Interface used to define an async SceneLoader plugin
  119894. */
  119895. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119896. /**
  119897. * Import meshes into a scene.
  119898. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119899. * @param scene The scene to import into
  119900. * @param data The data to import
  119901. * @param rootUrl The root url for scene and resources
  119902. * @param onProgress The callback when the load progresses
  119903. * @param fileName Defines the name of the file to load
  119904. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119905. */
  119906. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119907. meshes: AbstractMesh[];
  119908. particleSystems: IParticleSystem[];
  119909. skeletons: Skeleton[];
  119910. animationGroups: AnimationGroup[];
  119911. }>;
  119912. /**
  119913. * Load into a scene.
  119914. * @param scene The scene to load into
  119915. * @param data The data to import
  119916. * @param rootUrl The root url for scene and resources
  119917. * @param onProgress The callback when the load progresses
  119918. * @param fileName Defines the name of the file to load
  119919. * @returns Nothing
  119920. */
  119921. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119922. /**
  119923. * Load into an asset container.
  119924. * @param scene The scene to load into
  119925. * @param data The data to import
  119926. * @param rootUrl The root url for scene and resources
  119927. * @param onProgress The callback when the load progresses
  119928. * @param fileName Defines the name of the file to load
  119929. * @returns The loaded asset container
  119930. */
  119931. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119932. }
  119933. /**
  119934. * Mode that determines how to handle old animation groups before loading new ones.
  119935. */
  119936. export enum SceneLoaderAnimationGroupLoadingMode {
  119937. /**
  119938. * Reset all old animations to initial state then dispose them.
  119939. */
  119940. Clean = 0,
  119941. /**
  119942. * Stop all old animations.
  119943. */
  119944. Stop = 1,
  119945. /**
  119946. * Restart old animations from first frame.
  119947. */
  119948. Sync = 2,
  119949. /**
  119950. * Old animations remains untouched.
  119951. */
  119952. NoSync = 3
  119953. }
  119954. /**
  119955. * Class used to load scene from various file formats using registered plugins
  119956. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  119957. */
  119958. export class SceneLoader {
  119959. /**
  119960. * No logging while loading
  119961. */
  119962. static readonly NO_LOGGING: number;
  119963. /**
  119964. * Minimal logging while loading
  119965. */
  119966. static readonly MINIMAL_LOGGING: number;
  119967. /**
  119968. * Summary logging while loading
  119969. */
  119970. static readonly SUMMARY_LOGGING: number;
  119971. /**
  119972. * Detailled logging while loading
  119973. */
  119974. static readonly DETAILED_LOGGING: number;
  119975. /**
  119976. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  119977. */
  119978. static get ForceFullSceneLoadingForIncremental(): boolean;
  119979. static set ForceFullSceneLoadingForIncremental(value: boolean);
  119980. /**
  119981. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  119982. */
  119983. static get ShowLoadingScreen(): boolean;
  119984. static set ShowLoadingScreen(value: boolean);
  119985. /**
  119986. * Defines the current logging level (while loading the scene)
  119987. * @ignorenaming
  119988. */
  119989. static get loggingLevel(): number;
  119990. static set loggingLevel(value: number);
  119991. /**
  119992. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  119993. */
  119994. static get CleanBoneMatrixWeights(): boolean;
  119995. static set CleanBoneMatrixWeights(value: boolean);
  119996. /**
  119997. * Event raised when a plugin is used to load a scene
  119998. */
  119999. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  120000. private static _registeredPlugins;
  120001. private static _getDefaultPlugin;
  120002. private static _getPluginForExtension;
  120003. private static _getPluginForDirectLoad;
  120004. private static _getPluginForFilename;
  120005. private static _getDirectLoad;
  120006. private static _loadData;
  120007. private static _getFileInfo;
  120008. /**
  120009. * Gets a plugin that can load the given extension
  120010. * @param extension defines the extension to load
  120011. * @returns a plugin or null if none works
  120012. */
  120013. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  120014. /**
  120015. * Gets a boolean indicating that the given extension can be loaded
  120016. * @param extension defines the extension to load
  120017. * @returns true if the extension is supported
  120018. */
  120019. static IsPluginForExtensionAvailable(extension: string): boolean;
  120020. /**
  120021. * Adds a new plugin to the list of registered plugins
  120022. * @param plugin defines the plugin to add
  120023. */
  120024. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  120025. /**
  120026. * Import meshes into a scene
  120027. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120028. * @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)
  120029. * @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)
  120030. * @param scene the instance of BABYLON.Scene to append to
  120031. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  120032. * @param onProgress a callback with a progress event for each file being loaded
  120033. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120034. * @param pluginExtension the extension used to determine the plugin
  120035. * @returns The loaded plugin
  120036. */
  120037. 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>;
  120038. /**
  120039. * Import meshes into a scene
  120040. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  120041. * @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)
  120042. * @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)
  120043. * @param scene the instance of BABYLON.Scene to append to
  120044. * @param onProgress a callback with a progress event for each file being loaded
  120045. * @param pluginExtension the extension used to determine the plugin
  120046. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  120047. */
  120048. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  120049. meshes: AbstractMesh[];
  120050. particleSystems: IParticleSystem[];
  120051. skeletons: Skeleton[];
  120052. animationGroups: AnimationGroup[];
  120053. }>;
  120054. /**
  120055. * Load a scene
  120056. * @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)
  120057. * @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)
  120058. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120059. * @param onSuccess a callback with the scene when import succeeds
  120060. * @param onProgress a callback with a progress event for each file being loaded
  120061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120062. * @param pluginExtension the extension used to determine the plugin
  120063. * @returns The loaded plugin
  120064. */
  120065. 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>;
  120066. /**
  120067. * Load a scene
  120068. * @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)
  120069. * @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)
  120070. * @param engine is the instance of BABYLON.Engine to use to create the scene
  120071. * @param onProgress a callback with a progress event for each file being loaded
  120072. * @param pluginExtension the extension used to determine the plugin
  120073. * @returns The loaded scene
  120074. */
  120075. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120076. /**
  120077. * Append a scene
  120078. * @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)
  120079. * @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)
  120080. * @param scene is the instance of BABYLON.Scene to append to
  120081. * @param onSuccess a callback with the scene when import succeeds
  120082. * @param onProgress a callback with a progress event for each file being loaded
  120083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120084. * @param pluginExtension the extension used to determine the plugin
  120085. * @returns The loaded plugin
  120086. */
  120087. 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>;
  120088. /**
  120089. * Append a scene
  120090. * @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)
  120091. * @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)
  120092. * @param scene is the instance of BABYLON.Scene to append to
  120093. * @param onProgress a callback with a progress event for each file being loaded
  120094. * @param pluginExtension the extension used to determine the plugin
  120095. * @returns The given scene
  120096. */
  120097. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  120098. /**
  120099. * Load a scene into an asset container
  120100. * @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)
  120101. * @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)
  120102. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120103. * @param onSuccess a callback with the scene when import succeeds
  120104. * @param onProgress a callback with a progress event for each file being loaded
  120105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120106. * @param pluginExtension the extension used to determine the plugin
  120107. * @returns The loaded plugin
  120108. */
  120109. 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>;
  120110. /**
  120111. * Load a scene into an asset container
  120112. * @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)
  120113. * @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)
  120114. * @param scene is the instance of Scene to append to
  120115. * @param onProgress a callback with a progress event for each file being loaded
  120116. * @param pluginExtension the extension used to determine the plugin
  120117. * @returns The loaded asset container
  120118. */
  120119. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  120120. /**
  120121. * Import animations from a file into a scene
  120122. * @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)
  120123. * @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)
  120124. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120125. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120126. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120127. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120128. * @param onSuccess a callback with the scene when import succeeds
  120129. * @param onProgress a callback with a progress event for each file being loaded
  120130. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120131. */
  120132. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  120133. /**
  120134. * Import animations from a file into a scene
  120135. * @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)
  120136. * @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)
  120137. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120138. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  120139. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  120140. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  120141. * @param onSuccess a callback with the scene when import succeeds
  120142. * @param onProgress a callback with a progress event for each file being loaded
  120143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  120144. * @returns the updated scene with imported animations
  120145. */
  120146. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  120147. }
  120148. }
  120149. declare module BABYLON {
  120150. /**
  120151. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  120152. */
  120153. export type MotionControllerHandedness = "none" | "left" | "right";
  120154. /**
  120155. * The type of components available in motion controllers.
  120156. * This is not the name of the component.
  120157. */
  120158. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  120159. /**
  120160. * The state of a controller component
  120161. */
  120162. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  120163. /**
  120164. * The schema of motion controller layout.
  120165. * No object will be initialized using this interface
  120166. * This is used just to define the profile.
  120167. */
  120168. export interface IMotionControllerLayout {
  120169. /**
  120170. * Path to load the assets. Usually relative to the base path
  120171. */
  120172. assetPath: string;
  120173. /**
  120174. * Available components (unsorted)
  120175. */
  120176. components: {
  120177. /**
  120178. * A map of component Ids
  120179. */
  120180. [componentId: string]: {
  120181. /**
  120182. * The type of input the component outputs
  120183. */
  120184. type: MotionControllerComponentType;
  120185. /**
  120186. * The indices of this component in the gamepad object
  120187. */
  120188. gamepadIndices: {
  120189. /**
  120190. * Index of button
  120191. */
  120192. button?: number;
  120193. /**
  120194. * If available, index of x-axis
  120195. */
  120196. xAxis?: number;
  120197. /**
  120198. * If available, index of y-axis
  120199. */
  120200. yAxis?: number;
  120201. };
  120202. /**
  120203. * The mesh's root node name
  120204. */
  120205. rootNodeName: string;
  120206. /**
  120207. * Animation definitions for this model
  120208. */
  120209. visualResponses: {
  120210. [stateKey: string]: {
  120211. /**
  120212. * What property will be animated
  120213. */
  120214. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  120215. /**
  120216. * What states influence this visual response
  120217. */
  120218. states: MotionControllerComponentStateType[];
  120219. /**
  120220. * Type of animation - movement or visibility
  120221. */
  120222. valueNodeProperty: "transform" | "visibility";
  120223. /**
  120224. * Base node name to move. Its position will be calculated according to the min and max nodes
  120225. */
  120226. valueNodeName?: string;
  120227. /**
  120228. * Minimum movement node
  120229. */
  120230. minNodeName?: string;
  120231. /**
  120232. * Max movement node
  120233. */
  120234. maxNodeName?: string;
  120235. };
  120236. };
  120237. /**
  120238. * If touch enabled, what is the name of node to display user feedback
  120239. */
  120240. touchPointNodeName?: string;
  120241. };
  120242. };
  120243. /**
  120244. * Is it xr standard mapping or not
  120245. */
  120246. gamepadMapping: "" | "xr-standard";
  120247. /**
  120248. * Base root node of this entire model
  120249. */
  120250. rootNodeName: string;
  120251. /**
  120252. * Defines the main button component id
  120253. */
  120254. selectComponentId: string;
  120255. }
  120256. /**
  120257. * A definition for the layout map in the input profile
  120258. */
  120259. export interface IMotionControllerLayoutMap {
  120260. /**
  120261. * Layouts with handedness type as a key
  120262. */
  120263. [handedness: string]: IMotionControllerLayout;
  120264. }
  120265. /**
  120266. * The XR Input profile schema
  120267. * Profiles can be found here:
  120268. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120269. */
  120270. export interface IMotionControllerProfile {
  120271. /**
  120272. * fallback profiles for this profileId
  120273. */
  120274. fallbackProfileIds: string[];
  120275. /**
  120276. * The layout map, with handedness as key
  120277. */
  120278. layouts: IMotionControllerLayoutMap;
  120279. /**
  120280. * The id of this profile
  120281. * correlates to the profile(s) in the xrInput.profiles array
  120282. */
  120283. profileId: string;
  120284. }
  120285. /**
  120286. * A helper-interface for the 3 meshes needed for controller button animation
  120287. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120288. */
  120289. export interface IMotionControllerButtonMeshMap {
  120290. /**
  120291. * the mesh that defines the pressed value mesh position.
  120292. * This is used to find the max-position of this button
  120293. */
  120294. pressedMesh: AbstractMesh;
  120295. /**
  120296. * the mesh that defines the unpressed value mesh position.
  120297. * This is used to find the min (or initial) position of this button
  120298. */
  120299. unpressedMesh: AbstractMesh;
  120300. /**
  120301. * The mesh that will be changed when value changes
  120302. */
  120303. valueMesh: AbstractMesh;
  120304. }
  120305. /**
  120306. * A helper-interface for the 3 meshes needed for controller axis animation.
  120307. * This will be expanded when touchpad animations are fully supported
  120308. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120309. */
  120310. export interface IMotionControllerMeshMap {
  120311. /**
  120312. * the mesh that defines the maximum value mesh position.
  120313. */
  120314. maxMesh?: AbstractMesh;
  120315. /**
  120316. * the mesh that defines the minimum value mesh position.
  120317. */
  120318. minMesh?: AbstractMesh;
  120319. /**
  120320. * The mesh that will be changed when axis value changes
  120321. */
  120322. valueMesh: AbstractMesh;
  120323. }
  120324. /**
  120325. * The elements needed for change-detection of the gamepad objects in motion controllers
  120326. */
  120327. export interface IMinimalMotionControllerObject {
  120328. /**
  120329. * Available axes of this controller
  120330. */
  120331. axes: number[];
  120332. /**
  120333. * An array of available buttons
  120334. */
  120335. buttons: Array<{
  120336. /**
  120337. * Value of the button/trigger
  120338. */
  120339. value: number;
  120340. /**
  120341. * If the button/trigger is currently touched
  120342. */
  120343. touched: boolean;
  120344. /**
  120345. * If the button/trigger is currently pressed
  120346. */
  120347. pressed: boolean;
  120348. }>;
  120349. /**
  120350. * EXPERIMENTAL haptic support.
  120351. */
  120352. hapticActuators?: Array<{
  120353. pulse: (value: number, duration: number) => Promise<boolean>;
  120354. }>;
  120355. }
  120356. /**
  120357. * An Abstract Motion controller
  120358. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120359. * Each component has an observable to check for changes in value and state
  120360. */
  120361. export abstract class WebXRAbstractMotionController implements IDisposable {
  120362. protected scene: Scene;
  120363. protected layout: IMotionControllerLayout;
  120364. /**
  120365. * The gamepad object correlating to this controller
  120366. */
  120367. gamepadObject: IMinimalMotionControllerObject;
  120368. /**
  120369. * handedness (left/right/none) of this controller
  120370. */
  120371. handedness: MotionControllerHandedness;
  120372. private _initComponent;
  120373. private _modelReady;
  120374. /**
  120375. * A map of components (WebXRControllerComponent) in this motion controller
  120376. * Components have a ComponentType and can also have both button and axis definitions
  120377. */
  120378. readonly components: {
  120379. [id: string]: WebXRControllerComponent;
  120380. };
  120381. /**
  120382. * Disable the model's animation. Can be set at any time.
  120383. */
  120384. disableAnimation: boolean;
  120385. /**
  120386. * Observers registered here will be triggered when the model of this controller is done loading
  120387. */
  120388. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120389. /**
  120390. * The profile id of this motion controller
  120391. */
  120392. abstract profileId: string;
  120393. /**
  120394. * The root mesh of the model. It is null if the model was not yet initialized
  120395. */
  120396. rootMesh: Nullable<AbstractMesh>;
  120397. /**
  120398. * constructs a new abstract motion controller
  120399. * @param scene the scene to which the model of the controller will be added
  120400. * @param layout The profile layout to load
  120401. * @param gamepadObject The gamepad object correlating to this controller
  120402. * @param handedness handedness (left/right/none) of this controller
  120403. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120404. */
  120405. constructor(scene: Scene, layout: IMotionControllerLayout,
  120406. /**
  120407. * The gamepad object correlating to this controller
  120408. */
  120409. gamepadObject: IMinimalMotionControllerObject,
  120410. /**
  120411. * handedness (left/right/none) of this controller
  120412. */
  120413. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120414. /**
  120415. * Dispose this controller, the model mesh and all its components
  120416. */
  120417. dispose(): void;
  120418. /**
  120419. * Returns all components of specific type
  120420. * @param type the type to search for
  120421. * @return an array of components with this type
  120422. */
  120423. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120424. /**
  120425. * get a component based an its component id as defined in layout.components
  120426. * @param id the id of the component
  120427. * @returns the component correlates to the id or undefined if not found
  120428. */
  120429. getComponent(id: string): WebXRControllerComponent;
  120430. /**
  120431. * Get the list of components available in this motion controller
  120432. * @returns an array of strings correlating to available components
  120433. */
  120434. getComponentIds(): string[];
  120435. /**
  120436. * Get the first component of specific type
  120437. * @param type type of component to find
  120438. * @return a controller component or null if not found
  120439. */
  120440. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120441. /**
  120442. * Get the main (Select) component of this controller as defined in the layout
  120443. * @returns the main component of this controller
  120444. */
  120445. getMainComponent(): WebXRControllerComponent;
  120446. /**
  120447. * Loads the model correlating to this controller
  120448. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120449. * @returns A promise fulfilled with the result of the model loading
  120450. */
  120451. loadModel(): Promise<boolean>;
  120452. /**
  120453. * Update this model using the current XRFrame
  120454. * @param xrFrame the current xr frame to use and update the model
  120455. */
  120456. updateFromXRFrame(xrFrame: XRFrame): void;
  120457. /**
  120458. * Backwards compatibility due to a deeply-integrated typo
  120459. */
  120460. get handness(): XREye;
  120461. /**
  120462. * Pulse (vibrate) this controller
  120463. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120464. * Consecutive calls to this function will cancel the last pulse call
  120465. *
  120466. * @param value the strength of the pulse in 0.0...1.0 range
  120467. * @param duration Duration of the pulse in milliseconds
  120468. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120469. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  120470. */
  120471. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120472. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120473. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120474. /**
  120475. * Moves the axis on the controller mesh based on its current state
  120476. * @param axis the index of the axis
  120477. * @param axisValue the value of the axis which determines the meshes new position
  120478. * @hidden
  120479. */
  120480. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120481. /**
  120482. * Update the model itself with the current frame data
  120483. * @param xrFrame the frame to use for updating the model mesh
  120484. */
  120485. protected updateModel(xrFrame: XRFrame): void;
  120486. /**
  120487. * Get the filename and path for this controller's model
  120488. * @returns a map of filename and path
  120489. */
  120490. protected abstract _getFilenameAndPath(): {
  120491. filename: string;
  120492. path: string;
  120493. };
  120494. /**
  120495. * This function is called before the mesh is loaded. It checks for loading constraints.
  120496. * For example, this function can check if the GLB loader is available
  120497. * If this function returns false, the generic controller will be loaded instead
  120498. * @returns Is the client ready to load the mesh
  120499. */
  120500. protected abstract _getModelLoadingConstraints(): boolean;
  120501. /**
  120502. * This function will be called after the model was successfully loaded and can be used
  120503. * for mesh transformations before it is available for the user
  120504. * @param meshes the loaded meshes
  120505. */
  120506. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120507. /**
  120508. * Set the root mesh for this controller. Important for the WebXR controller class
  120509. * @param meshes the loaded meshes
  120510. */
  120511. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120512. /**
  120513. * A function executed each frame that updates the mesh (if needed)
  120514. * @param xrFrame the current xrFrame
  120515. */
  120516. protected abstract _updateModel(xrFrame: XRFrame): void;
  120517. private _getGenericFilenameAndPath;
  120518. private _getGenericParentMesh;
  120519. }
  120520. }
  120521. declare module BABYLON {
  120522. /**
  120523. * A generic trigger-only motion controller for WebXR
  120524. */
  120525. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120526. /**
  120527. * Static version of the profile id of this controller
  120528. */
  120529. static ProfileId: string;
  120530. profileId: string;
  120531. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120532. protected _getFilenameAndPath(): {
  120533. filename: string;
  120534. path: string;
  120535. };
  120536. protected _getModelLoadingConstraints(): boolean;
  120537. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120538. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120539. protected _updateModel(): void;
  120540. }
  120541. }
  120542. declare module BABYLON {
  120543. /**
  120544. * Class containing static functions to help procedurally build meshes
  120545. */
  120546. export class SphereBuilder {
  120547. /**
  120548. * Creates a sphere mesh
  120549. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120550. * * 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`)
  120551. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120552. * * 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
  120553. * * 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)
  120554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120557. * @param name defines the name of the mesh
  120558. * @param options defines the options used to create the mesh
  120559. * @param scene defines the hosting scene
  120560. * @returns the sphere mesh
  120561. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120562. */
  120563. static CreateSphere(name: string, options: {
  120564. segments?: number;
  120565. diameter?: number;
  120566. diameterX?: number;
  120567. diameterY?: number;
  120568. diameterZ?: number;
  120569. arc?: number;
  120570. slice?: number;
  120571. sideOrientation?: number;
  120572. frontUVs?: Vector4;
  120573. backUVs?: Vector4;
  120574. updatable?: boolean;
  120575. }, scene?: Nullable<Scene>): Mesh;
  120576. }
  120577. }
  120578. declare module BABYLON {
  120579. /**
  120580. * A profiled motion controller has its profile loaded from an online repository.
  120581. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120582. */
  120583. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120584. private _repositoryUrl;
  120585. private _buttonMeshMapping;
  120586. private _touchDots;
  120587. /**
  120588. * The profile ID of this controller. Will be populated when the controller initializes.
  120589. */
  120590. profileId: string;
  120591. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120592. dispose(): void;
  120593. protected _getFilenameAndPath(): {
  120594. filename: string;
  120595. path: string;
  120596. };
  120597. protected _getModelLoadingConstraints(): boolean;
  120598. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120599. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120600. protected _updateModel(_xrFrame: XRFrame): void;
  120601. }
  120602. }
  120603. declare module BABYLON {
  120604. /**
  120605. * A construction function type to create a new controller based on an xrInput object
  120606. */
  120607. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120608. /**
  120609. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120610. *
  120611. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120612. * it should be replaced with auto-loaded controllers.
  120613. *
  120614. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120615. */
  120616. export class WebXRMotionControllerManager {
  120617. private static _AvailableControllers;
  120618. private static _Fallbacks;
  120619. private static _ProfileLoadingPromises;
  120620. private static _ProfilesList;
  120621. /**
  120622. * The base URL of the online controller repository. Can be changed at any time.
  120623. */
  120624. static BaseRepositoryUrl: string;
  120625. /**
  120626. * Which repository gets priority - local or online
  120627. */
  120628. static PrioritizeOnlineRepository: boolean;
  120629. /**
  120630. * Use the online repository, or use only locally-defined controllers
  120631. */
  120632. static UseOnlineRepository: boolean;
  120633. /**
  120634. * Clear the cache used for profile loading and reload when requested again
  120635. */
  120636. static ClearProfilesCache(): void;
  120637. /**
  120638. * Register the default fallbacks.
  120639. * This function is called automatically when this file is imported.
  120640. */
  120641. static DefaultFallbacks(): void;
  120642. /**
  120643. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120644. * @param profileId the profile to which a fallback needs to be found
  120645. * @return an array with corresponding fallback profiles
  120646. */
  120647. static FindFallbackWithProfileId(profileId: string): string[];
  120648. /**
  120649. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120650. * The order of search:
  120651. *
  120652. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120653. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120654. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120655. * 4) return the generic trigger controller if none were found
  120656. *
  120657. * @param xrInput the xrInput to which a new controller is initialized
  120658. * @param scene the scene to which the model will be added
  120659. * @param forceProfile force a certain profile for this controller
  120660. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120661. */
  120662. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120663. /**
  120664. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120665. *
  120666. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120667. *
  120668. * @param type the profile type to register
  120669. * @param constructFunction the function to be called when loading this profile
  120670. */
  120671. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120672. /**
  120673. * Register a fallback to a specific profile.
  120674. * @param profileId the profileId that will receive the fallbacks
  120675. * @param fallbacks A list of fallback profiles
  120676. */
  120677. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120678. /**
  120679. * Will update the list of profiles available in the repository
  120680. * @return a promise that resolves to a map of profiles available online
  120681. */
  120682. static UpdateProfilesList(): Promise<{
  120683. [profile: string]: string;
  120684. }>;
  120685. private static _LoadProfileFromRepository;
  120686. private static _LoadProfilesFromAvailableControllers;
  120687. }
  120688. }
  120689. declare module BABYLON {
  120690. /**
  120691. * Configuration options for the WebXR controller creation
  120692. */
  120693. export interface IWebXRControllerOptions {
  120694. /**
  120695. * Should the controller mesh be animated when a user interacts with it
  120696. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120697. */
  120698. disableMotionControllerAnimation?: boolean;
  120699. /**
  120700. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120701. */
  120702. doNotLoadControllerMesh?: boolean;
  120703. /**
  120704. * Force a specific controller type for this controller.
  120705. * This can be used when creating your own profile or when testing different controllers
  120706. */
  120707. forceControllerProfile?: string;
  120708. /**
  120709. * Defines a rendering group ID for meshes that will be loaded.
  120710. * This is for the default controllers only.
  120711. */
  120712. renderingGroupId?: number;
  120713. }
  120714. /**
  120715. * Represents an XR controller
  120716. */
  120717. export class WebXRInputSource {
  120718. private _scene;
  120719. /** The underlying input source for the controller */
  120720. inputSource: XRInputSource;
  120721. private _options;
  120722. private _tmpQuaternion;
  120723. private _tmpVector;
  120724. private _uniqueId;
  120725. /**
  120726. * 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
  120727. */
  120728. grip?: AbstractMesh;
  120729. /**
  120730. * If available, this is the gamepad object related to this controller.
  120731. * Using this object it is possible to get click events and trackpad changes of the
  120732. * webxr controller that is currently being used.
  120733. */
  120734. motionController?: WebXRAbstractMotionController;
  120735. /**
  120736. * Event that fires when the controller is removed/disposed.
  120737. * The object provided as event data is this controller, after associated assets were disposed.
  120738. * uniqueId is still available.
  120739. */
  120740. onDisposeObservable: Observable<WebXRInputSource>;
  120741. /**
  120742. * Will be triggered when the mesh associated with the motion controller is done loading.
  120743. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120744. * A shortened version of controller -> motion controller -> on mesh loaded.
  120745. */
  120746. onMeshLoadedObservable: Observable<AbstractMesh>;
  120747. /**
  120748. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120749. */
  120750. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120751. /**
  120752. * Pointer which can be used to select objects or attach a visible laser to
  120753. */
  120754. pointer: AbstractMesh;
  120755. /**
  120756. * Creates the controller
  120757. * @see https://doc.babylonjs.com/how_to/webxr
  120758. * @param _scene the scene which the controller should be associated to
  120759. * @param inputSource the underlying input source for the controller
  120760. * @param _options options for this controller creation
  120761. */
  120762. constructor(_scene: Scene,
  120763. /** The underlying input source for the controller */
  120764. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120765. /**
  120766. * Get this controllers unique id
  120767. */
  120768. get uniqueId(): string;
  120769. /**
  120770. * Disposes of the object
  120771. */
  120772. dispose(): void;
  120773. /**
  120774. * Gets a world space ray coming from the pointer or grip
  120775. * @param result the resulting ray
  120776. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120777. */
  120778. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120779. /**
  120780. * Updates the controller pose based on the given XRFrame
  120781. * @param xrFrame xr frame to update the pose with
  120782. * @param referenceSpace reference space to use
  120783. */
  120784. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120785. }
  120786. }
  120787. declare module BABYLON {
  120788. /**
  120789. * The schema for initialization options of the XR Input class
  120790. */
  120791. export interface IWebXRInputOptions {
  120792. /**
  120793. * If set to true no model will be automatically loaded
  120794. */
  120795. doNotLoadControllerMeshes?: boolean;
  120796. /**
  120797. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120798. * If not found, the xr input profile data will be used.
  120799. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120800. */
  120801. forceInputProfile?: string;
  120802. /**
  120803. * Do not send a request to the controller repository to load the profile.
  120804. *
  120805. * Instead, use the controllers available in babylon itself.
  120806. */
  120807. disableOnlineControllerRepository?: boolean;
  120808. /**
  120809. * A custom URL for the controllers repository
  120810. */
  120811. customControllersRepositoryURL?: string;
  120812. /**
  120813. * Should the controller model's components not move according to the user input
  120814. */
  120815. disableControllerAnimation?: boolean;
  120816. /**
  120817. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120818. */
  120819. controllerOptions?: IWebXRControllerOptions;
  120820. }
  120821. /**
  120822. * XR input used to track XR inputs such as controllers/rays
  120823. */
  120824. export class WebXRInput implements IDisposable {
  120825. /**
  120826. * the xr session manager for this session
  120827. */
  120828. xrSessionManager: WebXRSessionManager;
  120829. /**
  120830. * the WebXR camera for this session. Mainly used for teleportation
  120831. */
  120832. xrCamera: WebXRCamera;
  120833. private readonly options;
  120834. /**
  120835. * XR controllers being tracked
  120836. */
  120837. controllers: Array<WebXRInputSource>;
  120838. private _frameObserver;
  120839. private _sessionEndedObserver;
  120840. private _sessionInitObserver;
  120841. /**
  120842. * Event when a controller has been connected/added
  120843. */
  120844. onControllerAddedObservable: Observable<WebXRInputSource>;
  120845. /**
  120846. * Event when a controller has been removed/disconnected
  120847. */
  120848. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120849. /**
  120850. * Initializes the WebXRInput
  120851. * @param xrSessionManager the xr session manager for this session
  120852. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120853. * @param options = initialization options for this xr input
  120854. */
  120855. constructor(
  120856. /**
  120857. * the xr session manager for this session
  120858. */
  120859. xrSessionManager: WebXRSessionManager,
  120860. /**
  120861. * the WebXR camera for this session. Mainly used for teleportation
  120862. */
  120863. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120864. private _onInputSourcesChange;
  120865. private _addAndRemoveControllers;
  120866. /**
  120867. * Disposes of the object
  120868. */
  120869. dispose(): void;
  120870. }
  120871. }
  120872. declare module BABYLON {
  120873. /**
  120874. * This is the base class for all WebXR features.
  120875. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120876. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120877. */
  120878. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120879. protected _xrSessionManager: WebXRSessionManager;
  120880. private _attached;
  120881. private _removeOnDetach;
  120882. /**
  120883. * Should auto-attach be disabled?
  120884. */
  120885. disableAutoAttach: boolean;
  120886. /**
  120887. * Construct a new (abstract) WebXR feature
  120888. * @param _xrSessionManager the xr session manager for this feature
  120889. */
  120890. constructor(_xrSessionManager: WebXRSessionManager);
  120891. /**
  120892. * Is this feature attached
  120893. */
  120894. get attached(): boolean;
  120895. /**
  120896. * attach this feature
  120897. *
  120898. * @param force should attachment be forced (even when already attached)
  120899. * @returns true if successful, false is failed or already attached
  120900. */
  120901. attach(force?: boolean): boolean;
  120902. /**
  120903. * detach this feature.
  120904. *
  120905. * @returns true if successful, false if failed or already detached
  120906. */
  120907. detach(): boolean;
  120908. /**
  120909. * Dispose this feature and all of the resources attached
  120910. */
  120911. dispose(): void;
  120912. /**
  120913. * This is used to register callbacks that will automatically be removed when detach is called.
  120914. * @param observable the observable to which the observer will be attached
  120915. * @param callback the callback to register
  120916. */
  120917. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120918. /**
  120919. * Code in this function will be executed on each xrFrame received from the browser.
  120920. * This function will not execute after the feature is detached.
  120921. * @param _xrFrame the current frame
  120922. */
  120923. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120924. }
  120925. }
  120926. declare module BABYLON {
  120927. /**
  120928. * Renders a layer on top of an existing scene
  120929. */
  120930. export class UtilityLayerRenderer implements IDisposable {
  120931. /** the original scene that will be rendered on top of */
  120932. originalScene: Scene;
  120933. private _pointerCaptures;
  120934. private _lastPointerEvents;
  120935. private static _DefaultUtilityLayer;
  120936. private static _DefaultKeepDepthUtilityLayer;
  120937. private _sharedGizmoLight;
  120938. private _renderCamera;
  120939. /**
  120940. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  120941. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  120942. * @returns the camera that is used when rendering the utility layer
  120943. */
  120944. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  120945. /**
  120946. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  120947. * @param cam the camera that should be used when rendering the utility layer
  120948. */
  120949. setRenderCamera(cam: Nullable<Camera>): void;
  120950. /**
  120951. * @hidden
  120952. * Light which used by gizmos to get light shading
  120953. */
  120954. _getSharedGizmoLight(): HemisphericLight;
  120955. /**
  120956. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  120957. */
  120958. pickUtilitySceneFirst: boolean;
  120959. /**
  120960. * 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)
  120961. */
  120962. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  120963. /**
  120964. * 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)
  120965. */
  120966. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  120967. /**
  120968. * The scene that is rendered on top of the original scene
  120969. */
  120970. utilityLayerScene: Scene;
  120971. /**
  120972. * If the utility layer should automatically be rendered on top of existing scene
  120973. */
  120974. shouldRender: boolean;
  120975. /**
  120976. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  120977. */
  120978. onlyCheckPointerDownEvents: boolean;
  120979. /**
  120980. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  120981. */
  120982. processAllEvents: boolean;
  120983. /**
  120984. * Observable raised when the pointer move from the utility layer scene to the main scene
  120985. */
  120986. onPointerOutObservable: Observable<number>;
  120987. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  120988. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  120989. private _afterRenderObserver;
  120990. private _sceneDisposeObserver;
  120991. private _originalPointerObserver;
  120992. /**
  120993. * Instantiates a UtilityLayerRenderer
  120994. * @param originalScene the original scene that will be rendered on top of
  120995. * @param handleEvents boolean indicating if the utility layer should handle events
  120996. */
  120997. constructor(
  120998. /** the original scene that will be rendered on top of */
  120999. originalScene: Scene, handleEvents?: boolean);
  121000. private _notifyObservers;
  121001. /**
  121002. * Renders the utility layers scene on top of the original scene
  121003. */
  121004. render(): void;
  121005. /**
  121006. * Disposes of the renderer
  121007. */
  121008. dispose(): void;
  121009. private _updateCamera;
  121010. }
  121011. }
  121012. declare module BABYLON {
  121013. /**
  121014. * Options interface for the pointer selection module
  121015. */
  121016. export interface IWebXRControllerPointerSelectionOptions {
  121017. /**
  121018. * if provided, this scene will be used to render meshes.
  121019. */
  121020. customUtilityLayerScene?: Scene;
  121021. /**
  121022. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  121023. * If not disabled, the last picked point will be used to execute a pointer up event
  121024. * If disabled, pointer up event will be triggered right after the pointer down event.
  121025. * Used in screen and gaze target ray mode only
  121026. */
  121027. disablePointerUpOnTouchOut: boolean;
  121028. /**
  121029. * For gaze mode (time to select instead of press)
  121030. */
  121031. forceGazeMode: boolean;
  121032. /**
  121033. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  121034. * to start a new countdown to the pointer down event.
  121035. * Defaults to 1.
  121036. */
  121037. gazeModePointerMovedFactor?: number;
  121038. /**
  121039. * Different button type to use instead of the main component
  121040. */
  121041. overrideButtonId?: string;
  121042. /**
  121043. * use this rendering group id for the meshes (optional)
  121044. */
  121045. renderingGroupId?: number;
  121046. /**
  121047. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  121048. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  121049. * 3000 means 3 seconds between pointing at something and selecting it
  121050. */
  121051. timeToSelect?: number;
  121052. /**
  121053. * Should meshes created here be added to a utility layer or the main scene
  121054. */
  121055. useUtilityLayer?: boolean;
  121056. /**
  121057. * the xr input to use with this pointer selection
  121058. */
  121059. xrInput: WebXRInput;
  121060. }
  121061. /**
  121062. * A module that will enable pointer selection for motion controllers of XR Input Sources
  121063. */
  121064. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  121065. private readonly _options;
  121066. private static _idCounter;
  121067. private _attachController;
  121068. private _controllers;
  121069. private _scene;
  121070. private _tmpVectorForPickCompare;
  121071. /**
  121072. * The module's name
  121073. */
  121074. static readonly Name: string;
  121075. /**
  121076. * The (Babylon) version of this module.
  121077. * This is an integer representing the implementation version.
  121078. * This number does not correspond to the WebXR specs version
  121079. */
  121080. static readonly Version: number;
  121081. /**
  121082. * Disable lighting on the laser pointer (so it will always be visible)
  121083. */
  121084. disablePointerLighting: boolean;
  121085. /**
  121086. * Disable lighting on the selection mesh (so it will always be visible)
  121087. */
  121088. disableSelectionMeshLighting: boolean;
  121089. /**
  121090. * Should the laser pointer be displayed
  121091. */
  121092. displayLaserPointer: boolean;
  121093. /**
  121094. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  121095. */
  121096. displaySelectionMesh: boolean;
  121097. /**
  121098. * This color will be set to the laser pointer when selection is triggered
  121099. */
  121100. laserPointerPickedColor: Color3;
  121101. /**
  121102. * Default color of the laser pointer
  121103. */
  121104. lasterPointerDefaultColor: Color3;
  121105. /**
  121106. * default color of the selection ring
  121107. */
  121108. selectionMeshDefaultColor: Color3;
  121109. /**
  121110. * This color will be applied to the selection ring when selection is triggered
  121111. */
  121112. selectionMeshPickedColor: Color3;
  121113. /**
  121114. * Optional filter to be used for ray selection. This predicate shares behavior with
  121115. * scene.pointerMovePredicate which takes priority if it is also assigned.
  121116. */
  121117. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121118. /**
  121119. * constructs a new background remover module
  121120. * @param _xrSessionManager the session manager for this module
  121121. * @param _options read-only options to be used in this module
  121122. */
  121123. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  121124. /**
  121125. * attach this feature
  121126. * Will usually be called by the features manager
  121127. *
  121128. * @returns true if successful.
  121129. */
  121130. attach(): boolean;
  121131. /**
  121132. * detach this feature.
  121133. * Will usually be called by the features manager
  121134. *
  121135. * @returns true if successful.
  121136. */
  121137. detach(): boolean;
  121138. /**
  121139. * Will get the mesh under a specific pointer.
  121140. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  121141. * @param controllerId the controllerId to check
  121142. * @returns The mesh under pointer or null if no mesh is under the pointer
  121143. */
  121144. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  121145. /**
  121146. * Get the xr controller that correlates to the pointer id in the pointer event
  121147. *
  121148. * @param id the pointer id to search for
  121149. * @returns the controller that correlates to this id or null if not found
  121150. */
  121151. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  121152. protected _onXRFrame(_xrFrame: XRFrame): void;
  121153. private _attachGazeMode;
  121154. private _attachScreenRayMode;
  121155. private _attachTrackedPointerRayMode;
  121156. private _convertNormalToDirectionOfRay;
  121157. private _detachController;
  121158. private _generateNewMeshPair;
  121159. private _pickingMoved;
  121160. private _updatePointerDistance;
  121161. }
  121162. }
  121163. declare module BABYLON {
  121164. /**
  121165. * Button which can be used to enter a different mode of XR
  121166. */
  121167. export class WebXREnterExitUIButton {
  121168. /** button element */
  121169. element: HTMLElement;
  121170. /** XR initialization options for the button */
  121171. sessionMode: XRSessionMode;
  121172. /** Reference space type */
  121173. referenceSpaceType: XRReferenceSpaceType;
  121174. /**
  121175. * Creates a WebXREnterExitUIButton
  121176. * @param element button element
  121177. * @param sessionMode XR initialization session mode
  121178. * @param referenceSpaceType the type of reference space to be used
  121179. */
  121180. constructor(
  121181. /** button element */
  121182. element: HTMLElement,
  121183. /** XR initialization options for the button */
  121184. sessionMode: XRSessionMode,
  121185. /** Reference space type */
  121186. referenceSpaceType: XRReferenceSpaceType);
  121187. /**
  121188. * Extendable function which can be used to update the button's visuals when the state changes
  121189. * @param activeButton the current active button in the UI
  121190. */
  121191. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  121192. }
  121193. /**
  121194. * Options to create the webXR UI
  121195. */
  121196. export class WebXREnterExitUIOptions {
  121197. /**
  121198. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  121199. */
  121200. customButtons?: Array<WebXREnterExitUIButton>;
  121201. /**
  121202. * A reference space type to use when creating the default button.
  121203. * Default is local-floor
  121204. */
  121205. referenceSpaceType?: XRReferenceSpaceType;
  121206. /**
  121207. * Context to enter xr with
  121208. */
  121209. renderTarget?: Nullable<WebXRRenderTarget>;
  121210. /**
  121211. * A session mode to use when creating the default button.
  121212. * Default is immersive-vr
  121213. */
  121214. sessionMode?: XRSessionMode;
  121215. /**
  121216. * A list of optional features to init the session with
  121217. */
  121218. optionalFeatures?: string[];
  121219. }
  121220. /**
  121221. * UI to allow the user to enter/exit XR mode
  121222. */
  121223. export class WebXREnterExitUI implements IDisposable {
  121224. private scene;
  121225. /** version of the options passed to this UI */
  121226. options: WebXREnterExitUIOptions;
  121227. private _activeButton;
  121228. private _buttons;
  121229. private _overlay;
  121230. /**
  121231. * Fired every time the active button is changed.
  121232. *
  121233. * When xr is entered via a button that launches xr that button will be the callback parameter
  121234. *
  121235. * When exiting xr the callback parameter will be null)
  121236. */
  121237. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121238. /**
  121239. *
  121240. * @param scene babylon scene object to use
  121241. * @param options (read-only) version of the options passed to this UI
  121242. */
  121243. private constructor();
  121244. /**
  121245. * Creates UI to allow the user to enter/exit XR mode
  121246. * @param scene the scene to add the ui to
  121247. * @param helper the xr experience helper to enter/exit xr with
  121248. * @param options options to configure the UI
  121249. * @returns the created ui
  121250. */
  121251. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121252. /**
  121253. * Disposes of the XR UI component
  121254. */
  121255. dispose(): void;
  121256. private _updateButtons;
  121257. }
  121258. }
  121259. declare module BABYLON {
  121260. /**
  121261. * Class containing static functions to help procedurally build meshes
  121262. */
  121263. export class LinesBuilder {
  121264. /**
  121265. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121266. * * 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
  121267. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121268. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121269. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121270. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121271. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121272. * * 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
  121273. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121276. * @param name defines the name of the new line system
  121277. * @param options defines the options used to create the line system
  121278. * @param scene defines the hosting scene
  121279. * @returns a new line system mesh
  121280. */
  121281. static CreateLineSystem(name: string, options: {
  121282. lines: Vector3[][];
  121283. updatable?: boolean;
  121284. instance?: Nullable<LinesMesh>;
  121285. colors?: Nullable<Color4[][]>;
  121286. useVertexAlpha?: boolean;
  121287. }, scene: Nullable<Scene>): LinesMesh;
  121288. /**
  121289. * Creates a line mesh
  121290. * 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
  121291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121292. * * The parameter `points` is an array successive Vector3
  121293. * * 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
  121294. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121295. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121296. * * When updating an instance, remember that only point positions can change, not the number of points
  121297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121299. * @param name defines the name of the new line system
  121300. * @param options defines the options used to create the line system
  121301. * @param scene defines the hosting scene
  121302. * @returns a new line mesh
  121303. */
  121304. static CreateLines(name: string, options: {
  121305. points: Vector3[];
  121306. updatable?: boolean;
  121307. instance?: Nullable<LinesMesh>;
  121308. colors?: Color4[];
  121309. useVertexAlpha?: boolean;
  121310. }, scene?: Nullable<Scene>): LinesMesh;
  121311. /**
  121312. * Creates a dashed line mesh
  121313. * * 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
  121314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121315. * * The parameter `points` is an array successive Vector3
  121316. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121317. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121318. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121319. * * 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
  121320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121321. * * When updating an instance, remember that only point positions can change, not the number of points
  121322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121323. * @param name defines the name of the mesh
  121324. * @param options defines the options used to create the mesh
  121325. * @param scene defines the hosting scene
  121326. * @returns the dashed line mesh
  121327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121328. */
  121329. static CreateDashedLines(name: string, options: {
  121330. points: Vector3[];
  121331. dashSize?: number;
  121332. gapSize?: number;
  121333. dashNb?: number;
  121334. updatable?: boolean;
  121335. instance?: LinesMesh;
  121336. useVertexAlpha?: boolean;
  121337. }, scene?: Nullable<Scene>): LinesMesh;
  121338. }
  121339. }
  121340. declare module BABYLON {
  121341. /**
  121342. * The options container for the teleportation module
  121343. */
  121344. export interface IWebXRTeleportationOptions {
  121345. /**
  121346. * if provided, this scene will be used to render meshes.
  121347. */
  121348. customUtilityLayerScene?: Scene;
  121349. /**
  121350. * Values to configure the default target mesh
  121351. */
  121352. defaultTargetMeshOptions?: {
  121353. /**
  121354. * Fill color of the teleportation area
  121355. */
  121356. teleportationFillColor?: string;
  121357. /**
  121358. * Border color for the teleportation area
  121359. */
  121360. teleportationBorderColor?: string;
  121361. /**
  121362. * Disable the mesh's animation sequence
  121363. */
  121364. disableAnimation?: boolean;
  121365. /**
  121366. * Disable lighting on the material or the ring and arrow
  121367. */
  121368. disableLighting?: boolean;
  121369. /**
  121370. * Override the default material of the torus and arrow
  121371. */
  121372. torusArrowMaterial?: Material;
  121373. };
  121374. /**
  121375. * A list of meshes to use as floor meshes.
  121376. * Meshes can be added and removed after initializing the feature using the
  121377. * addFloorMesh and removeFloorMesh functions
  121378. * If empty, rotation will still work
  121379. */
  121380. floorMeshes?: AbstractMesh[];
  121381. /**
  121382. * use this rendering group id for the meshes (optional)
  121383. */
  121384. renderingGroupId?: number;
  121385. /**
  121386. * Should teleportation move only to snap points
  121387. */
  121388. snapPointsOnly?: boolean;
  121389. /**
  121390. * An array of points to which the teleportation will snap to.
  121391. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121392. */
  121393. snapPositions?: Vector3[];
  121394. /**
  121395. * How close should the teleportation ray be in order to snap to position.
  121396. * Default to 0.8 units (meters)
  121397. */
  121398. snapToPositionRadius?: number;
  121399. /**
  121400. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121401. * If you want to support rotation, make sure your mesh has a direction indicator.
  121402. *
  121403. * When left untouched, the default mesh will be initialized.
  121404. */
  121405. teleportationTargetMesh?: AbstractMesh;
  121406. /**
  121407. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121408. */
  121409. timeToTeleport?: number;
  121410. /**
  121411. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121412. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121413. */
  121414. useMainComponentOnly?: boolean;
  121415. /**
  121416. * Should meshes created here be added to a utility layer or the main scene
  121417. */
  121418. useUtilityLayer?: boolean;
  121419. /**
  121420. * Babylon XR Input class for controller
  121421. */
  121422. xrInput: WebXRInput;
  121423. }
  121424. /**
  121425. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121426. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121427. * the input of the attached controllers.
  121428. */
  121429. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121430. private _options;
  121431. private _controllers;
  121432. private _currentTeleportationControllerId;
  121433. private _floorMeshes;
  121434. private _quadraticBezierCurve;
  121435. private _selectionFeature;
  121436. private _snapToPositions;
  121437. private _snappedToPoint;
  121438. private _teleportationRingMaterial?;
  121439. private _tmpRay;
  121440. private _tmpVector;
  121441. /**
  121442. * The module's name
  121443. */
  121444. static readonly Name: string;
  121445. /**
  121446. * The (Babylon) version of this module.
  121447. * This is an integer representing the implementation version.
  121448. * This number does not correspond to the webxr specs version
  121449. */
  121450. static readonly Version: number;
  121451. /**
  121452. * Is movement backwards enabled
  121453. */
  121454. backwardsMovementEnabled: boolean;
  121455. /**
  121456. * Distance to travel when moving backwards
  121457. */
  121458. backwardsTeleportationDistance: number;
  121459. /**
  121460. * The distance from the user to the inspection point in the direction of the controller
  121461. * A higher number will allow the user to move further
  121462. * defaults to 5 (meters, in xr units)
  121463. */
  121464. parabolicCheckRadius: number;
  121465. /**
  121466. * Should the module support parabolic ray on top of direct ray
  121467. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121468. * Very helpful when moving between floors / different heights
  121469. */
  121470. parabolicRayEnabled: boolean;
  121471. /**
  121472. * How much rotation should be applied when rotating right and left
  121473. */
  121474. rotationAngle: number;
  121475. /**
  121476. * Is rotation enabled when moving forward?
  121477. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121478. */
  121479. rotationEnabled: boolean;
  121480. /**
  121481. * constructs a new anchor system
  121482. * @param _xrSessionManager an instance of WebXRSessionManager
  121483. * @param _options configuration object for this feature
  121484. */
  121485. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121486. /**
  121487. * Get the snapPointsOnly flag
  121488. */
  121489. get snapPointsOnly(): boolean;
  121490. /**
  121491. * Sets the snapPointsOnly flag
  121492. * @param snapToPoints should teleportation be exclusively to snap points
  121493. */
  121494. set snapPointsOnly(snapToPoints: boolean);
  121495. /**
  121496. * Add a new mesh to the floor meshes array
  121497. * @param mesh the mesh to use as floor mesh
  121498. */
  121499. addFloorMesh(mesh: AbstractMesh): void;
  121500. /**
  121501. * Add a new snap-to point to fix teleportation to this position
  121502. * @param newSnapPoint The new Snap-To point
  121503. */
  121504. addSnapPoint(newSnapPoint: Vector3): void;
  121505. attach(): boolean;
  121506. detach(): boolean;
  121507. dispose(): void;
  121508. /**
  121509. * Remove a mesh from the floor meshes array
  121510. * @param mesh the mesh to remove
  121511. */
  121512. removeFloorMesh(mesh: AbstractMesh): void;
  121513. /**
  121514. * Remove a mesh from the floor meshes array using its name
  121515. * @param name the mesh name to remove
  121516. */
  121517. removeFloorMeshByName(name: string): void;
  121518. /**
  121519. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  121520. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121521. * @returns was the point found and removed or not
  121522. */
  121523. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121524. /**
  121525. * This function sets a selection feature that will be disabled when
  121526. * the forward ray is shown and will be reattached when hidden.
  121527. * This is used to remove the selection rays when moving.
  121528. * @param selectionFeature the feature to disable when forward movement is enabled
  121529. */
  121530. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121531. protected _onXRFrame(_xrFrame: XRFrame): void;
  121532. private _attachController;
  121533. private _createDefaultTargetMesh;
  121534. private _detachController;
  121535. private _findClosestSnapPointWithRadius;
  121536. private _setTargetMeshPosition;
  121537. private _setTargetMeshVisibility;
  121538. private _showParabolicPath;
  121539. private _teleportForward;
  121540. }
  121541. }
  121542. declare module BABYLON {
  121543. /**
  121544. * Options for the default xr helper
  121545. */
  121546. export class WebXRDefaultExperienceOptions {
  121547. /**
  121548. * Enable or disable default UI to enter XR
  121549. */
  121550. disableDefaultUI?: boolean;
  121551. /**
  121552. * Should teleportation not initialize. defaults to false.
  121553. */
  121554. disableTeleportation?: boolean;
  121555. /**
  121556. * Floor meshes that will be used for teleport
  121557. */
  121558. floorMeshes?: Array<AbstractMesh>;
  121559. /**
  121560. * If set to true, the first frame will not be used to reset position
  121561. * The first frame is mainly used when copying transformation from the old camera
  121562. * Mainly used in AR
  121563. */
  121564. ignoreNativeCameraTransformation?: boolean;
  121565. /**
  121566. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121567. */
  121568. inputOptions?: IWebXRInputOptions;
  121569. /**
  121570. * optional configuration for the output canvas
  121571. */
  121572. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121573. /**
  121574. * optional UI options. This can be used among other to change session mode and reference space type
  121575. */
  121576. uiOptions?: WebXREnterExitUIOptions;
  121577. /**
  121578. * When loading teleportation and pointer select, use stable versions instead of latest.
  121579. */
  121580. useStablePlugins?: boolean;
  121581. /**
  121582. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121583. */
  121584. renderingGroupId?: number;
  121585. /**
  121586. * A list of optional features to init the session with
  121587. * If set to true, all features we support will be added
  121588. */
  121589. optionalFeatures?: boolean | string[];
  121590. }
  121591. /**
  121592. * Default experience which provides a similar setup to the previous webVRExperience
  121593. */
  121594. export class WebXRDefaultExperience {
  121595. /**
  121596. * Base experience
  121597. */
  121598. baseExperience: WebXRExperienceHelper;
  121599. /**
  121600. * Enables ui for entering/exiting xr
  121601. */
  121602. enterExitUI: WebXREnterExitUI;
  121603. /**
  121604. * Input experience extension
  121605. */
  121606. input: WebXRInput;
  121607. /**
  121608. * Enables laser pointer and selection
  121609. */
  121610. pointerSelection: WebXRControllerPointerSelection;
  121611. /**
  121612. * Default target xr should render to
  121613. */
  121614. renderTarget: WebXRRenderTarget;
  121615. /**
  121616. * Enables teleportation
  121617. */
  121618. teleportation: WebXRMotionControllerTeleportation;
  121619. private constructor();
  121620. /**
  121621. * Creates the default xr experience
  121622. * @param scene scene
  121623. * @param options options for basic configuration
  121624. * @returns resulting WebXRDefaultExperience
  121625. */
  121626. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121627. /**
  121628. * DIsposes of the experience helper
  121629. */
  121630. dispose(): void;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Options to modify the vr teleportation behavior.
  121636. */
  121637. export interface VRTeleportationOptions {
  121638. /**
  121639. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121640. */
  121641. floorMeshName?: string;
  121642. /**
  121643. * A list of meshes to be used as the teleportation floor. (default: empty)
  121644. */
  121645. floorMeshes?: Mesh[];
  121646. /**
  121647. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121648. */
  121649. teleportationMode?: number;
  121650. /**
  121651. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121652. */
  121653. teleportationTime?: number;
  121654. /**
  121655. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121656. */
  121657. teleportationSpeed?: number;
  121658. /**
  121659. * The easing function used in the animation or null for Linear. (default CircleEase)
  121660. */
  121661. easingFunction?: EasingFunction;
  121662. }
  121663. /**
  121664. * Options to modify the vr experience helper's behavior.
  121665. */
  121666. export interface VRExperienceHelperOptions extends WebVROptions {
  121667. /**
  121668. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121669. */
  121670. createDeviceOrientationCamera?: boolean;
  121671. /**
  121672. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121673. */
  121674. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121675. /**
  121676. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121677. */
  121678. laserToggle?: boolean;
  121679. /**
  121680. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121681. */
  121682. floorMeshes?: Mesh[];
  121683. /**
  121684. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121685. */
  121686. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121687. /**
  121688. * Defines if WebXR should be used instead of WebVR (if available)
  121689. */
  121690. useXR?: boolean;
  121691. }
  121692. /**
  121693. * Event containing information after VR has been entered
  121694. */
  121695. export class OnAfterEnteringVRObservableEvent {
  121696. /**
  121697. * If entering vr was successful
  121698. */
  121699. success: boolean;
  121700. }
  121701. /**
  121702. * Helps to quickly add VR support to an existing scene.
  121703. * See http://doc.babylonjs.com/how_to/webvr_helper
  121704. */
  121705. export class VRExperienceHelper {
  121706. /** Options to modify the vr experience helper's behavior. */
  121707. webVROptions: VRExperienceHelperOptions;
  121708. private _scene;
  121709. private _position;
  121710. private _btnVR;
  121711. private _btnVRDisplayed;
  121712. private _webVRsupported;
  121713. private _webVRready;
  121714. private _webVRrequesting;
  121715. private _webVRpresenting;
  121716. private _hasEnteredVR;
  121717. private _fullscreenVRpresenting;
  121718. private _inputElement;
  121719. private _webVRCamera;
  121720. private _vrDeviceOrientationCamera;
  121721. private _deviceOrientationCamera;
  121722. private _existingCamera;
  121723. private _onKeyDown;
  121724. private _onVrDisplayPresentChange;
  121725. private _onVRDisplayChanged;
  121726. private _onVRRequestPresentStart;
  121727. private _onVRRequestPresentComplete;
  121728. /**
  121729. * 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)
  121730. */
  121731. enableGazeEvenWhenNoPointerLock: boolean;
  121732. /**
  121733. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121734. */
  121735. exitVROnDoubleTap: boolean;
  121736. /**
  121737. * Observable raised right before entering VR.
  121738. */
  121739. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121740. /**
  121741. * Observable raised when entering VR has completed.
  121742. */
  121743. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121744. /**
  121745. * Observable raised when exiting VR.
  121746. */
  121747. onExitingVRObservable: Observable<VRExperienceHelper>;
  121748. /**
  121749. * Observable raised when controller mesh is loaded.
  121750. */
  121751. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121752. /** Return this.onEnteringVRObservable
  121753. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121754. */
  121755. get onEnteringVR(): Observable<VRExperienceHelper>;
  121756. /** Return this.onExitingVRObservable
  121757. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121758. */
  121759. get onExitingVR(): Observable<VRExperienceHelper>;
  121760. /** Return this.onControllerMeshLoadedObservable
  121761. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121762. */
  121763. get onControllerMeshLoaded(): Observable<WebVRController>;
  121764. private _rayLength;
  121765. private _useCustomVRButton;
  121766. private _teleportationRequested;
  121767. private _teleportActive;
  121768. private _floorMeshName;
  121769. private _floorMeshesCollection;
  121770. private _teleportationMode;
  121771. private _teleportationTime;
  121772. private _teleportationSpeed;
  121773. private _teleportationEasing;
  121774. private _rotationAllowed;
  121775. private _teleportBackwardsVector;
  121776. private _teleportationTarget;
  121777. private _isDefaultTeleportationTarget;
  121778. private _postProcessMove;
  121779. private _teleportationFillColor;
  121780. private _teleportationBorderColor;
  121781. private _rotationAngle;
  121782. private _haloCenter;
  121783. private _cameraGazer;
  121784. private _padSensibilityUp;
  121785. private _padSensibilityDown;
  121786. private _leftController;
  121787. private _rightController;
  121788. private _gazeColor;
  121789. private _laserColor;
  121790. private _pickedLaserColor;
  121791. private _pickedGazeColor;
  121792. /**
  121793. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121794. */
  121795. onNewMeshSelected: Observable<AbstractMesh>;
  121796. /**
  121797. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121798. * This observable will provide the mesh and the controller used to select the mesh
  121799. */
  121800. onMeshSelectedWithController: Observable<{
  121801. mesh: AbstractMesh;
  121802. controller: WebVRController;
  121803. }>;
  121804. /**
  121805. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121806. */
  121807. onNewMeshPicked: Observable<PickingInfo>;
  121808. private _circleEase;
  121809. /**
  121810. * Observable raised before camera teleportation
  121811. */
  121812. onBeforeCameraTeleport: Observable<Vector3>;
  121813. /**
  121814. * Observable raised after camera teleportation
  121815. */
  121816. onAfterCameraTeleport: Observable<Vector3>;
  121817. /**
  121818. * Observable raised when current selected mesh gets unselected
  121819. */
  121820. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121821. private _raySelectionPredicate;
  121822. /**
  121823. * To be optionaly changed by user to define custom ray selection
  121824. */
  121825. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121826. /**
  121827. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121828. */
  121829. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121830. /**
  121831. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121832. */
  121833. teleportationEnabled: boolean;
  121834. private _defaultHeight;
  121835. private _teleportationInitialized;
  121836. private _interactionsEnabled;
  121837. private _interactionsRequested;
  121838. private _displayGaze;
  121839. private _displayLaserPointer;
  121840. /**
  121841. * The mesh used to display where the user is going to teleport.
  121842. */
  121843. get teleportationTarget(): Mesh;
  121844. /**
  121845. * Sets the mesh to be used to display where the user is going to teleport.
  121846. */
  121847. set teleportationTarget(value: Mesh);
  121848. /**
  121849. * 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
  121850. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121851. * See http://doc.babylonjs.com/resources/baking_transformations
  121852. */
  121853. get gazeTrackerMesh(): Mesh;
  121854. set gazeTrackerMesh(value: Mesh);
  121855. /**
  121856. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121857. */
  121858. updateGazeTrackerScale: boolean;
  121859. /**
  121860. * If the gaze trackers color should be updated when selecting meshes
  121861. */
  121862. updateGazeTrackerColor: boolean;
  121863. /**
  121864. * If the controller laser color should be updated when selecting meshes
  121865. */
  121866. updateControllerLaserColor: boolean;
  121867. /**
  121868. * The gaze tracking mesh corresponding to the left controller
  121869. */
  121870. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121871. /**
  121872. * The gaze tracking mesh corresponding to the right controller
  121873. */
  121874. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121875. /**
  121876. * If the ray of the gaze should be displayed.
  121877. */
  121878. get displayGaze(): boolean;
  121879. /**
  121880. * Sets if the ray of the gaze should be displayed.
  121881. */
  121882. set displayGaze(value: boolean);
  121883. /**
  121884. * If the ray of the LaserPointer should be displayed.
  121885. */
  121886. get displayLaserPointer(): boolean;
  121887. /**
  121888. * Sets if the ray of the LaserPointer should be displayed.
  121889. */
  121890. set displayLaserPointer(value: boolean);
  121891. /**
  121892. * The deviceOrientationCamera used as the camera when not in VR.
  121893. */
  121894. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121895. /**
  121896. * Based on the current WebVR support, returns the current VR camera used.
  121897. */
  121898. get currentVRCamera(): Nullable<Camera>;
  121899. /**
  121900. * The webVRCamera which is used when in VR.
  121901. */
  121902. get webVRCamera(): WebVRFreeCamera;
  121903. /**
  121904. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121905. */
  121906. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121907. /**
  121908. * The html button that is used to trigger entering into VR.
  121909. */
  121910. get vrButton(): Nullable<HTMLButtonElement>;
  121911. private get _teleportationRequestInitiated();
  121912. /**
  121913. * Defines whether or not Pointer lock should be requested when switching to
  121914. * full screen.
  121915. */
  121916. requestPointerLockOnFullScreen: boolean;
  121917. /**
  121918. * If asking to force XR, this will be populated with the default xr experience
  121919. */
  121920. xr: WebXRDefaultExperience;
  121921. /**
  121922. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121923. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121924. */
  121925. xrTestDone: boolean;
  121926. /**
  121927. * Instantiates a VRExperienceHelper.
  121928. * Helps to quickly add VR support to an existing scene.
  121929. * @param scene The scene the VRExperienceHelper belongs to.
  121930. * @param webVROptions Options to modify the vr experience helper's behavior.
  121931. */
  121932. constructor(scene: Scene,
  121933. /** Options to modify the vr experience helper's behavior. */
  121934. webVROptions?: VRExperienceHelperOptions);
  121935. private completeVRInit;
  121936. private _onDefaultMeshLoaded;
  121937. private _onResize;
  121938. private _onFullscreenChange;
  121939. /**
  121940. * Gets a value indicating if we are currently in VR mode.
  121941. */
  121942. get isInVRMode(): boolean;
  121943. private onVrDisplayPresentChange;
  121944. private onVRDisplayChanged;
  121945. private moveButtonToBottomRight;
  121946. private displayVRButton;
  121947. private updateButtonVisibility;
  121948. private _cachedAngularSensibility;
  121949. /**
  121950. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  121951. * Otherwise, will use the fullscreen API.
  121952. */
  121953. enterVR(): void;
  121954. /**
  121955. * Attempt to exit VR, or fullscreen.
  121956. */
  121957. exitVR(): void;
  121958. /**
  121959. * The position of the vr experience helper.
  121960. */
  121961. get position(): Vector3;
  121962. /**
  121963. * Sets the position of the vr experience helper.
  121964. */
  121965. set position(value: Vector3);
  121966. /**
  121967. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  121968. */
  121969. enableInteractions(): void;
  121970. private get _noControllerIsActive();
  121971. private beforeRender;
  121972. private _isTeleportationFloor;
  121973. /**
  121974. * Adds a floor mesh to be used for teleportation.
  121975. * @param floorMesh the mesh to be used for teleportation.
  121976. */
  121977. addFloorMesh(floorMesh: Mesh): void;
  121978. /**
  121979. * Removes a floor mesh from being used for teleportation.
  121980. * @param floorMesh the mesh to be removed.
  121981. */
  121982. removeFloorMesh(floorMesh: Mesh): void;
  121983. /**
  121984. * Enables interactions and teleportation using the VR controllers and gaze.
  121985. * @param vrTeleportationOptions options to modify teleportation behavior.
  121986. */
  121987. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  121988. private _onNewGamepadConnected;
  121989. private _tryEnableInteractionOnController;
  121990. private _onNewGamepadDisconnected;
  121991. private _enableInteractionOnController;
  121992. private _checkTeleportWithRay;
  121993. private _checkRotate;
  121994. private _checkTeleportBackwards;
  121995. private _enableTeleportationOnController;
  121996. private _createTeleportationCircles;
  121997. private _displayTeleportationTarget;
  121998. private _hideTeleportationTarget;
  121999. private _rotateCamera;
  122000. private _moveTeleportationSelectorTo;
  122001. private _workingVector;
  122002. private _workingQuaternion;
  122003. private _workingMatrix;
  122004. /**
  122005. * Time Constant Teleportation Mode
  122006. */
  122007. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  122008. /**
  122009. * Speed Constant Teleportation Mode
  122010. */
  122011. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  122012. /**
  122013. * Teleports the users feet to the desired location
  122014. * @param location The location where the user's feet should be placed
  122015. */
  122016. teleportCamera(location: Vector3): void;
  122017. private _convertNormalToDirectionOfRay;
  122018. private _castRayAndSelectObject;
  122019. private _notifySelectedMeshUnselected;
  122020. /**
  122021. * Permanently set new colors for the laser pointer
  122022. * @param color the new laser color
  122023. * @param pickedColor the new laser color when picked mesh detected
  122024. */
  122025. setLaserColor(color: Color3, pickedColor?: Color3): void;
  122026. /**
  122027. * Set lighting enabled / disabled on the laser pointer of both controllers
  122028. * @param enabled should the lighting be enabled on the laser pointer
  122029. */
  122030. setLaserLightingState(enabled?: boolean): void;
  122031. /**
  122032. * Permanently set new colors for the gaze pointer
  122033. * @param color the new gaze color
  122034. * @param pickedColor the new gaze color when picked mesh detected
  122035. */
  122036. setGazeColor(color: Color3, pickedColor?: Color3): void;
  122037. /**
  122038. * Sets the color of the laser ray from the vr controllers.
  122039. * @param color new color for the ray.
  122040. */
  122041. changeLaserColor(color: Color3): void;
  122042. /**
  122043. * Sets the color of the ray from the vr headsets gaze.
  122044. * @param color new color for the ray.
  122045. */
  122046. changeGazeColor(color: Color3): void;
  122047. /**
  122048. * Exits VR and disposes of the vr experience helper
  122049. */
  122050. dispose(): void;
  122051. /**
  122052. * Gets the name of the VRExperienceHelper class
  122053. * @returns "VRExperienceHelper"
  122054. */
  122055. getClassName(): string;
  122056. }
  122057. }
  122058. declare module BABYLON {
  122059. /**
  122060. * Contains an array of blocks representing the octree
  122061. */
  122062. export interface IOctreeContainer<T> {
  122063. /**
  122064. * Blocks within the octree
  122065. */
  122066. blocks: Array<OctreeBlock<T>>;
  122067. }
  122068. /**
  122069. * Class used to store a cell in an octree
  122070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122071. */
  122072. export class OctreeBlock<T> {
  122073. /**
  122074. * Gets the content of the current block
  122075. */
  122076. entries: T[];
  122077. /**
  122078. * Gets the list of block children
  122079. */
  122080. blocks: Array<OctreeBlock<T>>;
  122081. private _depth;
  122082. private _maxDepth;
  122083. private _capacity;
  122084. private _minPoint;
  122085. private _maxPoint;
  122086. private _boundingVectors;
  122087. private _creationFunc;
  122088. /**
  122089. * Creates a new block
  122090. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  122091. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  122092. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122093. * @param depth defines the current depth of this block in the octree
  122094. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  122095. * @param creationFunc defines a callback to call when an element is added to the block
  122096. */
  122097. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  122098. /**
  122099. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  122100. */
  122101. get capacity(): number;
  122102. /**
  122103. * Gets the minimum vector (in world space) of the block's bounding box
  122104. */
  122105. get minPoint(): Vector3;
  122106. /**
  122107. * Gets the maximum vector (in world space) of the block's bounding box
  122108. */
  122109. get maxPoint(): Vector3;
  122110. /**
  122111. * Add a new element to this block
  122112. * @param entry defines the element to add
  122113. */
  122114. addEntry(entry: T): void;
  122115. /**
  122116. * Remove an element from this block
  122117. * @param entry defines the element to remove
  122118. */
  122119. removeEntry(entry: T): void;
  122120. /**
  122121. * Add an array of elements to this block
  122122. * @param entries defines the array of elements to add
  122123. */
  122124. addEntries(entries: T[]): void;
  122125. /**
  122126. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  122127. * @param frustumPlanes defines the frustum planes to test
  122128. * @param selection defines the array to store current content if selection is positive
  122129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122130. */
  122131. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122132. /**
  122133. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  122134. * @param sphereCenter defines the bounding sphere center
  122135. * @param sphereRadius defines the bounding sphere radius
  122136. * @param selection defines the array to store current content if selection is positive
  122137. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122138. */
  122139. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  122140. /**
  122141. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  122142. * @param ray defines the ray to test with
  122143. * @param selection defines the array to store current content if selection is positive
  122144. */
  122145. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  122146. /**
  122147. * Subdivide the content into child blocks (this block will then be empty)
  122148. */
  122149. createInnerBlocks(): void;
  122150. /**
  122151. * @hidden
  122152. */
  122153. 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;
  122154. }
  122155. }
  122156. declare module BABYLON {
  122157. /**
  122158. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  122159. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122160. */
  122161. export class Octree<T> {
  122162. /** 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.) */
  122163. maxDepth: number;
  122164. /**
  122165. * Blocks within the octree containing objects
  122166. */
  122167. blocks: Array<OctreeBlock<T>>;
  122168. /**
  122169. * Content stored in the octree
  122170. */
  122171. dynamicContent: T[];
  122172. private _maxBlockCapacity;
  122173. private _selectionContent;
  122174. private _creationFunc;
  122175. /**
  122176. * Creates a octree
  122177. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122178. * @param creationFunc function to be used to instatiate the octree
  122179. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  122180. * @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.)
  122181. */
  122182. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  122183. /** 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.) */
  122184. maxDepth?: number);
  122185. /**
  122186. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  122187. * @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);
  122188. * @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);
  122189. * @param entries meshes to be added to the octree blocks
  122190. */
  122191. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  122192. /**
  122193. * Adds a mesh to the octree
  122194. * @param entry Mesh to add to the octree
  122195. */
  122196. addMesh(entry: T): void;
  122197. /**
  122198. * Remove an element from the octree
  122199. * @param entry defines the element to remove
  122200. */
  122201. removeMesh(entry: T): void;
  122202. /**
  122203. * Selects an array of meshes within the frustum
  122204. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  122205. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  122206. * @returns array of meshes within the frustum
  122207. */
  122208. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  122209. /**
  122210. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  122211. * @param sphereCenter defines the bounding sphere center
  122212. * @param sphereRadius defines the bounding sphere radius
  122213. * @param allowDuplicate defines if the selection array can contains duplicated entries
  122214. * @returns an array of objects that intersect the sphere
  122215. */
  122216. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  122217. /**
  122218. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  122219. * @param ray defines the ray to test with
  122220. * @returns array of intersected objects
  122221. */
  122222. intersectsRay(ray: Ray): SmartArray<T>;
  122223. /**
  122224. * Adds a mesh into the octree block if it intersects the block
  122225. */
  122226. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  122227. /**
  122228. * Adds a submesh into the octree block if it intersects the block
  122229. */
  122230. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122231. }
  122232. }
  122233. declare module BABYLON {
  122234. interface Scene {
  122235. /**
  122236. * @hidden
  122237. * Backing Filed
  122238. */
  122239. _selectionOctree: Octree<AbstractMesh>;
  122240. /**
  122241. * Gets the octree used to boost mesh selection (picking)
  122242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122243. */
  122244. selectionOctree: Octree<AbstractMesh>;
  122245. /**
  122246. * Creates or updates the octree used to boost selection (picking)
  122247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122248. * @param maxCapacity defines the maximum capacity per leaf
  122249. * @param maxDepth defines the maximum depth of the octree
  122250. * @returns an octree of AbstractMesh
  122251. */
  122252. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122253. }
  122254. interface AbstractMesh {
  122255. /**
  122256. * @hidden
  122257. * Backing Field
  122258. */
  122259. _submeshesOctree: Octree<SubMesh>;
  122260. /**
  122261. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122262. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122263. * @param maxCapacity defines the maximum size of each block (64 by default)
  122264. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122265. * @returns the new octree
  122266. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122268. */
  122269. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122270. }
  122271. /**
  122272. * Defines the octree scene component responsible to manage any octrees
  122273. * in a given scene.
  122274. */
  122275. export class OctreeSceneComponent {
  122276. /**
  122277. * The component name help to identify the component in the list of scene components.
  122278. */
  122279. readonly name: string;
  122280. /**
  122281. * The scene the component belongs to.
  122282. */
  122283. scene: Scene;
  122284. /**
  122285. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122286. */
  122287. readonly checksIsEnabled: boolean;
  122288. /**
  122289. * Creates a new instance of the component for the given scene
  122290. * @param scene Defines the scene to register the component in
  122291. */
  122292. constructor(scene: Scene);
  122293. /**
  122294. * Registers the component in a given scene
  122295. */
  122296. register(): void;
  122297. /**
  122298. * Return the list of active meshes
  122299. * @returns the list of active meshes
  122300. */
  122301. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122302. /**
  122303. * Return the list of active sub meshes
  122304. * @param mesh The mesh to get the candidates sub meshes from
  122305. * @returns the list of active sub meshes
  122306. */
  122307. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122308. private _tempRay;
  122309. /**
  122310. * Return the list of sub meshes intersecting with a given local ray
  122311. * @param mesh defines the mesh to find the submesh for
  122312. * @param localRay defines the ray in local space
  122313. * @returns the list of intersecting sub meshes
  122314. */
  122315. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122316. /**
  122317. * Return the list of sub meshes colliding with a collider
  122318. * @param mesh defines the mesh to find the submesh for
  122319. * @param collider defines the collider to evaluate the collision against
  122320. * @returns the list of colliding sub meshes
  122321. */
  122322. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122323. /**
  122324. * Rebuilds the elements related to this component in case of
  122325. * context lost for instance.
  122326. */
  122327. rebuild(): void;
  122328. /**
  122329. * Disposes the component and the associated ressources.
  122330. */
  122331. dispose(): void;
  122332. }
  122333. }
  122334. declare module BABYLON {
  122335. /**
  122336. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122337. */
  122338. export class Gizmo implements IDisposable {
  122339. /** The utility layer the gizmo will be added to */
  122340. gizmoLayer: UtilityLayerRenderer;
  122341. /**
  122342. * The root mesh of the gizmo
  122343. */
  122344. _rootMesh: Mesh;
  122345. private _attachedMesh;
  122346. /**
  122347. * Ratio for the scale of the gizmo (Default: 1)
  122348. */
  122349. scaleRatio: number;
  122350. /**
  122351. * If a custom mesh has been set (Default: false)
  122352. */
  122353. protected _customMeshSet: boolean;
  122354. /**
  122355. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122356. * * When set, interactions will be enabled
  122357. */
  122358. get attachedMesh(): Nullable<AbstractMesh>;
  122359. set attachedMesh(value: Nullable<AbstractMesh>);
  122360. /**
  122361. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122362. * @param mesh The mesh to replace the default mesh of the gizmo
  122363. */
  122364. setCustomMesh(mesh: Mesh): void;
  122365. /**
  122366. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122367. */
  122368. updateGizmoRotationToMatchAttachedMesh: boolean;
  122369. /**
  122370. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122371. */
  122372. updateGizmoPositionToMatchAttachedMesh: boolean;
  122373. /**
  122374. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122375. */
  122376. updateScale: boolean;
  122377. protected _interactionsEnabled: boolean;
  122378. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122379. private _beforeRenderObserver;
  122380. private _tempVector;
  122381. /**
  122382. * Creates a gizmo
  122383. * @param gizmoLayer The utility layer the gizmo will be added to
  122384. */
  122385. constructor(
  122386. /** The utility layer the gizmo will be added to */
  122387. gizmoLayer?: UtilityLayerRenderer);
  122388. /**
  122389. * Updates the gizmo to match the attached mesh's position/rotation
  122390. */
  122391. protected _update(): void;
  122392. /**
  122393. * Disposes of the gizmo
  122394. */
  122395. dispose(): void;
  122396. }
  122397. }
  122398. declare module BABYLON {
  122399. /**
  122400. * Single plane drag gizmo
  122401. */
  122402. export class PlaneDragGizmo extends Gizmo {
  122403. /**
  122404. * Drag behavior responsible for the gizmos dragging interactions
  122405. */
  122406. dragBehavior: PointerDragBehavior;
  122407. private _pointerObserver;
  122408. /**
  122409. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122410. */
  122411. snapDistance: number;
  122412. /**
  122413. * Event that fires each time the gizmo snaps to a new location.
  122414. * * snapDistance is the the change in distance
  122415. */
  122416. onSnapObservable: Observable<{
  122417. snapDistance: number;
  122418. }>;
  122419. private _plane;
  122420. private _coloredMaterial;
  122421. private _hoverMaterial;
  122422. private _isEnabled;
  122423. private _parent;
  122424. /** @hidden */
  122425. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122426. /** @hidden */
  122427. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122428. /**
  122429. * Creates a PlaneDragGizmo
  122430. * @param gizmoLayer The utility layer the gizmo will be added to
  122431. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122432. * @param color The color of the gizmo
  122433. */
  122434. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122435. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122436. /**
  122437. * If the gizmo is enabled
  122438. */
  122439. set isEnabled(value: boolean);
  122440. get isEnabled(): boolean;
  122441. /**
  122442. * Disposes of the gizmo
  122443. */
  122444. dispose(): void;
  122445. }
  122446. }
  122447. declare module BABYLON {
  122448. /**
  122449. * Gizmo that enables dragging a mesh along 3 axis
  122450. */
  122451. export class PositionGizmo extends Gizmo {
  122452. /**
  122453. * Internal gizmo used for interactions on the x axis
  122454. */
  122455. xGizmo: AxisDragGizmo;
  122456. /**
  122457. * Internal gizmo used for interactions on the y axis
  122458. */
  122459. yGizmo: AxisDragGizmo;
  122460. /**
  122461. * Internal gizmo used for interactions on the z axis
  122462. */
  122463. zGizmo: AxisDragGizmo;
  122464. /**
  122465. * Internal gizmo used for interactions on the yz plane
  122466. */
  122467. xPlaneGizmo: PlaneDragGizmo;
  122468. /**
  122469. * Internal gizmo used for interactions on the xz plane
  122470. */
  122471. yPlaneGizmo: PlaneDragGizmo;
  122472. /**
  122473. * Internal gizmo used for interactions on the xy plane
  122474. */
  122475. zPlaneGizmo: PlaneDragGizmo;
  122476. /**
  122477. * private variables
  122478. */
  122479. private _meshAttached;
  122480. private _updateGizmoRotationToMatchAttachedMesh;
  122481. private _snapDistance;
  122482. private _scaleRatio;
  122483. /** Fires an event when any of it's sub gizmos are dragged */
  122484. onDragStartObservable: Observable<unknown>;
  122485. /** Fires an event when any of it's sub gizmos are released from dragging */
  122486. onDragEndObservable: Observable<unknown>;
  122487. /**
  122488. * If set to true, planar drag is enabled
  122489. */
  122490. private _planarGizmoEnabled;
  122491. get attachedMesh(): Nullable<AbstractMesh>;
  122492. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122493. /**
  122494. * Creates a PositionGizmo
  122495. * @param gizmoLayer The utility layer the gizmo will be added to
  122496. */
  122497. constructor(gizmoLayer?: UtilityLayerRenderer);
  122498. /**
  122499. * If the planar drag gizmo is enabled
  122500. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122501. */
  122502. set planarGizmoEnabled(value: boolean);
  122503. get planarGizmoEnabled(): boolean;
  122504. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122505. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122506. /**
  122507. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122508. */
  122509. set snapDistance(value: number);
  122510. get snapDistance(): number;
  122511. /**
  122512. * Ratio for the scale of the gizmo (Default: 1)
  122513. */
  122514. set scaleRatio(value: number);
  122515. get scaleRatio(): number;
  122516. /**
  122517. * Disposes of the gizmo
  122518. */
  122519. dispose(): void;
  122520. /**
  122521. * CustomMeshes are not supported by this gizmo
  122522. * @param mesh The mesh to replace the default mesh of the gizmo
  122523. */
  122524. setCustomMesh(mesh: Mesh): void;
  122525. }
  122526. }
  122527. declare module BABYLON {
  122528. /**
  122529. * Single axis drag gizmo
  122530. */
  122531. export class AxisDragGizmo extends Gizmo {
  122532. /**
  122533. * Drag behavior responsible for the gizmos dragging interactions
  122534. */
  122535. dragBehavior: PointerDragBehavior;
  122536. private _pointerObserver;
  122537. /**
  122538. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122539. */
  122540. snapDistance: number;
  122541. /**
  122542. * Event that fires each time the gizmo snaps to a new location.
  122543. * * snapDistance is the the change in distance
  122544. */
  122545. onSnapObservable: Observable<{
  122546. snapDistance: number;
  122547. }>;
  122548. private _isEnabled;
  122549. private _parent;
  122550. private _arrow;
  122551. private _coloredMaterial;
  122552. private _hoverMaterial;
  122553. /** @hidden */
  122554. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122555. /** @hidden */
  122556. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122557. /**
  122558. * Creates an AxisDragGizmo
  122559. * @param gizmoLayer The utility layer the gizmo will be added to
  122560. * @param dragAxis The axis which the gizmo will be able to drag on
  122561. * @param color The color of the gizmo
  122562. */
  122563. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122564. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122565. /**
  122566. * If the gizmo is enabled
  122567. */
  122568. set isEnabled(value: boolean);
  122569. get isEnabled(): boolean;
  122570. /**
  122571. * Disposes of the gizmo
  122572. */
  122573. dispose(): void;
  122574. }
  122575. }
  122576. declare module BABYLON.Debug {
  122577. /**
  122578. * The Axes viewer will show 3 axes in a specific point in space
  122579. */
  122580. export class AxesViewer {
  122581. private _xAxis;
  122582. private _yAxis;
  122583. private _zAxis;
  122584. private _scaleLinesFactor;
  122585. private _instanced;
  122586. /**
  122587. * Gets the hosting scene
  122588. */
  122589. scene: Scene;
  122590. /**
  122591. * Gets or sets a number used to scale line length
  122592. */
  122593. scaleLines: number;
  122594. /** Gets the node hierarchy used to render x-axis */
  122595. get xAxis(): TransformNode;
  122596. /** Gets the node hierarchy used to render y-axis */
  122597. get yAxis(): TransformNode;
  122598. /** Gets the node hierarchy used to render z-axis */
  122599. get zAxis(): TransformNode;
  122600. /**
  122601. * Creates a new AxesViewer
  122602. * @param scene defines the hosting scene
  122603. * @param scaleLines defines a number used to scale line length (1 by default)
  122604. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122605. * @param xAxis defines the node hierarchy used to render the x-axis
  122606. * @param yAxis defines the node hierarchy used to render the y-axis
  122607. * @param zAxis defines the node hierarchy used to render the z-axis
  122608. */
  122609. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122610. /**
  122611. * Force the viewer to update
  122612. * @param position defines the position of the viewer
  122613. * @param xaxis defines the x axis of the viewer
  122614. * @param yaxis defines the y axis of the viewer
  122615. * @param zaxis defines the z axis of the viewer
  122616. */
  122617. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122618. /**
  122619. * Creates an instance of this axes viewer.
  122620. * @returns a new axes viewer with instanced meshes
  122621. */
  122622. createInstance(): AxesViewer;
  122623. /** Releases resources */
  122624. dispose(): void;
  122625. private static _SetRenderingGroupId;
  122626. }
  122627. }
  122628. declare module BABYLON.Debug {
  122629. /**
  122630. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122631. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122632. */
  122633. export class BoneAxesViewer extends AxesViewer {
  122634. /**
  122635. * Gets or sets the target mesh where to display the axes viewer
  122636. */
  122637. mesh: Nullable<Mesh>;
  122638. /**
  122639. * Gets or sets the target bone where to display the axes viewer
  122640. */
  122641. bone: Nullable<Bone>;
  122642. /** Gets current position */
  122643. pos: Vector3;
  122644. /** Gets direction of X axis */
  122645. xaxis: Vector3;
  122646. /** Gets direction of Y axis */
  122647. yaxis: Vector3;
  122648. /** Gets direction of Z axis */
  122649. zaxis: Vector3;
  122650. /**
  122651. * Creates a new BoneAxesViewer
  122652. * @param scene defines the hosting scene
  122653. * @param bone defines the target bone
  122654. * @param mesh defines the target mesh
  122655. * @param scaleLines defines a scaling factor for line length (1 by default)
  122656. */
  122657. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122658. /**
  122659. * Force the viewer to update
  122660. */
  122661. update(): void;
  122662. /** Releases resources */
  122663. dispose(): void;
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * Interface used to define scene explorer extensibility option
  122669. */
  122670. export interface IExplorerExtensibilityOption {
  122671. /**
  122672. * Define the option label
  122673. */
  122674. label: string;
  122675. /**
  122676. * Defines the action to execute on click
  122677. */
  122678. action: (entity: any) => void;
  122679. }
  122680. /**
  122681. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122682. */
  122683. export interface IExplorerExtensibilityGroup {
  122684. /**
  122685. * Defines a predicate to test if a given type mut be extended
  122686. */
  122687. predicate: (entity: any) => boolean;
  122688. /**
  122689. * Gets the list of options added to a type
  122690. */
  122691. entries: IExplorerExtensibilityOption[];
  122692. }
  122693. /**
  122694. * Interface used to define the options to use to create the Inspector
  122695. */
  122696. export interface IInspectorOptions {
  122697. /**
  122698. * Display in overlay mode (default: false)
  122699. */
  122700. overlay?: boolean;
  122701. /**
  122702. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122703. */
  122704. globalRoot?: HTMLElement;
  122705. /**
  122706. * Display the Scene explorer
  122707. */
  122708. showExplorer?: boolean;
  122709. /**
  122710. * Display the property inspector
  122711. */
  122712. showInspector?: boolean;
  122713. /**
  122714. * Display in embed mode (both panes on the right)
  122715. */
  122716. embedMode?: boolean;
  122717. /**
  122718. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122719. */
  122720. handleResize?: boolean;
  122721. /**
  122722. * Allow the panes to popup (default: true)
  122723. */
  122724. enablePopup?: boolean;
  122725. /**
  122726. * Allow the panes to be closed by users (default: true)
  122727. */
  122728. enableClose?: boolean;
  122729. /**
  122730. * Optional list of extensibility entries
  122731. */
  122732. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122733. /**
  122734. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122735. */
  122736. inspectorURL?: string;
  122737. /**
  122738. * Optional initial tab (default to DebugLayerTab.Properties)
  122739. */
  122740. initialTab?: DebugLayerTab;
  122741. }
  122742. interface Scene {
  122743. /**
  122744. * @hidden
  122745. * Backing field
  122746. */
  122747. _debugLayer: DebugLayer;
  122748. /**
  122749. * Gets the debug layer (aka Inspector) associated with the scene
  122750. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122751. */
  122752. debugLayer: DebugLayer;
  122753. }
  122754. /**
  122755. * Enum of inspector action tab
  122756. */
  122757. export enum DebugLayerTab {
  122758. /**
  122759. * Properties tag (default)
  122760. */
  122761. Properties = 0,
  122762. /**
  122763. * Debug tab
  122764. */
  122765. Debug = 1,
  122766. /**
  122767. * Statistics tab
  122768. */
  122769. Statistics = 2,
  122770. /**
  122771. * Tools tab
  122772. */
  122773. Tools = 3,
  122774. /**
  122775. * Settings tab
  122776. */
  122777. Settings = 4
  122778. }
  122779. /**
  122780. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122781. * what is happening in your scene
  122782. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122783. */
  122784. export class DebugLayer {
  122785. /**
  122786. * Define the url to get the inspector script from.
  122787. * By default it uses the babylonjs CDN.
  122788. * @ignoreNaming
  122789. */
  122790. static InspectorURL: string;
  122791. private _scene;
  122792. private BJSINSPECTOR;
  122793. private _onPropertyChangedObservable?;
  122794. /**
  122795. * Observable triggered when a property is changed through the inspector.
  122796. */
  122797. get onPropertyChangedObservable(): any;
  122798. /**
  122799. * Instantiates a new debug layer.
  122800. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122801. * what is happening in your scene
  122802. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122803. * @param scene Defines the scene to inspect
  122804. */
  122805. constructor(scene: Scene);
  122806. /** Creates the inspector window. */
  122807. private _createInspector;
  122808. /**
  122809. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122810. * @param entity defines the entity to select
  122811. * @param lineContainerTitle defines the specific block to highlight
  122812. */
  122813. select(entity: any, lineContainerTitle?: string): void;
  122814. /** Get the inspector from bundle or global */
  122815. private _getGlobalInspector;
  122816. /**
  122817. * Get if the inspector is visible or not.
  122818. * @returns true if visible otherwise, false
  122819. */
  122820. isVisible(): boolean;
  122821. /**
  122822. * Hide the inspector and close its window.
  122823. */
  122824. hide(): void;
  122825. /**
  122826. * Update the scene in the inspector
  122827. */
  122828. setAsActiveScene(): void;
  122829. /**
  122830. * Launch the debugLayer.
  122831. * @param config Define the configuration of the inspector
  122832. * @return a promise fulfilled when the debug layer is visible
  122833. */
  122834. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122835. }
  122836. }
  122837. declare module BABYLON {
  122838. /**
  122839. * Class containing static functions to help procedurally build meshes
  122840. */
  122841. export class BoxBuilder {
  122842. /**
  122843. * Creates a box mesh
  122844. * * The parameter `size` sets the size (float) of each box side (default 1)
  122845. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122846. * * 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)
  122847. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122851. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122852. * @param name defines the name of the mesh
  122853. * @param options defines the options used to create the mesh
  122854. * @param scene defines the hosting scene
  122855. * @returns the box mesh
  122856. */
  122857. static CreateBox(name: string, options: {
  122858. size?: number;
  122859. width?: number;
  122860. height?: number;
  122861. depth?: number;
  122862. faceUV?: Vector4[];
  122863. faceColors?: Color4[];
  122864. sideOrientation?: number;
  122865. frontUVs?: Vector4;
  122866. backUVs?: Vector4;
  122867. wrap?: boolean;
  122868. topBaseAt?: number;
  122869. bottomBaseAt?: number;
  122870. updatable?: boolean;
  122871. }, scene?: Nullable<Scene>): Mesh;
  122872. }
  122873. }
  122874. declare module BABYLON.Debug {
  122875. /**
  122876. * Used to show the physics impostor around the specific mesh
  122877. */
  122878. export class PhysicsViewer {
  122879. /** @hidden */
  122880. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122881. /** @hidden */
  122882. protected _meshes: Array<Nullable<AbstractMesh>>;
  122883. /** @hidden */
  122884. protected _scene: Nullable<Scene>;
  122885. /** @hidden */
  122886. protected _numMeshes: number;
  122887. /** @hidden */
  122888. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122889. private _renderFunction;
  122890. private _utilityLayer;
  122891. private _debugBoxMesh;
  122892. private _debugSphereMesh;
  122893. private _debugCylinderMesh;
  122894. private _debugMaterial;
  122895. private _debugMeshMeshes;
  122896. /**
  122897. * Creates a new PhysicsViewer
  122898. * @param scene defines the hosting scene
  122899. */
  122900. constructor(scene: Scene);
  122901. /** @hidden */
  122902. protected _updateDebugMeshes(): void;
  122903. /**
  122904. * Renders a specified physic impostor
  122905. * @param impostor defines the impostor to render
  122906. * @param targetMesh defines the mesh represented by the impostor
  122907. * @returns the new debug mesh used to render the impostor
  122908. */
  122909. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122910. /**
  122911. * Hides a specified physic impostor
  122912. * @param impostor defines the impostor to hide
  122913. */
  122914. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122915. private _getDebugMaterial;
  122916. private _getDebugBoxMesh;
  122917. private _getDebugSphereMesh;
  122918. private _getDebugCylinderMesh;
  122919. private _getDebugMeshMesh;
  122920. private _getDebugMesh;
  122921. /** Releases all resources */
  122922. dispose(): void;
  122923. }
  122924. }
  122925. declare module BABYLON {
  122926. /**
  122927. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122928. * in order to better appreciate the issue one might have.
  122929. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122930. */
  122931. export class RayHelper {
  122932. /**
  122933. * Defines the ray we are currently tryin to visualize.
  122934. */
  122935. ray: Nullable<Ray>;
  122936. private _renderPoints;
  122937. private _renderLine;
  122938. private _renderFunction;
  122939. private _scene;
  122940. private _updateToMeshFunction;
  122941. private _attachedToMesh;
  122942. private _meshSpaceDirection;
  122943. private _meshSpaceOrigin;
  122944. /**
  122945. * Helper function to create a colored helper in a scene in one line.
  122946. * @param ray Defines the ray we are currently tryin to visualize
  122947. * @param scene Defines the scene the ray is used in
  122948. * @param color Defines the color we want to see the ray in
  122949. * @returns The newly created ray helper.
  122950. */
  122951. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  122952. /**
  122953. * Instantiate a new ray helper.
  122954. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122955. * in order to better appreciate the issue one might have.
  122956. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122957. * @param ray Defines the ray we are currently tryin to visualize
  122958. */
  122959. constructor(ray: Ray);
  122960. /**
  122961. * Shows the ray we are willing to debug.
  122962. * @param scene Defines the scene the ray needs to be rendered in
  122963. * @param color Defines the color the ray needs to be rendered in
  122964. */
  122965. show(scene: Scene, color?: Color3): void;
  122966. /**
  122967. * Hides the ray we are debugging.
  122968. */
  122969. hide(): void;
  122970. private _render;
  122971. /**
  122972. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  122973. * @param mesh Defines the mesh we want the helper attached to
  122974. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  122975. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  122976. * @param length Defines the length of the ray
  122977. */
  122978. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  122979. /**
  122980. * Detach the ray helper from the mesh it has previously been attached to.
  122981. */
  122982. detachFromMesh(): void;
  122983. private _updateToMesh;
  122984. /**
  122985. * Dispose the helper and release its associated resources.
  122986. */
  122987. dispose(): void;
  122988. }
  122989. }
  122990. declare module BABYLON.Debug {
  122991. /**
  122992. * Class used to render a debug view of a given skeleton
  122993. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  122994. */
  122995. export class SkeletonViewer {
  122996. /** defines the skeleton to render */
  122997. skeleton: Skeleton;
  122998. /** defines the mesh attached to the skeleton */
  122999. mesh: AbstractMesh;
  123000. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123001. autoUpdateBonesMatrices: boolean;
  123002. /** defines the rendering group id to use with the viewer */
  123003. renderingGroupId: number;
  123004. /** Gets or sets the color used to render the skeleton */
  123005. color: Color3;
  123006. private _scene;
  123007. private _debugLines;
  123008. private _debugMesh;
  123009. private _isEnabled;
  123010. private _renderFunction;
  123011. private _utilityLayer;
  123012. /**
  123013. * Returns the mesh used to render the bones
  123014. */
  123015. get debugMesh(): Nullable<LinesMesh>;
  123016. /**
  123017. * Creates a new SkeletonViewer
  123018. * @param skeleton defines the skeleton to render
  123019. * @param mesh defines the mesh attached to the skeleton
  123020. * @param scene defines the hosting scene
  123021. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  123022. * @param renderingGroupId defines the rendering group id to use with the viewer
  123023. */
  123024. constructor(
  123025. /** defines the skeleton to render */
  123026. skeleton: Skeleton,
  123027. /** defines the mesh attached to the skeleton */
  123028. mesh: AbstractMesh, scene: Scene,
  123029. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  123030. autoUpdateBonesMatrices?: boolean,
  123031. /** defines the rendering group id to use with the viewer */
  123032. renderingGroupId?: number);
  123033. /** Gets or sets a boolean indicating if the viewer is enabled */
  123034. set isEnabled(value: boolean);
  123035. get isEnabled(): boolean;
  123036. private _getBonePosition;
  123037. private _getLinesForBonesWithLength;
  123038. private _getLinesForBonesNoLength;
  123039. /** Update the viewer to sync with current skeleton state */
  123040. update(): void;
  123041. /** Release associated resources */
  123042. dispose(): void;
  123043. }
  123044. }
  123045. declare module BABYLON {
  123046. /**
  123047. * This class will take all inputs from Keyboard, Pointer, and
  123048. * any Gamepads and provide a polling system that all devices
  123049. * will use. This class assumes that there will only be one
  123050. * pointer device and one keyboard.
  123051. */
  123052. export class DeviceInputSystem implements IDisposable {
  123053. /** POINTER_DEVICE */
  123054. static readonly POINTER_DEVICE: string;
  123055. /** KEYBOARD_DEVICE */
  123056. static readonly KEYBOARD_DEVICE: string;
  123057. /**
  123058. * Observable to be triggered when a device is connected
  123059. */
  123060. onDeviceConnectedObservable: Observable<string>;
  123061. /**
  123062. * Observable to be triggered when a device is disconnected
  123063. */
  123064. onDeviceDisconnectedObservable: Observable<string>;
  123065. private _inputs;
  123066. private _gamepads;
  123067. private _keyboardActive;
  123068. private _pointerActive;
  123069. private _elementToAttachTo;
  123070. private _keyboardDownEvent;
  123071. private _keyboardUpEvent;
  123072. private _pointerMoveEvent;
  123073. private _pointerDownEvent;
  123074. private _pointerUpEvent;
  123075. private _gamepadConnectedEvent;
  123076. private _gamepadDisconnectedEvent;
  123077. private static _MAX_KEYCODES;
  123078. private static _MAX_POINTER_INPUTS;
  123079. /**
  123080. * Default Constructor
  123081. * @param engine - engine to pull input element from
  123082. */
  123083. constructor(engine: Engine);
  123084. /**
  123085. * Checks for current device input value, given an id and input index
  123086. * @param deviceName Id of connected device
  123087. * @param inputIndex Index of device input
  123088. * @returns Current value of input
  123089. */
  123090. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  123091. /**
  123092. * Dispose of all the eventlisteners and clears the observables
  123093. */
  123094. dispose(): void;
  123095. /**
  123096. * Add device and inputs to device map
  123097. * @param deviceName Assigned name of device (may be SN)
  123098. * @param numberOfInputs Number of input entries to create for given device
  123099. */
  123100. private _registerDevice;
  123101. /**
  123102. * Given a specific device name, remove that device from the device map
  123103. * @param deviceName Name of device to be removed
  123104. */
  123105. private _unregisterDevice;
  123106. /**
  123107. * Handle all actions that come from keyboard interaction
  123108. */
  123109. private _handleKeyActions;
  123110. /**
  123111. * Handle all actions that come from pointer interaction
  123112. */
  123113. private _handlePointerActions;
  123114. /**
  123115. * Handle all actions that come from gamepad interaction
  123116. */
  123117. private _handleGamepadActions;
  123118. /**
  123119. * Update all non-event based devices with each frame
  123120. */
  123121. private _updateDevice;
  123122. }
  123123. }
  123124. declare module BABYLON {
  123125. /**
  123126. * Options to create the null engine
  123127. */
  123128. export class NullEngineOptions {
  123129. /**
  123130. * Render width (Default: 512)
  123131. */
  123132. renderWidth: number;
  123133. /**
  123134. * Render height (Default: 256)
  123135. */
  123136. renderHeight: number;
  123137. /**
  123138. * Texture size (Default: 512)
  123139. */
  123140. textureSize: number;
  123141. /**
  123142. * If delta time between frames should be constant
  123143. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123144. */
  123145. deterministicLockstep: boolean;
  123146. /**
  123147. * Maximum about of steps between frames (Default: 4)
  123148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123149. */
  123150. lockstepMaxSteps: number;
  123151. }
  123152. /**
  123153. * The null engine class provides support for headless version of babylon.js.
  123154. * This can be used in server side scenario or for testing purposes
  123155. */
  123156. export class NullEngine extends Engine {
  123157. private _options;
  123158. /**
  123159. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  123160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123161. * @returns true if engine is in deterministic lock step mode
  123162. */
  123163. isDeterministicLockStep(): boolean;
  123164. /**
  123165. * Gets the max steps when engine is running in deterministic lock step
  123166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123167. * @returns the max steps
  123168. */
  123169. getLockstepMaxSteps(): number;
  123170. /**
  123171. * Gets the current hardware scaling level.
  123172. * By default the hardware scaling level is computed from the window device ratio.
  123173. * 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.
  123174. * @returns a number indicating the current hardware scaling level
  123175. */
  123176. getHardwareScalingLevel(): number;
  123177. constructor(options?: NullEngineOptions);
  123178. /**
  123179. * Creates a vertex buffer
  123180. * @param vertices the data for the vertex buffer
  123181. * @returns the new WebGL static buffer
  123182. */
  123183. createVertexBuffer(vertices: FloatArray): DataBuffer;
  123184. /**
  123185. * Creates a new index buffer
  123186. * @param indices defines the content of the index buffer
  123187. * @param updatable defines if the index buffer must be updatable
  123188. * @returns a new webGL buffer
  123189. */
  123190. createIndexBuffer(indices: IndicesArray): DataBuffer;
  123191. /**
  123192. * Clear the current render buffer or the current render target (if any is set up)
  123193. * @param color defines the color to use
  123194. * @param backBuffer defines if the back buffer must be cleared
  123195. * @param depth defines if the depth buffer must be cleared
  123196. * @param stencil defines if the stencil buffer must be cleared
  123197. */
  123198. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  123199. /**
  123200. * Gets the current render width
  123201. * @param useScreen defines if screen size must be used (or the current render target if any)
  123202. * @returns a number defining the current render width
  123203. */
  123204. getRenderWidth(useScreen?: boolean): number;
  123205. /**
  123206. * Gets the current render height
  123207. * @param useScreen defines if screen size must be used (or the current render target if any)
  123208. * @returns a number defining the current render height
  123209. */
  123210. getRenderHeight(useScreen?: boolean): number;
  123211. /**
  123212. * Set the WebGL's viewport
  123213. * @param viewport defines the viewport element to be used
  123214. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  123215. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  123216. */
  123217. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  123218. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  123219. /**
  123220. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  123221. * @param pipelineContext defines the pipeline context to use
  123222. * @param uniformsNames defines the list of uniform names
  123223. * @returns an array of webGL uniform locations
  123224. */
  123225. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  123226. /**
  123227. * Gets the lsit of active attributes for a given webGL program
  123228. * @param pipelineContext defines the pipeline context to use
  123229. * @param attributesNames defines the list of attribute names to get
  123230. * @returns an array of indices indicating the offset of each attribute
  123231. */
  123232. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123233. /**
  123234. * Binds an effect to the webGL context
  123235. * @param effect defines the effect to bind
  123236. */
  123237. bindSamplers(effect: Effect): void;
  123238. /**
  123239. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123240. * @param effect defines the effect to activate
  123241. */
  123242. enableEffect(effect: Effect): void;
  123243. /**
  123244. * Set various states to the webGL context
  123245. * @param culling defines backface culling state
  123246. * @param zOffset defines the value to apply to zOffset (0 by default)
  123247. * @param force defines if states must be applied even if cache is up to date
  123248. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123249. */
  123250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123251. /**
  123252. * Set the value of an uniform to an array of int32
  123253. * @param uniform defines the webGL uniform location where to store the value
  123254. * @param array defines the array of int32 to store
  123255. */
  123256. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123257. /**
  123258. * Set the value of an uniform to an array of int32 (stored as vec2)
  123259. * @param uniform defines the webGL uniform location where to store the value
  123260. * @param array defines the array of int32 to store
  123261. */
  123262. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123263. /**
  123264. * Set the value of an uniform to an array of int32 (stored as vec3)
  123265. * @param uniform defines the webGL uniform location where to store the value
  123266. * @param array defines the array of int32 to store
  123267. */
  123268. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123269. /**
  123270. * Set the value of an uniform to an array of int32 (stored as vec4)
  123271. * @param uniform defines the webGL uniform location where to store the value
  123272. * @param array defines the array of int32 to store
  123273. */
  123274. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123275. /**
  123276. * Set the value of an uniform to an array of float32
  123277. * @param uniform defines the webGL uniform location where to store the value
  123278. * @param array defines the array of float32 to store
  123279. */
  123280. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123281. /**
  123282. * Set the value of an uniform to an array of float32 (stored as vec2)
  123283. * @param uniform defines the webGL uniform location where to store the value
  123284. * @param array defines the array of float32 to store
  123285. */
  123286. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123287. /**
  123288. * Set the value of an uniform to an array of float32 (stored as vec3)
  123289. * @param uniform defines the webGL uniform location where to store the value
  123290. * @param array defines the array of float32 to store
  123291. */
  123292. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123293. /**
  123294. * Set the value of an uniform to an array of float32 (stored as vec4)
  123295. * @param uniform defines the webGL uniform location where to store the value
  123296. * @param array defines the array of float32 to store
  123297. */
  123298. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123299. /**
  123300. * Set the value of an uniform to an array of number
  123301. * @param uniform defines the webGL uniform location where to store the value
  123302. * @param array defines the array of number to store
  123303. */
  123304. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123305. /**
  123306. * Set the value of an uniform to an array of number (stored as vec2)
  123307. * @param uniform defines the webGL uniform location where to store the value
  123308. * @param array defines the array of number to store
  123309. */
  123310. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123311. /**
  123312. * Set the value of an uniform to an array of number (stored as vec3)
  123313. * @param uniform defines the webGL uniform location where to store the value
  123314. * @param array defines the array of number to store
  123315. */
  123316. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123317. /**
  123318. * Set the value of an uniform to an array of number (stored as vec4)
  123319. * @param uniform defines the webGL uniform location where to store the value
  123320. * @param array defines the array of number to store
  123321. */
  123322. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123323. /**
  123324. * Set the value of an uniform to an array of float32 (stored as matrices)
  123325. * @param uniform defines the webGL uniform location where to store the value
  123326. * @param matrices defines the array of float32 to store
  123327. */
  123328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123329. /**
  123330. * Set the value of an uniform to a matrix (3x3)
  123331. * @param uniform defines the webGL uniform location where to store the value
  123332. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123333. */
  123334. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123335. /**
  123336. * Set the value of an uniform to a matrix (2x2)
  123337. * @param uniform defines the webGL uniform location where to store the value
  123338. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123339. */
  123340. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123341. /**
  123342. * Set the value of an uniform to a number (float)
  123343. * @param uniform defines the webGL uniform location where to store the value
  123344. * @param value defines the float number to store
  123345. */
  123346. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123347. /**
  123348. * Set the value of an uniform to a vec2
  123349. * @param uniform defines the webGL uniform location where to store the value
  123350. * @param x defines the 1st component of the value
  123351. * @param y defines the 2nd component of the value
  123352. */
  123353. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123354. /**
  123355. * Set the value of an uniform to a vec3
  123356. * @param uniform defines the webGL uniform location where to store the value
  123357. * @param x defines the 1st component of the value
  123358. * @param y defines the 2nd component of the value
  123359. * @param z defines the 3rd component of the value
  123360. */
  123361. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123362. /**
  123363. * Set the value of an uniform to a boolean
  123364. * @param uniform defines the webGL uniform location where to store the value
  123365. * @param bool defines the boolean to store
  123366. */
  123367. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123368. /**
  123369. * Set the value of an uniform to a vec4
  123370. * @param uniform defines the webGL uniform location where to store the value
  123371. * @param x defines the 1st component of the value
  123372. * @param y defines the 2nd component of the value
  123373. * @param z defines the 3rd component of the value
  123374. * @param w defines the 4th component of the value
  123375. */
  123376. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123377. /**
  123378. * Sets the current alpha mode
  123379. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123380. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123381. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123382. */
  123383. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123384. /**
  123385. * Bind webGl buffers directly to the webGL context
  123386. * @param vertexBuffers defines the vertex buffer to bind
  123387. * @param indexBuffer defines the index buffer to bind
  123388. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123389. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123390. * @param effect defines the effect associated with the vertex buffer
  123391. */
  123392. bindBuffers(vertexBuffers: {
  123393. [key: string]: VertexBuffer;
  123394. }, indexBuffer: DataBuffer, effect: Effect): void;
  123395. /**
  123396. * Force the entire cache to be cleared
  123397. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123398. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123399. */
  123400. wipeCaches(bruteForce?: boolean): void;
  123401. /**
  123402. * Send a draw order
  123403. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123404. * @param indexStart defines the starting index
  123405. * @param indexCount defines the number of index to draw
  123406. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123407. */
  123408. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123409. /**
  123410. * Draw a list of indexed primitives
  123411. * @param fillMode defines the primitive to use
  123412. * @param indexStart defines the starting index
  123413. * @param indexCount defines the number of index to draw
  123414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123415. */
  123416. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123417. /**
  123418. * Draw a list of unindexed primitives
  123419. * @param fillMode defines the primitive to use
  123420. * @param verticesStart defines the index of first vertex to draw
  123421. * @param verticesCount defines the count of vertices to draw
  123422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123423. */
  123424. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123425. /** @hidden */
  123426. _createTexture(): WebGLTexture;
  123427. /** @hidden */
  123428. _releaseTexture(texture: InternalTexture): void;
  123429. /**
  123430. * Usually called from Texture.ts.
  123431. * Passed information to create a WebGLTexture
  123432. * @param urlArg defines a value which contains one of the following:
  123433. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123434. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123435. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123437. * @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)
  123438. * @param scene needed for loading to the correct scene
  123439. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123440. * @param onLoad optional callback to be called upon successful completion
  123441. * @param onError optional callback to be called upon failure
  123442. * @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
  123443. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123444. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123445. * @param forcedExtension defines the extension to use to pick the right loader
  123446. * @param mimeType defines an optional mime type
  123447. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123448. */
  123449. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  123450. /**
  123451. * Creates a new render target texture
  123452. * @param size defines the size of the texture
  123453. * @param options defines the options used to create the texture
  123454. * @returns a new render target texture stored in an InternalTexture
  123455. */
  123456. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123457. /**
  123458. * Update the sampling mode of a given texture
  123459. * @param samplingMode defines the required sampling mode
  123460. * @param texture defines the texture to update
  123461. */
  123462. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123463. /**
  123464. * Binds the frame buffer to the specified texture.
  123465. * @param texture The texture to render to or null for the default canvas
  123466. * @param faceIndex The face of the texture to render to in case of cube texture
  123467. * @param requiredWidth The width of the target to render to
  123468. * @param requiredHeight The height of the target to render to
  123469. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123470. * @param lodLevel defines le lod level to bind to the frame buffer
  123471. */
  123472. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123473. /**
  123474. * Unbind the current render target texture from the webGL context
  123475. * @param texture defines the render target texture to unbind
  123476. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123477. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123478. */
  123479. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123480. /**
  123481. * Creates a dynamic vertex buffer
  123482. * @param vertices the data for the dynamic vertex buffer
  123483. * @returns the new WebGL dynamic buffer
  123484. */
  123485. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123486. /**
  123487. * Update the content of a dynamic texture
  123488. * @param texture defines the texture to update
  123489. * @param canvas defines the canvas containing the source
  123490. * @param invertY defines if data must be stored with Y axis inverted
  123491. * @param premulAlpha defines if alpha is stored as premultiplied
  123492. * @param format defines the format of the data
  123493. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123494. */
  123495. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123496. /**
  123497. * Gets a boolean indicating if all created effects are ready
  123498. * @returns true if all effects are ready
  123499. */
  123500. areAllEffectsReady(): boolean;
  123501. /**
  123502. * @hidden
  123503. * Get the current error code of the webGL context
  123504. * @returns the error code
  123505. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123506. */
  123507. getError(): number;
  123508. /** @hidden */
  123509. _getUnpackAlignement(): number;
  123510. /** @hidden */
  123511. _unpackFlipY(value: boolean): void;
  123512. /**
  123513. * Update a dynamic index buffer
  123514. * @param indexBuffer defines the target index buffer
  123515. * @param indices defines the data to update
  123516. * @param offset defines the offset in the target index buffer where update should start
  123517. */
  123518. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123519. /**
  123520. * Updates a dynamic vertex buffer.
  123521. * @param vertexBuffer the vertex buffer to update
  123522. * @param vertices the data used to update the vertex buffer
  123523. * @param byteOffset the byte offset of the data (optional)
  123524. * @param byteLength the byte length of the data (optional)
  123525. */
  123526. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123527. /** @hidden */
  123528. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123529. /** @hidden */
  123530. _bindTexture(channel: number, texture: InternalTexture): void;
  123531. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123532. /**
  123533. * 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
  123534. */
  123535. releaseEffects(): void;
  123536. displayLoadingUI(): void;
  123537. hideLoadingUI(): void;
  123538. /** @hidden */
  123539. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123540. /** @hidden */
  123541. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123542. /** @hidden */
  123543. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123544. /** @hidden */
  123545. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123546. }
  123547. }
  123548. declare module BABYLON {
  123549. /**
  123550. * @hidden
  123551. **/
  123552. export class _TimeToken {
  123553. _startTimeQuery: Nullable<WebGLQuery>;
  123554. _endTimeQuery: Nullable<WebGLQuery>;
  123555. _timeElapsedQuery: Nullable<WebGLQuery>;
  123556. _timeElapsedQueryEnded: boolean;
  123557. }
  123558. }
  123559. declare module BABYLON {
  123560. /** @hidden */
  123561. export class _OcclusionDataStorage {
  123562. /** @hidden */
  123563. occlusionInternalRetryCounter: number;
  123564. /** @hidden */
  123565. isOcclusionQueryInProgress: boolean;
  123566. /** @hidden */
  123567. isOccluded: boolean;
  123568. /** @hidden */
  123569. occlusionRetryCount: number;
  123570. /** @hidden */
  123571. occlusionType: number;
  123572. /** @hidden */
  123573. occlusionQueryAlgorithmType: number;
  123574. }
  123575. interface Engine {
  123576. /**
  123577. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123578. * @return the new query
  123579. */
  123580. createQuery(): WebGLQuery;
  123581. /**
  123582. * Delete and release a webGL query
  123583. * @param query defines the query to delete
  123584. * @return the current engine
  123585. */
  123586. deleteQuery(query: WebGLQuery): Engine;
  123587. /**
  123588. * Check if a given query has resolved and got its value
  123589. * @param query defines the query to check
  123590. * @returns true if the query got its value
  123591. */
  123592. isQueryResultAvailable(query: WebGLQuery): boolean;
  123593. /**
  123594. * Gets the value of a given query
  123595. * @param query defines the query to check
  123596. * @returns the value of the query
  123597. */
  123598. getQueryResult(query: WebGLQuery): number;
  123599. /**
  123600. * Initiates an occlusion query
  123601. * @param algorithmType defines the algorithm to use
  123602. * @param query defines the query to use
  123603. * @returns the current engine
  123604. * @see http://doc.babylonjs.com/features/occlusionquery
  123605. */
  123606. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123607. /**
  123608. * Ends an occlusion query
  123609. * @see http://doc.babylonjs.com/features/occlusionquery
  123610. * @param algorithmType defines the algorithm to use
  123611. * @returns the current engine
  123612. */
  123613. endOcclusionQuery(algorithmType: number): Engine;
  123614. /**
  123615. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123616. * Please note that only one query can be issued at a time
  123617. * @returns a time token used to track the time span
  123618. */
  123619. startTimeQuery(): Nullable<_TimeToken>;
  123620. /**
  123621. * Ends a time query
  123622. * @param token defines the token used to measure the time span
  123623. * @returns the time spent (in ns)
  123624. */
  123625. endTimeQuery(token: _TimeToken): int;
  123626. /** @hidden */
  123627. _currentNonTimestampToken: Nullable<_TimeToken>;
  123628. /** @hidden */
  123629. _createTimeQuery(): WebGLQuery;
  123630. /** @hidden */
  123631. _deleteTimeQuery(query: WebGLQuery): void;
  123632. /** @hidden */
  123633. _getGlAlgorithmType(algorithmType: number): number;
  123634. /** @hidden */
  123635. _getTimeQueryResult(query: WebGLQuery): any;
  123636. /** @hidden */
  123637. _getTimeQueryAvailability(query: WebGLQuery): any;
  123638. }
  123639. interface AbstractMesh {
  123640. /**
  123641. * Backing filed
  123642. * @hidden
  123643. */
  123644. __occlusionDataStorage: _OcclusionDataStorage;
  123645. /**
  123646. * Access property
  123647. * @hidden
  123648. */
  123649. _occlusionDataStorage: _OcclusionDataStorage;
  123650. /**
  123651. * 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.
  123652. * The default value is -1 which means don't break the query and wait till the result
  123653. * @see http://doc.babylonjs.com/features/occlusionquery
  123654. */
  123655. occlusionRetryCount: number;
  123656. /**
  123657. * 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:
  123658. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123659. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123660. * * 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.
  123661. * @see http://doc.babylonjs.com/features/occlusionquery
  123662. */
  123663. occlusionType: number;
  123664. /**
  123665. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123666. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123667. * * 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.
  123668. * @see http://doc.babylonjs.com/features/occlusionquery
  123669. */
  123670. occlusionQueryAlgorithmType: number;
  123671. /**
  123672. * 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
  123673. * @see http://doc.babylonjs.com/features/occlusionquery
  123674. */
  123675. isOccluded: boolean;
  123676. /**
  123677. * Flag to check the progress status of the query
  123678. * @see http://doc.babylonjs.com/features/occlusionquery
  123679. */
  123680. isOcclusionQueryInProgress: boolean;
  123681. }
  123682. }
  123683. declare module BABYLON {
  123684. /** @hidden */
  123685. export var _forceTransformFeedbackToBundle: boolean;
  123686. interface Engine {
  123687. /**
  123688. * Creates a webGL transform feedback object
  123689. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123690. * @returns the webGL transform feedback object
  123691. */
  123692. createTransformFeedback(): WebGLTransformFeedback;
  123693. /**
  123694. * Delete a webGL transform feedback object
  123695. * @param value defines the webGL transform feedback object to delete
  123696. */
  123697. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123698. /**
  123699. * Bind a webGL transform feedback object to the webgl context
  123700. * @param value defines the webGL transform feedback object to bind
  123701. */
  123702. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123703. /**
  123704. * Begins a transform feedback operation
  123705. * @param usePoints defines if points or triangles must be used
  123706. */
  123707. beginTransformFeedback(usePoints: boolean): void;
  123708. /**
  123709. * Ends a transform feedback operation
  123710. */
  123711. endTransformFeedback(): void;
  123712. /**
  123713. * Specify the varyings to use with transform feedback
  123714. * @param program defines the associated webGL program
  123715. * @param value defines the list of strings representing the varying names
  123716. */
  123717. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123718. /**
  123719. * Bind a webGL buffer for a transform feedback operation
  123720. * @param value defines the webGL buffer to bind
  123721. */
  123722. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123723. }
  123724. }
  123725. declare module BABYLON {
  123726. /**
  123727. * Creation options of the multi render target texture.
  123728. */
  123729. export interface IMultiRenderTargetOptions {
  123730. /**
  123731. * Define if the texture needs to create mip maps after render.
  123732. */
  123733. generateMipMaps?: boolean;
  123734. /**
  123735. * Define the types of all the draw buffers we want to create
  123736. */
  123737. types?: number[];
  123738. /**
  123739. * Define the sampling modes of all the draw buffers we want to create
  123740. */
  123741. samplingModes?: number[];
  123742. /**
  123743. * Define if a depth buffer is required
  123744. */
  123745. generateDepthBuffer?: boolean;
  123746. /**
  123747. * Define if a stencil buffer is required
  123748. */
  123749. generateStencilBuffer?: boolean;
  123750. /**
  123751. * Define if a depth texture is required instead of a depth buffer
  123752. */
  123753. generateDepthTexture?: boolean;
  123754. /**
  123755. * Define the number of desired draw buffers
  123756. */
  123757. textureCount?: number;
  123758. /**
  123759. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123760. */
  123761. doNotChangeAspectRatio?: boolean;
  123762. /**
  123763. * Define the default type of the buffers we are creating
  123764. */
  123765. defaultType?: number;
  123766. }
  123767. /**
  123768. * A multi render target, like a render target provides the ability to render to a texture.
  123769. * Unlike the render target, it can render to several draw buffers in one draw.
  123770. * This is specially interesting in deferred rendering or for any effects requiring more than
  123771. * just one color from a single pass.
  123772. */
  123773. export class MultiRenderTarget extends RenderTargetTexture {
  123774. private _internalTextures;
  123775. private _textures;
  123776. private _multiRenderTargetOptions;
  123777. /**
  123778. * Get if draw buffers are currently supported by the used hardware and browser.
  123779. */
  123780. get isSupported(): boolean;
  123781. /**
  123782. * Get the list of textures generated by the multi render target.
  123783. */
  123784. get textures(): Texture[];
  123785. /**
  123786. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123787. */
  123788. get depthTexture(): Texture;
  123789. /**
  123790. * Set the wrapping mode on U of all the textures we are rendering to.
  123791. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123792. */
  123793. set wrapU(wrap: number);
  123794. /**
  123795. * Set the wrapping mode on V of all the textures we are rendering to.
  123796. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123797. */
  123798. set wrapV(wrap: number);
  123799. /**
  123800. * Instantiate a new multi render target texture.
  123801. * A multi render target, like a render target provides the ability to render to a texture.
  123802. * Unlike the render target, it can render to several draw buffers in one draw.
  123803. * This is specially interesting in deferred rendering or for any effects requiring more than
  123804. * just one color from a single pass.
  123805. * @param name Define the name of the texture
  123806. * @param size Define the size of the buffers to render to
  123807. * @param count Define the number of target we are rendering into
  123808. * @param scene Define the scene the texture belongs to
  123809. * @param options Define the options used to create the multi render target
  123810. */
  123811. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123812. /** @hidden */
  123813. _rebuild(): void;
  123814. private _createInternalTextures;
  123815. private _createTextures;
  123816. /**
  123817. * Define the number of samples used if MSAA is enabled.
  123818. */
  123819. get samples(): number;
  123820. set samples(value: number);
  123821. /**
  123822. * Resize all the textures in the multi render target.
  123823. * Be carrefull as it will recreate all the data in the new texture.
  123824. * @param size Define the new size
  123825. */
  123826. resize(size: any): void;
  123827. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123828. /**
  123829. * Dispose the render targets and their associated resources
  123830. */
  123831. dispose(): void;
  123832. /**
  123833. * Release all the underlying texture used as draw buffers.
  123834. */
  123835. releaseInternalTextures(): void;
  123836. }
  123837. }
  123838. declare module BABYLON {
  123839. interface ThinEngine {
  123840. /**
  123841. * Unbind a list of render target textures from the webGL context
  123842. * This is used only when drawBuffer extension or webGL2 are active
  123843. * @param textures defines the render target textures to unbind
  123844. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123845. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123846. */
  123847. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123848. /**
  123849. * Create a multi render target texture
  123850. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123851. * @param size defines the size of the texture
  123852. * @param options defines the creation options
  123853. * @returns the cube texture as an InternalTexture
  123854. */
  123855. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123856. /**
  123857. * Update the sample count for a given multiple render target texture
  123858. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123859. * @param textures defines the textures to update
  123860. * @param samples defines the sample count to set
  123861. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123862. */
  123863. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123864. }
  123865. }
  123866. declare module BABYLON {
  123867. /**
  123868. * Class used to define an additional view for the engine
  123869. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123870. */
  123871. export class EngineView {
  123872. /** Defines the canvas where to render the view */
  123873. target: HTMLCanvasElement;
  123874. /** Defines an optional camera used to render the view (will use active camera else) */
  123875. camera?: Camera;
  123876. }
  123877. interface Engine {
  123878. /**
  123879. * Gets or sets the HTML element to use for attaching events
  123880. */
  123881. inputElement: Nullable<HTMLElement>;
  123882. /**
  123883. * Gets the current engine view
  123884. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123885. */
  123886. activeView: Nullable<EngineView>;
  123887. /** Gets or sets the list of views */
  123888. views: EngineView[];
  123889. /**
  123890. * Register a new child canvas
  123891. * @param canvas defines the canvas to register
  123892. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123893. * @returns the associated view
  123894. */
  123895. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123896. /**
  123897. * Remove a registered child canvas
  123898. * @param canvas defines the canvas to remove
  123899. * @returns the current engine
  123900. */
  123901. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123902. }
  123903. }
  123904. declare module BABYLON {
  123905. interface Engine {
  123906. /** @hidden */
  123907. _excludedCompressedTextures: string[];
  123908. /** @hidden */
  123909. _textureFormatInUse: string;
  123910. /**
  123911. * Gets the list of texture formats supported
  123912. */
  123913. readonly texturesSupported: Array<string>;
  123914. /**
  123915. * Gets the texture format in use
  123916. */
  123917. readonly textureFormatInUse: Nullable<string>;
  123918. /**
  123919. * Set the compressed texture extensions or file names to skip.
  123920. *
  123921. * @param skippedFiles defines the list of those texture files you want to skip
  123922. * Example: [".dds", ".env", "myfile.png"]
  123923. */
  123924. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123925. /**
  123926. * Set the compressed texture format to use, based on the formats you have, and the formats
  123927. * supported by the hardware / browser.
  123928. *
  123929. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123930. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123931. * to API arguments needed to compressed textures. This puts the burden on the container
  123932. * generator to house the arcane code for determining these for current & future formats.
  123933. *
  123934. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123935. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123936. *
  123937. * Note: The result of this call is not taken into account when a texture is base64.
  123938. *
  123939. * @param formatsAvailable defines the list of those format families you have created
  123940. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  123941. *
  123942. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  123943. * @returns The extension selected.
  123944. */
  123945. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  123946. }
  123947. }
  123948. declare module BABYLON {
  123949. /**
  123950. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  123951. */
  123952. export interface CubeMapInfo {
  123953. /**
  123954. * The pixel array for the front face.
  123955. * This is stored in format, left to right, up to down format.
  123956. */
  123957. front: Nullable<ArrayBufferView>;
  123958. /**
  123959. * The pixel array for the back face.
  123960. * This is stored in format, left to right, up to down format.
  123961. */
  123962. back: Nullable<ArrayBufferView>;
  123963. /**
  123964. * The pixel array for the left face.
  123965. * This is stored in format, left to right, up to down format.
  123966. */
  123967. left: Nullable<ArrayBufferView>;
  123968. /**
  123969. * The pixel array for the right face.
  123970. * This is stored in format, left to right, up to down format.
  123971. */
  123972. right: Nullable<ArrayBufferView>;
  123973. /**
  123974. * The pixel array for the up face.
  123975. * This is stored in format, left to right, up to down format.
  123976. */
  123977. up: Nullable<ArrayBufferView>;
  123978. /**
  123979. * The pixel array for the down face.
  123980. * This is stored in format, left to right, up to down format.
  123981. */
  123982. down: Nullable<ArrayBufferView>;
  123983. /**
  123984. * The size of the cubemap stored.
  123985. *
  123986. * Each faces will be size * size pixels.
  123987. */
  123988. size: number;
  123989. /**
  123990. * The format of the texture.
  123991. *
  123992. * RGBA, RGB.
  123993. */
  123994. format: number;
  123995. /**
  123996. * The type of the texture data.
  123997. *
  123998. * UNSIGNED_INT, FLOAT.
  123999. */
  124000. type: number;
  124001. /**
  124002. * Specifies whether the texture is in gamma space.
  124003. */
  124004. gammaSpace: boolean;
  124005. }
  124006. /**
  124007. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  124008. */
  124009. export class PanoramaToCubeMapTools {
  124010. private static FACE_LEFT;
  124011. private static FACE_RIGHT;
  124012. private static FACE_FRONT;
  124013. private static FACE_BACK;
  124014. private static FACE_DOWN;
  124015. private static FACE_UP;
  124016. /**
  124017. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  124018. *
  124019. * @param float32Array The source data.
  124020. * @param inputWidth The width of the input panorama.
  124021. * @param inputHeight The height of the input panorama.
  124022. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  124023. * @return The cubemap data
  124024. */
  124025. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  124026. private static CreateCubemapTexture;
  124027. private static CalcProjectionSpherical;
  124028. }
  124029. }
  124030. declare module BABYLON {
  124031. /**
  124032. * Helper class dealing with the extraction of spherical polynomial dataArray
  124033. * from a cube map.
  124034. */
  124035. export class CubeMapToSphericalPolynomialTools {
  124036. private static FileFaces;
  124037. /**
  124038. * Converts a texture to the according Spherical Polynomial data.
  124039. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124040. *
  124041. * @param texture The texture to extract the information from.
  124042. * @return The Spherical Polynomial data.
  124043. */
  124044. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  124045. /**
  124046. * Converts a cubemap to the according Spherical Polynomial data.
  124047. * This extracts the first 3 orders only as they are the only one used in the lighting.
  124048. *
  124049. * @param cubeInfo The Cube map to extract the information from.
  124050. * @return The Spherical Polynomial data.
  124051. */
  124052. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  124053. }
  124054. }
  124055. declare module BABYLON {
  124056. interface BaseTexture {
  124057. /**
  124058. * Get the polynomial representation of the texture data.
  124059. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  124060. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  124061. */
  124062. sphericalPolynomial: Nullable<SphericalPolynomial>;
  124063. }
  124064. }
  124065. declare module BABYLON {
  124066. /** @hidden */
  124067. export var rgbdEncodePixelShader: {
  124068. name: string;
  124069. shader: string;
  124070. };
  124071. }
  124072. declare module BABYLON {
  124073. /** @hidden */
  124074. export var rgbdDecodePixelShader: {
  124075. name: string;
  124076. shader: string;
  124077. };
  124078. }
  124079. declare module BABYLON {
  124080. /**
  124081. * Raw texture data and descriptor sufficient for WebGL texture upload
  124082. */
  124083. export interface EnvironmentTextureInfo {
  124084. /**
  124085. * Version of the environment map
  124086. */
  124087. version: number;
  124088. /**
  124089. * Width of image
  124090. */
  124091. width: number;
  124092. /**
  124093. * Irradiance information stored in the file.
  124094. */
  124095. irradiance: any;
  124096. /**
  124097. * Specular information stored in the file.
  124098. */
  124099. specular: any;
  124100. }
  124101. /**
  124102. * Defines One Image in the file. It requires only the position in the file
  124103. * as well as the length.
  124104. */
  124105. interface BufferImageData {
  124106. /**
  124107. * Length of the image data.
  124108. */
  124109. length: number;
  124110. /**
  124111. * Position of the data from the null terminator delimiting the end of the JSON.
  124112. */
  124113. position: number;
  124114. }
  124115. /**
  124116. * Defines the specular data enclosed in the file.
  124117. * This corresponds to the version 1 of the data.
  124118. */
  124119. export interface EnvironmentTextureSpecularInfoV1 {
  124120. /**
  124121. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  124122. */
  124123. specularDataPosition?: number;
  124124. /**
  124125. * This contains all the images data needed to reconstruct the cubemap.
  124126. */
  124127. mipmaps: Array<BufferImageData>;
  124128. /**
  124129. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  124130. */
  124131. lodGenerationScale: number;
  124132. }
  124133. /**
  124134. * Sets of helpers addressing the serialization and deserialization of environment texture
  124135. * stored in a BabylonJS env file.
  124136. * Those files are usually stored as .env files.
  124137. */
  124138. export class EnvironmentTextureTools {
  124139. /**
  124140. * Magic number identifying the env file.
  124141. */
  124142. private static _MagicBytes;
  124143. /**
  124144. * Gets the environment info from an env file.
  124145. * @param data The array buffer containing the .env bytes.
  124146. * @returns the environment file info (the json header) if successfully parsed.
  124147. */
  124148. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  124149. /**
  124150. * Creates an environment texture from a loaded cube texture.
  124151. * @param texture defines the cube texture to convert in env file
  124152. * @return a promise containing the environment data if succesfull.
  124153. */
  124154. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  124155. /**
  124156. * Creates a JSON representation of the spherical data.
  124157. * @param texture defines the texture containing the polynomials
  124158. * @return the JSON representation of the spherical info
  124159. */
  124160. private static _CreateEnvTextureIrradiance;
  124161. /**
  124162. * Creates the ArrayBufferViews used for initializing environment texture image data.
  124163. * @param data the image data
  124164. * @param info parameters that determine what views will be created for accessing the underlying buffer
  124165. * @return the views described by info providing access to the underlying buffer
  124166. */
  124167. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  124168. /**
  124169. * Uploads the texture info contained in the env file to the GPU.
  124170. * @param texture defines the internal texture to upload to
  124171. * @param data defines the data to load
  124172. * @param info defines the texture info retrieved through the GetEnvInfo method
  124173. * @returns a promise
  124174. */
  124175. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  124176. private static _OnImageReadyAsync;
  124177. /**
  124178. * Uploads the levels of image data to the GPU.
  124179. * @param texture defines the internal texture to upload to
  124180. * @param imageData defines the array buffer views of image data [mipmap][face]
  124181. * @returns a promise
  124182. */
  124183. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  124184. /**
  124185. * Uploads spherical polynomials information to the texture.
  124186. * @param texture defines the texture we are trying to upload the information to
  124187. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  124188. */
  124189. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  124190. /** @hidden */
  124191. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  124192. }
  124193. }
  124194. declare module BABYLON {
  124195. /**
  124196. * Contains position and normal vectors for a vertex
  124197. */
  124198. export class PositionNormalVertex {
  124199. /** the position of the vertex (defaut: 0,0,0) */
  124200. position: Vector3;
  124201. /** the normal of the vertex (defaut: 0,1,0) */
  124202. normal: Vector3;
  124203. /**
  124204. * Creates a PositionNormalVertex
  124205. * @param position the position of the vertex (defaut: 0,0,0)
  124206. * @param normal the normal of the vertex (defaut: 0,1,0)
  124207. */
  124208. constructor(
  124209. /** the position of the vertex (defaut: 0,0,0) */
  124210. position?: Vector3,
  124211. /** the normal of the vertex (defaut: 0,1,0) */
  124212. normal?: Vector3);
  124213. /**
  124214. * Clones the PositionNormalVertex
  124215. * @returns the cloned PositionNormalVertex
  124216. */
  124217. clone(): PositionNormalVertex;
  124218. }
  124219. /**
  124220. * Contains position, normal and uv vectors for a vertex
  124221. */
  124222. export class PositionNormalTextureVertex {
  124223. /** the position of the vertex (defaut: 0,0,0) */
  124224. position: Vector3;
  124225. /** the normal of the vertex (defaut: 0,1,0) */
  124226. normal: Vector3;
  124227. /** the uv of the vertex (default: 0,0) */
  124228. uv: Vector2;
  124229. /**
  124230. * Creates a PositionNormalTextureVertex
  124231. * @param position the position of the vertex (defaut: 0,0,0)
  124232. * @param normal the normal of the vertex (defaut: 0,1,0)
  124233. * @param uv the uv of the vertex (default: 0,0)
  124234. */
  124235. constructor(
  124236. /** the position of the vertex (defaut: 0,0,0) */
  124237. position?: Vector3,
  124238. /** the normal of the vertex (defaut: 0,1,0) */
  124239. normal?: Vector3,
  124240. /** the uv of the vertex (default: 0,0) */
  124241. uv?: Vector2);
  124242. /**
  124243. * Clones the PositionNormalTextureVertex
  124244. * @returns the cloned PositionNormalTextureVertex
  124245. */
  124246. clone(): PositionNormalTextureVertex;
  124247. }
  124248. }
  124249. declare module BABYLON {
  124250. /** @hidden */
  124251. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124252. private _genericAttributeLocation;
  124253. private _varyingLocationCount;
  124254. private _varyingLocationMap;
  124255. private _replacements;
  124256. private _textureCount;
  124257. private _uniforms;
  124258. lineProcessor(line: string): string;
  124259. attributeProcessor(attribute: string): string;
  124260. varyingProcessor(varying: string, isFragment: boolean): string;
  124261. uniformProcessor(uniform: string): string;
  124262. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124263. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124264. }
  124265. }
  124266. declare module BABYLON {
  124267. /**
  124268. * Container for accessors for natively-stored mesh data buffers.
  124269. */
  124270. class NativeDataBuffer extends DataBuffer {
  124271. /**
  124272. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124273. */
  124274. nativeIndexBuffer?: any;
  124275. /**
  124276. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124277. */
  124278. nativeVertexBuffer?: any;
  124279. }
  124280. /** @hidden */
  124281. class NativeTexture extends InternalTexture {
  124282. getInternalTexture(): InternalTexture;
  124283. getViewCount(): number;
  124284. }
  124285. /** @hidden */
  124286. export class NativeEngine extends Engine {
  124287. private readonly _native;
  124288. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124289. private readonly INVALID_HANDLE;
  124290. getHardwareScalingLevel(): number;
  124291. constructor();
  124292. dispose(): void;
  124293. /**
  124294. * Can be used to override the current requestAnimationFrame requester.
  124295. * @hidden
  124296. */
  124297. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124298. /**
  124299. * Override default engine behavior.
  124300. * @param color
  124301. * @param backBuffer
  124302. * @param depth
  124303. * @param stencil
  124304. */
  124305. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124306. /**
  124307. * Gets host document
  124308. * @returns the host document object
  124309. */
  124310. getHostDocument(): Nullable<Document>;
  124311. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124312. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124313. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124314. recordVertexArrayObject(vertexBuffers: {
  124315. [key: string]: VertexBuffer;
  124316. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124317. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124318. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124319. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124320. /**
  124321. * Draw a list of indexed primitives
  124322. * @param fillMode defines the primitive to use
  124323. * @param indexStart defines the starting index
  124324. * @param indexCount defines the number of index to draw
  124325. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124326. */
  124327. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124328. /**
  124329. * Draw a list of unindexed primitives
  124330. * @param fillMode defines the primitive to use
  124331. * @param verticesStart defines the index of first vertex to draw
  124332. * @param verticesCount defines the count of vertices to draw
  124333. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124334. */
  124335. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124336. createPipelineContext(): IPipelineContext;
  124337. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124338. /** @hidden */
  124339. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124340. /** @hidden */
  124341. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124342. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124343. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124344. protected _setProgram(program: WebGLProgram): void;
  124345. _releaseEffect(effect: Effect): void;
  124346. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124347. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124348. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124349. bindSamplers(effect: Effect): void;
  124350. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124351. getRenderWidth(useScreen?: boolean): number;
  124352. getRenderHeight(useScreen?: boolean): number;
  124353. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124354. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124355. /**
  124356. * Set the z offset to apply to current rendering
  124357. * @param value defines the offset to apply
  124358. */
  124359. setZOffset(value: number): void;
  124360. /**
  124361. * Gets the current value of the zOffset
  124362. * @returns the current zOffset state
  124363. */
  124364. getZOffset(): number;
  124365. /**
  124366. * Enable or disable depth buffering
  124367. * @param enable defines the state to set
  124368. */
  124369. setDepthBuffer(enable: boolean): void;
  124370. /**
  124371. * Gets a boolean indicating if depth writing is enabled
  124372. * @returns the current depth writing state
  124373. */
  124374. getDepthWrite(): boolean;
  124375. /**
  124376. * Enable or disable depth writing
  124377. * @param enable defines the state to set
  124378. */
  124379. setDepthWrite(enable: boolean): void;
  124380. /**
  124381. * Enable or disable color writing
  124382. * @param enable defines the state to set
  124383. */
  124384. setColorWrite(enable: boolean): void;
  124385. /**
  124386. * Gets a boolean indicating if color writing is enabled
  124387. * @returns the current color writing state
  124388. */
  124389. getColorWrite(): boolean;
  124390. /**
  124391. * Sets alpha constants used by some alpha blending modes
  124392. * @param r defines the red component
  124393. * @param g defines the green component
  124394. * @param b defines the blue component
  124395. * @param a defines the alpha component
  124396. */
  124397. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124398. /**
  124399. * Sets the current alpha mode
  124400. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124401. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124403. */
  124404. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124405. /**
  124406. * Gets the current alpha mode
  124407. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124408. * @returns the current alpha mode
  124409. */
  124410. getAlphaMode(): number;
  124411. setInt(uniform: WebGLUniformLocation, int: number): void;
  124412. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124413. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124414. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124415. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124416. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124417. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124418. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124419. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124420. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124421. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124422. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124423. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124424. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124425. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124426. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124427. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124428. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124429. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124430. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124431. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124432. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124433. wipeCaches(bruteForce?: boolean): void;
  124434. _createTexture(): WebGLTexture;
  124435. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124436. /**
  124437. * Usually called from Texture.ts.
  124438. * Passed information to create a WebGLTexture
  124439. * @param url defines a value which contains one of the following:
  124440. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124441. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124442. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124443. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124444. * @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)
  124445. * @param scene needed for loading to the correct scene
  124446. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124447. * @param onLoad optional callback to be called upon successful completion
  124448. * @param onError optional callback to be called upon failure
  124449. * @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
  124450. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124451. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124452. * @param forcedExtension defines the extension to use to pick the right loader
  124453. * @param mimeType defines an optional mime type
  124454. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124455. */
  124456. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  124457. /**
  124458. * Creates a cube texture
  124459. * @param rootUrl defines the url where the files to load is located
  124460. * @param scene defines the current scene
  124461. * @param files defines the list of files to load (1 per face)
  124462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124463. * @param onLoad defines an optional callback raised when the texture is loaded
  124464. * @param onError defines an optional callback raised if there is an issue to load the texture
  124465. * @param format defines the format of the data
  124466. * @param forcedExtension defines the extension to use to pick the right loader
  124467. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124470. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124471. * @returns the cube texture as an InternalTexture
  124472. */
  124473. 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;
  124474. private _getSamplingFilter;
  124475. private static _GetNativeTextureFormat;
  124476. createRenderTargetTexture(size: number | {
  124477. width: number;
  124478. height: number;
  124479. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124480. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124481. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124482. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124483. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124484. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124485. /**
  124486. * Updates a dynamic vertex buffer.
  124487. * @param vertexBuffer the vertex buffer to update
  124488. * @param data the data used to update the vertex buffer
  124489. * @param byteOffset the byte offset of the data (optional)
  124490. * @param byteLength the byte length of the data (optional)
  124491. */
  124492. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124493. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124494. private _updateAnisotropicLevel;
  124495. private _getAddressMode;
  124496. /** @hidden */
  124497. _bindTexture(channel: number, texture: InternalTexture): void;
  124498. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124499. releaseEffects(): void;
  124500. /** @hidden */
  124501. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124502. /** @hidden */
  124503. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124504. /** @hidden */
  124505. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124506. /** @hidden */
  124507. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124508. }
  124509. }
  124510. declare module BABYLON {
  124511. /**
  124512. * Gather the list of clipboard event types as constants.
  124513. */
  124514. export class ClipboardEventTypes {
  124515. /**
  124516. * The clipboard event is fired when a copy command is active (pressed).
  124517. */
  124518. static readonly COPY: number;
  124519. /**
  124520. * The clipboard event is fired when a cut command is active (pressed).
  124521. */
  124522. static readonly CUT: number;
  124523. /**
  124524. * The clipboard event is fired when a paste command is active (pressed).
  124525. */
  124526. static readonly PASTE: number;
  124527. }
  124528. /**
  124529. * This class is used to store clipboard related info for the onClipboardObservable event.
  124530. */
  124531. export class ClipboardInfo {
  124532. /**
  124533. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124534. */
  124535. type: number;
  124536. /**
  124537. * Defines the related dom event
  124538. */
  124539. event: ClipboardEvent;
  124540. /**
  124541. *Creates an instance of ClipboardInfo.
  124542. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124543. * @param event Defines the related dom event
  124544. */
  124545. constructor(
  124546. /**
  124547. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124548. */
  124549. type: number,
  124550. /**
  124551. * Defines the related dom event
  124552. */
  124553. event: ClipboardEvent);
  124554. /**
  124555. * Get the clipboard event's type from the keycode.
  124556. * @param keyCode Defines the keyCode for the current keyboard event.
  124557. * @return {number}
  124558. */
  124559. static GetTypeFromCharacter(keyCode: number): number;
  124560. }
  124561. }
  124562. declare module BABYLON {
  124563. /**
  124564. * Google Daydream controller
  124565. */
  124566. export class DaydreamController extends WebVRController {
  124567. /**
  124568. * Base Url for the controller model.
  124569. */
  124570. static MODEL_BASE_URL: string;
  124571. /**
  124572. * File name for the controller model.
  124573. */
  124574. static MODEL_FILENAME: string;
  124575. /**
  124576. * Gamepad Id prefix used to identify Daydream Controller.
  124577. */
  124578. static readonly GAMEPAD_ID_PREFIX: string;
  124579. /**
  124580. * Creates a new DaydreamController from a gamepad
  124581. * @param vrGamepad the gamepad that the controller should be created from
  124582. */
  124583. constructor(vrGamepad: any);
  124584. /**
  124585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124586. * @param scene scene in which to add meshes
  124587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124588. */
  124589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124590. /**
  124591. * Called once for each button that changed state since the last frame
  124592. * @param buttonIdx Which button index changed
  124593. * @param state New state of the button
  124594. * @param changes Which properties on the state changed since last frame
  124595. */
  124596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124597. }
  124598. }
  124599. declare module BABYLON {
  124600. /**
  124601. * Gear VR Controller
  124602. */
  124603. export class GearVRController extends WebVRController {
  124604. /**
  124605. * Base Url for the controller model.
  124606. */
  124607. static MODEL_BASE_URL: string;
  124608. /**
  124609. * File name for the controller model.
  124610. */
  124611. static MODEL_FILENAME: string;
  124612. /**
  124613. * Gamepad Id prefix used to identify this controller.
  124614. */
  124615. static readonly GAMEPAD_ID_PREFIX: string;
  124616. private readonly _buttonIndexToObservableNameMap;
  124617. /**
  124618. * Creates a new GearVRController from a gamepad
  124619. * @param vrGamepad the gamepad that the controller should be created from
  124620. */
  124621. constructor(vrGamepad: any);
  124622. /**
  124623. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124624. * @param scene scene in which to add meshes
  124625. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124626. */
  124627. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124628. /**
  124629. * Called once for each button that changed state since the last frame
  124630. * @param buttonIdx Which button index changed
  124631. * @param state New state of the button
  124632. * @param changes Which properties on the state changed since last frame
  124633. */
  124634. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124635. }
  124636. }
  124637. declare module BABYLON {
  124638. /**
  124639. * Generic Controller
  124640. */
  124641. export class GenericController extends WebVRController {
  124642. /**
  124643. * Base Url for the controller model.
  124644. */
  124645. static readonly MODEL_BASE_URL: string;
  124646. /**
  124647. * File name for the controller model.
  124648. */
  124649. static readonly MODEL_FILENAME: string;
  124650. /**
  124651. * Creates a new GenericController from a gamepad
  124652. * @param vrGamepad the gamepad that the controller should be created from
  124653. */
  124654. constructor(vrGamepad: any);
  124655. /**
  124656. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124657. * @param scene scene in which to add meshes
  124658. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124659. */
  124660. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124661. /**
  124662. * Called once for each button that changed state since the last frame
  124663. * @param buttonIdx Which button index changed
  124664. * @param state New state of the button
  124665. * @param changes Which properties on the state changed since last frame
  124666. */
  124667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124668. }
  124669. }
  124670. declare module BABYLON {
  124671. /**
  124672. * Oculus Touch Controller
  124673. */
  124674. export class OculusTouchController extends WebVRController {
  124675. /**
  124676. * Base Url for the controller model.
  124677. */
  124678. static MODEL_BASE_URL: string;
  124679. /**
  124680. * File name for the left controller model.
  124681. */
  124682. static MODEL_LEFT_FILENAME: string;
  124683. /**
  124684. * File name for the right controller model.
  124685. */
  124686. static MODEL_RIGHT_FILENAME: string;
  124687. /**
  124688. * Base Url for the Quest controller model.
  124689. */
  124690. static QUEST_MODEL_BASE_URL: string;
  124691. /**
  124692. * @hidden
  124693. * If the controllers are running on a device that needs the updated Quest controller models
  124694. */
  124695. static _IsQuest: boolean;
  124696. /**
  124697. * Fired when the secondary trigger on this controller is modified
  124698. */
  124699. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124700. /**
  124701. * Fired when the thumb rest on this controller is modified
  124702. */
  124703. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124704. /**
  124705. * Creates a new OculusTouchController from a gamepad
  124706. * @param vrGamepad the gamepad that the controller should be created from
  124707. */
  124708. constructor(vrGamepad: any);
  124709. /**
  124710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124711. * @param scene scene in which to add meshes
  124712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124713. */
  124714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124715. /**
  124716. * Fired when the A button on this controller is modified
  124717. */
  124718. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124719. /**
  124720. * Fired when the B button on this controller is modified
  124721. */
  124722. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124723. /**
  124724. * Fired when the X button on this controller is modified
  124725. */
  124726. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124727. /**
  124728. * Fired when the Y button on this controller is modified
  124729. */
  124730. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124731. /**
  124732. * Called once for each button that changed state since the last frame
  124733. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124734. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124735. * 2) secondary trigger (same)
  124736. * 3) A (right) X (left), touch, pressed = value
  124737. * 4) B / Y
  124738. * 5) thumb rest
  124739. * @param buttonIdx Which button index changed
  124740. * @param state New state of the button
  124741. * @param changes Which properties on the state changed since last frame
  124742. */
  124743. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124744. }
  124745. }
  124746. declare module BABYLON {
  124747. /**
  124748. * Vive Controller
  124749. */
  124750. export class ViveController extends WebVRController {
  124751. /**
  124752. * Base Url for the controller model.
  124753. */
  124754. static MODEL_BASE_URL: string;
  124755. /**
  124756. * File name for the controller model.
  124757. */
  124758. static MODEL_FILENAME: string;
  124759. /**
  124760. * Creates a new ViveController from a gamepad
  124761. * @param vrGamepad the gamepad that the controller should be created from
  124762. */
  124763. constructor(vrGamepad: any);
  124764. /**
  124765. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124766. * @param scene scene in which to add meshes
  124767. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124768. */
  124769. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124770. /**
  124771. * Fired when the left button on this controller is modified
  124772. */
  124773. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124774. /**
  124775. * Fired when the right button on this controller is modified
  124776. */
  124777. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124778. /**
  124779. * Fired when the menu button on this controller is modified
  124780. */
  124781. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124782. /**
  124783. * Called once for each button that changed state since the last frame
  124784. * Vive mapping:
  124785. * 0: touchpad
  124786. * 1: trigger
  124787. * 2: left AND right buttons
  124788. * 3: menu button
  124789. * @param buttonIdx Which button index changed
  124790. * @param state New state of the button
  124791. * @param changes Which properties on the state changed since last frame
  124792. */
  124793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124794. }
  124795. }
  124796. declare module BABYLON {
  124797. /**
  124798. * Defines the WindowsMotionController object that the state of the windows motion controller
  124799. */
  124800. export class WindowsMotionController extends WebVRController {
  124801. /**
  124802. * The base url used to load the left and right controller models
  124803. */
  124804. static MODEL_BASE_URL: string;
  124805. /**
  124806. * The name of the left controller model file
  124807. */
  124808. static MODEL_LEFT_FILENAME: string;
  124809. /**
  124810. * The name of the right controller model file
  124811. */
  124812. static MODEL_RIGHT_FILENAME: string;
  124813. /**
  124814. * The controller name prefix for this controller type
  124815. */
  124816. static readonly GAMEPAD_ID_PREFIX: string;
  124817. /**
  124818. * The controller id pattern for this controller type
  124819. */
  124820. private static readonly GAMEPAD_ID_PATTERN;
  124821. private _loadedMeshInfo;
  124822. protected readonly _mapping: {
  124823. buttons: string[];
  124824. buttonMeshNames: {
  124825. trigger: string;
  124826. menu: string;
  124827. grip: string;
  124828. thumbstick: string;
  124829. trackpad: string;
  124830. };
  124831. buttonObservableNames: {
  124832. trigger: string;
  124833. menu: string;
  124834. grip: string;
  124835. thumbstick: string;
  124836. trackpad: string;
  124837. };
  124838. axisMeshNames: string[];
  124839. pointingPoseMeshName: string;
  124840. };
  124841. /**
  124842. * Fired when the trackpad on this controller is clicked
  124843. */
  124844. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124845. /**
  124846. * Fired when the trackpad on this controller is modified
  124847. */
  124848. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124849. /**
  124850. * The current x and y values of this controller's trackpad
  124851. */
  124852. trackpad: StickValues;
  124853. /**
  124854. * Creates a new WindowsMotionController from a gamepad
  124855. * @param vrGamepad the gamepad that the controller should be created from
  124856. */
  124857. constructor(vrGamepad: any);
  124858. /**
  124859. * Fired when the trigger on this controller is modified
  124860. */
  124861. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124862. /**
  124863. * Fired when the menu button on this controller is modified
  124864. */
  124865. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124866. /**
  124867. * Fired when the grip button on this controller is modified
  124868. */
  124869. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124870. /**
  124871. * Fired when the thumbstick button on this controller is modified
  124872. */
  124873. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124874. /**
  124875. * Fired when the touchpad button on this controller is modified
  124876. */
  124877. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124878. /**
  124879. * Fired when the touchpad values on this controller are modified
  124880. */
  124881. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124882. protected _updateTrackpad(): void;
  124883. /**
  124884. * Called once per frame by the engine.
  124885. */
  124886. update(): void;
  124887. /**
  124888. * Called once for each button that changed state since the last frame
  124889. * @param buttonIdx Which button index changed
  124890. * @param state New state of the button
  124891. * @param changes Which properties on the state changed since last frame
  124892. */
  124893. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124894. /**
  124895. * Moves the buttons on the controller mesh based on their current state
  124896. * @param buttonName the name of the button to move
  124897. * @param buttonValue the value of the button which determines the buttons new position
  124898. */
  124899. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124900. /**
  124901. * Moves the axis on the controller mesh based on its current state
  124902. * @param axis the index of the axis
  124903. * @param axisValue the value of the axis which determines the meshes new position
  124904. * @hidden
  124905. */
  124906. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124907. /**
  124908. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124909. * @param scene scene in which to add meshes
  124910. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124911. */
  124912. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124913. /**
  124914. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124915. * can be transformed by button presses and axes values, based on this._mapping.
  124916. *
  124917. * @param scene scene in which the meshes exist
  124918. * @param meshes list of meshes that make up the controller model to process
  124919. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124920. */
  124921. private processModel;
  124922. private createMeshInfo;
  124923. /**
  124924. * Gets the ray of the controller in the direction the controller is pointing
  124925. * @param length the length the resulting ray should be
  124926. * @returns a ray in the direction the controller is pointing
  124927. */
  124928. getForwardRay(length?: number): Ray;
  124929. /**
  124930. * Disposes of the controller
  124931. */
  124932. dispose(): void;
  124933. }
  124934. /**
  124935. * This class represents a new windows motion controller in XR.
  124936. */
  124937. export class XRWindowsMotionController extends WindowsMotionController {
  124938. /**
  124939. * Changing the original WIndowsMotionController mapping to fir the new mapping
  124940. */
  124941. protected readonly _mapping: {
  124942. buttons: string[];
  124943. buttonMeshNames: {
  124944. trigger: string;
  124945. menu: string;
  124946. grip: string;
  124947. thumbstick: string;
  124948. trackpad: string;
  124949. };
  124950. buttonObservableNames: {
  124951. trigger: string;
  124952. menu: string;
  124953. grip: string;
  124954. thumbstick: string;
  124955. trackpad: string;
  124956. };
  124957. axisMeshNames: string[];
  124958. pointingPoseMeshName: string;
  124959. };
  124960. /**
  124961. * Construct a new XR-Based windows motion controller
  124962. *
  124963. * @param gamepadInfo the gamepad object from the browser
  124964. */
  124965. constructor(gamepadInfo: any);
  124966. /**
  124967. * holds the thumbstick values (X,Y)
  124968. */
  124969. thumbstickValues: StickValues;
  124970. /**
  124971. * Fired when the thumbstick on this controller is clicked
  124972. */
  124973. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  124974. /**
  124975. * Fired when the thumbstick on this controller is modified
  124976. */
  124977. onThumbstickValuesChangedObservable: Observable<StickValues>;
  124978. /**
  124979. * Fired when the touchpad button on this controller is modified
  124980. */
  124981. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124982. /**
  124983. * Fired when the touchpad values on this controller are modified
  124984. */
  124985. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124986. /**
  124987. * Fired when the thumbstick button on this controller is modified
  124988. * here to prevent breaking changes
  124989. */
  124990. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124991. /**
  124992. * updating the thumbstick(!) and not the trackpad.
  124993. * This is named this way due to the difference between WebVR and XR and to avoid
  124994. * changing the parent class.
  124995. */
  124996. protected _updateTrackpad(): void;
  124997. /**
  124998. * Disposes the class with joy
  124999. */
  125000. dispose(): void;
  125001. }
  125002. }
  125003. declare module BABYLON {
  125004. /**
  125005. * Class containing static functions to help procedurally build meshes
  125006. */
  125007. export class PolyhedronBuilder {
  125008. /**
  125009. * Creates a polyhedron mesh
  125010. * * 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
  125011. * * The parameter `size` (positive float, default 1) sets the polygon size
  125012. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125013. * * 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`
  125014. * * 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
  125015. * * 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)`)
  125016. * * 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
  125017. * * 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
  125018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125021. * @param name defines the name of the mesh
  125022. * @param options defines the options used to create the mesh
  125023. * @param scene defines the hosting scene
  125024. * @returns the polyhedron mesh
  125025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125026. */
  125027. static CreatePolyhedron(name: string, options: {
  125028. type?: number;
  125029. size?: number;
  125030. sizeX?: number;
  125031. sizeY?: number;
  125032. sizeZ?: number;
  125033. custom?: any;
  125034. faceUV?: Vector4[];
  125035. faceColors?: Color4[];
  125036. flat?: boolean;
  125037. updatable?: boolean;
  125038. sideOrientation?: number;
  125039. frontUVs?: Vector4;
  125040. backUVs?: Vector4;
  125041. }, scene?: Nullable<Scene>): Mesh;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * Gizmo that enables scaling a mesh along 3 axis
  125047. */
  125048. export class ScaleGizmo extends Gizmo {
  125049. /**
  125050. * Internal gizmo used for interactions on the x axis
  125051. */
  125052. xGizmo: AxisScaleGizmo;
  125053. /**
  125054. * Internal gizmo used for interactions on the y axis
  125055. */
  125056. yGizmo: AxisScaleGizmo;
  125057. /**
  125058. * Internal gizmo used for interactions on the z axis
  125059. */
  125060. zGizmo: AxisScaleGizmo;
  125061. /**
  125062. * Internal gizmo used to scale all axis equally
  125063. */
  125064. uniformScaleGizmo: AxisScaleGizmo;
  125065. private _meshAttached;
  125066. private _updateGizmoRotationToMatchAttachedMesh;
  125067. private _snapDistance;
  125068. private _scaleRatio;
  125069. private _uniformScalingMesh;
  125070. private _octahedron;
  125071. private _sensitivity;
  125072. /** Fires an event when any of it's sub gizmos are dragged */
  125073. onDragStartObservable: Observable<unknown>;
  125074. /** Fires an event when any of it's sub gizmos are released from dragging */
  125075. onDragEndObservable: Observable<unknown>;
  125076. get attachedMesh(): Nullable<AbstractMesh>;
  125077. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125078. /**
  125079. * Creates a ScaleGizmo
  125080. * @param gizmoLayer The utility layer the gizmo will be added to
  125081. */
  125082. constructor(gizmoLayer?: UtilityLayerRenderer);
  125083. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125084. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125085. /**
  125086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125087. */
  125088. set snapDistance(value: number);
  125089. get snapDistance(): number;
  125090. /**
  125091. * Ratio for the scale of the gizmo (Default: 1)
  125092. */
  125093. set scaleRatio(value: number);
  125094. get scaleRatio(): number;
  125095. /**
  125096. * Sensitivity factor for dragging (Default: 1)
  125097. */
  125098. set sensitivity(value: number);
  125099. get sensitivity(): number;
  125100. /**
  125101. * Disposes of the gizmo
  125102. */
  125103. dispose(): void;
  125104. }
  125105. }
  125106. declare module BABYLON {
  125107. /**
  125108. * Single axis scale gizmo
  125109. */
  125110. export class AxisScaleGizmo extends Gizmo {
  125111. /**
  125112. * Drag behavior responsible for the gizmos dragging interactions
  125113. */
  125114. dragBehavior: PointerDragBehavior;
  125115. private _pointerObserver;
  125116. /**
  125117. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125118. */
  125119. snapDistance: number;
  125120. /**
  125121. * Event that fires each time the gizmo snaps to a new location.
  125122. * * snapDistance is the the change in distance
  125123. */
  125124. onSnapObservable: Observable<{
  125125. snapDistance: number;
  125126. }>;
  125127. /**
  125128. * If the scaling operation should be done on all axis (default: false)
  125129. */
  125130. uniformScaling: boolean;
  125131. /**
  125132. * Custom sensitivity value for the drag strength
  125133. */
  125134. sensitivity: number;
  125135. private _isEnabled;
  125136. private _parent;
  125137. private _arrow;
  125138. private _coloredMaterial;
  125139. private _hoverMaterial;
  125140. /**
  125141. * Creates an AxisScaleGizmo
  125142. * @param gizmoLayer The utility layer the gizmo will be added to
  125143. * @param dragAxis The axis which the gizmo will be able to scale on
  125144. * @param color The color of the gizmo
  125145. */
  125146. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  125147. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125148. /**
  125149. * If the gizmo is enabled
  125150. */
  125151. set isEnabled(value: boolean);
  125152. get isEnabled(): boolean;
  125153. /**
  125154. * Disposes of the gizmo
  125155. */
  125156. dispose(): void;
  125157. /**
  125158. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125159. * @param mesh The mesh to replace the default mesh of the gizmo
  125160. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  125161. */
  125162. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  125163. }
  125164. }
  125165. declare module BABYLON {
  125166. /**
  125167. * Bounding box gizmo
  125168. */
  125169. export class BoundingBoxGizmo extends Gizmo {
  125170. private _lineBoundingBox;
  125171. private _rotateSpheresParent;
  125172. private _scaleBoxesParent;
  125173. private _boundingDimensions;
  125174. private _renderObserver;
  125175. private _pointerObserver;
  125176. private _scaleDragSpeed;
  125177. private _tmpQuaternion;
  125178. private _tmpVector;
  125179. private _tmpRotationMatrix;
  125180. /**
  125181. * 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)
  125182. */
  125183. ignoreChildren: boolean;
  125184. /**
  125185. * 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)
  125186. */
  125187. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  125188. /**
  125189. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  125190. */
  125191. rotationSphereSize: number;
  125192. /**
  125193. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  125194. */
  125195. scaleBoxSize: number;
  125196. /**
  125197. * 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)
  125198. */
  125199. fixedDragMeshScreenSize: boolean;
  125200. /**
  125201. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  125202. */
  125203. fixedDragMeshScreenSizeDistanceFactor: number;
  125204. /**
  125205. * Fired when a rotation sphere or scale box is dragged
  125206. */
  125207. onDragStartObservable: Observable<{}>;
  125208. /**
  125209. * Fired when a scale box is dragged
  125210. */
  125211. onScaleBoxDragObservable: Observable<{}>;
  125212. /**
  125213. * Fired when a scale box drag is ended
  125214. */
  125215. onScaleBoxDragEndObservable: Observable<{}>;
  125216. /**
  125217. * Fired when a rotation sphere is dragged
  125218. */
  125219. onRotationSphereDragObservable: Observable<{}>;
  125220. /**
  125221. * Fired when a rotation sphere drag is ended
  125222. */
  125223. onRotationSphereDragEndObservable: Observable<{}>;
  125224. /**
  125225. * 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)
  125226. */
  125227. scalePivot: Nullable<Vector3>;
  125228. /**
  125229. * Mesh used as a pivot to rotate the attached mesh
  125230. */
  125231. private _anchorMesh;
  125232. private _existingMeshScale;
  125233. private _dragMesh;
  125234. private pointerDragBehavior;
  125235. private coloredMaterial;
  125236. private hoverColoredMaterial;
  125237. /**
  125238. * Sets the color of the bounding box gizmo
  125239. * @param color the color to set
  125240. */
  125241. setColor(color: Color3): void;
  125242. /**
  125243. * Creates an BoundingBoxGizmo
  125244. * @param gizmoLayer The utility layer the gizmo will be added to
  125245. * @param color The color of the gizmo
  125246. */
  125247. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125248. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125249. private _selectNode;
  125250. /**
  125251. * Updates the bounding box information for the Gizmo
  125252. */
  125253. updateBoundingBox(): void;
  125254. private _updateRotationSpheres;
  125255. private _updateScaleBoxes;
  125256. /**
  125257. * Enables rotation on the specified axis and disables rotation on the others
  125258. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125259. */
  125260. setEnabledRotationAxis(axis: string): void;
  125261. /**
  125262. * Enables/disables scaling
  125263. * @param enable if scaling should be enabled
  125264. * @param homogeneousScaling defines if scaling should only be homogeneous
  125265. */
  125266. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125267. private _updateDummy;
  125268. /**
  125269. * Enables a pointer drag behavior on the bounding box of the gizmo
  125270. */
  125271. enableDragBehavior(): void;
  125272. /**
  125273. * Disposes of the gizmo
  125274. */
  125275. dispose(): void;
  125276. /**
  125277. * 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)
  125278. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125279. * @returns the bounding box mesh with the passed in mesh as a child
  125280. */
  125281. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125282. /**
  125283. * CustomMeshes are not supported by this gizmo
  125284. * @param mesh The mesh to replace the default mesh of the gizmo
  125285. */
  125286. setCustomMesh(mesh: Mesh): void;
  125287. }
  125288. }
  125289. declare module BABYLON {
  125290. /**
  125291. * Single plane rotation gizmo
  125292. */
  125293. export class PlaneRotationGizmo extends Gizmo {
  125294. /**
  125295. * Drag behavior responsible for the gizmos dragging interactions
  125296. */
  125297. dragBehavior: PointerDragBehavior;
  125298. private _pointerObserver;
  125299. /**
  125300. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125301. */
  125302. snapDistance: number;
  125303. /**
  125304. * Event that fires each time the gizmo snaps to a new location.
  125305. * * snapDistance is the the change in distance
  125306. */
  125307. onSnapObservable: Observable<{
  125308. snapDistance: number;
  125309. }>;
  125310. private _isEnabled;
  125311. private _parent;
  125312. /**
  125313. * Creates a PlaneRotationGizmo
  125314. * @param gizmoLayer The utility layer the gizmo will be added to
  125315. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125316. * @param color The color of the gizmo
  125317. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125318. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125319. */
  125320. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125322. /**
  125323. * If the gizmo is enabled
  125324. */
  125325. set isEnabled(value: boolean);
  125326. get isEnabled(): boolean;
  125327. /**
  125328. * Disposes of the gizmo
  125329. */
  125330. dispose(): void;
  125331. }
  125332. }
  125333. declare module BABYLON {
  125334. /**
  125335. * Gizmo that enables rotating a mesh along 3 axis
  125336. */
  125337. export class RotationGizmo extends Gizmo {
  125338. /**
  125339. * Internal gizmo used for interactions on the x axis
  125340. */
  125341. xGizmo: PlaneRotationGizmo;
  125342. /**
  125343. * Internal gizmo used for interactions on the y axis
  125344. */
  125345. yGizmo: PlaneRotationGizmo;
  125346. /**
  125347. * Internal gizmo used for interactions on the z axis
  125348. */
  125349. zGizmo: PlaneRotationGizmo;
  125350. /** Fires an event when any of it's sub gizmos are dragged */
  125351. onDragStartObservable: Observable<unknown>;
  125352. /** Fires an event when any of it's sub gizmos are released from dragging */
  125353. onDragEndObservable: Observable<unknown>;
  125354. private _meshAttached;
  125355. get attachedMesh(): Nullable<AbstractMesh>;
  125356. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125357. /**
  125358. * Creates a RotationGizmo
  125359. * @param gizmoLayer The utility layer the gizmo will be added to
  125360. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125361. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125362. */
  125363. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125364. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125365. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125366. /**
  125367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125368. */
  125369. set snapDistance(value: number);
  125370. get snapDistance(): number;
  125371. /**
  125372. * Ratio for the scale of the gizmo (Default: 1)
  125373. */
  125374. set scaleRatio(value: number);
  125375. get scaleRatio(): number;
  125376. /**
  125377. * Disposes of the gizmo
  125378. */
  125379. dispose(): void;
  125380. /**
  125381. * CustomMeshes are not supported by this gizmo
  125382. * @param mesh The mesh to replace the default mesh of the gizmo
  125383. */
  125384. setCustomMesh(mesh: Mesh): void;
  125385. }
  125386. }
  125387. declare module BABYLON {
  125388. /**
  125389. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125390. */
  125391. export class GizmoManager implements IDisposable {
  125392. private scene;
  125393. /**
  125394. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125395. */
  125396. gizmos: {
  125397. positionGizmo: Nullable<PositionGizmo>;
  125398. rotationGizmo: Nullable<RotationGizmo>;
  125399. scaleGizmo: Nullable<ScaleGizmo>;
  125400. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125401. };
  125402. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125403. clearGizmoOnEmptyPointerEvent: boolean;
  125404. /** Fires an event when the manager is attached to a mesh */
  125405. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125406. private _gizmosEnabled;
  125407. private _pointerObserver;
  125408. private _attachedMesh;
  125409. private _boundingBoxColor;
  125410. private _defaultUtilityLayer;
  125411. private _defaultKeepDepthUtilityLayer;
  125412. /**
  125413. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125414. */
  125415. boundingBoxDragBehavior: SixDofDragBehavior;
  125416. /**
  125417. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125418. */
  125419. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125420. /**
  125421. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125422. */
  125423. usePointerToAttachGizmos: boolean;
  125424. /**
  125425. * Utility layer that the bounding box gizmo belongs to
  125426. */
  125427. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125428. /**
  125429. * Utility layer that all gizmos besides bounding box belong to
  125430. */
  125431. get utilityLayer(): UtilityLayerRenderer;
  125432. /**
  125433. * Instatiates a gizmo manager
  125434. * @param scene the scene to overlay the gizmos on top of
  125435. */
  125436. constructor(scene: Scene);
  125437. /**
  125438. * Attaches a set of gizmos to the specified mesh
  125439. * @param mesh The mesh the gizmo's should be attached to
  125440. */
  125441. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125442. /**
  125443. * If the position gizmo is enabled
  125444. */
  125445. set positionGizmoEnabled(value: boolean);
  125446. get positionGizmoEnabled(): boolean;
  125447. /**
  125448. * If the rotation gizmo is enabled
  125449. */
  125450. set rotationGizmoEnabled(value: boolean);
  125451. get rotationGizmoEnabled(): boolean;
  125452. /**
  125453. * If the scale gizmo is enabled
  125454. */
  125455. set scaleGizmoEnabled(value: boolean);
  125456. get scaleGizmoEnabled(): boolean;
  125457. /**
  125458. * If the boundingBox gizmo is enabled
  125459. */
  125460. set boundingBoxGizmoEnabled(value: boolean);
  125461. get boundingBoxGizmoEnabled(): boolean;
  125462. /**
  125463. * Disposes of the gizmo manager
  125464. */
  125465. dispose(): void;
  125466. }
  125467. }
  125468. declare module BABYLON {
  125469. /**
  125470. * A directional light is defined by a direction (what a surprise!).
  125471. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125472. * 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.
  125473. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125474. */
  125475. export class DirectionalLight extends ShadowLight {
  125476. private _shadowFrustumSize;
  125477. /**
  125478. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125479. */
  125480. get shadowFrustumSize(): number;
  125481. /**
  125482. * Specifies a fix frustum size for the shadow generation.
  125483. */
  125484. set shadowFrustumSize(value: number);
  125485. private _shadowOrthoScale;
  125486. /**
  125487. * Gets the shadow projection scale against the optimal computed one.
  125488. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125489. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125490. */
  125491. get shadowOrthoScale(): number;
  125492. /**
  125493. * Sets the shadow projection scale against the optimal computed one.
  125494. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125495. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125496. */
  125497. set shadowOrthoScale(value: number);
  125498. /**
  125499. * Automatically compute the projection matrix to best fit (including all the casters)
  125500. * on each frame.
  125501. */
  125502. autoUpdateExtends: boolean;
  125503. /**
  125504. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125505. * on each frame. autoUpdateExtends must be set to true for this to work
  125506. */
  125507. autoCalcShadowZBounds: boolean;
  125508. private _orthoLeft;
  125509. private _orthoRight;
  125510. private _orthoTop;
  125511. private _orthoBottom;
  125512. /**
  125513. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125514. * The directional light is emitted from everywhere in the given direction.
  125515. * It can cast shadows.
  125516. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125517. * @param name The friendly name of the light
  125518. * @param direction The direction of the light
  125519. * @param scene The scene the light belongs to
  125520. */
  125521. constructor(name: string, direction: Vector3, scene: Scene);
  125522. /**
  125523. * Returns the string "DirectionalLight".
  125524. * @return The class name
  125525. */
  125526. getClassName(): string;
  125527. /**
  125528. * Returns the integer 1.
  125529. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125530. */
  125531. getTypeID(): number;
  125532. /**
  125533. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125534. * Returns the DirectionalLight Shadow projection matrix.
  125535. */
  125536. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125537. /**
  125538. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125539. * Returns the DirectionalLight Shadow projection matrix.
  125540. */
  125541. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125542. /**
  125543. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125544. * Returns the DirectionalLight Shadow projection matrix.
  125545. */
  125546. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125547. protected _buildUniformLayout(): void;
  125548. /**
  125549. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125550. * @param effect The effect to update
  125551. * @param lightIndex The index of the light in the effect to update
  125552. * @returns The directional light
  125553. */
  125554. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125555. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125556. /**
  125557. * Gets the minZ used for shadow according to both the scene and the light.
  125558. *
  125559. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125560. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125561. * @param activeCamera The camera we are returning the min for
  125562. * @returns the depth min z
  125563. */
  125564. getDepthMinZ(activeCamera: Camera): number;
  125565. /**
  125566. * Gets the maxZ used for shadow according to both the scene and the light.
  125567. *
  125568. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125569. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125570. * @param activeCamera The camera we are returning the max for
  125571. * @returns the depth max z
  125572. */
  125573. getDepthMaxZ(activeCamera: Camera): number;
  125574. /**
  125575. * Prepares the list of defines specific to the light type.
  125576. * @param defines the list of defines
  125577. * @param lightIndex defines the index of the light for the effect
  125578. */
  125579. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125580. }
  125581. }
  125582. declare module BABYLON {
  125583. /**
  125584. * Class containing static functions to help procedurally build meshes
  125585. */
  125586. export class HemisphereBuilder {
  125587. /**
  125588. * Creates a hemisphere mesh
  125589. * @param name defines the name of the mesh
  125590. * @param options defines the options used to create the mesh
  125591. * @param scene defines the hosting scene
  125592. * @returns the hemisphere mesh
  125593. */
  125594. static CreateHemisphere(name: string, options: {
  125595. segments?: number;
  125596. diameter?: number;
  125597. sideOrientation?: number;
  125598. }, scene: any): Mesh;
  125599. }
  125600. }
  125601. declare module BABYLON {
  125602. /**
  125603. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125604. * These values define a cone of light starting from the position, emitting toward the direction.
  125605. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125606. * and the exponent defines the speed of the decay of the light with distance (reach).
  125607. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125608. */
  125609. export class SpotLight extends ShadowLight {
  125610. private _angle;
  125611. private _innerAngle;
  125612. private _cosHalfAngle;
  125613. private _lightAngleScale;
  125614. private _lightAngleOffset;
  125615. /**
  125616. * Gets the cone angle of the spot light in Radians.
  125617. */
  125618. get angle(): number;
  125619. /**
  125620. * Sets the cone angle of the spot light in Radians.
  125621. */
  125622. set angle(value: number);
  125623. /**
  125624. * Only used in gltf falloff mode, this defines the angle where
  125625. * the directional falloff will start before cutting at angle which could be seen
  125626. * as outer angle.
  125627. */
  125628. get innerAngle(): number;
  125629. /**
  125630. * Only used in gltf falloff mode, this defines the angle where
  125631. * the directional falloff will start before cutting at angle which could be seen
  125632. * as outer angle.
  125633. */
  125634. set innerAngle(value: number);
  125635. private _shadowAngleScale;
  125636. /**
  125637. * Allows scaling the angle of the light for shadow generation only.
  125638. */
  125639. get shadowAngleScale(): number;
  125640. /**
  125641. * Allows scaling the angle of the light for shadow generation only.
  125642. */
  125643. set shadowAngleScale(value: number);
  125644. /**
  125645. * The light decay speed with the distance from the emission spot.
  125646. */
  125647. exponent: number;
  125648. private _projectionTextureMatrix;
  125649. /**
  125650. * Allows reading the projecton texture
  125651. */
  125652. get projectionTextureMatrix(): Matrix;
  125653. protected _projectionTextureLightNear: number;
  125654. /**
  125655. * Gets the near clip of the Spotlight for texture projection.
  125656. */
  125657. get projectionTextureLightNear(): number;
  125658. /**
  125659. * Sets the near clip of the Spotlight for texture projection.
  125660. */
  125661. set projectionTextureLightNear(value: number);
  125662. protected _projectionTextureLightFar: number;
  125663. /**
  125664. * Gets the far clip of the Spotlight for texture projection.
  125665. */
  125666. get projectionTextureLightFar(): number;
  125667. /**
  125668. * Sets the far clip of the Spotlight for texture projection.
  125669. */
  125670. set projectionTextureLightFar(value: number);
  125671. protected _projectionTextureUpDirection: Vector3;
  125672. /**
  125673. * Gets the Up vector of the Spotlight for texture projection.
  125674. */
  125675. get projectionTextureUpDirection(): Vector3;
  125676. /**
  125677. * Sets the Up vector of the Spotlight for texture projection.
  125678. */
  125679. set projectionTextureUpDirection(value: Vector3);
  125680. private _projectionTexture;
  125681. /**
  125682. * Gets the projection texture of the light.
  125683. */
  125684. get projectionTexture(): Nullable<BaseTexture>;
  125685. /**
  125686. * Sets the projection texture of the light.
  125687. */
  125688. set projectionTexture(value: Nullable<BaseTexture>);
  125689. private _projectionTextureViewLightDirty;
  125690. private _projectionTextureProjectionLightDirty;
  125691. private _projectionTextureDirty;
  125692. private _projectionTextureViewTargetVector;
  125693. private _projectionTextureViewLightMatrix;
  125694. private _projectionTextureProjectionLightMatrix;
  125695. private _projectionTextureScalingMatrix;
  125696. /**
  125697. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125698. * It can cast shadows.
  125699. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125700. * @param name The light friendly name
  125701. * @param position The position of the spot light in the scene
  125702. * @param direction The direction of the light in the scene
  125703. * @param angle The cone angle of the light in Radians
  125704. * @param exponent The light decay speed with the distance from the emission spot
  125705. * @param scene The scene the lights belongs to
  125706. */
  125707. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125708. /**
  125709. * Returns the string "SpotLight".
  125710. * @returns the class name
  125711. */
  125712. getClassName(): string;
  125713. /**
  125714. * Returns the integer 2.
  125715. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125716. */
  125717. getTypeID(): number;
  125718. /**
  125719. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125720. */
  125721. protected _setDirection(value: Vector3): void;
  125722. /**
  125723. * Overrides the position setter to recompute the projection texture view light Matrix.
  125724. */
  125725. protected _setPosition(value: Vector3): void;
  125726. /**
  125727. * 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.
  125728. * Returns the SpotLight.
  125729. */
  125730. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125731. protected _computeProjectionTextureViewLightMatrix(): void;
  125732. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125733. /**
  125734. * Main function for light texture projection matrix computing.
  125735. */
  125736. protected _computeProjectionTextureMatrix(): void;
  125737. protected _buildUniformLayout(): void;
  125738. private _computeAngleValues;
  125739. /**
  125740. * Sets the passed Effect "effect" with the Light textures.
  125741. * @param effect The effect to update
  125742. * @param lightIndex The index of the light in the effect to update
  125743. * @returns The light
  125744. */
  125745. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125746. /**
  125747. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125748. * @param effect The effect to update
  125749. * @param lightIndex The index of the light in the effect to update
  125750. * @returns The spot light
  125751. */
  125752. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125753. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125754. /**
  125755. * Disposes the light and the associated resources.
  125756. */
  125757. dispose(): void;
  125758. /**
  125759. * Prepares the list of defines specific to the light type.
  125760. * @param defines the list of defines
  125761. * @param lightIndex defines the index of the light for the effect
  125762. */
  125763. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125764. }
  125765. }
  125766. declare module BABYLON {
  125767. /**
  125768. * Gizmo that enables viewing a light
  125769. */
  125770. export class LightGizmo extends Gizmo {
  125771. private _lightMesh;
  125772. private _material;
  125773. private _cachedPosition;
  125774. private _cachedForward;
  125775. private _attachedMeshParent;
  125776. /**
  125777. * Creates a LightGizmo
  125778. * @param gizmoLayer The utility layer the gizmo will be added to
  125779. */
  125780. constructor(gizmoLayer?: UtilityLayerRenderer);
  125781. private _light;
  125782. /**
  125783. * The light that the gizmo is attached to
  125784. */
  125785. set light(light: Nullable<Light>);
  125786. get light(): Nullable<Light>;
  125787. /**
  125788. * Gets the material used to render the light gizmo
  125789. */
  125790. get material(): StandardMaterial;
  125791. /**
  125792. * @hidden
  125793. * Updates the gizmo to match the attached mesh's position/rotation
  125794. */
  125795. protected _update(): void;
  125796. private static _Scale;
  125797. /**
  125798. * Creates the lines for a light mesh
  125799. */
  125800. private static _CreateLightLines;
  125801. /**
  125802. * Disposes of the light gizmo
  125803. */
  125804. dispose(): void;
  125805. private static _CreateHemisphericLightMesh;
  125806. private static _CreatePointLightMesh;
  125807. private static _CreateSpotLightMesh;
  125808. private static _CreateDirectionalLightMesh;
  125809. }
  125810. }
  125811. declare module BABYLON {
  125812. /** @hidden */
  125813. export var backgroundFragmentDeclaration: {
  125814. name: string;
  125815. shader: string;
  125816. };
  125817. }
  125818. declare module BABYLON {
  125819. /** @hidden */
  125820. export var backgroundUboDeclaration: {
  125821. name: string;
  125822. shader: string;
  125823. };
  125824. }
  125825. declare module BABYLON {
  125826. /** @hidden */
  125827. export var backgroundPixelShader: {
  125828. name: string;
  125829. shader: string;
  125830. };
  125831. }
  125832. declare module BABYLON {
  125833. /** @hidden */
  125834. export var backgroundVertexDeclaration: {
  125835. name: string;
  125836. shader: string;
  125837. };
  125838. }
  125839. declare module BABYLON {
  125840. /** @hidden */
  125841. export var backgroundVertexShader: {
  125842. name: string;
  125843. shader: string;
  125844. };
  125845. }
  125846. declare module BABYLON {
  125847. /**
  125848. * Background material used to create an efficient environement around your scene.
  125849. */
  125850. export class BackgroundMaterial extends PushMaterial {
  125851. /**
  125852. * Standard reflectance value at parallel view angle.
  125853. */
  125854. static StandardReflectance0: number;
  125855. /**
  125856. * Standard reflectance value at grazing angle.
  125857. */
  125858. static StandardReflectance90: number;
  125859. protected _primaryColor: Color3;
  125860. /**
  125861. * Key light Color (multiply against the environement texture)
  125862. */
  125863. primaryColor: Color3;
  125864. protected __perceptualColor: Nullable<Color3>;
  125865. /**
  125866. * Experimental Internal Use Only.
  125867. *
  125868. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125869. * This acts as a helper to set the primary color to a more "human friendly" value.
  125870. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125871. * output color as close as possible from the chosen value.
  125872. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125873. * part of lighting setup.)
  125874. */
  125875. get _perceptualColor(): Nullable<Color3>;
  125876. set _perceptualColor(value: Nullable<Color3>);
  125877. protected _primaryColorShadowLevel: float;
  125878. /**
  125879. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125880. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125881. */
  125882. get primaryColorShadowLevel(): float;
  125883. set primaryColorShadowLevel(value: float);
  125884. protected _primaryColorHighlightLevel: float;
  125885. /**
  125886. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125887. * The primary color is used at the level chosen to define what the white area would look.
  125888. */
  125889. get primaryColorHighlightLevel(): float;
  125890. set primaryColorHighlightLevel(value: float);
  125891. protected _reflectionTexture: Nullable<BaseTexture>;
  125892. /**
  125893. * Reflection Texture used in the material.
  125894. * Should be author in a specific way for the best result (refer to the documentation).
  125895. */
  125896. reflectionTexture: Nullable<BaseTexture>;
  125897. protected _reflectionBlur: float;
  125898. /**
  125899. * Reflection Texture level of blur.
  125900. *
  125901. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125902. * texture twice.
  125903. */
  125904. reflectionBlur: float;
  125905. protected _diffuseTexture: Nullable<BaseTexture>;
  125906. /**
  125907. * Diffuse Texture used in the material.
  125908. * Should be author in a specific way for the best result (refer to the documentation).
  125909. */
  125910. diffuseTexture: Nullable<BaseTexture>;
  125911. protected _shadowLights: Nullable<IShadowLight[]>;
  125912. /**
  125913. * Specify the list of lights casting shadow on the material.
  125914. * All scene shadow lights will be included if null.
  125915. */
  125916. shadowLights: Nullable<IShadowLight[]>;
  125917. protected _shadowLevel: float;
  125918. /**
  125919. * Helps adjusting the shadow to a softer level if required.
  125920. * 0 means black shadows and 1 means no shadows.
  125921. */
  125922. shadowLevel: float;
  125923. protected _sceneCenter: Vector3;
  125924. /**
  125925. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125926. * It is usually zero but might be interesting to modify according to your setup.
  125927. */
  125928. sceneCenter: Vector3;
  125929. protected _opacityFresnel: boolean;
  125930. /**
  125931. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125932. * This helps ensuring a nice transition when the camera goes under the ground.
  125933. */
  125934. opacityFresnel: boolean;
  125935. protected _reflectionFresnel: boolean;
  125936. /**
  125937. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  125938. * This helps adding a mirror texture on the ground.
  125939. */
  125940. reflectionFresnel: boolean;
  125941. protected _reflectionFalloffDistance: number;
  125942. /**
  125943. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  125944. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  125945. */
  125946. reflectionFalloffDistance: number;
  125947. protected _reflectionAmount: number;
  125948. /**
  125949. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  125950. */
  125951. reflectionAmount: number;
  125952. protected _reflectionReflectance0: number;
  125953. /**
  125954. * This specifies the weight of the reflection at grazing angle.
  125955. */
  125956. reflectionReflectance0: number;
  125957. protected _reflectionReflectance90: number;
  125958. /**
  125959. * This specifies the weight of the reflection at a perpendicular point of view.
  125960. */
  125961. reflectionReflectance90: number;
  125962. /**
  125963. * Sets the reflection reflectance fresnel values according to the default standard
  125964. * empirically know to work well :-)
  125965. */
  125966. set reflectionStandardFresnelWeight(value: number);
  125967. protected _useRGBColor: boolean;
  125968. /**
  125969. * Helps to directly use the maps channels instead of their level.
  125970. */
  125971. useRGBColor: boolean;
  125972. protected _enableNoise: boolean;
  125973. /**
  125974. * This helps reducing the banding effect that could occur on the background.
  125975. */
  125976. enableNoise: boolean;
  125977. /**
  125978. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125979. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  125980. * Recommended to be keep at 1.0 except for special cases.
  125981. */
  125982. get fovMultiplier(): number;
  125983. set fovMultiplier(value: number);
  125984. private _fovMultiplier;
  125985. /**
  125986. * Enable the FOV adjustment feature controlled by fovMultiplier.
  125987. */
  125988. useEquirectangularFOV: boolean;
  125989. private _maxSimultaneousLights;
  125990. /**
  125991. * Number of Simultaneous lights allowed on the material.
  125992. */
  125993. maxSimultaneousLights: int;
  125994. /**
  125995. * Default configuration related to image processing available in the Background Material.
  125996. */
  125997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125998. /**
  125999. * Keep track of the image processing observer to allow dispose and replace.
  126000. */
  126001. private _imageProcessingObserver;
  126002. /**
  126003. * Attaches a new image processing configuration to the PBR Material.
  126004. * @param configuration (if null the scene configuration will be use)
  126005. */
  126006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126007. /**
  126008. * Gets the image processing configuration used either in this material.
  126009. */
  126010. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  126011. /**
  126012. * Sets the Default image processing configuration used either in the this material.
  126013. *
  126014. * If sets to null, the scene one is in use.
  126015. */
  126016. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  126017. /**
  126018. * Gets wether the color curves effect is enabled.
  126019. */
  126020. get cameraColorCurvesEnabled(): boolean;
  126021. /**
  126022. * Sets wether the color curves effect is enabled.
  126023. */
  126024. set cameraColorCurvesEnabled(value: boolean);
  126025. /**
  126026. * Gets wether the color grading effect is enabled.
  126027. */
  126028. get cameraColorGradingEnabled(): boolean;
  126029. /**
  126030. * Gets wether the color grading effect is enabled.
  126031. */
  126032. set cameraColorGradingEnabled(value: boolean);
  126033. /**
  126034. * Gets wether tonemapping is enabled or not.
  126035. */
  126036. get cameraToneMappingEnabled(): boolean;
  126037. /**
  126038. * Sets wether tonemapping is enabled or not
  126039. */
  126040. set cameraToneMappingEnabled(value: boolean);
  126041. /**
  126042. * The camera exposure used on this material.
  126043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126044. * This corresponds to a photographic exposure.
  126045. */
  126046. get cameraExposure(): float;
  126047. /**
  126048. * The camera exposure used on this material.
  126049. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126050. * This corresponds to a photographic exposure.
  126051. */
  126052. set cameraExposure(value: float);
  126053. /**
  126054. * Gets The camera contrast used on this material.
  126055. */
  126056. get cameraContrast(): float;
  126057. /**
  126058. * Sets The camera contrast used on this material.
  126059. */
  126060. set cameraContrast(value: float);
  126061. /**
  126062. * Gets the Color Grading 2D Lookup Texture.
  126063. */
  126064. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126065. /**
  126066. * Sets the Color Grading 2D Lookup Texture.
  126067. */
  126068. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126069. /**
  126070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126072. * 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;
  126073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126074. */
  126075. get cameraColorCurves(): Nullable<ColorCurves>;
  126076. /**
  126077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126079. * 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;
  126080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126081. */
  126082. set cameraColorCurves(value: Nullable<ColorCurves>);
  126083. /**
  126084. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  126085. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  126086. */
  126087. switchToBGR: boolean;
  126088. private _renderTargets;
  126089. private _reflectionControls;
  126090. private _white;
  126091. private _primaryShadowColor;
  126092. private _primaryHighlightColor;
  126093. /**
  126094. * Instantiates a Background Material in the given scene
  126095. * @param name The friendly name of the material
  126096. * @param scene The scene to add the material to
  126097. */
  126098. constructor(name: string, scene: Scene);
  126099. /**
  126100. * Gets a boolean indicating that current material needs to register RTT
  126101. */
  126102. get hasRenderTargetTextures(): boolean;
  126103. /**
  126104. * The entire material has been created in order to prevent overdraw.
  126105. * @returns false
  126106. */
  126107. needAlphaTesting(): boolean;
  126108. /**
  126109. * The entire material has been created in order to prevent overdraw.
  126110. * @returns true if blending is enable
  126111. */
  126112. needAlphaBlending(): boolean;
  126113. /**
  126114. * Checks wether the material is ready to be rendered for a given mesh.
  126115. * @param mesh The mesh to render
  126116. * @param subMesh The submesh to check against
  126117. * @param useInstances Specify wether or not the material is used with instances
  126118. * @returns true if all the dependencies are ready (Textures, Effects...)
  126119. */
  126120. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126121. /**
  126122. * Compute the primary color according to the chosen perceptual color.
  126123. */
  126124. private _computePrimaryColorFromPerceptualColor;
  126125. /**
  126126. * Compute the highlights and shadow colors according to their chosen levels.
  126127. */
  126128. private _computePrimaryColors;
  126129. /**
  126130. * Build the uniform buffer used in the material.
  126131. */
  126132. buildUniformLayout(): void;
  126133. /**
  126134. * Unbind the material.
  126135. */
  126136. unbind(): void;
  126137. /**
  126138. * Bind only the world matrix to the material.
  126139. * @param world The world matrix to bind.
  126140. */
  126141. bindOnlyWorldMatrix(world: Matrix): void;
  126142. /**
  126143. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  126144. * @param world The world matrix to bind.
  126145. * @param subMesh The submesh to bind for.
  126146. */
  126147. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126148. /**
  126149. * Checks to see if a texture is used in the material.
  126150. * @param texture - Base texture to use.
  126151. * @returns - Boolean specifying if a texture is used in the material.
  126152. */
  126153. hasTexture(texture: BaseTexture): boolean;
  126154. /**
  126155. * Dispose the material.
  126156. * @param forceDisposeEffect Force disposal of the associated effect.
  126157. * @param forceDisposeTextures Force disposal of the associated textures.
  126158. */
  126159. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126160. /**
  126161. * Clones the material.
  126162. * @param name The cloned name.
  126163. * @returns The cloned material.
  126164. */
  126165. clone(name: string): BackgroundMaterial;
  126166. /**
  126167. * Serializes the current material to its JSON representation.
  126168. * @returns The JSON representation.
  126169. */
  126170. serialize(): any;
  126171. /**
  126172. * Gets the class name of the material
  126173. * @returns "BackgroundMaterial"
  126174. */
  126175. getClassName(): string;
  126176. /**
  126177. * Parse a JSON input to create back a background material.
  126178. * @param source The JSON data to parse
  126179. * @param scene The scene to create the parsed material in
  126180. * @param rootUrl The root url of the assets the material depends upon
  126181. * @returns the instantiated BackgroundMaterial.
  126182. */
  126183. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  126184. }
  126185. }
  126186. declare module BABYLON {
  126187. /**
  126188. * Represents the different options available during the creation of
  126189. * a Environment helper.
  126190. *
  126191. * This can control the default ground, skybox and image processing setup of your scene.
  126192. */
  126193. export interface IEnvironmentHelperOptions {
  126194. /**
  126195. * Specifies whether or not to create a ground.
  126196. * True by default.
  126197. */
  126198. createGround: boolean;
  126199. /**
  126200. * Specifies the ground size.
  126201. * 15 by default.
  126202. */
  126203. groundSize: number;
  126204. /**
  126205. * The texture used on the ground for the main color.
  126206. * Comes from the BabylonJS CDN by default.
  126207. *
  126208. * Remarks: Can be either a texture or a url.
  126209. */
  126210. groundTexture: string | BaseTexture;
  126211. /**
  126212. * The color mixed in the ground texture by default.
  126213. * BabylonJS clearColor by default.
  126214. */
  126215. groundColor: Color3;
  126216. /**
  126217. * Specifies the ground opacity.
  126218. * 1 by default.
  126219. */
  126220. groundOpacity: number;
  126221. /**
  126222. * Enables the ground to receive shadows.
  126223. * True by default.
  126224. */
  126225. enableGroundShadow: boolean;
  126226. /**
  126227. * Helps preventing the shadow to be fully black on the ground.
  126228. * 0.5 by default.
  126229. */
  126230. groundShadowLevel: number;
  126231. /**
  126232. * Creates a mirror texture attach to the ground.
  126233. * false by default.
  126234. */
  126235. enableGroundMirror: boolean;
  126236. /**
  126237. * Specifies the ground mirror size ratio.
  126238. * 0.3 by default as the default kernel is 64.
  126239. */
  126240. groundMirrorSizeRatio: number;
  126241. /**
  126242. * Specifies the ground mirror blur kernel size.
  126243. * 64 by default.
  126244. */
  126245. groundMirrorBlurKernel: number;
  126246. /**
  126247. * Specifies the ground mirror visibility amount.
  126248. * 1 by default
  126249. */
  126250. groundMirrorAmount: number;
  126251. /**
  126252. * Specifies the ground mirror reflectance weight.
  126253. * This uses the standard weight of the background material to setup the fresnel effect
  126254. * of the mirror.
  126255. * 1 by default.
  126256. */
  126257. groundMirrorFresnelWeight: number;
  126258. /**
  126259. * Specifies the ground mirror Falloff distance.
  126260. * This can helps reducing the size of the reflection.
  126261. * 0 by Default.
  126262. */
  126263. groundMirrorFallOffDistance: number;
  126264. /**
  126265. * Specifies the ground mirror texture type.
  126266. * Unsigned Int by Default.
  126267. */
  126268. groundMirrorTextureType: number;
  126269. /**
  126270. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126271. * the shown objects.
  126272. */
  126273. groundYBias: number;
  126274. /**
  126275. * Specifies whether or not to create a skybox.
  126276. * True by default.
  126277. */
  126278. createSkybox: boolean;
  126279. /**
  126280. * Specifies the skybox size.
  126281. * 20 by default.
  126282. */
  126283. skyboxSize: number;
  126284. /**
  126285. * The texture used on the skybox for the main color.
  126286. * Comes from the BabylonJS CDN by default.
  126287. *
  126288. * Remarks: Can be either a texture or a url.
  126289. */
  126290. skyboxTexture: string | BaseTexture;
  126291. /**
  126292. * The color mixed in the skybox texture by default.
  126293. * BabylonJS clearColor by default.
  126294. */
  126295. skyboxColor: Color3;
  126296. /**
  126297. * The background rotation around the Y axis of the scene.
  126298. * This helps aligning the key lights of your scene with the background.
  126299. * 0 by default.
  126300. */
  126301. backgroundYRotation: number;
  126302. /**
  126303. * Compute automatically the size of the elements to best fit with the scene.
  126304. */
  126305. sizeAuto: boolean;
  126306. /**
  126307. * Default position of the rootMesh if autoSize is not true.
  126308. */
  126309. rootPosition: Vector3;
  126310. /**
  126311. * Sets up the image processing in the scene.
  126312. * true by default.
  126313. */
  126314. setupImageProcessing: boolean;
  126315. /**
  126316. * The texture used as your environment texture in the scene.
  126317. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126318. *
  126319. * Remarks: Can be either a texture or a url.
  126320. */
  126321. environmentTexture: string | BaseTexture;
  126322. /**
  126323. * The value of the exposure to apply to the scene.
  126324. * 0.6 by default if setupImageProcessing is true.
  126325. */
  126326. cameraExposure: number;
  126327. /**
  126328. * The value of the contrast to apply to the scene.
  126329. * 1.6 by default if setupImageProcessing is true.
  126330. */
  126331. cameraContrast: number;
  126332. /**
  126333. * Specifies whether or not tonemapping should be enabled in the scene.
  126334. * true by default if setupImageProcessing is true.
  126335. */
  126336. toneMappingEnabled: boolean;
  126337. }
  126338. /**
  126339. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126340. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126341. * It also helps with the default setup of your imageProcessing configuration.
  126342. */
  126343. export class EnvironmentHelper {
  126344. /**
  126345. * Default ground texture URL.
  126346. */
  126347. private static _groundTextureCDNUrl;
  126348. /**
  126349. * Default skybox texture URL.
  126350. */
  126351. private static _skyboxTextureCDNUrl;
  126352. /**
  126353. * Default environment texture URL.
  126354. */
  126355. private static _environmentTextureCDNUrl;
  126356. /**
  126357. * Creates the default options for the helper.
  126358. */
  126359. private static _getDefaultOptions;
  126360. private _rootMesh;
  126361. /**
  126362. * Gets the root mesh created by the helper.
  126363. */
  126364. get rootMesh(): Mesh;
  126365. private _skybox;
  126366. /**
  126367. * Gets the skybox created by the helper.
  126368. */
  126369. get skybox(): Nullable<Mesh>;
  126370. private _skyboxTexture;
  126371. /**
  126372. * Gets the skybox texture created by the helper.
  126373. */
  126374. get skyboxTexture(): Nullable<BaseTexture>;
  126375. private _skyboxMaterial;
  126376. /**
  126377. * Gets the skybox material created by the helper.
  126378. */
  126379. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126380. private _ground;
  126381. /**
  126382. * Gets the ground mesh created by the helper.
  126383. */
  126384. get ground(): Nullable<Mesh>;
  126385. private _groundTexture;
  126386. /**
  126387. * Gets the ground texture created by the helper.
  126388. */
  126389. get groundTexture(): Nullable<BaseTexture>;
  126390. private _groundMirror;
  126391. /**
  126392. * Gets the ground mirror created by the helper.
  126393. */
  126394. get groundMirror(): Nullable<MirrorTexture>;
  126395. /**
  126396. * Gets the ground mirror render list to helps pushing the meshes
  126397. * you wish in the ground reflection.
  126398. */
  126399. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126400. private _groundMaterial;
  126401. /**
  126402. * Gets the ground material created by the helper.
  126403. */
  126404. get groundMaterial(): Nullable<BackgroundMaterial>;
  126405. /**
  126406. * Stores the creation options.
  126407. */
  126408. private readonly _scene;
  126409. private _options;
  126410. /**
  126411. * This observable will be notified with any error during the creation of the environment,
  126412. * mainly texture creation errors.
  126413. */
  126414. onErrorObservable: Observable<{
  126415. message?: string;
  126416. exception?: any;
  126417. }>;
  126418. /**
  126419. * constructor
  126420. * @param options Defines the options we want to customize the helper
  126421. * @param scene The scene to add the material to
  126422. */
  126423. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126424. /**
  126425. * Updates the background according to the new options
  126426. * @param options
  126427. */
  126428. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126429. /**
  126430. * Sets the primary color of all the available elements.
  126431. * @param color the main color to affect to the ground and the background
  126432. */
  126433. setMainColor(color: Color3): void;
  126434. /**
  126435. * Setup the image processing according to the specified options.
  126436. */
  126437. private _setupImageProcessing;
  126438. /**
  126439. * Setup the environment texture according to the specified options.
  126440. */
  126441. private _setupEnvironmentTexture;
  126442. /**
  126443. * Setup the background according to the specified options.
  126444. */
  126445. private _setupBackground;
  126446. /**
  126447. * Get the scene sizes according to the setup.
  126448. */
  126449. private _getSceneSize;
  126450. /**
  126451. * Setup the ground according to the specified options.
  126452. */
  126453. private _setupGround;
  126454. /**
  126455. * Setup the ground material according to the specified options.
  126456. */
  126457. private _setupGroundMaterial;
  126458. /**
  126459. * Setup the ground diffuse texture according to the specified options.
  126460. */
  126461. private _setupGroundDiffuseTexture;
  126462. /**
  126463. * Setup the ground mirror texture according to the specified options.
  126464. */
  126465. private _setupGroundMirrorTexture;
  126466. /**
  126467. * Setup the ground to receive the mirror texture.
  126468. */
  126469. private _setupMirrorInGroundMaterial;
  126470. /**
  126471. * Setup the skybox according to the specified options.
  126472. */
  126473. private _setupSkybox;
  126474. /**
  126475. * Setup the skybox material according to the specified options.
  126476. */
  126477. private _setupSkyboxMaterial;
  126478. /**
  126479. * Setup the skybox reflection texture according to the specified options.
  126480. */
  126481. private _setupSkyboxReflectionTexture;
  126482. private _errorHandler;
  126483. /**
  126484. * Dispose all the elements created by the Helper.
  126485. */
  126486. dispose(): void;
  126487. }
  126488. }
  126489. declare module BABYLON {
  126490. /**
  126491. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126492. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126493. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126494. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126495. */
  126496. export class PhotoDome extends TransformNode {
  126497. /**
  126498. * Define the image as a Monoscopic panoramic 360 image.
  126499. */
  126500. static readonly MODE_MONOSCOPIC: number;
  126501. /**
  126502. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126503. */
  126504. static readonly MODE_TOPBOTTOM: number;
  126505. /**
  126506. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126507. */
  126508. static readonly MODE_SIDEBYSIDE: number;
  126509. private _useDirectMapping;
  126510. /**
  126511. * The texture being displayed on the sphere
  126512. */
  126513. protected _photoTexture: Texture;
  126514. /**
  126515. * Gets or sets the texture being displayed on the sphere
  126516. */
  126517. get photoTexture(): Texture;
  126518. set photoTexture(value: Texture);
  126519. /**
  126520. * Observable raised when an error occured while loading the 360 image
  126521. */
  126522. onLoadErrorObservable: Observable<string>;
  126523. /**
  126524. * The skybox material
  126525. */
  126526. protected _material: BackgroundMaterial;
  126527. /**
  126528. * The surface used for the skybox
  126529. */
  126530. protected _mesh: Mesh;
  126531. /**
  126532. * Gets the mesh used for the skybox.
  126533. */
  126534. get mesh(): Mesh;
  126535. /**
  126536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126537. * Also see the options.resolution property.
  126538. */
  126539. get fovMultiplier(): number;
  126540. set fovMultiplier(value: number);
  126541. private _imageMode;
  126542. /**
  126543. * Gets or set the current video mode for the video. It can be:
  126544. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126545. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126546. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126547. */
  126548. get imageMode(): number;
  126549. set imageMode(value: number);
  126550. /**
  126551. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126552. * @param name Element's name, child elements will append suffixes for their own names.
  126553. * @param urlsOfPhoto defines the url of the photo to display
  126554. * @param options defines an object containing optional or exposed sub element properties
  126555. * @param onError defines a callback called when an error occured while loading the texture
  126556. */
  126557. constructor(name: string, urlOfPhoto: string, options: {
  126558. resolution?: number;
  126559. size?: number;
  126560. useDirectMapping?: boolean;
  126561. faceForward?: boolean;
  126562. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126563. private _onBeforeCameraRenderObserver;
  126564. private _changeImageMode;
  126565. /**
  126566. * Releases resources associated with this node.
  126567. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126568. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126569. */
  126570. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126571. }
  126572. }
  126573. declare module BABYLON {
  126574. /**
  126575. * Class used to host RGBD texture specific utilities
  126576. */
  126577. export class RGBDTextureTools {
  126578. /**
  126579. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126580. * @param texture the texture to expand.
  126581. */
  126582. static ExpandRGBDTexture(texture: Texture): void;
  126583. }
  126584. }
  126585. declare module BABYLON {
  126586. /**
  126587. * Class used to host texture specific utilities
  126588. */
  126589. export class BRDFTextureTools {
  126590. /**
  126591. * Prevents texture cache collision
  126592. */
  126593. private static _instanceNumber;
  126594. /**
  126595. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126596. * @param scene defines the hosting scene
  126597. * @returns the environment BRDF texture
  126598. */
  126599. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126600. private static _environmentBRDFBase64Texture;
  126601. }
  126602. }
  126603. declare module BABYLON {
  126604. /**
  126605. * @hidden
  126606. */
  126607. export interface IMaterialClearCoatDefines {
  126608. CLEARCOAT: boolean;
  126609. CLEARCOAT_DEFAULTIOR: boolean;
  126610. CLEARCOAT_TEXTURE: boolean;
  126611. CLEARCOAT_TEXTUREDIRECTUV: number;
  126612. CLEARCOAT_BUMP: boolean;
  126613. CLEARCOAT_BUMPDIRECTUV: number;
  126614. CLEARCOAT_TINT: boolean;
  126615. CLEARCOAT_TINT_TEXTURE: boolean;
  126616. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126617. /** @hidden */
  126618. _areTexturesDirty: boolean;
  126619. }
  126620. /**
  126621. * Define the code related to the clear coat parameters of the pbr material.
  126622. */
  126623. export class PBRClearCoatConfiguration {
  126624. /**
  126625. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126626. * The default fits with a polyurethane material.
  126627. */
  126628. private static readonly _DefaultIndexOfRefraction;
  126629. private _isEnabled;
  126630. /**
  126631. * Defines if the clear coat is enabled in the material.
  126632. */
  126633. isEnabled: boolean;
  126634. /**
  126635. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126636. */
  126637. intensity: number;
  126638. /**
  126639. * Defines the clear coat layer roughness.
  126640. */
  126641. roughness: number;
  126642. private _indexOfRefraction;
  126643. /**
  126644. * Defines the index of refraction of the clear coat.
  126645. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126646. * The default fits with a polyurethane material.
  126647. * Changing the default value is more performance intensive.
  126648. */
  126649. indexOfRefraction: number;
  126650. private _texture;
  126651. /**
  126652. * Stores the clear coat values in a texture.
  126653. */
  126654. texture: Nullable<BaseTexture>;
  126655. private _bumpTexture;
  126656. /**
  126657. * Define the clear coat specific bump texture.
  126658. */
  126659. bumpTexture: Nullable<BaseTexture>;
  126660. private _isTintEnabled;
  126661. /**
  126662. * Defines if the clear coat tint is enabled in the material.
  126663. */
  126664. isTintEnabled: boolean;
  126665. /**
  126666. * Defines the clear coat tint of the material.
  126667. * This is only use if tint is enabled
  126668. */
  126669. tintColor: Color3;
  126670. /**
  126671. * Defines the distance at which the tint color should be found in the
  126672. * clear coat media.
  126673. * This is only use if tint is enabled
  126674. */
  126675. tintColorAtDistance: number;
  126676. /**
  126677. * Defines the clear coat layer thickness.
  126678. * This is only use if tint is enabled
  126679. */
  126680. tintThickness: number;
  126681. private _tintTexture;
  126682. /**
  126683. * Stores the clear tint values in a texture.
  126684. * rgb is tint
  126685. * a is a thickness factor
  126686. */
  126687. tintTexture: Nullable<BaseTexture>;
  126688. /** @hidden */
  126689. private _internalMarkAllSubMeshesAsTexturesDirty;
  126690. /** @hidden */
  126691. _markAllSubMeshesAsTexturesDirty(): void;
  126692. /**
  126693. * Instantiate a new istance of clear coat configuration.
  126694. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126695. */
  126696. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126697. /**
  126698. * Gets wehter the submesh is ready to be used or not.
  126699. * @param defines the list of "defines" to update.
  126700. * @param scene defines the scene the material belongs to.
  126701. * @param engine defines the engine the material belongs to.
  126702. * @param disableBumpMap defines wether the material disables bump or not.
  126703. * @returns - boolean indicating that the submesh is ready or not.
  126704. */
  126705. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126706. /**
  126707. * Checks to see if a texture is used in the material.
  126708. * @param defines the list of "defines" to update.
  126709. * @param scene defines the scene to the material belongs to.
  126710. */
  126711. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126712. /**
  126713. * Binds the material data.
  126714. * @param uniformBuffer defines the Uniform buffer to fill in.
  126715. * @param scene defines the scene the material belongs to.
  126716. * @param engine defines the engine the material belongs to.
  126717. * @param disableBumpMap defines wether the material disables bump or not.
  126718. * @param isFrozen defines wether the material is frozen or not.
  126719. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126720. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126721. */
  126722. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126723. /**
  126724. * Checks to see if a texture is used in the material.
  126725. * @param texture - Base texture to use.
  126726. * @returns - Boolean specifying if a texture is used in the material.
  126727. */
  126728. hasTexture(texture: BaseTexture): boolean;
  126729. /**
  126730. * Returns an array of the actively used textures.
  126731. * @param activeTextures Array of BaseTextures
  126732. */
  126733. getActiveTextures(activeTextures: BaseTexture[]): void;
  126734. /**
  126735. * Returns the animatable textures.
  126736. * @param animatables Array of animatable textures.
  126737. */
  126738. getAnimatables(animatables: IAnimatable[]): void;
  126739. /**
  126740. * Disposes the resources of the material.
  126741. * @param forceDisposeTextures - Forces the disposal of all textures.
  126742. */
  126743. dispose(forceDisposeTextures?: boolean): void;
  126744. /**
  126745. * Get the current class name of the texture useful for serialization or dynamic coding.
  126746. * @returns "PBRClearCoatConfiguration"
  126747. */
  126748. getClassName(): string;
  126749. /**
  126750. * Add fallbacks to the effect fallbacks list.
  126751. * @param defines defines the Base texture to use.
  126752. * @param fallbacks defines the current fallback list.
  126753. * @param currentRank defines the current fallback rank.
  126754. * @returns the new fallback rank.
  126755. */
  126756. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126757. /**
  126758. * Add the required uniforms to the current list.
  126759. * @param uniforms defines the current uniform list.
  126760. */
  126761. static AddUniforms(uniforms: string[]): void;
  126762. /**
  126763. * Add the required samplers to the current list.
  126764. * @param samplers defines the current sampler list.
  126765. */
  126766. static AddSamplers(samplers: string[]): void;
  126767. /**
  126768. * Add the required uniforms to the current buffer.
  126769. * @param uniformBuffer defines the current uniform buffer.
  126770. */
  126771. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126772. /**
  126773. * Makes a duplicate of the current configuration into another one.
  126774. * @param clearCoatConfiguration define the config where to copy the info
  126775. */
  126776. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126777. /**
  126778. * Serializes this clear coat configuration.
  126779. * @returns - An object with the serialized config.
  126780. */
  126781. serialize(): any;
  126782. /**
  126783. * Parses a anisotropy Configuration from a serialized object.
  126784. * @param source - Serialized object.
  126785. * @param scene Defines the scene we are parsing for
  126786. * @param rootUrl Defines the rootUrl to load from
  126787. */
  126788. parse(source: any, scene: Scene, rootUrl: string): void;
  126789. }
  126790. }
  126791. declare module BABYLON {
  126792. /**
  126793. * @hidden
  126794. */
  126795. export interface IMaterialAnisotropicDefines {
  126796. ANISOTROPIC: boolean;
  126797. ANISOTROPIC_TEXTURE: boolean;
  126798. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126799. MAINUV1: boolean;
  126800. _areTexturesDirty: boolean;
  126801. _needUVs: boolean;
  126802. }
  126803. /**
  126804. * Define the code related to the anisotropic parameters of the pbr material.
  126805. */
  126806. export class PBRAnisotropicConfiguration {
  126807. private _isEnabled;
  126808. /**
  126809. * Defines if the anisotropy is enabled in the material.
  126810. */
  126811. isEnabled: boolean;
  126812. /**
  126813. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126814. */
  126815. intensity: number;
  126816. /**
  126817. * Defines if the effect is along the tangents, bitangents or in between.
  126818. * By default, the effect is "strectching" the highlights along the tangents.
  126819. */
  126820. direction: Vector2;
  126821. private _texture;
  126822. /**
  126823. * Stores the anisotropy values in a texture.
  126824. * rg is direction (like normal from -1 to 1)
  126825. * b is a intensity
  126826. */
  126827. texture: Nullable<BaseTexture>;
  126828. /** @hidden */
  126829. private _internalMarkAllSubMeshesAsTexturesDirty;
  126830. /** @hidden */
  126831. _markAllSubMeshesAsTexturesDirty(): void;
  126832. /**
  126833. * Instantiate a new istance of anisotropy configuration.
  126834. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126835. */
  126836. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126837. /**
  126838. * Specifies that the submesh is ready to be used.
  126839. * @param defines the list of "defines" to update.
  126840. * @param scene defines the scene the material belongs to.
  126841. * @returns - boolean indicating that the submesh is ready or not.
  126842. */
  126843. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126844. /**
  126845. * Checks to see if a texture is used in the material.
  126846. * @param defines the list of "defines" to update.
  126847. * @param mesh the mesh we are preparing the defines for.
  126848. * @param scene defines the scene the material belongs to.
  126849. */
  126850. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126851. /**
  126852. * Binds the material data.
  126853. * @param uniformBuffer defines the Uniform buffer to fill in.
  126854. * @param scene defines the scene the material belongs to.
  126855. * @param isFrozen defines wether the material is frozen or not.
  126856. */
  126857. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126858. /**
  126859. * Checks to see if a texture is used in the material.
  126860. * @param texture - Base texture to use.
  126861. * @returns - Boolean specifying if a texture is used in the material.
  126862. */
  126863. hasTexture(texture: BaseTexture): boolean;
  126864. /**
  126865. * Returns an array of the actively used textures.
  126866. * @param activeTextures Array of BaseTextures
  126867. */
  126868. getActiveTextures(activeTextures: BaseTexture[]): void;
  126869. /**
  126870. * Returns the animatable textures.
  126871. * @param animatables Array of animatable textures.
  126872. */
  126873. getAnimatables(animatables: IAnimatable[]): void;
  126874. /**
  126875. * Disposes the resources of the material.
  126876. * @param forceDisposeTextures - Forces the disposal of all textures.
  126877. */
  126878. dispose(forceDisposeTextures?: boolean): void;
  126879. /**
  126880. * Get the current class name of the texture useful for serialization or dynamic coding.
  126881. * @returns "PBRAnisotropicConfiguration"
  126882. */
  126883. getClassName(): string;
  126884. /**
  126885. * Add fallbacks to the effect fallbacks list.
  126886. * @param defines defines the Base texture to use.
  126887. * @param fallbacks defines the current fallback list.
  126888. * @param currentRank defines the current fallback rank.
  126889. * @returns the new fallback rank.
  126890. */
  126891. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126892. /**
  126893. * Add the required uniforms to the current list.
  126894. * @param uniforms defines the current uniform list.
  126895. */
  126896. static AddUniforms(uniforms: string[]): void;
  126897. /**
  126898. * Add the required uniforms to the current buffer.
  126899. * @param uniformBuffer defines the current uniform buffer.
  126900. */
  126901. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126902. /**
  126903. * Add the required samplers to the current list.
  126904. * @param samplers defines the current sampler list.
  126905. */
  126906. static AddSamplers(samplers: string[]): void;
  126907. /**
  126908. * Makes a duplicate of the current configuration into another one.
  126909. * @param anisotropicConfiguration define the config where to copy the info
  126910. */
  126911. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126912. /**
  126913. * Serializes this anisotropy configuration.
  126914. * @returns - An object with the serialized config.
  126915. */
  126916. serialize(): any;
  126917. /**
  126918. * Parses a anisotropy Configuration from a serialized object.
  126919. * @param source - Serialized object.
  126920. * @param scene Defines the scene we are parsing for
  126921. * @param rootUrl Defines the rootUrl to load from
  126922. */
  126923. parse(source: any, scene: Scene, rootUrl: string): void;
  126924. }
  126925. }
  126926. declare module BABYLON {
  126927. /**
  126928. * @hidden
  126929. */
  126930. export interface IMaterialBRDFDefines {
  126931. BRDF_V_HEIGHT_CORRELATED: boolean;
  126932. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126933. SPHERICAL_HARMONICS: boolean;
  126934. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126935. /** @hidden */
  126936. _areMiscDirty: boolean;
  126937. }
  126938. /**
  126939. * Define the code related to the BRDF parameters of the pbr material.
  126940. */
  126941. export class PBRBRDFConfiguration {
  126942. /**
  126943. * Default value used for the energy conservation.
  126944. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126945. */
  126946. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  126947. /**
  126948. * Default value used for the Smith Visibility Height Correlated mode.
  126949. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126950. */
  126951. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  126952. /**
  126953. * Default value used for the IBL diffuse part.
  126954. * This can help switching back to the polynomials mode globally which is a tiny bit
  126955. * less GPU intensive at the drawback of a lower quality.
  126956. */
  126957. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  126958. /**
  126959. * Default value used for activating energy conservation for the specular workflow.
  126960. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126961. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126962. */
  126963. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  126964. private _useEnergyConservation;
  126965. /**
  126966. * Defines if the material uses energy conservation.
  126967. */
  126968. useEnergyConservation: boolean;
  126969. private _useSmithVisibilityHeightCorrelated;
  126970. /**
  126971. * LEGACY Mode set to false
  126972. * Defines if the material uses height smith correlated visibility term.
  126973. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  126974. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  126975. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  126976. * Not relying on height correlated will also disable energy conservation.
  126977. */
  126978. useSmithVisibilityHeightCorrelated: boolean;
  126979. private _useSphericalHarmonics;
  126980. /**
  126981. * LEGACY Mode set to false
  126982. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  126983. * diffuse part of the IBL.
  126984. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  126985. * to the ground truth.
  126986. */
  126987. useSphericalHarmonics: boolean;
  126988. private _useSpecularGlossinessInputEnergyConservation;
  126989. /**
  126990. * Defines if the material uses energy conservation, when the specular workflow is active.
  126991. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126992. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126993. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  126994. */
  126995. useSpecularGlossinessInputEnergyConservation: boolean;
  126996. /** @hidden */
  126997. private _internalMarkAllSubMeshesAsMiscDirty;
  126998. /** @hidden */
  126999. _markAllSubMeshesAsMiscDirty(): void;
  127000. /**
  127001. * Instantiate a new istance of clear coat configuration.
  127002. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  127003. */
  127004. constructor(markAllSubMeshesAsMiscDirty: () => void);
  127005. /**
  127006. * Checks to see if a texture is used in the material.
  127007. * @param defines the list of "defines" to update.
  127008. */
  127009. prepareDefines(defines: IMaterialBRDFDefines): void;
  127010. /**
  127011. * Get the current class name of the texture useful for serialization or dynamic coding.
  127012. * @returns "PBRClearCoatConfiguration"
  127013. */
  127014. getClassName(): string;
  127015. /**
  127016. * Makes a duplicate of the current configuration into another one.
  127017. * @param brdfConfiguration define the config where to copy the info
  127018. */
  127019. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  127020. /**
  127021. * Serializes this BRDF configuration.
  127022. * @returns - An object with the serialized config.
  127023. */
  127024. serialize(): any;
  127025. /**
  127026. * Parses a anisotropy Configuration from a serialized object.
  127027. * @param source - Serialized object.
  127028. * @param scene Defines the scene we are parsing for
  127029. * @param rootUrl Defines the rootUrl to load from
  127030. */
  127031. parse(source: any, scene: Scene, rootUrl: string): void;
  127032. }
  127033. }
  127034. declare module BABYLON {
  127035. /**
  127036. * @hidden
  127037. */
  127038. export interface IMaterialSheenDefines {
  127039. SHEEN: boolean;
  127040. SHEEN_TEXTURE: boolean;
  127041. SHEEN_TEXTUREDIRECTUV: number;
  127042. SHEEN_LINKWITHALBEDO: boolean;
  127043. SHEEN_ROUGHNESS: boolean;
  127044. SHEEN_ALBEDOSCALING: boolean;
  127045. /** @hidden */
  127046. _areTexturesDirty: boolean;
  127047. }
  127048. /**
  127049. * Define the code related to the Sheen parameters of the pbr material.
  127050. */
  127051. export class PBRSheenConfiguration {
  127052. private _isEnabled;
  127053. /**
  127054. * Defines if the material uses sheen.
  127055. */
  127056. isEnabled: boolean;
  127057. private _linkSheenWithAlbedo;
  127058. /**
  127059. * Defines if the sheen is linked to the sheen color.
  127060. */
  127061. linkSheenWithAlbedo: boolean;
  127062. /**
  127063. * Defines the sheen intensity.
  127064. */
  127065. intensity: number;
  127066. /**
  127067. * Defines the sheen color.
  127068. */
  127069. color: Color3;
  127070. private _texture;
  127071. /**
  127072. * Stores the sheen tint values in a texture.
  127073. * rgb is tint
  127074. * a is a intensity
  127075. */
  127076. texture: Nullable<BaseTexture>;
  127077. private _roughness;
  127078. /**
  127079. * Defines the sheen roughness.
  127080. * It is not taken into account if linkSheenWithAlbedo is true.
  127081. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  127082. */
  127083. roughness: Nullable<number>;
  127084. private _albedoScaling;
  127085. /**
  127086. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  127087. * It allows the strength of the sheen effect to not depend on the base color of the material,
  127088. * making it easier to setup and tweak the effect
  127089. */
  127090. albedoScaling: boolean;
  127091. /** @hidden */
  127092. private _internalMarkAllSubMeshesAsTexturesDirty;
  127093. /** @hidden */
  127094. _markAllSubMeshesAsTexturesDirty(): void;
  127095. /**
  127096. * Instantiate a new istance of clear coat configuration.
  127097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127098. */
  127099. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127100. /**
  127101. * Specifies that the submesh is ready to be used.
  127102. * @param defines the list of "defines" to update.
  127103. * @param scene defines the scene the material belongs to.
  127104. * @returns - boolean indicating that the submesh is ready or not.
  127105. */
  127106. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  127107. /**
  127108. * Checks to see if a texture is used in the material.
  127109. * @param defines the list of "defines" to update.
  127110. * @param scene defines the scene the material belongs to.
  127111. */
  127112. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  127113. /**
  127114. * Binds the material data.
  127115. * @param uniformBuffer defines the Uniform buffer to fill in.
  127116. * @param scene defines the scene the material belongs to.
  127117. * @param isFrozen defines wether the material is frozen or not.
  127118. */
  127119. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  127120. /**
  127121. * Checks to see if a texture is used in the material.
  127122. * @param texture - Base texture to use.
  127123. * @returns - Boolean specifying if a texture is used in the material.
  127124. */
  127125. hasTexture(texture: BaseTexture): boolean;
  127126. /**
  127127. * Returns an array of the actively used textures.
  127128. * @param activeTextures Array of BaseTextures
  127129. */
  127130. getActiveTextures(activeTextures: BaseTexture[]): void;
  127131. /**
  127132. * Returns the animatable textures.
  127133. * @param animatables Array of animatable textures.
  127134. */
  127135. getAnimatables(animatables: IAnimatable[]): void;
  127136. /**
  127137. * Disposes the resources of the material.
  127138. * @param forceDisposeTextures - Forces the disposal of all textures.
  127139. */
  127140. dispose(forceDisposeTextures?: boolean): void;
  127141. /**
  127142. * Get the current class name of the texture useful for serialization or dynamic coding.
  127143. * @returns "PBRSheenConfiguration"
  127144. */
  127145. getClassName(): string;
  127146. /**
  127147. * Add fallbacks to the effect fallbacks list.
  127148. * @param defines defines the Base texture to use.
  127149. * @param fallbacks defines the current fallback list.
  127150. * @param currentRank defines the current fallback rank.
  127151. * @returns the new fallback rank.
  127152. */
  127153. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127154. /**
  127155. * Add the required uniforms to the current list.
  127156. * @param uniforms defines the current uniform list.
  127157. */
  127158. static AddUniforms(uniforms: string[]): void;
  127159. /**
  127160. * Add the required uniforms to the current buffer.
  127161. * @param uniformBuffer defines the current uniform buffer.
  127162. */
  127163. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127164. /**
  127165. * Add the required samplers to the current list.
  127166. * @param samplers defines the current sampler list.
  127167. */
  127168. static AddSamplers(samplers: string[]): void;
  127169. /**
  127170. * Makes a duplicate of the current configuration into another one.
  127171. * @param sheenConfiguration define the config where to copy the info
  127172. */
  127173. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  127174. /**
  127175. * Serializes this BRDF configuration.
  127176. * @returns - An object with the serialized config.
  127177. */
  127178. serialize(): any;
  127179. /**
  127180. * Parses a anisotropy Configuration from a serialized object.
  127181. * @param source - Serialized object.
  127182. * @param scene Defines the scene we are parsing for
  127183. * @param rootUrl Defines the rootUrl to load from
  127184. */
  127185. parse(source: any, scene: Scene, rootUrl: string): void;
  127186. }
  127187. }
  127188. declare module BABYLON {
  127189. /**
  127190. * @hidden
  127191. */
  127192. export interface IMaterialSubSurfaceDefines {
  127193. SUBSURFACE: boolean;
  127194. SS_REFRACTION: boolean;
  127195. SS_TRANSLUCENCY: boolean;
  127196. SS_SCATERRING: boolean;
  127197. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127198. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127199. SS_REFRACTIONMAP_3D: boolean;
  127200. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127201. SS_LODINREFRACTIONALPHA: boolean;
  127202. SS_GAMMAREFRACTION: boolean;
  127203. SS_RGBDREFRACTION: boolean;
  127204. SS_LINEARSPECULARREFRACTION: boolean;
  127205. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127206. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127207. /** @hidden */
  127208. _areTexturesDirty: boolean;
  127209. }
  127210. /**
  127211. * Define the code related to the sub surface parameters of the pbr material.
  127212. */
  127213. export class PBRSubSurfaceConfiguration {
  127214. private _isRefractionEnabled;
  127215. /**
  127216. * Defines if the refraction is enabled in the material.
  127217. */
  127218. isRefractionEnabled: boolean;
  127219. private _isTranslucencyEnabled;
  127220. /**
  127221. * Defines if the translucency is enabled in the material.
  127222. */
  127223. isTranslucencyEnabled: boolean;
  127224. private _isScatteringEnabled;
  127225. /**
  127226. * Defines the refraction intensity of the material.
  127227. * The refraction when enabled replaces the Diffuse part of the material.
  127228. * The intensity helps transitionning between diffuse and refraction.
  127229. */
  127230. refractionIntensity: number;
  127231. /**
  127232. * Defines the translucency intensity of the material.
  127233. * When translucency has been enabled, this defines how much of the "translucency"
  127234. * is addded to the diffuse part of the material.
  127235. */
  127236. translucencyIntensity: number;
  127237. /**
  127238. * Defines the scattering intensity of the material.
  127239. * When scattering has been enabled, this defines how much of the "scattered light"
  127240. * is addded to the diffuse part of the material.
  127241. */
  127242. scatteringIntensity: number;
  127243. private _thicknessTexture;
  127244. /**
  127245. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127246. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127247. * 0 would mean minimumThickness
  127248. * 1 would mean maximumThickness
  127249. * The other channels might be use as a mask to vary the different effects intensity.
  127250. */
  127251. thicknessTexture: Nullable<BaseTexture>;
  127252. private _refractionTexture;
  127253. /**
  127254. * Defines the texture to use for refraction.
  127255. */
  127256. refractionTexture: Nullable<BaseTexture>;
  127257. private _indexOfRefraction;
  127258. /**
  127259. * Defines the index of refraction used in the material.
  127260. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127261. */
  127262. indexOfRefraction: number;
  127263. private _invertRefractionY;
  127264. /**
  127265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127266. */
  127267. invertRefractionY: boolean;
  127268. private _linkRefractionWithTransparency;
  127269. /**
  127270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127271. * Materials half opaque for instance using refraction could benefit from this control.
  127272. */
  127273. linkRefractionWithTransparency: boolean;
  127274. /**
  127275. * Defines the minimum thickness stored in the thickness map.
  127276. * If no thickness map is defined, this value will be used to simulate thickness.
  127277. */
  127278. minimumThickness: number;
  127279. /**
  127280. * Defines the maximum thickness stored in the thickness map.
  127281. */
  127282. maximumThickness: number;
  127283. /**
  127284. * Defines the volume tint of the material.
  127285. * This is used for both translucency and scattering.
  127286. */
  127287. tintColor: Color3;
  127288. /**
  127289. * Defines the distance at which the tint color should be found in the media.
  127290. * This is used for refraction only.
  127291. */
  127292. tintColorAtDistance: number;
  127293. /**
  127294. * Defines how far each channel transmit through the media.
  127295. * It is defined as a color to simplify it selection.
  127296. */
  127297. diffusionDistance: Color3;
  127298. private _useMaskFromThicknessTexture;
  127299. /**
  127300. * Stores the intensity of the different subsurface effects in the thickness texture.
  127301. * * the green channel is the translucency intensity.
  127302. * * the blue channel is the scattering intensity.
  127303. * * the alpha channel is the refraction intensity.
  127304. */
  127305. useMaskFromThicknessTexture: boolean;
  127306. /** @hidden */
  127307. private _internalMarkAllSubMeshesAsTexturesDirty;
  127308. /** @hidden */
  127309. _markAllSubMeshesAsTexturesDirty(): void;
  127310. /**
  127311. * Instantiate a new istance of sub surface configuration.
  127312. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127313. */
  127314. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127315. /**
  127316. * Gets wehter the submesh is ready to be used or not.
  127317. * @param defines the list of "defines" to update.
  127318. * @param scene defines the scene the material belongs to.
  127319. * @returns - boolean indicating that the submesh is ready or not.
  127320. */
  127321. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127322. /**
  127323. * Checks to see if a texture is used in the material.
  127324. * @param defines the list of "defines" to update.
  127325. * @param scene defines the scene to the material belongs to.
  127326. */
  127327. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127328. /**
  127329. * Binds the material data.
  127330. * @param uniformBuffer defines the Uniform buffer to fill in.
  127331. * @param scene defines the scene the material belongs to.
  127332. * @param engine defines the engine the material belongs to.
  127333. * @param isFrozen defines wether the material is frozen or not.
  127334. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127335. */
  127336. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127337. /**
  127338. * Unbinds the material from the mesh.
  127339. * @param activeEffect defines the effect that should be unbound from.
  127340. * @returns true if unbound, otherwise false
  127341. */
  127342. unbind(activeEffect: Effect): boolean;
  127343. /**
  127344. * Returns the texture used for refraction or null if none is used.
  127345. * @param scene defines the scene the material belongs to.
  127346. * @returns - Refraction texture if present. If no refraction texture and refraction
  127347. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127348. */
  127349. private _getRefractionTexture;
  127350. /**
  127351. * Returns true if alpha blending should be disabled.
  127352. */
  127353. get disableAlphaBlending(): boolean;
  127354. /**
  127355. * Fills the list of render target textures.
  127356. * @param renderTargets the list of render targets to update
  127357. */
  127358. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127359. /**
  127360. * Checks to see if a texture is used in the material.
  127361. * @param texture - Base texture to use.
  127362. * @returns - Boolean specifying if a texture is used in the material.
  127363. */
  127364. hasTexture(texture: BaseTexture): boolean;
  127365. /**
  127366. * Gets a boolean indicating that current material needs to register RTT
  127367. * @returns true if this uses a render target otherwise false.
  127368. */
  127369. hasRenderTargetTextures(): boolean;
  127370. /**
  127371. * Returns an array of the actively used textures.
  127372. * @param activeTextures Array of BaseTextures
  127373. */
  127374. getActiveTextures(activeTextures: BaseTexture[]): void;
  127375. /**
  127376. * Returns the animatable textures.
  127377. * @param animatables Array of animatable textures.
  127378. */
  127379. getAnimatables(animatables: IAnimatable[]): void;
  127380. /**
  127381. * Disposes the resources of the material.
  127382. * @param forceDisposeTextures - Forces the disposal of all textures.
  127383. */
  127384. dispose(forceDisposeTextures?: boolean): void;
  127385. /**
  127386. * Get the current class name of the texture useful for serialization or dynamic coding.
  127387. * @returns "PBRSubSurfaceConfiguration"
  127388. */
  127389. getClassName(): string;
  127390. /**
  127391. * Add fallbacks to the effect fallbacks list.
  127392. * @param defines defines the Base texture to use.
  127393. * @param fallbacks defines the current fallback list.
  127394. * @param currentRank defines the current fallback rank.
  127395. * @returns the new fallback rank.
  127396. */
  127397. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127398. /**
  127399. * Add the required uniforms to the current list.
  127400. * @param uniforms defines the current uniform list.
  127401. */
  127402. static AddUniforms(uniforms: string[]): void;
  127403. /**
  127404. * Add the required samplers to the current list.
  127405. * @param samplers defines the current sampler list.
  127406. */
  127407. static AddSamplers(samplers: string[]): void;
  127408. /**
  127409. * Add the required uniforms to the current buffer.
  127410. * @param uniformBuffer defines the current uniform buffer.
  127411. */
  127412. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127413. /**
  127414. * Makes a duplicate of the current configuration into another one.
  127415. * @param configuration define the config where to copy the info
  127416. */
  127417. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127418. /**
  127419. * Serializes this Sub Surface configuration.
  127420. * @returns - An object with the serialized config.
  127421. */
  127422. serialize(): any;
  127423. /**
  127424. * Parses a anisotropy Configuration from a serialized object.
  127425. * @param source - Serialized object.
  127426. * @param scene Defines the scene we are parsing for
  127427. * @param rootUrl Defines the rootUrl to load from
  127428. */
  127429. parse(source: any, scene: Scene, rootUrl: string): void;
  127430. }
  127431. }
  127432. declare module BABYLON {
  127433. /** @hidden */
  127434. export var pbrFragmentDeclaration: {
  127435. name: string;
  127436. shader: string;
  127437. };
  127438. }
  127439. declare module BABYLON {
  127440. /** @hidden */
  127441. export var pbrUboDeclaration: {
  127442. name: string;
  127443. shader: string;
  127444. };
  127445. }
  127446. declare module BABYLON {
  127447. /** @hidden */
  127448. export var pbrFragmentExtraDeclaration: {
  127449. name: string;
  127450. shader: string;
  127451. };
  127452. }
  127453. declare module BABYLON {
  127454. /** @hidden */
  127455. export var pbrFragmentSamplersDeclaration: {
  127456. name: string;
  127457. shader: string;
  127458. };
  127459. }
  127460. declare module BABYLON {
  127461. /** @hidden */
  127462. export var pbrHelperFunctions: {
  127463. name: string;
  127464. shader: string;
  127465. };
  127466. }
  127467. declare module BABYLON {
  127468. /** @hidden */
  127469. export var harmonicsFunctions: {
  127470. name: string;
  127471. shader: string;
  127472. };
  127473. }
  127474. declare module BABYLON {
  127475. /** @hidden */
  127476. export var pbrDirectLightingSetupFunctions: {
  127477. name: string;
  127478. shader: string;
  127479. };
  127480. }
  127481. declare module BABYLON {
  127482. /** @hidden */
  127483. export var pbrDirectLightingFalloffFunctions: {
  127484. name: string;
  127485. shader: string;
  127486. };
  127487. }
  127488. declare module BABYLON {
  127489. /** @hidden */
  127490. export var pbrBRDFFunctions: {
  127491. name: string;
  127492. shader: string;
  127493. };
  127494. }
  127495. declare module BABYLON {
  127496. /** @hidden */
  127497. export var pbrDirectLightingFunctions: {
  127498. name: string;
  127499. shader: string;
  127500. };
  127501. }
  127502. declare module BABYLON {
  127503. /** @hidden */
  127504. export var pbrIBLFunctions: {
  127505. name: string;
  127506. shader: string;
  127507. };
  127508. }
  127509. declare module BABYLON {
  127510. /** @hidden */
  127511. export var pbrBlockAlbedoOpacity: {
  127512. name: string;
  127513. shader: string;
  127514. };
  127515. }
  127516. declare module BABYLON {
  127517. /** @hidden */
  127518. export var pbrBlockReflectivity: {
  127519. name: string;
  127520. shader: string;
  127521. };
  127522. }
  127523. declare module BABYLON {
  127524. /** @hidden */
  127525. export var pbrBlockAmbientOcclusion: {
  127526. name: string;
  127527. shader: string;
  127528. };
  127529. }
  127530. declare module BABYLON {
  127531. /** @hidden */
  127532. export var pbrBlockAlphaFresnel: {
  127533. name: string;
  127534. shader: string;
  127535. };
  127536. }
  127537. declare module BABYLON {
  127538. /** @hidden */
  127539. export var pbrBlockAnisotropic: {
  127540. name: string;
  127541. shader: string;
  127542. };
  127543. }
  127544. declare module BABYLON {
  127545. /** @hidden */
  127546. export var pbrBlockReflection: {
  127547. name: string;
  127548. shader: string;
  127549. };
  127550. }
  127551. declare module BABYLON {
  127552. /** @hidden */
  127553. export var pbrBlockSheen: {
  127554. name: string;
  127555. shader: string;
  127556. };
  127557. }
  127558. declare module BABYLON {
  127559. /** @hidden */
  127560. export var pbrBlockClearcoat: {
  127561. name: string;
  127562. shader: string;
  127563. };
  127564. }
  127565. declare module BABYLON {
  127566. /** @hidden */
  127567. export var pbrBlockSubSurface: {
  127568. name: string;
  127569. shader: string;
  127570. };
  127571. }
  127572. declare module BABYLON {
  127573. /** @hidden */
  127574. export var pbrBlockNormalGeometric: {
  127575. name: string;
  127576. shader: string;
  127577. };
  127578. }
  127579. declare module BABYLON {
  127580. /** @hidden */
  127581. export var pbrBlockNormalFinal: {
  127582. name: string;
  127583. shader: string;
  127584. };
  127585. }
  127586. declare module BABYLON {
  127587. /** @hidden */
  127588. export var pbrBlockGeometryInfo: {
  127589. name: string;
  127590. shader: string;
  127591. };
  127592. }
  127593. declare module BABYLON {
  127594. /** @hidden */
  127595. export var pbrBlockReflectance0: {
  127596. name: string;
  127597. shader: string;
  127598. };
  127599. }
  127600. declare module BABYLON {
  127601. /** @hidden */
  127602. export var pbrBlockReflectance: {
  127603. name: string;
  127604. shader: string;
  127605. };
  127606. }
  127607. declare module BABYLON {
  127608. /** @hidden */
  127609. export var pbrBlockDirectLighting: {
  127610. name: string;
  127611. shader: string;
  127612. };
  127613. }
  127614. declare module BABYLON {
  127615. /** @hidden */
  127616. export var pbrBlockFinalLitComponents: {
  127617. name: string;
  127618. shader: string;
  127619. };
  127620. }
  127621. declare module BABYLON {
  127622. /** @hidden */
  127623. export var pbrBlockFinalUnlitComponents: {
  127624. name: string;
  127625. shader: string;
  127626. };
  127627. }
  127628. declare module BABYLON {
  127629. /** @hidden */
  127630. export var pbrBlockFinalColorComposition: {
  127631. name: string;
  127632. shader: string;
  127633. };
  127634. }
  127635. declare module BABYLON {
  127636. /** @hidden */
  127637. export var pbrBlockImageProcessing: {
  127638. name: string;
  127639. shader: string;
  127640. };
  127641. }
  127642. declare module BABYLON {
  127643. /** @hidden */
  127644. export var pbrDebug: {
  127645. name: string;
  127646. shader: string;
  127647. };
  127648. }
  127649. declare module BABYLON {
  127650. /** @hidden */
  127651. export var pbrPixelShader: {
  127652. name: string;
  127653. shader: string;
  127654. };
  127655. }
  127656. declare module BABYLON {
  127657. /** @hidden */
  127658. export var pbrVertexDeclaration: {
  127659. name: string;
  127660. shader: string;
  127661. };
  127662. }
  127663. declare module BABYLON {
  127664. /** @hidden */
  127665. export var pbrVertexShader: {
  127666. name: string;
  127667. shader: string;
  127668. };
  127669. }
  127670. declare module BABYLON {
  127671. /**
  127672. * Manages the defines for the PBR Material.
  127673. * @hidden
  127674. */
  127675. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127676. PBR: boolean;
  127677. MAINUV1: boolean;
  127678. MAINUV2: boolean;
  127679. UV1: boolean;
  127680. UV2: boolean;
  127681. ALBEDO: boolean;
  127682. GAMMAALBEDO: boolean;
  127683. ALBEDODIRECTUV: number;
  127684. VERTEXCOLOR: boolean;
  127685. AMBIENT: boolean;
  127686. AMBIENTDIRECTUV: number;
  127687. AMBIENTINGRAYSCALE: boolean;
  127688. OPACITY: boolean;
  127689. VERTEXALPHA: boolean;
  127690. OPACITYDIRECTUV: number;
  127691. OPACITYRGB: boolean;
  127692. ALPHATEST: boolean;
  127693. DEPTHPREPASS: boolean;
  127694. ALPHABLEND: boolean;
  127695. ALPHAFROMALBEDO: boolean;
  127696. ALPHATESTVALUE: string;
  127697. SPECULAROVERALPHA: boolean;
  127698. RADIANCEOVERALPHA: boolean;
  127699. ALPHAFRESNEL: boolean;
  127700. LINEARALPHAFRESNEL: boolean;
  127701. PREMULTIPLYALPHA: boolean;
  127702. EMISSIVE: boolean;
  127703. EMISSIVEDIRECTUV: number;
  127704. REFLECTIVITY: boolean;
  127705. REFLECTIVITYDIRECTUV: number;
  127706. SPECULARTERM: boolean;
  127707. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127708. MICROSURFACEAUTOMATIC: boolean;
  127709. LODBASEDMICROSFURACE: boolean;
  127710. MICROSURFACEMAP: boolean;
  127711. MICROSURFACEMAPDIRECTUV: number;
  127712. METALLICWORKFLOW: boolean;
  127713. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127714. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127715. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127716. AOSTOREINMETALMAPRED: boolean;
  127717. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127718. ENVIRONMENTBRDF: boolean;
  127719. ENVIRONMENTBRDF_RGBD: boolean;
  127720. NORMAL: boolean;
  127721. TANGENT: boolean;
  127722. BUMP: boolean;
  127723. BUMPDIRECTUV: number;
  127724. OBJECTSPACE_NORMALMAP: boolean;
  127725. PARALLAX: boolean;
  127726. PARALLAXOCCLUSION: boolean;
  127727. NORMALXYSCALE: boolean;
  127728. LIGHTMAP: boolean;
  127729. LIGHTMAPDIRECTUV: number;
  127730. USELIGHTMAPASSHADOWMAP: boolean;
  127731. GAMMALIGHTMAP: boolean;
  127732. RGBDLIGHTMAP: boolean;
  127733. REFLECTION: boolean;
  127734. REFLECTIONMAP_3D: boolean;
  127735. REFLECTIONMAP_SPHERICAL: boolean;
  127736. REFLECTIONMAP_PLANAR: boolean;
  127737. REFLECTIONMAP_CUBIC: boolean;
  127738. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127739. REFLECTIONMAP_PROJECTION: boolean;
  127740. REFLECTIONMAP_SKYBOX: boolean;
  127741. REFLECTIONMAP_EXPLICIT: boolean;
  127742. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127743. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127744. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127745. INVERTCUBICMAP: boolean;
  127746. USESPHERICALFROMREFLECTIONMAP: boolean;
  127747. USEIRRADIANCEMAP: boolean;
  127748. SPHERICAL_HARMONICS: boolean;
  127749. USESPHERICALINVERTEX: boolean;
  127750. REFLECTIONMAP_OPPOSITEZ: boolean;
  127751. LODINREFLECTIONALPHA: boolean;
  127752. GAMMAREFLECTION: boolean;
  127753. RGBDREFLECTION: boolean;
  127754. LINEARSPECULARREFLECTION: boolean;
  127755. RADIANCEOCCLUSION: boolean;
  127756. HORIZONOCCLUSION: boolean;
  127757. INSTANCES: boolean;
  127758. NUM_BONE_INFLUENCERS: number;
  127759. BonesPerMesh: number;
  127760. BONETEXTURE: boolean;
  127761. NONUNIFORMSCALING: boolean;
  127762. MORPHTARGETS: boolean;
  127763. MORPHTARGETS_NORMAL: boolean;
  127764. MORPHTARGETS_TANGENT: boolean;
  127765. MORPHTARGETS_UV: boolean;
  127766. NUM_MORPH_INFLUENCERS: number;
  127767. IMAGEPROCESSING: boolean;
  127768. VIGNETTE: boolean;
  127769. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127770. VIGNETTEBLENDMODEOPAQUE: boolean;
  127771. TONEMAPPING: boolean;
  127772. TONEMAPPING_ACES: boolean;
  127773. CONTRAST: boolean;
  127774. COLORCURVES: boolean;
  127775. COLORGRADING: boolean;
  127776. COLORGRADING3D: boolean;
  127777. SAMPLER3DGREENDEPTH: boolean;
  127778. SAMPLER3DBGRMAP: boolean;
  127779. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127780. EXPOSURE: boolean;
  127781. MULTIVIEW: boolean;
  127782. USEPHYSICALLIGHTFALLOFF: boolean;
  127783. USEGLTFLIGHTFALLOFF: boolean;
  127784. TWOSIDEDLIGHTING: boolean;
  127785. SHADOWFLOAT: boolean;
  127786. CLIPPLANE: boolean;
  127787. CLIPPLANE2: boolean;
  127788. CLIPPLANE3: boolean;
  127789. CLIPPLANE4: boolean;
  127790. CLIPPLANE5: boolean;
  127791. CLIPPLANE6: boolean;
  127792. POINTSIZE: boolean;
  127793. FOG: boolean;
  127794. LOGARITHMICDEPTH: boolean;
  127795. FORCENORMALFORWARD: boolean;
  127796. SPECULARAA: boolean;
  127797. CLEARCOAT: boolean;
  127798. CLEARCOAT_DEFAULTIOR: boolean;
  127799. CLEARCOAT_TEXTURE: boolean;
  127800. CLEARCOAT_TEXTUREDIRECTUV: number;
  127801. CLEARCOAT_BUMP: boolean;
  127802. CLEARCOAT_BUMPDIRECTUV: number;
  127803. CLEARCOAT_TINT: boolean;
  127804. CLEARCOAT_TINT_TEXTURE: boolean;
  127805. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127806. ANISOTROPIC: boolean;
  127807. ANISOTROPIC_TEXTURE: boolean;
  127808. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127809. BRDF_V_HEIGHT_CORRELATED: boolean;
  127810. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127811. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127812. SHEEN: boolean;
  127813. SHEEN_TEXTURE: boolean;
  127814. SHEEN_TEXTUREDIRECTUV: number;
  127815. SHEEN_LINKWITHALBEDO: boolean;
  127816. SHEEN_ROUGHNESS: boolean;
  127817. SHEEN_ALBEDOSCALING: boolean;
  127818. SUBSURFACE: boolean;
  127819. SS_REFRACTION: boolean;
  127820. SS_TRANSLUCENCY: boolean;
  127821. SS_SCATERRING: boolean;
  127822. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127823. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127824. SS_REFRACTIONMAP_3D: boolean;
  127825. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127826. SS_LODINREFRACTIONALPHA: boolean;
  127827. SS_GAMMAREFRACTION: boolean;
  127828. SS_RGBDREFRACTION: boolean;
  127829. SS_LINEARSPECULARREFRACTION: boolean;
  127830. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127831. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127832. UNLIT: boolean;
  127833. DEBUGMODE: number;
  127834. /**
  127835. * Initializes the PBR Material defines.
  127836. */
  127837. constructor();
  127838. /**
  127839. * Resets the PBR Material defines.
  127840. */
  127841. reset(): void;
  127842. }
  127843. /**
  127844. * The Physically based material base class of BJS.
  127845. *
  127846. * This offers the main features of a standard PBR material.
  127847. * For more information, please refer to the documentation :
  127848. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127849. */
  127850. export abstract class PBRBaseMaterial extends PushMaterial {
  127851. /**
  127852. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127853. */
  127854. static readonly PBRMATERIAL_OPAQUE: number;
  127855. /**
  127856. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127857. */
  127858. static readonly PBRMATERIAL_ALPHATEST: number;
  127859. /**
  127860. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127861. */
  127862. static readonly PBRMATERIAL_ALPHABLEND: number;
  127863. /**
  127864. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127865. * They are also discarded below the alpha cutoff threshold to improve performances.
  127866. */
  127867. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127868. /**
  127869. * Defines the default value of how much AO map is occluding the analytical lights
  127870. * (point spot...).
  127871. */
  127872. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127873. /**
  127874. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127875. */
  127876. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127877. /**
  127878. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127879. * to enhance interoperability with other engines.
  127880. */
  127881. static readonly LIGHTFALLOFF_GLTF: number;
  127882. /**
  127883. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127884. * to enhance interoperability with other materials.
  127885. */
  127886. static readonly LIGHTFALLOFF_STANDARD: number;
  127887. /**
  127888. * Intensity of the direct lights e.g. the four lights available in your scene.
  127889. * This impacts both the direct diffuse and specular highlights.
  127890. */
  127891. protected _directIntensity: number;
  127892. /**
  127893. * Intensity of the emissive part of the material.
  127894. * This helps controlling the emissive effect without modifying the emissive color.
  127895. */
  127896. protected _emissiveIntensity: number;
  127897. /**
  127898. * Intensity of the environment e.g. how much the environment will light the object
  127899. * either through harmonics for rough material or through the refelction for shiny ones.
  127900. */
  127901. protected _environmentIntensity: number;
  127902. /**
  127903. * This is a special control allowing the reduction of the specular highlights coming from the
  127904. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127905. */
  127906. protected _specularIntensity: number;
  127907. /**
  127908. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127909. */
  127910. private _lightingInfos;
  127911. /**
  127912. * Debug Control allowing disabling the bump map on this material.
  127913. */
  127914. protected _disableBumpMap: boolean;
  127915. /**
  127916. * AKA Diffuse Texture in standard nomenclature.
  127917. */
  127918. protected _albedoTexture: Nullable<BaseTexture>;
  127919. /**
  127920. * AKA Occlusion Texture in other nomenclature.
  127921. */
  127922. protected _ambientTexture: Nullable<BaseTexture>;
  127923. /**
  127924. * AKA Occlusion Texture Intensity in other nomenclature.
  127925. */
  127926. protected _ambientTextureStrength: number;
  127927. /**
  127928. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127929. * 1 means it completely occludes it
  127930. * 0 mean it has no impact
  127931. */
  127932. protected _ambientTextureImpactOnAnalyticalLights: number;
  127933. /**
  127934. * Stores the alpha values in a texture.
  127935. */
  127936. protected _opacityTexture: Nullable<BaseTexture>;
  127937. /**
  127938. * Stores the reflection values in a texture.
  127939. */
  127940. protected _reflectionTexture: Nullable<BaseTexture>;
  127941. /**
  127942. * Stores the emissive values in a texture.
  127943. */
  127944. protected _emissiveTexture: Nullable<BaseTexture>;
  127945. /**
  127946. * AKA Specular texture in other nomenclature.
  127947. */
  127948. protected _reflectivityTexture: Nullable<BaseTexture>;
  127949. /**
  127950. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127951. */
  127952. protected _metallicTexture: Nullable<BaseTexture>;
  127953. /**
  127954. * Specifies the metallic scalar of the metallic/roughness workflow.
  127955. * Can also be used to scale the metalness values of the metallic texture.
  127956. */
  127957. protected _metallic: Nullable<number>;
  127958. /**
  127959. * Specifies the roughness scalar of the metallic/roughness workflow.
  127960. * Can also be used to scale the roughness values of the metallic texture.
  127961. */
  127962. protected _roughness: Nullable<number>;
  127963. /**
  127964. * Specifies the an F0 factor to help configuring the material F0.
  127965. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127966. * to 0.5 the previously hard coded value stays the same.
  127967. * Can also be used to scale the F0 values of the metallic texture.
  127968. */
  127969. protected _metallicF0Factor: number;
  127970. /**
  127971. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127972. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127973. * your expectation as it multiplies with the texture data.
  127974. */
  127975. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  127976. /**
  127977. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127978. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127979. */
  127980. protected _microSurfaceTexture: Nullable<BaseTexture>;
  127981. /**
  127982. * Stores surface normal data used to displace a mesh in a texture.
  127983. */
  127984. protected _bumpTexture: Nullable<BaseTexture>;
  127985. /**
  127986. * Stores the pre-calculated light information of a mesh in a texture.
  127987. */
  127988. protected _lightmapTexture: Nullable<BaseTexture>;
  127989. /**
  127990. * The color of a material in ambient lighting.
  127991. */
  127992. protected _ambientColor: Color3;
  127993. /**
  127994. * AKA Diffuse Color in other nomenclature.
  127995. */
  127996. protected _albedoColor: Color3;
  127997. /**
  127998. * AKA Specular Color in other nomenclature.
  127999. */
  128000. protected _reflectivityColor: Color3;
  128001. /**
  128002. * The color applied when light is reflected from a material.
  128003. */
  128004. protected _reflectionColor: Color3;
  128005. /**
  128006. * The color applied when light is emitted from a material.
  128007. */
  128008. protected _emissiveColor: Color3;
  128009. /**
  128010. * AKA Glossiness in other nomenclature.
  128011. */
  128012. protected _microSurface: number;
  128013. /**
  128014. * Specifies that the material will use the light map as a show map.
  128015. */
  128016. protected _useLightmapAsShadowmap: boolean;
  128017. /**
  128018. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128019. * makes the reflect vector face the model (under horizon).
  128020. */
  128021. protected _useHorizonOcclusion: boolean;
  128022. /**
  128023. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128024. * too much the area relying on ambient texture to define their ambient occlusion.
  128025. */
  128026. protected _useRadianceOcclusion: boolean;
  128027. /**
  128028. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128029. */
  128030. protected _useAlphaFromAlbedoTexture: boolean;
  128031. /**
  128032. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  128033. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128034. */
  128035. protected _useSpecularOverAlpha: boolean;
  128036. /**
  128037. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128038. */
  128039. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128040. /**
  128041. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128042. */
  128043. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  128044. /**
  128045. * Specifies if the metallic texture contains the roughness information in its green channel.
  128046. */
  128047. protected _useRoughnessFromMetallicTextureGreen: boolean;
  128048. /**
  128049. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128050. */
  128051. protected _useMetallnessFromMetallicTextureBlue: boolean;
  128052. /**
  128053. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128054. */
  128055. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  128056. /**
  128057. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128058. */
  128059. protected _useAmbientInGrayScale: boolean;
  128060. /**
  128061. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128062. * The material will try to infer what glossiness each pixel should be.
  128063. */
  128064. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  128065. /**
  128066. * Defines the falloff type used in this material.
  128067. * It by default is Physical.
  128068. */
  128069. protected _lightFalloff: number;
  128070. /**
  128071. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128072. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128073. */
  128074. protected _useRadianceOverAlpha: boolean;
  128075. /**
  128076. * Allows using an object space normal map (instead of tangent space).
  128077. */
  128078. protected _useObjectSpaceNormalMap: boolean;
  128079. /**
  128080. * Allows using the bump map in parallax mode.
  128081. */
  128082. protected _useParallax: boolean;
  128083. /**
  128084. * Allows using the bump map in parallax occlusion mode.
  128085. */
  128086. protected _useParallaxOcclusion: boolean;
  128087. /**
  128088. * Controls the scale bias of the parallax mode.
  128089. */
  128090. protected _parallaxScaleBias: number;
  128091. /**
  128092. * If sets to true, disables all the lights affecting the material.
  128093. */
  128094. protected _disableLighting: boolean;
  128095. /**
  128096. * Number of Simultaneous lights allowed on the material.
  128097. */
  128098. protected _maxSimultaneousLights: number;
  128099. /**
  128100. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  128101. */
  128102. protected _invertNormalMapX: boolean;
  128103. /**
  128104. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  128105. */
  128106. protected _invertNormalMapY: boolean;
  128107. /**
  128108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128109. */
  128110. protected _twoSidedLighting: boolean;
  128111. /**
  128112. * Defines the alpha limits in alpha test mode.
  128113. */
  128114. protected _alphaCutOff: number;
  128115. /**
  128116. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128117. */
  128118. protected _forceAlphaTest: boolean;
  128119. /**
  128120. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128121. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128122. */
  128123. protected _useAlphaFresnel: boolean;
  128124. /**
  128125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128126. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128127. */
  128128. protected _useLinearAlphaFresnel: boolean;
  128129. /**
  128130. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  128131. * from cos thetav and roughness:
  128132. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  128133. */
  128134. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  128135. /**
  128136. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128137. */
  128138. protected _forceIrradianceInFragment: boolean;
  128139. /**
  128140. * Force normal to face away from face.
  128141. */
  128142. protected _forceNormalForward: boolean;
  128143. /**
  128144. * Enables specular anti aliasing in the PBR shader.
  128145. * It will both interacts on the Geometry for analytical and IBL lighting.
  128146. * It also prefilter the roughness map based on the bump values.
  128147. */
  128148. protected _enableSpecularAntiAliasing: boolean;
  128149. /**
  128150. * Default configuration related to image processing available in the PBR Material.
  128151. */
  128152. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  128153. /**
  128154. * Keep track of the image processing observer to allow dispose and replace.
  128155. */
  128156. private _imageProcessingObserver;
  128157. /**
  128158. * Attaches a new image processing configuration to the PBR Material.
  128159. * @param configuration
  128160. */
  128161. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  128162. /**
  128163. * Stores the available render targets.
  128164. */
  128165. private _renderTargets;
  128166. /**
  128167. * Sets the global ambient color for the material used in lighting calculations.
  128168. */
  128169. private _globalAmbientColor;
  128170. /**
  128171. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  128172. */
  128173. private _useLogarithmicDepth;
  128174. /**
  128175. * If set to true, no lighting calculations will be applied.
  128176. */
  128177. private _unlit;
  128178. private _debugMode;
  128179. /**
  128180. * @hidden
  128181. * This is reserved for the inspector.
  128182. * Defines the material debug mode.
  128183. * It helps seeing only some components of the material while troubleshooting.
  128184. */
  128185. debugMode: number;
  128186. /**
  128187. * @hidden
  128188. * This is reserved for the inspector.
  128189. * Specify from where on screen the debug mode should start.
  128190. * The value goes from -1 (full screen) to 1 (not visible)
  128191. * It helps with side by side comparison against the final render
  128192. * This defaults to -1
  128193. */
  128194. private debugLimit;
  128195. /**
  128196. * @hidden
  128197. * This is reserved for the inspector.
  128198. * As the default viewing range might not be enough (if the ambient is really small for instance)
  128199. * You can use the factor to better multiply the final value.
  128200. */
  128201. private debugFactor;
  128202. /**
  128203. * Defines the clear coat layer parameters for the material.
  128204. */
  128205. readonly clearCoat: PBRClearCoatConfiguration;
  128206. /**
  128207. * Defines the anisotropic parameters for the material.
  128208. */
  128209. readonly anisotropy: PBRAnisotropicConfiguration;
  128210. /**
  128211. * Defines the BRDF parameters for the material.
  128212. */
  128213. readonly brdf: PBRBRDFConfiguration;
  128214. /**
  128215. * Defines the Sheen parameters for the material.
  128216. */
  128217. readonly sheen: PBRSheenConfiguration;
  128218. /**
  128219. * Defines the SubSurface parameters for the material.
  128220. */
  128221. readonly subSurface: PBRSubSurfaceConfiguration;
  128222. protected _rebuildInParallel: boolean;
  128223. /**
  128224. * Instantiates a new PBRMaterial instance.
  128225. *
  128226. * @param name The material name
  128227. * @param scene The scene the material will be use in.
  128228. */
  128229. constructor(name: string, scene: Scene);
  128230. /**
  128231. * Gets a boolean indicating that current material needs to register RTT
  128232. */
  128233. get hasRenderTargetTextures(): boolean;
  128234. /**
  128235. * Gets the name of the material class.
  128236. */
  128237. getClassName(): string;
  128238. /**
  128239. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128240. */
  128241. get useLogarithmicDepth(): boolean;
  128242. /**
  128243. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128244. */
  128245. set useLogarithmicDepth(value: boolean);
  128246. /**
  128247. * Returns true if alpha blending should be disabled.
  128248. */
  128249. protected get _disableAlphaBlending(): boolean;
  128250. /**
  128251. * Specifies whether or not this material should be rendered in alpha blend mode.
  128252. */
  128253. needAlphaBlending(): boolean;
  128254. /**
  128255. * Specifies whether or not this material should be rendered in alpha test mode.
  128256. */
  128257. needAlphaTesting(): boolean;
  128258. /**
  128259. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128260. */
  128261. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128262. /**
  128263. * Gets the texture used for the alpha test.
  128264. */
  128265. getAlphaTestTexture(): Nullable<BaseTexture>;
  128266. /**
  128267. * Specifies that the submesh is ready to be used.
  128268. * @param mesh - BJS mesh.
  128269. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128270. * @param useInstances - Specifies that instances should be used.
  128271. * @returns - boolean indicating that the submesh is ready or not.
  128272. */
  128273. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128274. /**
  128275. * Specifies if the material uses metallic roughness workflow.
  128276. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128277. */
  128278. isMetallicWorkflow(): boolean;
  128279. private _prepareEffect;
  128280. private _prepareDefines;
  128281. /**
  128282. * Force shader compilation
  128283. */
  128284. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128285. /**
  128286. * Initializes the uniform buffer layout for the shader.
  128287. */
  128288. buildUniformLayout(): void;
  128289. /**
  128290. * Unbinds the material from the mesh
  128291. */
  128292. unbind(): void;
  128293. /**
  128294. * Binds the submesh data.
  128295. * @param world - The world matrix.
  128296. * @param mesh - The BJS mesh.
  128297. * @param subMesh - A submesh of the BJS mesh.
  128298. */
  128299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128300. /**
  128301. * Returns the animatable textures.
  128302. * @returns - Array of animatable textures.
  128303. */
  128304. getAnimatables(): IAnimatable[];
  128305. /**
  128306. * Returns the texture used for reflections.
  128307. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128308. */
  128309. private _getReflectionTexture;
  128310. /**
  128311. * Returns an array of the actively used textures.
  128312. * @returns - Array of BaseTextures
  128313. */
  128314. getActiveTextures(): BaseTexture[];
  128315. /**
  128316. * Checks to see if a texture is used in the material.
  128317. * @param texture - Base texture to use.
  128318. * @returns - Boolean specifying if a texture is used in the material.
  128319. */
  128320. hasTexture(texture: BaseTexture): boolean;
  128321. /**
  128322. * Disposes the resources of the material.
  128323. * @param forceDisposeEffect - Forces the disposal of effects.
  128324. * @param forceDisposeTextures - Forces the disposal of all textures.
  128325. */
  128326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128327. }
  128328. }
  128329. declare module BABYLON {
  128330. /**
  128331. * The Physically based material of BJS.
  128332. *
  128333. * This offers the main features of a standard PBR material.
  128334. * For more information, please refer to the documentation :
  128335. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128336. */
  128337. export class PBRMaterial extends PBRBaseMaterial {
  128338. /**
  128339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128340. */
  128341. static readonly PBRMATERIAL_OPAQUE: number;
  128342. /**
  128343. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128344. */
  128345. static readonly PBRMATERIAL_ALPHATEST: number;
  128346. /**
  128347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128348. */
  128349. static readonly PBRMATERIAL_ALPHABLEND: number;
  128350. /**
  128351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128352. * They are also discarded below the alpha cutoff threshold to improve performances.
  128353. */
  128354. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128355. /**
  128356. * Defines the default value of how much AO map is occluding the analytical lights
  128357. * (point spot...).
  128358. */
  128359. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128360. /**
  128361. * Intensity of the direct lights e.g. the four lights available in your scene.
  128362. * This impacts both the direct diffuse and specular highlights.
  128363. */
  128364. directIntensity: number;
  128365. /**
  128366. * Intensity of the emissive part of the material.
  128367. * This helps controlling the emissive effect without modifying the emissive color.
  128368. */
  128369. emissiveIntensity: number;
  128370. /**
  128371. * Intensity of the environment e.g. how much the environment will light the object
  128372. * either through harmonics for rough material or through the refelction for shiny ones.
  128373. */
  128374. environmentIntensity: number;
  128375. /**
  128376. * This is a special control allowing the reduction of the specular highlights coming from the
  128377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128378. */
  128379. specularIntensity: number;
  128380. /**
  128381. * Debug Control allowing disabling the bump map on this material.
  128382. */
  128383. disableBumpMap: boolean;
  128384. /**
  128385. * AKA Diffuse Texture in standard nomenclature.
  128386. */
  128387. albedoTexture: BaseTexture;
  128388. /**
  128389. * AKA Occlusion Texture in other nomenclature.
  128390. */
  128391. ambientTexture: BaseTexture;
  128392. /**
  128393. * AKA Occlusion Texture Intensity in other nomenclature.
  128394. */
  128395. ambientTextureStrength: number;
  128396. /**
  128397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128398. * 1 means it completely occludes it
  128399. * 0 mean it has no impact
  128400. */
  128401. ambientTextureImpactOnAnalyticalLights: number;
  128402. /**
  128403. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128404. */
  128405. opacityTexture: BaseTexture;
  128406. /**
  128407. * Stores the reflection values in a texture.
  128408. */
  128409. reflectionTexture: Nullable<BaseTexture>;
  128410. /**
  128411. * Stores the emissive values in a texture.
  128412. */
  128413. emissiveTexture: BaseTexture;
  128414. /**
  128415. * AKA Specular texture in other nomenclature.
  128416. */
  128417. reflectivityTexture: BaseTexture;
  128418. /**
  128419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128420. */
  128421. metallicTexture: BaseTexture;
  128422. /**
  128423. * Specifies the metallic scalar of the metallic/roughness workflow.
  128424. * Can also be used to scale the metalness values of the metallic texture.
  128425. */
  128426. metallic: Nullable<number>;
  128427. /**
  128428. * Specifies the roughness scalar of the metallic/roughness workflow.
  128429. * Can also be used to scale the roughness values of the metallic texture.
  128430. */
  128431. roughness: Nullable<number>;
  128432. /**
  128433. * Specifies the an F0 factor to help configuring the material F0.
  128434. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128435. * to 0.5 the previously hard coded value stays the same.
  128436. * Can also be used to scale the F0 values of the metallic texture.
  128437. */
  128438. metallicF0Factor: number;
  128439. /**
  128440. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128441. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128442. * your expectation as it multiplies with the texture data.
  128443. */
  128444. useMetallicF0FactorFromMetallicTexture: boolean;
  128445. /**
  128446. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128447. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128448. */
  128449. microSurfaceTexture: BaseTexture;
  128450. /**
  128451. * Stores surface normal data used to displace a mesh in a texture.
  128452. */
  128453. bumpTexture: BaseTexture;
  128454. /**
  128455. * Stores the pre-calculated light information of a mesh in a texture.
  128456. */
  128457. lightmapTexture: BaseTexture;
  128458. /**
  128459. * Stores the refracted light information in a texture.
  128460. */
  128461. get refractionTexture(): Nullable<BaseTexture>;
  128462. set refractionTexture(value: Nullable<BaseTexture>);
  128463. /**
  128464. * The color of a material in ambient lighting.
  128465. */
  128466. ambientColor: Color3;
  128467. /**
  128468. * AKA Diffuse Color in other nomenclature.
  128469. */
  128470. albedoColor: Color3;
  128471. /**
  128472. * AKA Specular Color in other nomenclature.
  128473. */
  128474. reflectivityColor: Color3;
  128475. /**
  128476. * The color reflected from the material.
  128477. */
  128478. reflectionColor: Color3;
  128479. /**
  128480. * The color emitted from the material.
  128481. */
  128482. emissiveColor: Color3;
  128483. /**
  128484. * AKA Glossiness in other nomenclature.
  128485. */
  128486. microSurface: number;
  128487. /**
  128488. * source material index of refraction (IOR)' / 'destination material IOR.
  128489. */
  128490. get indexOfRefraction(): number;
  128491. set indexOfRefraction(value: number);
  128492. /**
  128493. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128494. */
  128495. get invertRefractionY(): boolean;
  128496. set invertRefractionY(value: boolean);
  128497. /**
  128498. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128499. * Materials half opaque for instance using refraction could benefit from this control.
  128500. */
  128501. get linkRefractionWithTransparency(): boolean;
  128502. set linkRefractionWithTransparency(value: boolean);
  128503. /**
  128504. * If true, the light map contains occlusion information instead of lighting info.
  128505. */
  128506. useLightmapAsShadowmap: boolean;
  128507. /**
  128508. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128509. */
  128510. useAlphaFromAlbedoTexture: boolean;
  128511. /**
  128512. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128513. */
  128514. forceAlphaTest: boolean;
  128515. /**
  128516. * Defines the alpha limits in alpha test mode.
  128517. */
  128518. alphaCutOff: number;
  128519. /**
  128520. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128521. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128522. */
  128523. useSpecularOverAlpha: boolean;
  128524. /**
  128525. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128526. */
  128527. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128528. /**
  128529. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128530. */
  128531. useRoughnessFromMetallicTextureAlpha: boolean;
  128532. /**
  128533. * Specifies if the metallic texture contains the roughness information in its green channel.
  128534. */
  128535. useRoughnessFromMetallicTextureGreen: boolean;
  128536. /**
  128537. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128538. */
  128539. useMetallnessFromMetallicTextureBlue: boolean;
  128540. /**
  128541. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128542. */
  128543. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128544. /**
  128545. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128546. */
  128547. useAmbientInGrayScale: boolean;
  128548. /**
  128549. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128550. * The material will try to infer what glossiness each pixel should be.
  128551. */
  128552. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128553. /**
  128554. * BJS is using an harcoded light falloff based on a manually sets up range.
  128555. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128556. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128557. */
  128558. get usePhysicalLightFalloff(): boolean;
  128559. /**
  128560. * BJS is using an harcoded light falloff based on a manually sets up range.
  128561. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128562. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128563. */
  128564. set usePhysicalLightFalloff(value: boolean);
  128565. /**
  128566. * In order to support the falloff compatibility with gltf, a special mode has been added
  128567. * to reproduce the gltf light falloff.
  128568. */
  128569. get useGLTFLightFalloff(): boolean;
  128570. /**
  128571. * In order to support the falloff compatibility with gltf, a special mode has been added
  128572. * to reproduce the gltf light falloff.
  128573. */
  128574. set useGLTFLightFalloff(value: boolean);
  128575. /**
  128576. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128577. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128578. */
  128579. useRadianceOverAlpha: boolean;
  128580. /**
  128581. * Allows using an object space normal map (instead of tangent space).
  128582. */
  128583. useObjectSpaceNormalMap: boolean;
  128584. /**
  128585. * Allows using the bump map in parallax mode.
  128586. */
  128587. useParallax: boolean;
  128588. /**
  128589. * Allows using the bump map in parallax occlusion mode.
  128590. */
  128591. useParallaxOcclusion: boolean;
  128592. /**
  128593. * Controls the scale bias of the parallax mode.
  128594. */
  128595. parallaxScaleBias: number;
  128596. /**
  128597. * If sets to true, disables all the lights affecting the material.
  128598. */
  128599. disableLighting: boolean;
  128600. /**
  128601. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128602. */
  128603. forceIrradianceInFragment: boolean;
  128604. /**
  128605. * Number of Simultaneous lights allowed on the material.
  128606. */
  128607. maxSimultaneousLights: number;
  128608. /**
  128609. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128610. */
  128611. invertNormalMapX: boolean;
  128612. /**
  128613. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128614. */
  128615. invertNormalMapY: boolean;
  128616. /**
  128617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128618. */
  128619. twoSidedLighting: boolean;
  128620. /**
  128621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128622. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128623. */
  128624. useAlphaFresnel: boolean;
  128625. /**
  128626. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128627. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128628. */
  128629. useLinearAlphaFresnel: boolean;
  128630. /**
  128631. * Let user defines the brdf lookup texture used for IBL.
  128632. * A default 8bit version is embedded but you could point at :
  128633. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128634. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128635. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128636. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128637. */
  128638. environmentBRDFTexture: Nullable<BaseTexture>;
  128639. /**
  128640. * Force normal to face away from face.
  128641. */
  128642. forceNormalForward: boolean;
  128643. /**
  128644. * Enables specular anti aliasing in the PBR shader.
  128645. * It will both interacts on the Geometry for analytical and IBL lighting.
  128646. * It also prefilter the roughness map based on the bump values.
  128647. */
  128648. enableSpecularAntiAliasing: boolean;
  128649. /**
  128650. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128651. * makes the reflect vector face the model (under horizon).
  128652. */
  128653. useHorizonOcclusion: boolean;
  128654. /**
  128655. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128656. * too much the area relying on ambient texture to define their ambient occlusion.
  128657. */
  128658. useRadianceOcclusion: boolean;
  128659. /**
  128660. * If set to true, no lighting calculations will be applied.
  128661. */
  128662. unlit: boolean;
  128663. /**
  128664. * Gets the image processing configuration used either in this material.
  128665. */
  128666. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128667. /**
  128668. * Sets the Default image processing configuration used either in the this material.
  128669. *
  128670. * If sets to null, the scene one is in use.
  128671. */
  128672. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128673. /**
  128674. * Gets wether the color curves effect is enabled.
  128675. */
  128676. get cameraColorCurvesEnabled(): boolean;
  128677. /**
  128678. * Sets wether the color curves effect is enabled.
  128679. */
  128680. set cameraColorCurvesEnabled(value: boolean);
  128681. /**
  128682. * Gets wether the color grading effect is enabled.
  128683. */
  128684. get cameraColorGradingEnabled(): boolean;
  128685. /**
  128686. * Gets wether the color grading effect is enabled.
  128687. */
  128688. set cameraColorGradingEnabled(value: boolean);
  128689. /**
  128690. * Gets wether tonemapping is enabled or not.
  128691. */
  128692. get cameraToneMappingEnabled(): boolean;
  128693. /**
  128694. * Sets wether tonemapping is enabled or not
  128695. */
  128696. set cameraToneMappingEnabled(value: boolean);
  128697. /**
  128698. * The camera exposure used on this material.
  128699. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128700. * This corresponds to a photographic exposure.
  128701. */
  128702. get cameraExposure(): number;
  128703. /**
  128704. * The camera exposure used on this material.
  128705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128706. * This corresponds to a photographic exposure.
  128707. */
  128708. set cameraExposure(value: number);
  128709. /**
  128710. * Gets The camera contrast used on this material.
  128711. */
  128712. get cameraContrast(): number;
  128713. /**
  128714. * Sets The camera contrast used on this material.
  128715. */
  128716. set cameraContrast(value: number);
  128717. /**
  128718. * Gets the Color Grading 2D Lookup Texture.
  128719. */
  128720. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128721. /**
  128722. * Sets the Color Grading 2D Lookup Texture.
  128723. */
  128724. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128725. /**
  128726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128728. * 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;
  128729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128730. */
  128731. get cameraColorCurves(): Nullable<ColorCurves>;
  128732. /**
  128733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128735. * 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;
  128736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128737. */
  128738. set cameraColorCurves(value: Nullable<ColorCurves>);
  128739. /**
  128740. * Instantiates a new PBRMaterial instance.
  128741. *
  128742. * @param name The material name
  128743. * @param scene The scene the material will be use in.
  128744. */
  128745. constructor(name: string, scene: Scene);
  128746. /**
  128747. * Returns the name of this material class.
  128748. */
  128749. getClassName(): string;
  128750. /**
  128751. * Makes a duplicate of the current material.
  128752. * @param name - name to use for the new material.
  128753. */
  128754. clone(name: string): PBRMaterial;
  128755. /**
  128756. * Serializes this PBR Material.
  128757. * @returns - An object with the serialized material.
  128758. */
  128759. serialize(): any;
  128760. /**
  128761. * Parses a PBR Material from a serialized object.
  128762. * @param source - Serialized object.
  128763. * @param scene - BJS scene instance.
  128764. * @param rootUrl - url for the scene object
  128765. * @returns - PBRMaterial
  128766. */
  128767. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128768. }
  128769. }
  128770. declare module BABYLON {
  128771. /**
  128772. * Direct draw surface info
  128773. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128774. */
  128775. export interface DDSInfo {
  128776. /**
  128777. * Width of the texture
  128778. */
  128779. width: number;
  128780. /**
  128781. * Width of the texture
  128782. */
  128783. height: number;
  128784. /**
  128785. * Number of Mipmaps for the texture
  128786. * @see https://en.wikipedia.org/wiki/Mipmap
  128787. */
  128788. mipmapCount: number;
  128789. /**
  128790. * If the textures format is a known fourCC format
  128791. * @see https://www.fourcc.org/
  128792. */
  128793. isFourCC: boolean;
  128794. /**
  128795. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128796. */
  128797. isRGB: boolean;
  128798. /**
  128799. * If the texture is a lumincance format
  128800. */
  128801. isLuminance: boolean;
  128802. /**
  128803. * If this is a cube texture
  128804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128805. */
  128806. isCube: boolean;
  128807. /**
  128808. * If the texture is a compressed format eg. FOURCC_DXT1
  128809. */
  128810. isCompressed: boolean;
  128811. /**
  128812. * The dxgiFormat of the texture
  128813. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128814. */
  128815. dxgiFormat: number;
  128816. /**
  128817. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128818. */
  128819. textureType: number;
  128820. /**
  128821. * Sphericle polynomial created for the dds texture
  128822. */
  128823. sphericalPolynomial?: SphericalPolynomial;
  128824. }
  128825. /**
  128826. * Class used to provide DDS decompression tools
  128827. */
  128828. export class DDSTools {
  128829. /**
  128830. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128831. */
  128832. static StoreLODInAlphaChannel: boolean;
  128833. /**
  128834. * Gets DDS information from an array buffer
  128835. * @param data defines the array buffer view to read data from
  128836. * @returns the DDS information
  128837. */
  128838. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128839. private static _FloatView;
  128840. private static _Int32View;
  128841. private static _ToHalfFloat;
  128842. private static _FromHalfFloat;
  128843. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128844. private static _GetHalfFloatRGBAArrayBuffer;
  128845. private static _GetFloatRGBAArrayBuffer;
  128846. private static _GetFloatAsUIntRGBAArrayBuffer;
  128847. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128848. private static _GetRGBAArrayBuffer;
  128849. private static _ExtractLongWordOrder;
  128850. private static _GetRGBArrayBuffer;
  128851. private static _GetLuminanceArrayBuffer;
  128852. /**
  128853. * Uploads DDS Levels to a Babylon Texture
  128854. * @hidden
  128855. */
  128856. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128857. }
  128858. interface ThinEngine {
  128859. /**
  128860. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128861. * @param rootUrl defines the url where the file to load is located
  128862. * @param scene defines the current scene
  128863. * @param lodScale defines scale to apply to the mip map selection
  128864. * @param lodOffset defines offset to apply to the mip map selection
  128865. * @param onLoad defines an optional callback raised when the texture is loaded
  128866. * @param onError defines an optional callback raised if there is an issue to load the texture
  128867. * @param format defines the format of the data
  128868. * @param forcedExtension defines the extension to use to pick the right loader
  128869. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128870. * @returns the cube texture as an InternalTexture
  128871. */
  128872. 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;
  128873. }
  128874. }
  128875. declare module BABYLON {
  128876. /**
  128877. * Implementation of the DDS Texture Loader.
  128878. * @hidden
  128879. */
  128880. export class _DDSTextureLoader implements IInternalTextureLoader {
  128881. /**
  128882. * Defines wether the loader supports cascade loading the different faces.
  128883. */
  128884. readonly supportCascades: boolean;
  128885. /**
  128886. * This returns if the loader support the current file information.
  128887. * @param extension defines the file extension of the file being loaded
  128888. * @returns true if the loader can load the specified file
  128889. */
  128890. canLoad(extension: string): boolean;
  128891. /**
  128892. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128893. * @param data contains the texture data
  128894. * @param texture defines the BabylonJS internal texture
  128895. * @param createPolynomials will be true if polynomials have been requested
  128896. * @param onLoad defines the callback to trigger once the texture is ready
  128897. * @param onError defines the callback to trigger in case of error
  128898. */
  128899. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128900. /**
  128901. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128902. * @param data contains the texture data
  128903. * @param texture defines the BabylonJS internal texture
  128904. * @param callback defines the method to call once ready to upload
  128905. */
  128906. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128907. }
  128908. }
  128909. declare module BABYLON {
  128910. /**
  128911. * Implementation of the ENV Texture Loader.
  128912. * @hidden
  128913. */
  128914. export class _ENVTextureLoader implements IInternalTextureLoader {
  128915. /**
  128916. * Defines wether the loader supports cascade loading the different faces.
  128917. */
  128918. readonly supportCascades: boolean;
  128919. /**
  128920. * This returns if the loader support the current file information.
  128921. * @param extension defines the file extension of the file being loaded
  128922. * @returns true if the loader can load the specified file
  128923. */
  128924. canLoad(extension: string): boolean;
  128925. /**
  128926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128927. * @param data contains the texture data
  128928. * @param texture defines the BabylonJS internal texture
  128929. * @param createPolynomials will be true if polynomials have been requested
  128930. * @param onLoad defines the callback to trigger once the texture is ready
  128931. * @param onError defines the callback to trigger in case of error
  128932. */
  128933. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128934. /**
  128935. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128936. * @param data contains the texture data
  128937. * @param texture defines the BabylonJS internal texture
  128938. * @param callback defines the method to call once ready to upload
  128939. */
  128940. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128941. }
  128942. }
  128943. declare module BABYLON {
  128944. /**
  128945. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128946. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128947. */
  128948. export class KhronosTextureContainer {
  128949. /** contents of the KTX container file */
  128950. data: ArrayBufferView;
  128951. private static HEADER_LEN;
  128952. private static COMPRESSED_2D;
  128953. private static COMPRESSED_3D;
  128954. private static TEX_2D;
  128955. private static TEX_3D;
  128956. /**
  128957. * Gets the openGL type
  128958. */
  128959. glType: number;
  128960. /**
  128961. * Gets the openGL type size
  128962. */
  128963. glTypeSize: number;
  128964. /**
  128965. * Gets the openGL format
  128966. */
  128967. glFormat: number;
  128968. /**
  128969. * Gets the openGL internal format
  128970. */
  128971. glInternalFormat: number;
  128972. /**
  128973. * Gets the base internal format
  128974. */
  128975. glBaseInternalFormat: number;
  128976. /**
  128977. * Gets image width in pixel
  128978. */
  128979. pixelWidth: number;
  128980. /**
  128981. * Gets image height in pixel
  128982. */
  128983. pixelHeight: number;
  128984. /**
  128985. * Gets image depth in pixels
  128986. */
  128987. pixelDepth: number;
  128988. /**
  128989. * Gets the number of array elements
  128990. */
  128991. numberOfArrayElements: number;
  128992. /**
  128993. * Gets the number of faces
  128994. */
  128995. numberOfFaces: number;
  128996. /**
  128997. * Gets the number of mipmap levels
  128998. */
  128999. numberOfMipmapLevels: number;
  129000. /**
  129001. * Gets the bytes of key value data
  129002. */
  129003. bytesOfKeyValueData: number;
  129004. /**
  129005. * Gets the load type
  129006. */
  129007. loadType: number;
  129008. /**
  129009. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  129010. */
  129011. isInvalid: boolean;
  129012. /**
  129013. * Creates a new KhronosTextureContainer
  129014. * @param data contents of the KTX container file
  129015. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  129016. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  129017. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  129018. */
  129019. constructor(
  129020. /** contents of the KTX container file */
  129021. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  129022. /**
  129023. * Uploads KTX content to a Babylon Texture.
  129024. * It is assumed that the texture has already been created & is currently bound
  129025. * @hidden
  129026. */
  129027. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  129028. private _upload2DCompressedLevels;
  129029. /**
  129030. * Checks if the given data starts with a KTX file identifier.
  129031. * @param data the data to check
  129032. * @returns true if the data is a KTX file or false otherwise
  129033. */
  129034. static IsValid(data: ArrayBufferView): boolean;
  129035. }
  129036. }
  129037. declare module BABYLON {
  129038. /**
  129039. * Class for loading KTX2 files
  129040. * !!! Experimental Extension Subject to Changes !!!
  129041. * @hidden
  129042. */
  129043. export class KhronosTextureContainer2 {
  129044. private static _ModulePromise;
  129045. private static _TranscodeFormat;
  129046. constructor(engine: ThinEngine);
  129047. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  129048. private _determineTranscodeFormat;
  129049. /**
  129050. * Checks if the given data starts with a KTX2 file identifier.
  129051. * @param data the data to check
  129052. * @returns true if the data is a KTX2 file or false otherwise
  129053. */
  129054. static IsValid(data: ArrayBufferView): boolean;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. /**
  129059. * Implementation of the KTX Texture Loader.
  129060. * @hidden
  129061. */
  129062. export class _KTXTextureLoader implements IInternalTextureLoader {
  129063. /**
  129064. * Defines wether the loader supports cascade loading the different faces.
  129065. */
  129066. readonly supportCascades: boolean;
  129067. /**
  129068. * This returns if the loader support the current file information.
  129069. * @param extension defines the file extension of the file being loaded
  129070. * @returns true if the loader can load the specified file
  129071. */
  129072. canLoad(extension: string): boolean;
  129073. /**
  129074. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129075. * @param data contains the texture data
  129076. * @param texture defines the BabylonJS internal texture
  129077. * @param createPolynomials will be true if polynomials have been requested
  129078. * @param onLoad defines the callback to trigger once the texture is ready
  129079. * @param onError defines the callback to trigger in case of error
  129080. */
  129081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129082. /**
  129083. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129084. * @param data contains the texture data
  129085. * @param texture defines the BabylonJS internal texture
  129086. * @param callback defines the method to call once ready to upload
  129087. */
  129088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  129089. }
  129090. }
  129091. declare module BABYLON {
  129092. /** @hidden */
  129093. export var _forceSceneHelpersToBundle: boolean;
  129094. interface Scene {
  129095. /**
  129096. * Creates a default light for the scene.
  129097. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  129098. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  129099. */
  129100. createDefaultLight(replace?: boolean): void;
  129101. /**
  129102. * Creates a default camera for the scene.
  129103. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  129104. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129105. * @param replace has default false, when true replaces the active camera in the scene
  129106. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  129107. */
  129108. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129109. /**
  129110. * Creates a default camera and a default light.
  129111. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  129112. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  129113. * @param replace has the default false, when true replaces the active camera/light in the scene
  129114. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  129115. */
  129116. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  129117. /**
  129118. * Creates a new sky box
  129119. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  129120. * @param environmentTexture defines the texture to use as environment texture
  129121. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  129122. * @param scale defines the overall scale of the skybox
  129123. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  129124. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  129125. * @returns a new mesh holding the sky box
  129126. */
  129127. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  129128. /**
  129129. * Creates a new environment
  129130. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  129131. * @param options defines the options you can use to configure the environment
  129132. * @returns the new EnvironmentHelper
  129133. */
  129134. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  129135. /**
  129136. * Creates a new VREXperienceHelper
  129137. * @see http://doc.babylonjs.com/how_to/webvr_helper
  129138. * @param webVROptions defines the options used to create the new VREXperienceHelper
  129139. * @returns a new VREXperienceHelper
  129140. */
  129141. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  129142. /**
  129143. * Creates a new WebXRDefaultExperience
  129144. * @see http://doc.babylonjs.com/how_to/webxr
  129145. * @param options experience options
  129146. * @returns a promise for a new WebXRDefaultExperience
  129147. */
  129148. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129149. }
  129150. }
  129151. declare module BABYLON {
  129152. /**
  129153. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  129154. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  129155. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  129156. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  129157. */
  129158. export class VideoDome extends TransformNode {
  129159. /**
  129160. * Define the video source as a Monoscopic panoramic 360 video.
  129161. */
  129162. static readonly MODE_MONOSCOPIC: number;
  129163. /**
  129164. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129165. */
  129166. static readonly MODE_TOPBOTTOM: number;
  129167. /**
  129168. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129169. */
  129170. static readonly MODE_SIDEBYSIDE: number;
  129171. private _halfDome;
  129172. private _useDirectMapping;
  129173. /**
  129174. * The video texture being displayed on the sphere
  129175. */
  129176. protected _videoTexture: VideoTexture;
  129177. /**
  129178. * Gets the video texture being displayed on the sphere
  129179. */
  129180. get videoTexture(): VideoTexture;
  129181. /**
  129182. * The skybox material
  129183. */
  129184. protected _material: BackgroundMaterial;
  129185. /**
  129186. * The surface used for the skybox
  129187. */
  129188. protected _mesh: Mesh;
  129189. /**
  129190. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  129191. */
  129192. private _halfDomeMask;
  129193. /**
  129194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129195. * Also see the options.resolution property.
  129196. */
  129197. get fovMultiplier(): number;
  129198. set fovMultiplier(value: number);
  129199. private _videoMode;
  129200. /**
  129201. * Gets or set the current video mode for the video. It can be:
  129202. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  129203. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  129204. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  129205. */
  129206. get videoMode(): number;
  129207. set videoMode(value: number);
  129208. /**
  129209. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  129210. *
  129211. */
  129212. get halfDome(): boolean;
  129213. /**
  129214. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  129215. */
  129216. set halfDome(enabled: boolean);
  129217. /**
  129218. * Oberserver used in Stereoscopic VR Mode.
  129219. */
  129220. private _onBeforeCameraRenderObserver;
  129221. /**
  129222. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  129223. * @param name Element's name, child elements will append suffixes for their own names.
  129224. * @param urlsOrVideo defines the url(s) or the video element to use
  129225. * @param options An object containing optional or exposed sub element properties
  129226. */
  129227. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  129228. resolution?: number;
  129229. clickToPlay?: boolean;
  129230. autoPlay?: boolean;
  129231. loop?: boolean;
  129232. size?: number;
  129233. poster?: string;
  129234. faceForward?: boolean;
  129235. useDirectMapping?: boolean;
  129236. halfDomeMode?: boolean;
  129237. }, scene: Scene);
  129238. private _changeVideoMode;
  129239. /**
  129240. * Releases resources associated with this node.
  129241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129243. */
  129244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /**
  129249. * This class can be used to get instrumentation data from a Babylon engine
  129250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129251. */
  129252. export class EngineInstrumentation implements IDisposable {
  129253. /**
  129254. * Define the instrumented engine.
  129255. */
  129256. engine: Engine;
  129257. private _captureGPUFrameTime;
  129258. private _gpuFrameTimeToken;
  129259. private _gpuFrameTime;
  129260. private _captureShaderCompilationTime;
  129261. private _shaderCompilationTime;
  129262. private _onBeginFrameObserver;
  129263. private _onEndFrameObserver;
  129264. private _onBeforeShaderCompilationObserver;
  129265. private _onAfterShaderCompilationObserver;
  129266. /**
  129267. * Gets the perf counter used for GPU frame time
  129268. */
  129269. get gpuFrameTimeCounter(): PerfCounter;
  129270. /**
  129271. * Gets the GPU frame time capture status
  129272. */
  129273. get captureGPUFrameTime(): boolean;
  129274. /**
  129275. * Enable or disable the GPU frame time capture
  129276. */
  129277. set captureGPUFrameTime(value: boolean);
  129278. /**
  129279. * Gets the perf counter used for shader compilation time
  129280. */
  129281. get shaderCompilationTimeCounter(): PerfCounter;
  129282. /**
  129283. * Gets the shader compilation time capture status
  129284. */
  129285. get captureShaderCompilationTime(): boolean;
  129286. /**
  129287. * Enable or disable the shader compilation time capture
  129288. */
  129289. set captureShaderCompilationTime(value: boolean);
  129290. /**
  129291. * Instantiates a new engine instrumentation.
  129292. * This class can be used to get instrumentation data from a Babylon engine
  129293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129294. * @param engine Defines the engine to instrument
  129295. */
  129296. constructor(
  129297. /**
  129298. * Define the instrumented engine.
  129299. */
  129300. engine: Engine);
  129301. /**
  129302. * Dispose and release associated resources.
  129303. */
  129304. dispose(): void;
  129305. }
  129306. }
  129307. declare module BABYLON {
  129308. /**
  129309. * This class can be used to get instrumentation data from a Babylon engine
  129310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129311. */
  129312. export class SceneInstrumentation implements IDisposable {
  129313. /**
  129314. * Defines the scene to instrument
  129315. */
  129316. scene: Scene;
  129317. private _captureActiveMeshesEvaluationTime;
  129318. private _activeMeshesEvaluationTime;
  129319. private _captureRenderTargetsRenderTime;
  129320. private _renderTargetsRenderTime;
  129321. private _captureFrameTime;
  129322. private _frameTime;
  129323. private _captureRenderTime;
  129324. private _renderTime;
  129325. private _captureInterFrameTime;
  129326. private _interFrameTime;
  129327. private _captureParticlesRenderTime;
  129328. private _particlesRenderTime;
  129329. private _captureSpritesRenderTime;
  129330. private _spritesRenderTime;
  129331. private _capturePhysicsTime;
  129332. private _physicsTime;
  129333. private _captureAnimationsTime;
  129334. private _animationsTime;
  129335. private _captureCameraRenderTime;
  129336. private _cameraRenderTime;
  129337. private _onBeforeActiveMeshesEvaluationObserver;
  129338. private _onAfterActiveMeshesEvaluationObserver;
  129339. private _onBeforeRenderTargetsRenderObserver;
  129340. private _onAfterRenderTargetsRenderObserver;
  129341. private _onAfterRenderObserver;
  129342. private _onBeforeDrawPhaseObserver;
  129343. private _onAfterDrawPhaseObserver;
  129344. private _onBeforeAnimationsObserver;
  129345. private _onBeforeParticlesRenderingObserver;
  129346. private _onAfterParticlesRenderingObserver;
  129347. private _onBeforeSpritesRenderingObserver;
  129348. private _onAfterSpritesRenderingObserver;
  129349. private _onBeforePhysicsObserver;
  129350. private _onAfterPhysicsObserver;
  129351. private _onAfterAnimationsObserver;
  129352. private _onBeforeCameraRenderObserver;
  129353. private _onAfterCameraRenderObserver;
  129354. /**
  129355. * Gets the perf counter used for active meshes evaluation time
  129356. */
  129357. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129358. /**
  129359. * Gets the active meshes evaluation time capture status
  129360. */
  129361. get captureActiveMeshesEvaluationTime(): boolean;
  129362. /**
  129363. * Enable or disable the active meshes evaluation time capture
  129364. */
  129365. set captureActiveMeshesEvaluationTime(value: boolean);
  129366. /**
  129367. * Gets the perf counter used for render targets render time
  129368. */
  129369. get renderTargetsRenderTimeCounter(): PerfCounter;
  129370. /**
  129371. * Gets the render targets render time capture status
  129372. */
  129373. get captureRenderTargetsRenderTime(): boolean;
  129374. /**
  129375. * Enable or disable the render targets render time capture
  129376. */
  129377. set captureRenderTargetsRenderTime(value: boolean);
  129378. /**
  129379. * Gets the perf counter used for particles render time
  129380. */
  129381. get particlesRenderTimeCounter(): PerfCounter;
  129382. /**
  129383. * Gets the particles render time capture status
  129384. */
  129385. get captureParticlesRenderTime(): boolean;
  129386. /**
  129387. * Enable or disable the particles render time capture
  129388. */
  129389. set captureParticlesRenderTime(value: boolean);
  129390. /**
  129391. * Gets the perf counter used for sprites render time
  129392. */
  129393. get spritesRenderTimeCounter(): PerfCounter;
  129394. /**
  129395. * Gets the sprites render time capture status
  129396. */
  129397. get captureSpritesRenderTime(): boolean;
  129398. /**
  129399. * Enable or disable the sprites render time capture
  129400. */
  129401. set captureSpritesRenderTime(value: boolean);
  129402. /**
  129403. * Gets the perf counter used for physics time
  129404. */
  129405. get physicsTimeCounter(): PerfCounter;
  129406. /**
  129407. * Gets the physics time capture status
  129408. */
  129409. get capturePhysicsTime(): boolean;
  129410. /**
  129411. * Enable or disable the physics time capture
  129412. */
  129413. set capturePhysicsTime(value: boolean);
  129414. /**
  129415. * Gets the perf counter used for animations time
  129416. */
  129417. get animationsTimeCounter(): PerfCounter;
  129418. /**
  129419. * Gets the animations time capture status
  129420. */
  129421. get captureAnimationsTime(): boolean;
  129422. /**
  129423. * Enable or disable the animations time capture
  129424. */
  129425. set captureAnimationsTime(value: boolean);
  129426. /**
  129427. * Gets the perf counter used for frame time capture
  129428. */
  129429. get frameTimeCounter(): PerfCounter;
  129430. /**
  129431. * Gets the frame time capture status
  129432. */
  129433. get captureFrameTime(): boolean;
  129434. /**
  129435. * Enable or disable the frame time capture
  129436. */
  129437. set captureFrameTime(value: boolean);
  129438. /**
  129439. * Gets the perf counter used for inter-frames time capture
  129440. */
  129441. get interFrameTimeCounter(): PerfCounter;
  129442. /**
  129443. * Gets the inter-frames time capture status
  129444. */
  129445. get captureInterFrameTime(): boolean;
  129446. /**
  129447. * Enable or disable the inter-frames time capture
  129448. */
  129449. set captureInterFrameTime(value: boolean);
  129450. /**
  129451. * Gets the perf counter used for render time capture
  129452. */
  129453. get renderTimeCounter(): PerfCounter;
  129454. /**
  129455. * Gets the render time capture status
  129456. */
  129457. get captureRenderTime(): boolean;
  129458. /**
  129459. * Enable or disable the render time capture
  129460. */
  129461. set captureRenderTime(value: boolean);
  129462. /**
  129463. * Gets the perf counter used for camera render time capture
  129464. */
  129465. get cameraRenderTimeCounter(): PerfCounter;
  129466. /**
  129467. * Gets the camera render time capture status
  129468. */
  129469. get captureCameraRenderTime(): boolean;
  129470. /**
  129471. * Enable or disable the camera render time capture
  129472. */
  129473. set captureCameraRenderTime(value: boolean);
  129474. /**
  129475. * Gets the perf counter used for draw calls
  129476. */
  129477. get drawCallsCounter(): PerfCounter;
  129478. /**
  129479. * Instantiates a new scene instrumentation.
  129480. * This class can be used to get instrumentation data from a Babylon engine
  129481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129482. * @param scene Defines the scene to instrument
  129483. */
  129484. constructor(
  129485. /**
  129486. * Defines the scene to instrument
  129487. */
  129488. scene: Scene);
  129489. /**
  129490. * Dispose and release associated resources.
  129491. */
  129492. dispose(): void;
  129493. }
  129494. }
  129495. declare module BABYLON {
  129496. /** @hidden */
  129497. export var glowMapGenerationPixelShader: {
  129498. name: string;
  129499. shader: string;
  129500. };
  129501. }
  129502. declare module BABYLON {
  129503. /** @hidden */
  129504. export var glowMapGenerationVertexShader: {
  129505. name: string;
  129506. shader: string;
  129507. };
  129508. }
  129509. declare module BABYLON {
  129510. /**
  129511. * Effect layer options. This helps customizing the behaviour
  129512. * of the effect layer.
  129513. */
  129514. export interface IEffectLayerOptions {
  129515. /**
  129516. * Multiplication factor apply to the canvas size to compute the render target size
  129517. * used to generated the objects (the smaller the faster).
  129518. */
  129519. mainTextureRatio: number;
  129520. /**
  129521. * Enforces a fixed size texture to ensure effect stability across devices.
  129522. */
  129523. mainTextureFixedSize?: number;
  129524. /**
  129525. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129526. */
  129527. alphaBlendingMode: number;
  129528. /**
  129529. * The camera attached to the layer.
  129530. */
  129531. camera: Nullable<Camera>;
  129532. /**
  129533. * The rendering group to draw the layer in.
  129534. */
  129535. renderingGroupId: number;
  129536. }
  129537. /**
  129538. * The effect layer Helps adding post process effect blended with the main pass.
  129539. *
  129540. * This can be for instance use to generate glow or higlight effects on the scene.
  129541. *
  129542. * The effect layer class can not be used directly and is intented to inherited from to be
  129543. * customized per effects.
  129544. */
  129545. export abstract class EffectLayer {
  129546. private _vertexBuffers;
  129547. private _indexBuffer;
  129548. private _cachedDefines;
  129549. private _effectLayerMapGenerationEffect;
  129550. private _effectLayerOptions;
  129551. private _mergeEffect;
  129552. protected _scene: Scene;
  129553. protected _engine: Engine;
  129554. protected _maxSize: number;
  129555. protected _mainTextureDesiredSize: ISize;
  129556. protected _mainTexture: RenderTargetTexture;
  129557. protected _shouldRender: boolean;
  129558. protected _postProcesses: PostProcess[];
  129559. protected _textures: BaseTexture[];
  129560. protected _emissiveTextureAndColor: {
  129561. texture: Nullable<BaseTexture>;
  129562. color: Color4;
  129563. };
  129564. /**
  129565. * The name of the layer
  129566. */
  129567. name: string;
  129568. /**
  129569. * The clear color of the texture used to generate the glow map.
  129570. */
  129571. neutralColor: Color4;
  129572. /**
  129573. * Specifies whether the highlight layer is enabled or not.
  129574. */
  129575. isEnabled: boolean;
  129576. /**
  129577. * Gets the camera attached to the layer.
  129578. */
  129579. get camera(): Nullable<Camera>;
  129580. /**
  129581. * Gets the rendering group id the layer should render in.
  129582. */
  129583. get renderingGroupId(): number;
  129584. set renderingGroupId(renderingGroupId: number);
  129585. /**
  129586. * An event triggered when the effect layer has been disposed.
  129587. */
  129588. onDisposeObservable: Observable<EffectLayer>;
  129589. /**
  129590. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129591. */
  129592. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129593. /**
  129594. * An event triggered when the generated texture is being merged in the scene.
  129595. */
  129596. onBeforeComposeObservable: Observable<EffectLayer>;
  129597. /**
  129598. * An event triggered when the mesh is rendered into the effect render target.
  129599. */
  129600. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129601. /**
  129602. * An event triggered after the mesh has been rendered into the effect render target.
  129603. */
  129604. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129605. /**
  129606. * An event triggered when the generated texture has been merged in the scene.
  129607. */
  129608. onAfterComposeObservable: Observable<EffectLayer>;
  129609. /**
  129610. * An event triggered when the efffect layer changes its size.
  129611. */
  129612. onSizeChangedObservable: Observable<EffectLayer>;
  129613. /** @hidden */
  129614. static _SceneComponentInitialization: (scene: Scene) => void;
  129615. /**
  129616. * Instantiates a new effect Layer and references it in the scene.
  129617. * @param name The name of the layer
  129618. * @param scene The scene to use the layer in
  129619. */
  129620. constructor(
  129621. /** The Friendly of the effect in the scene */
  129622. name: string, scene: Scene);
  129623. /**
  129624. * Get the effect name of the layer.
  129625. * @return The effect name
  129626. */
  129627. abstract getEffectName(): string;
  129628. /**
  129629. * Checks for the readiness of the element composing the layer.
  129630. * @param subMesh the mesh to check for
  129631. * @param useInstances specify whether or not to use instances to render the mesh
  129632. * @return true if ready otherwise, false
  129633. */
  129634. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129635. /**
  129636. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129637. * @returns true if the effect requires stencil during the main canvas render pass.
  129638. */
  129639. abstract needStencil(): boolean;
  129640. /**
  129641. * Create the merge effect. This is the shader use to blit the information back
  129642. * to the main canvas at the end of the scene rendering.
  129643. * @returns The effect containing the shader used to merge the effect on the main canvas
  129644. */
  129645. protected abstract _createMergeEffect(): Effect;
  129646. /**
  129647. * Creates the render target textures and post processes used in the effect layer.
  129648. */
  129649. protected abstract _createTextureAndPostProcesses(): void;
  129650. /**
  129651. * Implementation specific of rendering the generating effect on the main canvas.
  129652. * @param effect The effect used to render through
  129653. */
  129654. protected abstract _internalRender(effect: Effect): void;
  129655. /**
  129656. * Sets the required values for both the emissive texture and and the main color.
  129657. */
  129658. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129659. /**
  129660. * Free any resources and references associated to a mesh.
  129661. * Internal use
  129662. * @param mesh The mesh to free.
  129663. */
  129664. abstract _disposeMesh(mesh: Mesh): void;
  129665. /**
  129666. * Serializes this layer (Glow or Highlight for example)
  129667. * @returns a serialized layer object
  129668. */
  129669. abstract serialize?(): any;
  129670. /**
  129671. * Initializes the effect layer with the required options.
  129672. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129673. */
  129674. protected _init(options: Partial<IEffectLayerOptions>): void;
  129675. /**
  129676. * Generates the index buffer of the full screen quad blending to the main canvas.
  129677. */
  129678. private _generateIndexBuffer;
  129679. /**
  129680. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129681. */
  129682. private _generateVertexBuffer;
  129683. /**
  129684. * Sets the main texture desired size which is the closest power of two
  129685. * of the engine canvas size.
  129686. */
  129687. private _setMainTextureSize;
  129688. /**
  129689. * Creates the main texture for the effect layer.
  129690. */
  129691. protected _createMainTexture(): void;
  129692. /**
  129693. * Adds specific effects defines.
  129694. * @param defines The defines to add specifics to.
  129695. */
  129696. protected _addCustomEffectDefines(defines: string[]): void;
  129697. /**
  129698. * Checks for the readiness of the element composing the layer.
  129699. * @param subMesh the mesh to check for
  129700. * @param useInstances specify whether or not to use instances to render the mesh
  129701. * @param emissiveTexture the associated emissive texture used to generate the glow
  129702. * @return true if ready otherwise, false
  129703. */
  129704. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129705. /**
  129706. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129707. */
  129708. render(): void;
  129709. /**
  129710. * Determine if a given mesh will be used in the current effect.
  129711. * @param mesh mesh to test
  129712. * @returns true if the mesh will be used
  129713. */
  129714. hasMesh(mesh: AbstractMesh): boolean;
  129715. /**
  129716. * Returns true if the layer contains information to display, otherwise false.
  129717. * @returns true if the glow layer should be rendered
  129718. */
  129719. shouldRender(): boolean;
  129720. /**
  129721. * Returns true if the mesh should render, otherwise false.
  129722. * @param mesh The mesh to render
  129723. * @returns true if it should render otherwise false
  129724. */
  129725. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129726. /**
  129727. * Returns true if the mesh can be rendered, otherwise false.
  129728. * @param mesh The mesh to render
  129729. * @param material The material used on the mesh
  129730. * @returns true if it can be rendered otherwise false
  129731. */
  129732. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129733. /**
  129734. * Returns true if the mesh should render, otherwise false.
  129735. * @param mesh The mesh to render
  129736. * @returns true if it should render otherwise false
  129737. */
  129738. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129739. /**
  129740. * Renders the submesh passed in parameter to the generation map.
  129741. */
  129742. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129743. /**
  129744. * Defines whether the current material of the mesh should be use to render the effect.
  129745. * @param mesh defines the current mesh to render
  129746. */
  129747. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129748. /**
  129749. * Rebuild the required buffers.
  129750. * @hidden Internal use only.
  129751. */
  129752. _rebuild(): void;
  129753. /**
  129754. * Dispose only the render target textures and post process.
  129755. */
  129756. private _disposeTextureAndPostProcesses;
  129757. /**
  129758. * Dispose the highlight layer and free resources.
  129759. */
  129760. dispose(): void;
  129761. /**
  129762. * Gets the class name of the effect layer
  129763. * @returns the string with the class name of the effect layer
  129764. */
  129765. getClassName(): string;
  129766. /**
  129767. * Creates an effect layer from parsed effect layer data
  129768. * @param parsedEffectLayer defines effect layer data
  129769. * @param scene defines the current scene
  129770. * @param rootUrl defines the root URL containing the effect layer information
  129771. * @returns a parsed effect Layer
  129772. */
  129773. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129774. }
  129775. }
  129776. declare module BABYLON {
  129777. interface AbstractScene {
  129778. /**
  129779. * The list of effect layers (highlights/glow) added to the scene
  129780. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129781. * @see http://doc.babylonjs.com/how_to/glow_layer
  129782. */
  129783. effectLayers: Array<EffectLayer>;
  129784. /**
  129785. * Removes the given effect layer from this scene.
  129786. * @param toRemove defines the effect layer to remove
  129787. * @returns the index of the removed effect layer
  129788. */
  129789. removeEffectLayer(toRemove: EffectLayer): number;
  129790. /**
  129791. * Adds the given effect layer to this scene
  129792. * @param newEffectLayer defines the effect layer to add
  129793. */
  129794. addEffectLayer(newEffectLayer: EffectLayer): void;
  129795. }
  129796. /**
  129797. * Defines the layer scene component responsible to manage any effect layers
  129798. * in a given scene.
  129799. */
  129800. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129801. /**
  129802. * The component name helpfull to identify the component in the list of scene components.
  129803. */
  129804. readonly name: string;
  129805. /**
  129806. * The scene the component belongs to.
  129807. */
  129808. scene: Scene;
  129809. private _engine;
  129810. private _renderEffects;
  129811. private _needStencil;
  129812. private _previousStencilState;
  129813. /**
  129814. * Creates a new instance of the component for the given scene
  129815. * @param scene Defines the scene to register the component in
  129816. */
  129817. constructor(scene: Scene);
  129818. /**
  129819. * Registers the component in a given scene
  129820. */
  129821. register(): void;
  129822. /**
  129823. * Rebuilds the elements related to this component in case of
  129824. * context lost for instance.
  129825. */
  129826. rebuild(): void;
  129827. /**
  129828. * Serializes the component data to the specified json object
  129829. * @param serializationObject The object to serialize to
  129830. */
  129831. serialize(serializationObject: any): void;
  129832. /**
  129833. * Adds all the elements from the container to the scene
  129834. * @param container the container holding the elements
  129835. */
  129836. addFromContainer(container: AbstractScene): void;
  129837. /**
  129838. * Removes all the elements in the container from the scene
  129839. * @param container contains the elements to remove
  129840. * @param dispose if the removed element should be disposed (default: false)
  129841. */
  129842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129843. /**
  129844. * Disposes the component and the associated ressources.
  129845. */
  129846. dispose(): void;
  129847. private _isReadyForMesh;
  129848. private _renderMainTexture;
  129849. private _setStencil;
  129850. private _setStencilBack;
  129851. private _draw;
  129852. private _drawCamera;
  129853. private _drawRenderingGroup;
  129854. }
  129855. }
  129856. declare module BABYLON {
  129857. /** @hidden */
  129858. export var glowMapMergePixelShader: {
  129859. name: string;
  129860. shader: string;
  129861. };
  129862. }
  129863. declare module BABYLON {
  129864. /** @hidden */
  129865. export var glowMapMergeVertexShader: {
  129866. name: string;
  129867. shader: string;
  129868. };
  129869. }
  129870. declare module BABYLON {
  129871. interface AbstractScene {
  129872. /**
  129873. * Return a the first highlight layer of the scene with a given name.
  129874. * @param name The name of the highlight layer to look for.
  129875. * @return The highlight layer if found otherwise null.
  129876. */
  129877. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129878. }
  129879. /**
  129880. * Glow layer options. This helps customizing the behaviour
  129881. * of the glow layer.
  129882. */
  129883. export interface IGlowLayerOptions {
  129884. /**
  129885. * Multiplication factor apply to the canvas size to compute the render target size
  129886. * used to generated the glowing objects (the smaller the faster).
  129887. */
  129888. mainTextureRatio: number;
  129889. /**
  129890. * Enforces a fixed size texture to ensure resize independant blur.
  129891. */
  129892. mainTextureFixedSize?: number;
  129893. /**
  129894. * How big is the kernel of the blur texture.
  129895. */
  129896. blurKernelSize: number;
  129897. /**
  129898. * The camera attached to the layer.
  129899. */
  129900. camera: Nullable<Camera>;
  129901. /**
  129902. * Enable MSAA by chosing the number of samples.
  129903. */
  129904. mainTextureSamples?: number;
  129905. /**
  129906. * The rendering group to draw the layer in.
  129907. */
  129908. renderingGroupId: number;
  129909. }
  129910. /**
  129911. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129912. *
  129913. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129914. *
  129915. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129916. */
  129917. export class GlowLayer extends EffectLayer {
  129918. /**
  129919. * Effect Name of the layer.
  129920. */
  129921. static readonly EffectName: string;
  129922. /**
  129923. * The default blur kernel size used for the glow.
  129924. */
  129925. static DefaultBlurKernelSize: number;
  129926. /**
  129927. * The default texture size ratio used for the glow.
  129928. */
  129929. static DefaultTextureRatio: number;
  129930. /**
  129931. * Sets the kernel size of the blur.
  129932. */
  129933. set blurKernelSize(value: number);
  129934. /**
  129935. * Gets the kernel size of the blur.
  129936. */
  129937. get blurKernelSize(): number;
  129938. /**
  129939. * Sets the glow intensity.
  129940. */
  129941. set intensity(value: number);
  129942. /**
  129943. * Gets the glow intensity.
  129944. */
  129945. get intensity(): number;
  129946. private _options;
  129947. private _intensity;
  129948. private _horizontalBlurPostprocess1;
  129949. private _verticalBlurPostprocess1;
  129950. private _horizontalBlurPostprocess2;
  129951. private _verticalBlurPostprocess2;
  129952. private _blurTexture1;
  129953. private _blurTexture2;
  129954. private _postProcesses1;
  129955. private _postProcesses2;
  129956. private _includedOnlyMeshes;
  129957. private _excludedMeshes;
  129958. private _meshesUsingTheirOwnMaterials;
  129959. /**
  129960. * Callback used to let the user override the color selection on a per mesh basis
  129961. */
  129962. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  129963. /**
  129964. * Callback used to let the user override the texture selection on a per mesh basis
  129965. */
  129966. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  129967. /**
  129968. * Instantiates a new glow Layer and references it to the scene.
  129969. * @param name The name of the layer
  129970. * @param scene The scene to use the layer in
  129971. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  129972. */
  129973. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  129974. /**
  129975. * Get the effect name of the layer.
  129976. * @return The effect name
  129977. */
  129978. getEffectName(): string;
  129979. /**
  129980. * Create the merge effect. This is the shader use to blit the information back
  129981. * to the main canvas at the end of the scene rendering.
  129982. */
  129983. protected _createMergeEffect(): Effect;
  129984. /**
  129985. * Creates the render target textures and post processes used in the glow layer.
  129986. */
  129987. protected _createTextureAndPostProcesses(): void;
  129988. /**
  129989. * Checks for the readiness of the element composing the layer.
  129990. * @param subMesh the mesh to check for
  129991. * @param useInstances specify wether or not to use instances to render the mesh
  129992. * @param emissiveTexture the associated emissive texture used to generate the glow
  129993. * @return true if ready otherwise, false
  129994. */
  129995. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129996. /**
  129997. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129998. */
  129999. needStencil(): boolean;
  130000. /**
  130001. * Returns true if the mesh can be rendered, otherwise false.
  130002. * @param mesh The mesh to render
  130003. * @param material The material used on the mesh
  130004. * @returns true if it can be rendered otherwise false
  130005. */
  130006. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  130007. /**
  130008. * Implementation specific of rendering the generating effect on the main canvas.
  130009. * @param effect The effect used to render through
  130010. */
  130011. protected _internalRender(effect: Effect): void;
  130012. /**
  130013. * Sets the required values for both the emissive texture and and the main color.
  130014. */
  130015. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130016. /**
  130017. * Returns true if the mesh should render, otherwise false.
  130018. * @param mesh The mesh to render
  130019. * @returns true if it should render otherwise false
  130020. */
  130021. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130022. /**
  130023. * Adds specific effects defines.
  130024. * @param defines The defines to add specifics to.
  130025. */
  130026. protected _addCustomEffectDefines(defines: string[]): void;
  130027. /**
  130028. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  130029. * @param mesh The mesh to exclude from the glow layer
  130030. */
  130031. addExcludedMesh(mesh: Mesh): void;
  130032. /**
  130033. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  130034. * @param mesh The mesh to remove
  130035. */
  130036. removeExcludedMesh(mesh: Mesh): void;
  130037. /**
  130038. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  130039. * @param mesh The mesh to include in the glow layer
  130040. */
  130041. addIncludedOnlyMesh(mesh: Mesh): void;
  130042. /**
  130043. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  130044. * @param mesh The mesh to remove
  130045. */
  130046. removeIncludedOnlyMesh(mesh: Mesh): void;
  130047. /**
  130048. * Determine if a given mesh will be used in the glow layer
  130049. * @param mesh The mesh to test
  130050. * @returns true if the mesh will be highlighted by the current glow layer
  130051. */
  130052. hasMesh(mesh: AbstractMesh): boolean;
  130053. /**
  130054. * Defines whether the current material of the mesh should be use to render the effect.
  130055. * @param mesh defines the current mesh to render
  130056. */
  130057. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  130058. /**
  130059. * Add a mesh to be rendered through its own material and not with emissive only.
  130060. * @param mesh The mesh for which we need to use its material
  130061. */
  130062. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  130063. /**
  130064. * Remove a mesh from being rendered through its own material and not with emissive only.
  130065. * @param mesh The mesh for which we need to not use its material
  130066. */
  130067. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  130068. /**
  130069. * Free any resources and references associated to a mesh.
  130070. * Internal use
  130071. * @param mesh The mesh to free.
  130072. * @hidden
  130073. */
  130074. _disposeMesh(mesh: Mesh): void;
  130075. /**
  130076. * Gets the class name of the effect layer
  130077. * @returns the string with the class name of the effect layer
  130078. */
  130079. getClassName(): string;
  130080. /**
  130081. * Serializes this glow layer
  130082. * @returns a serialized glow layer object
  130083. */
  130084. serialize(): any;
  130085. /**
  130086. * Creates a Glow Layer from parsed glow layer data
  130087. * @param parsedGlowLayer defines glow layer data
  130088. * @param scene defines the current scene
  130089. * @param rootUrl defines the root URL containing the glow layer information
  130090. * @returns a parsed Glow Layer
  130091. */
  130092. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  130093. }
  130094. }
  130095. declare module BABYLON {
  130096. /** @hidden */
  130097. export var glowBlurPostProcessPixelShader: {
  130098. name: string;
  130099. shader: string;
  130100. };
  130101. }
  130102. declare module BABYLON {
  130103. interface AbstractScene {
  130104. /**
  130105. * Return a the first highlight layer of the scene with a given name.
  130106. * @param name The name of the highlight layer to look for.
  130107. * @return The highlight layer if found otherwise null.
  130108. */
  130109. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  130110. }
  130111. /**
  130112. * Highlight layer options. This helps customizing the behaviour
  130113. * of the highlight layer.
  130114. */
  130115. export interface IHighlightLayerOptions {
  130116. /**
  130117. * Multiplication factor apply to the canvas size to compute the render target size
  130118. * used to generated the glowing objects (the smaller the faster).
  130119. */
  130120. mainTextureRatio: number;
  130121. /**
  130122. * Enforces a fixed size texture to ensure resize independant blur.
  130123. */
  130124. mainTextureFixedSize?: number;
  130125. /**
  130126. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  130127. * of the picture to blur (the smaller the faster).
  130128. */
  130129. blurTextureSizeRatio: number;
  130130. /**
  130131. * How big in texel of the blur texture is the vertical blur.
  130132. */
  130133. blurVerticalSize: number;
  130134. /**
  130135. * How big in texel of the blur texture is the horizontal blur.
  130136. */
  130137. blurHorizontalSize: number;
  130138. /**
  130139. * Alpha blending mode used to apply the blur. Default is combine.
  130140. */
  130141. alphaBlendingMode: number;
  130142. /**
  130143. * The camera attached to the layer.
  130144. */
  130145. camera: Nullable<Camera>;
  130146. /**
  130147. * Should we display highlight as a solid stroke?
  130148. */
  130149. isStroke?: boolean;
  130150. /**
  130151. * The rendering group to draw the layer in.
  130152. */
  130153. renderingGroupId: number;
  130154. }
  130155. /**
  130156. * The highlight layer Helps adding a glow effect around a mesh.
  130157. *
  130158. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  130159. * glowy meshes to your scene.
  130160. *
  130161. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  130162. */
  130163. export class HighlightLayer extends EffectLayer {
  130164. name: string;
  130165. /**
  130166. * Effect Name of the highlight layer.
  130167. */
  130168. static readonly EffectName: string;
  130169. /**
  130170. * The neutral color used during the preparation of the glow effect.
  130171. * This is black by default as the blend operation is a blend operation.
  130172. */
  130173. static NeutralColor: Color4;
  130174. /**
  130175. * Stencil value used for glowing meshes.
  130176. */
  130177. static GlowingMeshStencilReference: number;
  130178. /**
  130179. * Stencil value used for the other meshes in the scene.
  130180. */
  130181. static NormalMeshStencilReference: number;
  130182. /**
  130183. * Specifies whether or not the inner glow is ACTIVE in the layer.
  130184. */
  130185. innerGlow: boolean;
  130186. /**
  130187. * Specifies whether or not the outer glow is ACTIVE in the layer.
  130188. */
  130189. outerGlow: boolean;
  130190. /**
  130191. * Specifies the horizontal size of the blur.
  130192. */
  130193. set blurHorizontalSize(value: number);
  130194. /**
  130195. * Specifies the vertical size of the blur.
  130196. */
  130197. set blurVerticalSize(value: number);
  130198. /**
  130199. * Gets the horizontal size of the blur.
  130200. */
  130201. get blurHorizontalSize(): number;
  130202. /**
  130203. * Gets the vertical size of the blur.
  130204. */
  130205. get blurVerticalSize(): number;
  130206. /**
  130207. * An event triggered when the highlight layer is being blurred.
  130208. */
  130209. onBeforeBlurObservable: Observable<HighlightLayer>;
  130210. /**
  130211. * An event triggered when the highlight layer has been blurred.
  130212. */
  130213. onAfterBlurObservable: Observable<HighlightLayer>;
  130214. private _instanceGlowingMeshStencilReference;
  130215. private _options;
  130216. private _downSamplePostprocess;
  130217. private _horizontalBlurPostprocess;
  130218. private _verticalBlurPostprocess;
  130219. private _blurTexture;
  130220. private _meshes;
  130221. private _excludedMeshes;
  130222. /**
  130223. * Instantiates a new highlight Layer and references it to the scene..
  130224. * @param name The name of the layer
  130225. * @param scene The scene to use the layer in
  130226. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  130227. */
  130228. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  130229. /**
  130230. * Get the effect name of the layer.
  130231. * @return The effect name
  130232. */
  130233. getEffectName(): string;
  130234. /**
  130235. * Create the merge effect. This is the shader use to blit the information back
  130236. * to the main canvas at the end of the scene rendering.
  130237. */
  130238. protected _createMergeEffect(): Effect;
  130239. /**
  130240. * Creates the render target textures and post processes used in the highlight layer.
  130241. */
  130242. protected _createTextureAndPostProcesses(): void;
  130243. /**
  130244. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130245. */
  130246. needStencil(): boolean;
  130247. /**
  130248. * Checks for the readiness of the element composing the layer.
  130249. * @param subMesh the mesh to check for
  130250. * @param useInstances specify wether or not to use instances to render the mesh
  130251. * @param emissiveTexture the associated emissive texture used to generate the glow
  130252. * @return true if ready otherwise, false
  130253. */
  130254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130255. /**
  130256. * Implementation specific of rendering the generating effect on the main canvas.
  130257. * @param effect The effect used to render through
  130258. */
  130259. protected _internalRender(effect: Effect): void;
  130260. /**
  130261. * Returns true if the layer contains information to display, otherwise false.
  130262. */
  130263. shouldRender(): boolean;
  130264. /**
  130265. * Returns true if the mesh should render, otherwise false.
  130266. * @param mesh The mesh to render
  130267. * @returns true if it should render otherwise false
  130268. */
  130269. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130270. /**
  130271. * Adds specific effects defines.
  130272. * @param defines The defines to add specifics to.
  130273. */
  130274. protected _addCustomEffectDefines(defines: string[]): void;
  130275. /**
  130276. * Sets the required values for both the emissive texture and and the main color.
  130277. */
  130278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130279. /**
  130280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130281. * @param mesh The mesh to exclude from the highlight layer
  130282. */
  130283. addExcludedMesh(mesh: Mesh): void;
  130284. /**
  130285. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130286. * @param mesh The mesh to highlight
  130287. */
  130288. removeExcludedMesh(mesh: Mesh): void;
  130289. /**
  130290. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130291. * @param mesh mesh to test
  130292. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130293. */
  130294. hasMesh(mesh: AbstractMesh): boolean;
  130295. /**
  130296. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130297. * @param mesh The mesh to highlight
  130298. * @param color The color of the highlight
  130299. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130300. */
  130301. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130302. /**
  130303. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130304. * @param mesh The mesh to highlight
  130305. */
  130306. removeMesh(mesh: Mesh): void;
  130307. /**
  130308. * Remove all the meshes currently referenced in the highlight layer
  130309. */
  130310. removeAllMeshes(): void;
  130311. /**
  130312. * Force the stencil to the normal expected value for none glowing parts
  130313. */
  130314. private _defaultStencilReference;
  130315. /**
  130316. * Free any resources and references associated to a mesh.
  130317. * Internal use
  130318. * @param mesh The mesh to free.
  130319. * @hidden
  130320. */
  130321. _disposeMesh(mesh: Mesh): void;
  130322. /**
  130323. * Dispose the highlight layer and free resources.
  130324. */
  130325. dispose(): void;
  130326. /**
  130327. * Gets the class name of the effect layer
  130328. * @returns the string with the class name of the effect layer
  130329. */
  130330. getClassName(): string;
  130331. /**
  130332. * Serializes this Highlight layer
  130333. * @returns a serialized Highlight layer object
  130334. */
  130335. serialize(): any;
  130336. /**
  130337. * Creates a Highlight layer from parsed Highlight layer data
  130338. * @param parsedHightlightLayer defines the Highlight layer data
  130339. * @param scene defines the current scene
  130340. * @param rootUrl defines the root URL containing the Highlight layer information
  130341. * @returns a parsed Highlight layer
  130342. */
  130343. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130344. }
  130345. }
  130346. declare module BABYLON {
  130347. interface AbstractScene {
  130348. /**
  130349. * The list of layers (background and foreground) of the scene
  130350. */
  130351. layers: Array<Layer>;
  130352. }
  130353. /**
  130354. * Defines the layer scene component responsible to manage any layers
  130355. * in a given scene.
  130356. */
  130357. export class LayerSceneComponent implements ISceneComponent {
  130358. /**
  130359. * The component name helpfull to identify the component in the list of scene components.
  130360. */
  130361. readonly name: string;
  130362. /**
  130363. * The scene the component belongs to.
  130364. */
  130365. scene: Scene;
  130366. private _engine;
  130367. /**
  130368. * Creates a new instance of the component for the given scene
  130369. * @param scene Defines the scene to register the component in
  130370. */
  130371. constructor(scene: Scene);
  130372. /**
  130373. * Registers the component in a given scene
  130374. */
  130375. register(): void;
  130376. /**
  130377. * Rebuilds the elements related to this component in case of
  130378. * context lost for instance.
  130379. */
  130380. rebuild(): void;
  130381. /**
  130382. * Disposes the component and the associated ressources.
  130383. */
  130384. dispose(): void;
  130385. private _draw;
  130386. private _drawCameraPredicate;
  130387. private _drawCameraBackground;
  130388. private _drawCameraForeground;
  130389. private _drawRenderTargetPredicate;
  130390. private _drawRenderTargetBackground;
  130391. private _drawRenderTargetForeground;
  130392. /**
  130393. * Adds all the elements from the container to the scene
  130394. * @param container the container holding the elements
  130395. */
  130396. addFromContainer(container: AbstractScene): void;
  130397. /**
  130398. * Removes all the elements in the container from the scene
  130399. * @param container contains the elements to remove
  130400. * @param dispose if the removed element should be disposed (default: false)
  130401. */
  130402. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130403. }
  130404. }
  130405. declare module BABYLON {
  130406. /** @hidden */
  130407. export var layerPixelShader: {
  130408. name: string;
  130409. shader: string;
  130410. };
  130411. }
  130412. declare module BABYLON {
  130413. /** @hidden */
  130414. export var layerVertexShader: {
  130415. name: string;
  130416. shader: string;
  130417. };
  130418. }
  130419. declare module BABYLON {
  130420. /**
  130421. * This represents a full screen 2d layer.
  130422. * This can be useful to display a picture in the background of your scene for instance.
  130423. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130424. */
  130425. export class Layer {
  130426. /**
  130427. * Define the name of the layer.
  130428. */
  130429. name: string;
  130430. /**
  130431. * Define the texture the layer should display.
  130432. */
  130433. texture: Nullable<Texture>;
  130434. /**
  130435. * Is the layer in background or foreground.
  130436. */
  130437. isBackground: boolean;
  130438. /**
  130439. * Define the color of the layer (instead of texture).
  130440. */
  130441. color: Color4;
  130442. /**
  130443. * Define the scale of the layer in order to zoom in out of the texture.
  130444. */
  130445. scale: Vector2;
  130446. /**
  130447. * Define an offset for the layer in order to shift the texture.
  130448. */
  130449. offset: Vector2;
  130450. /**
  130451. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130452. */
  130453. alphaBlendingMode: number;
  130454. /**
  130455. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130456. * Alpha test will not mix with the background color in case of transparency.
  130457. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130458. */
  130459. alphaTest: boolean;
  130460. /**
  130461. * Define a mask to restrict the layer to only some of the scene cameras.
  130462. */
  130463. layerMask: number;
  130464. /**
  130465. * Define the list of render target the layer is visible into.
  130466. */
  130467. renderTargetTextures: RenderTargetTexture[];
  130468. /**
  130469. * Define if the layer is only used in renderTarget or if it also
  130470. * renders in the main frame buffer of the canvas.
  130471. */
  130472. renderOnlyInRenderTargetTextures: boolean;
  130473. private _scene;
  130474. private _vertexBuffers;
  130475. private _indexBuffer;
  130476. private _effect;
  130477. private _previousDefines;
  130478. /**
  130479. * An event triggered when the layer is disposed.
  130480. */
  130481. onDisposeObservable: Observable<Layer>;
  130482. private _onDisposeObserver;
  130483. /**
  130484. * Back compatibility with callback before the onDisposeObservable existed.
  130485. * The set callback will be triggered when the layer has been disposed.
  130486. */
  130487. set onDispose(callback: () => void);
  130488. /**
  130489. * An event triggered before rendering the scene
  130490. */
  130491. onBeforeRenderObservable: Observable<Layer>;
  130492. private _onBeforeRenderObserver;
  130493. /**
  130494. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130495. * The set callback will be triggered just before rendering the layer.
  130496. */
  130497. set onBeforeRender(callback: () => void);
  130498. /**
  130499. * An event triggered after rendering the scene
  130500. */
  130501. onAfterRenderObservable: Observable<Layer>;
  130502. private _onAfterRenderObserver;
  130503. /**
  130504. * Back compatibility with callback before the onAfterRenderObservable existed.
  130505. * The set callback will be triggered just after rendering the layer.
  130506. */
  130507. set onAfterRender(callback: () => void);
  130508. /**
  130509. * Instantiates a new layer.
  130510. * This represents a full screen 2d layer.
  130511. * This can be useful to display a picture in the background of your scene for instance.
  130512. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130513. * @param name Define the name of the layer in the scene
  130514. * @param imgUrl Define the url of the texture to display in the layer
  130515. * @param scene Define the scene the layer belongs to
  130516. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130517. * @param color Defines a color for the layer
  130518. */
  130519. constructor(
  130520. /**
  130521. * Define the name of the layer.
  130522. */
  130523. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130524. private _createIndexBuffer;
  130525. /** @hidden */
  130526. _rebuild(): void;
  130527. /**
  130528. * Renders the layer in the scene.
  130529. */
  130530. render(): void;
  130531. /**
  130532. * Disposes and releases the associated ressources.
  130533. */
  130534. dispose(): void;
  130535. }
  130536. }
  130537. declare module BABYLON {
  130538. /** @hidden */
  130539. export var lensFlarePixelShader: {
  130540. name: string;
  130541. shader: string;
  130542. };
  130543. }
  130544. declare module BABYLON {
  130545. /** @hidden */
  130546. export var lensFlareVertexShader: {
  130547. name: string;
  130548. shader: string;
  130549. };
  130550. }
  130551. declare module BABYLON {
  130552. /**
  130553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130554. * It is usually composed of several `lensFlare`.
  130555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130556. */
  130557. export class LensFlareSystem {
  130558. /**
  130559. * Define the name of the lens flare system
  130560. */
  130561. name: string;
  130562. /**
  130563. * List of lens flares used in this system.
  130564. */
  130565. lensFlares: LensFlare[];
  130566. /**
  130567. * Define a limit from the border the lens flare can be visible.
  130568. */
  130569. borderLimit: number;
  130570. /**
  130571. * Define a viewport border we do not want to see the lens flare in.
  130572. */
  130573. viewportBorder: number;
  130574. /**
  130575. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130576. */
  130577. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130578. /**
  130579. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130580. */
  130581. layerMask: number;
  130582. /**
  130583. * Define the id of the lens flare system in the scene.
  130584. * (equal to name by default)
  130585. */
  130586. id: string;
  130587. private _scene;
  130588. private _emitter;
  130589. private _vertexBuffers;
  130590. private _indexBuffer;
  130591. private _effect;
  130592. private _positionX;
  130593. private _positionY;
  130594. private _isEnabled;
  130595. /** @hidden */
  130596. static _SceneComponentInitialization: (scene: Scene) => void;
  130597. /**
  130598. * Instantiates a lens flare system.
  130599. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130600. * It is usually composed of several `lensFlare`.
  130601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130602. * @param name Define the name of the lens flare system in the scene
  130603. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130604. * @param scene Define the scene the lens flare system belongs to
  130605. */
  130606. constructor(
  130607. /**
  130608. * Define the name of the lens flare system
  130609. */
  130610. name: string, emitter: any, scene: Scene);
  130611. /**
  130612. * Define if the lens flare system is enabled.
  130613. */
  130614. get isEnabled(): boolean;
  130615. set isEnabled(value: boolean);
  130616. /**
  130617. * Get the scene the effects belongs to.
  130618. * @returns the scene holding the lens flare system
  130619. */
  130620. getScene(): Scene;
  130621. /**
  130622. * Get the emitter of the lens flare system.
  130623. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130624. * @returns the emitter of the lens flare system
  130625. */
  130626. getEmitter(): any;
  130627. /**
  130628. * Set the emitter of the lens flare system.
  130629. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130630. * @param newEmitter Define the new emitter of the system
  130631. */
  130632. setEmitter(newEmitter: any): void;
  130633. /**
  130634. * Get the lens flare system emitter position.
  130635. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130636. * @returns the position
  130637. */
  130638. getEmitterPosition(): Vector3;
  130639. /**
  130640. * @hidden
  130641. */
  130642. computeEffectivePosition(globalViewport: Viewport): boolean;
  130643. /** @hidden */
  130644. _isVisible(): boolean;
  130645. /**
  130646. * @hidden
  130647. */
  130648. render(): boolean;
  130649. /**
  130650. * Dispose and release the lens flare with its associated resources.
  130651. */
  130652. dispose(): void;
  130653. /**
  130654. * Parse a lens flare system from a JSON repressentation
  130655. * @param parsedLensFlareSystem Define the JSON to parse
  130656. * @param scene Define the scene the parsed system should be instantiated in
  130657. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130658. * @returns the parsed system
  130659. */
  130660. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130661. /**
  130662. * Serialize the current Lens Flare System into a JSON representation.
  130663. * @returns the serialized JSON
  130664. */
  130665. serialize(): any;
  130666. }
  130667. }
  130668. declare module BABYLON {
  130669. /**
  130670. * This represents one of the lens effect in a `lensFlareSystem`.
  130671. * It controls one of the indiviual texture used in the effect.
  130672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130673. */
  130674. export class LensFlare {
  130675. /**
  130676. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130677. */
  130678. size: number;
  130679. /**
  130680. * 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.
  130681. */
  130682. position: number;
  130683. /**
  130684. * Define the lens color.
  130685. */
  130686. color: Color3;
  130687. /**
  130688. * Define the lens texture.
  130689. */
  130690. texture: Nullable<Texture>;
  130691. /**
  130692. * Define the alpha mode to render this particular lens.
  130693. */
  130694. alphaMode: number;
  130695. private _system;
  130696. /**
  130697. * Creates a new Lens Flare.
  130698. * This represents one of the lens effect in a `lensFlareSystem`.
  130699. * It controls one of the indiviual texture used in the effect.
  130700. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130701. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130702. * @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.
  130703. * @param color Define the lens color
  130704. * @param imgUrl Define the lens texture url
  130705. * @param system Define the `lensFlareSystem` this flare is part of
  130706. * @returns The newly created Lens Flare
  130707. */
  130708. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130709. /**
  130710. * Instantiates a new Lens Flare.
  130711. * This represents one of the lens effect in a `lensFlareSystem`.
  130712. * It controls one of the indiviual texture used in the effect.
  130713. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130714. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130715. * @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.
  130716. * @param color Define the lens color
  130717. * @param imgUrl Define the lens texture url
  130718. * @param system Define the `lensFlareSystem` this flare is part of
  130719. */
  130720. constructor(
  130721. /**
  130722. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130723. */
  130724. size: number,
  130725. /**
  130726. * 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.
  130727. */
  130728. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130729. /**
  130730. * Dispose and release the lens flare with its associated resources.
  130731. */
  130732. dispose(): void;
  130733. }
  130734. }
  130735. declare module BABYLON {
  130736. interface AbstractScene {
  130737. /**
  130738. * The list of lens flare system added to the scene
  130739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130740. */
  130741. lensFlareSystems: Array<LensFlareSystem>;
  130742. /**
  130743. * Removes the given lens flare system from this scene.
  130744. * @param toRemove The lens flare system to remove
  130745. * @returns The index of the removed lens flare system
  130746. */
  130747. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130748. /**
  130749. * Adds the given lens flare system to this scene
  130750. * @param newLensFlareSystem The lens flare system to add
  130751. */
  130752. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130753. /**
  130754. * Gets a lens flare system using its name
  130755. * @param name defines the name to look for
  130756. * @returns the lens flare system or null if not found
  130757. */
  130758. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130759. /**
  130760. * Gets a lens flare system using its id
  130761. * @param id defines the id to look for
  130762. * @returns the lens flare system or null if not found
  130763. */
  130764. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130765. }
  130766. /**
  130767. * Defines the lens flare scene component responsible to manage any lens flares
  130768. * in a given scene.
  130769. */
  130770. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130771. /**
  130772. * The component name helpfull to identify the component in the list of scene components.
  130773. */
  130774. readonly name: string;
  130775. /**
  130776. * The scene the component belongs to.
  130777. */
  130778. scene: Scene;
  130779. /**
  130780. * Creates a new instance of the component for the given scene
  130781. * @param scene Defines the scene to register the component in
  130782. */
  130783. constructor(scene: Scene);
  130784. /**
  130785. * Registers the component in a given scene
  130786. */
  130787. register(): void;
  130788. /**
  130789. * Rebuilds the elements related to this component in case of
  130790. * context lost for instance.
  130791. */
  130792. rebuild(): void;
  130793. /**
  130794. * Adds all the elements from the container to the scene
  130795. * @param container the container holding the elements
  130796. */
  130797. addFromContainer(container: AbstractScene): void;
  130798. /**
  130799. * Removes all the elements in the container from the scene
  130800. * @param container contains the elements to remove
  130801. * @param dispose if the removed element should be disposed (default: false)
  130802. */
  130803. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130804. /**
  130805. * Serializes the component data to the specified json object
  130806. * @param serializationObject The object to serialize to
  130807. */
  130808. serialize(serializationObject: any): void;
  130809. /**
  130810. * Disposes the component and the associated ressources.
  130811. */
  130812. dispose(): void;
  130813. private _draw;
  130814. }
  130815. }
  130816. declare module BABYLON {
  130817. /** @hidden */
  130818. export var depthPixelShader: {
  130819. name: string;
  130820. shader: string;
  130821. };
  130822. }
  130823. declare module BABYLON {
  130824. /** @hidden */
  130825. export var depthVertexShader: {
  130826. name: string;
  130827. shader: string;
  130828. };
  130829. }
  130830. declare module BABYLON {
  130831. /**
  130832. * This represents a depth renderer in Babylon.
  130833. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130834. */
  130835. export class DepthRenderer {
  130836. private _scene;
  130837. private _depthMap;
  130838. private _effect;
  130839. private readonly _storeNonLinearDepth;
  130840. private readonly _clearColor;
  130841. /** Get if the depth renderer is using packed depth or not */
  130842. readonly isPacked: boolean;
  130843. private _cachedDefines;
  130844. private _camera;
  130845. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130846. enabled: boolean;
  130847. /**
  130848. * Specifiess that the depth renderer will only be used within
  130849. * the camera it is created for.
  130850. * This can help forcing its rendering during the camera processing.
  130851. */
  130852. useOnlyInActiveCamera: boolean;
  130853. /** @hidden */
  130854. static _SceneComponentInitialization: (scene: Scene) => void;
  130855. /**
  130856. * Instantiates a depth renderer
  130857. * @param scene The scene the renderer belongs to
  130858. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130859. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130860. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130861. */
  130862. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130863. /**
  130864. * Creates the depth rendering effect and checks if the effect is ready.
  130865. * @param subMesh The submesh to be used to render the depth map of
  130866. * @param useInstances If multiple world instances should be used
  130867. * @returns if the depth renderer is ready to render the depth map
  130868. */
  130869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130870. /**
  130871. * Gets the texture which the depth map will be written to.
  130872. * @returns The depth map texture
  130873. */
  130874. getDepthMap(): RenderTargetTexture;
  130875. /**
  130876. * Disposes of the depth renderer.
  130877. */
  130878. dispose(): void;
  130879. }
  130880. }
  130881. declare module BABYLON {
  130882. /** @hidden */
  130883. export var minmaxReduxPixelShader: {
  130884. name: string;
  130885. shader: string;
  130886. };
  130887. }
  130888. declare module BABYLON {
  130889. /**
  130890. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130891. * and maximum values from all values of the texture.
  130892. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130893. * The source values are read from the red channel of the texture.
  130894. */
  130895. export class MinMaxReducer {
  130896. /**
  130897. * Observable triggered when the computation has been performed
  130898. */
  130899. onAfterReductionPerformed: Observable<{
  130900. min: number;
  130901. max: number;
  130902. }>;
  130903. protected _camera: Camera;
  130904. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130905. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130906. protected _postProcessManager: PostProcessManager;
  130907. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130908. protected _forceFullscreenViewport: boolean;
  130909. /**
  130910. * Creates a min/max reducer
  130911. * @param camera The camera to use for the post processes
  130912. */
  130913. constructor(camera: Camera);
  130914. /**
  130915. * Gets the texture used to read the values from.
  130916. */
  130917. get sourceTexture(): Nullable<RenderTargetTexture>;
  130918. /**
  130919. * Sets the source texture to read the values from.
  130920. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130921. * because in such textures '1' value must not be taken into account to compute the maximum
  130922. * as this value is used to clear the texture.
  130923. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130924. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130925. * @param depthRedux Indicates if the texture is a depth texture or not
  130926. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130927. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130928. */
  130929. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130930. /**
  130931. * Defines the refresh rate of the computation.
  130932. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130933. */
  130934. get refreshRate(): number;
  130935. set refreshRate(value: number);
  130936. protected _activated: boolean;
  130937. /**
  130938. * Gets the activation status of the reducer
  130939. */
  130940. get activated(): boolean;
  130941. /**
  130942. * Activates the reduction computation.
  130943. * When activated, the observers registered in onAfterReductionPerformed are
  130944. * called after the compuation is performed
  130945. */
  130946. activate(): void;
  130947. /**
  130948. * Deactivates the reduction computation.
  130949. */
  130950. deactivate(): void;
  130951. /**
  130952. * Disposes the min/max reducer
  130953. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  130954. */
  130955. dispose(disposeAll?: boolean): void;
  130956. }
  130957. }
  130958. declare module BABYLON {
  130959. /**
  130960. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  130961. */
  130962. export class DepthReducer extends MinMaxReducer {
  130963. private _depthRenderer;
  130964. private _depthRendererId;
  130965. /**
  130966. * Gets the depth renderer used for the computation.
  130967. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  130968. */
  130969. get depthRenderer(): Nullable<DepthRenderer>;
  130970. /**
  130971. * Creates a depth reducer
  130972. * @param camera The camera used to render the depth texture
  130973. */
  130974. constructor(camera: Camera);
  130975. /**
  130976. * Sets the depth renderer to use to generate the depth map
  130977. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  130978. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  130979. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130980. */
  130981. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  130982. /** @hidden */
  130983. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130984. /**
  130985. * Activates the reduction computation.
  130986. * When activated, the observers registered in onAfterReductionPerformed are
  130987. * called after the compuation is performed
  130988. */
  130989. activate(): void;
  130990. /**
  130991. * Deactivates the reduction computation.
  130992. */
  130993. deactivate(): void;
  130994. /**
  130995. * Disposes the depth reducer
  130996. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  130997. */
  130998. dispose(disposeAll?: boolean): void;
  130999. }
  131000. }
  131001. declare module BABYLON {
  131002. /**
  131003. * A CSM implementation allowing casting shadows on large scenes.
  131004. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131005. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  131006. */
  131007. export class CascadedShadowGenerator extends ShadowGenerator {
  131008. private static readonly frustumCornersNDCSpace;
  131009. /**
  131010. * Name of the CSM class
  131011. */
  131012. static CLASSNAME: string;
  131013. /**
  131014. * Defines the default number of cascades used by the CSM.
  131015. */
  131016. static readonly DEFAULT_CASCADES_COUNT: number;
  131017. /**
  131018. * Defines the minimum number of cascades used by the CSM.
  131019. */
  131020. static readonly MIN_CASCADES_COUNT: number;
  131021. /**
  131022. * Defines the maximum number of cascades used by the CSM.
  131023. */
  131024. static readonly MAX_CASCADES_COUNT: number;
  131025. protected _validateFilter(filter: number): number;
  131026. /**
  131027. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  131028. */
  131029. penumbraDarkness: number;
  131030. private _numCascades;
  131031. /**
  131032. * Gets or set the number of cascades used by the CSM.
  131033. */
  131034. get numCascades(): number;
  131035. set numCascades(value: number);
  131036. /**
  131037. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  131038. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  131039. */
  131040. stabilizeCascades: boolean;
  131041. private _freezeShadowCastersBoundingInfo;
  131042. private _freezeShadowCastersBoundingInfoObservable;
  131043. /**
  131044. * Enables or disables the shadow casters bounding info computation.
  131045. * If your shadow casters don't move, you can disable this feature.
  131046. * If it is enabled, the bounding box computation is done every frame.
  131047. */
  131048. get freezeShadowCastersBoundingInfo(): boolean;
  131049. set freezeShadowCastersBoundingInfo(freeze: boolean);
  131050. private _scbiMin;
  131051. private _scbiMax;
  131052. protected _computeShadowCastersBoundingInfo(): void;
  131053. protected _shadowCastersBoundingInfo: BoundingInfo;
  131054. /**
  131055. * Gets or sets the shadow casters bounding info.
  131056. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  131057. * so that the system won't overwrite the bounds you provide
  131058. */
  131059. get shadowCastersBoundingInfo(): BoundingInfo;
  131060. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  131061. protected _breaksAreDirty: boolean;
  131062. protected _minDistance: number;
  131063. protected _maxDistance: number;
  131064. /**
  131065. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  131066. *
  131067. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  131068. * If you don't know these values, simply leave them to their defaults and don't call this function.
  131069. * @param min minimal distance for the breaks (default to 0.)
  131070. * @param max maximal distance for the breaks (default to 1.)
  131071. */
  131072. setMinMaxDistance(min: number, max: number): void;
  131073. /** Gets the minimal distance used in the cascade break computation */
  131074. get minDistance(): number;
  131075. /** Gets the maximal distance used in the cascade break computation */
  131076. get maxDistance(): number;
  131077. /**
  131078. * Gets the class name of that object
  131079. * @returns "CascadedShadowGenerator"
  131080. */
  131081. getClassName(): string;
  131082. private _cascadeMinExtents;
  131083. private _cascadeMaxExtents;
  131084. /**
  131085. * Gets a cascade minimum extents
  131086. * @param cascadeIndex index of the cascade
  131087. * @returns the minimum cascade extents
  131088. */
  131089. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  131090. /**
  131091. * Gets a cascade maximum extents
  131092. * @param cascadeIndex index of the cascade
  131093. * @returns the maximum cascade extents
  131094. */
  131095. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  131096. private _cascades;
  131097. private _currentLayer;
  131098. private _viewSpaceFrustumsZ;
  131099. private _viewMatrices;
  131100. private _projectionMatrices;
  131101. private _transformMatrices;
  131102. private _transformMatricesAsArray;
  131103. private _frustumLengths;
  131104. private _lightSizeUVCorrection;
  131105. private _depthCorrection;
  131106. private _frustumCornersWorldSpace;
  131107. private _frustumCenter;
  131108. private _shadowCameraPos;
  131109. private _shadowMaxZ;
  131110. /**
  131111. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  131112. * It defaults to camera.maxZ
  131113. */
  131114. get shadowMaxZ(): number;
  131115. /**
  131116. * Sets the shadow max z distance.
  131117. */
  131118. set shadowMaxZ(value: number);
  131119. protected _debug: boolean;
  131120. /**
  131121. * Gets or sets the debug flag.
  131122. * When enabled, the cascades are materialized by different colors on the screen.
  131123. */
  131124. get debug(): boolean;
  131125. set debug(dbg: boolean);
  131126. private _depthClamp;
  131127. /**
  131128. * Gets or sets the depth clamping value.
  131129. *
  131130. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  131131. * to account for the shadow casters far away.
  131132. *
  131133. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  131134. */
  131135. get depthClamp(): boolean;
  131136. set depthClamp(value: boolean);
  131137. private _cascadeBlendPercentage;
  131138. /**
  131139. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  131140. * It defaults to 0.1 (10% blending).
  131141. */
  131142. get cascadeBlendPercentage(): number;
  131143. set cascadeBlendPercentage(value: number);
  131144. private _lambda;
  131145. /**
  131146. * Gets or set the lambda parameter.
  131147. * This parameter is used to split the camera frustum and create the cascades.
  131148. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  131149. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  131150. */
  131151. get lambda(): number;
  131152. set lambda(value: number);
  131153. /**
  131154. * Gets the view matrix corresponding to a given cascade
  131155. * @param cascadeNum cascade to retrieve the view matrix from
  131156. * @returns the cascade view matrix
  131157. */
  131158. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  131159. /**
  131160. * Gets the projection matrix corresponding to a given cascade
  131161. * @param cascadeNum cascade to retrieve the projection matrix from
  131162. * @returns the cascade projection matrix
  131163. */
  131164. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  131165. /**
  131166. * Gets the transformation matrix corresponding to a given cascade
  131167. * @param cascadeNum cascade to retrieve the transformation matrix from
  131168. * @returns the cascade transformation matrix
  131169. */
  131170. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  131171. private _depthRenderer;
  131172. /**
  131173. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  131174. *
  131175. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  131176. *
  131177. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  131178. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  131179. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  131180. */
  131181. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  131182. private _depthReducer;
  131183. private _autoCalcDepthBounds;
  131184. /**
  131185. * Gets or sets the autoCalcDepthBounds property.
  131186. *
  131187. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  131188. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  131189. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  131190. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  131191. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  131192. */
  131193. get autoCalcDepthBounds(): boolean;
  131194. set autoCalcDepthBounds(value: boolean);
  131195. /**
  131196. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  131197. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  131198. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  131199. * for setting the refresh rate on the renderer yourself!
  131200. */
  131201. get autoCalcDepthBoundsRefreshRate(): number;
  131202. set autoCalcDepthBoundsRefreshRate(value: number);
  131203. /**
  131204. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  131205. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  131206. * you change the camera near/far planes!
  131207. */
  131208. splitFrustum(): void;
  131209. private _splitFrustum;
  131210. private _computeMatrices;
  131211. private _computeFrustumInWorldSpace;
  131212. private _computeCascadeFrustum;
  131213. /**
  131214. * Support test.
  131215. */
  131216. static get IsSupported(): boolean;
  131217. /** @hidden */
  131218. static _SceneComponentInitialization: (scene: Scene) => void;
  131219. /**
  131220. * Creates a Cascaded Shadow Generator object.
  131221. * A ShadowGenerator is the required tool to use the shadows.
  131222. * Each directional light casting shadows needs to use its own ShadowGenerator.
  131223. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131224. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  131225. * @param light The directional light object generating the shadows.
  131226. * @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.
  131227. */
  131228. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  131229. protected _initializeGenerator(): void;
  131230. protected _createTargetRenderTexture(): void;
  131231. protected _initializeShadowMap(): void;
  131232. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131233. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131234. /**
  131235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131236. * @param defines Defines of the material we want to update
  131237. * @param lightIndex Index of the light in the enabled light list of the material
  131238. */
  131239. prepareDefines(defines: any, lightIndex: number): void;
  131240. /**
  131241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131242. * defined in the generator but impacting the effect).
  131243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131244. * @param effect The effect we are binfing the information for
  131245. */
  131246. bindShadowLight(lightIndex: string, effect: Effect): void;
  131247. /**
  131248. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131249. * (eq to view projection * shadow projection matrices)
  131250. * @returns The transform matrix used to create the shadow map
  131251. */
  131252. getTransformMatrix(): Matrix;
  131253. /**
  131254. * Disposes the ShadowGenerator.
  131255. * Returns nothing.
  131256. */
  131257. dispose(): void;
  131258. /**
  131259. * Serializes the shadow generator setup to a json object.
  131260. * @returns The serialized JSON object
  131261. */
  131262. serialize(): any;
  131263. /**
  131264. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131265. * @param parsedShadowGenerator The JSON object to parse
  131266. * @param scene The scene to create the shadow map for
  131267. * @returns The parsed shadow generator
  131268. */
  131269. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131270. }
  131271. }
  131272. declare module BABYLON {
  131273. /**
  131274. * Defines the shadow generator component responsible to manage any shadow generators
  131275. * in a given scene.
  131276. */
  131277. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131278. /**
  131279. * The component name helpfull to identify the component in the list of scene components.
  131280. */
  131281. readonly name: string;
  131282. /**
  131283. * The scene the component belongs to.
  131284. */
  131285. scene: Scene;
  131286. /**
  131287. * Creates a new instance of the component for the given scene
  131288. * @param scene Defines the scene to register the component in
  131289. */
  131290. constructor(scene: Scene);
  131291. /**
  131292. * Registers the component in a given scene
  131293. */
  131294. register(): void;
  131295. /**
  131296. * Rebuilds the elements related to this component in case of
  131297. * context lost for instance.
  131298. */
  131299. rebuild(): void;
  131300. /**
  131301. * Serializes the component data to the specified json object
  131302. * @param serializationObject The object to serialize to
  131303. */
  131304. serialize(serializationObject: any): void;
  131305. /**
  131306. * Adds all the elements from the container to the scene
  131307. * @param container the container holding the elements
  131308. */
  131309. addFromContainer(container: AbstractScene): void;
  131310. /**
  131311. * Removes all the elements in the container from the scene
  131312. * @param container contains the elements to remove
  131313. * @param dispose if the removed element should be disposed (default: false)
  131314. */
  131315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131316. /**
  131317. * Rebuilds the elements related to this component in case of
  131318. * context lost for instance.
  131319. */
  131320. dispose(): void;
  131321. private _gatherRenderTargets;
  131322. }
  131323. }
  131324. declare module BABYLON {
  131325. /**
  131326. * A point light is a light defined by an unique point in world space.
  131327. * The light is emitted in every direction from this point.
  131328. * A good example of a point light is a standard light bulb.
  131329. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131330. */
  131331. export class PointLight extends ShadowLight {
  131332. private _shadowAngle;
  131333. /**
  131334. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131335. * This specifies what angle the shadow will use to be created.
  131336. *
  131337. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131338. */
  131339. get shadowAngle(): number;
  131340. /**
  131341. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131342. * This specifies what angle the shadow will use to be created.
  131343. *
  131344. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131345. */
  131346. set shadowAngle(value: number);
  131347. /**
  131348. * Gets the direction if it has been set.
  131349. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131350. */
  131351. get direction(): Vector3;
  131352. /**
  131353. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131354. */
  131355. set direction(value: Vector3);
  131356. /**
  131357. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131358. * A PointLight emits the light in every direction.
  131359. * It can cast shadows.
  131360. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131361. * ```javascript
  131362. * var pointLight = new PointLight("pl", camera.position, scene);
  131363. * ```
  131364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131365. * @param name The light friendly name
  131366. * @param position The position of the point light in the scene
  131367. * @param scene The scene the lights belongs to
  131368. */
  131369. constructor(name: string, position: Vector3, scene: Scene);
  131370. /**
  131371. * Returns the string "PointLight"
  131372. * @returns the class name
  131373. */
  131374. getClassName(): string;
  131375. /**
  131376. * Returns the integer 0.
  131377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131378. */
  131379. getTypeID(): number;
  131380. /**
  131381. * Specifies wether or not the shadowmap should be a cube texture.
  131382. * @returns true if the shadowmap needs to be a cube texture.
  131383. */
  131384. needCube(): boolean;
  131385. /**
  131386. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131387. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131388. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131389. */
  131390. getShadowDirection(faceIndex?: number): Vector3;
  131391. /**
  131392. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131393. * - fov = PI / 2
  131394. * - aspect ratio : 1.0
  131395. * - z-near and far equal to the active camera minZ and maxZ.
  131396. * Returns the PointLight.
  131397. */
  131398. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131399. protected _buildUniformLayout(): void;
  131400. /**
  131401. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131402. * @param effect The effect to update
  131403. * @param lightIndex The index of the light in the effect to update
  131404. * @returns The point light
  131405. */
  131406. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131407. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131408. /**
  131409. * Prepares the list of defines specific to the light type.
  131410. * @param defines the list of defines
  131411. * @param lightIndex defines the index of the light for the effect
  131412. */
  131413. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131414. }
  131415. }
  131416. declare module BABYLON {
  131417. /**
  131418. * Header information of HDR texture files.
  131419. */
  131420. export interface HDRInfo {
  131421. /**
  131422. * The height of the texture in pixels.
  131423. */
  131424. height: number;
  131425. /**
  131426. * The width of the texture in pixels.
  131427. */
  131428. width: number;
  131429. /**
  131430. * The index of the beginning of the data in the binary file.
  131431. */
  131432. dataPosition: number;
  131433. }
  131434. /**
  131435. * This groups tools to convert HDR texture to native colors array.
  131436. */
  131437. export class HDRTools {
  131438. private static Ldexp;
  131439. private static Rgbe2float;
  131440. private static readStringLine;
  131441. /**
  131442. * Reads header information from an RGBE texture stored in a native array.
  131443. * More information on this format are available here:
  131444. * https://en.wikipedia.org/wiki/RGBE_image_format
  131445. *
  131446. * @param uint8array The binary file stored in native array.
  131447. * @return The header information.
  131448. */
  131449. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131450. /**
  131451. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131452. * This RGBE texture needs to store the information as a panorama.
  131453. *
  131454. * More information on this format are available here:
  131455. * https://en.wikipedia.org/wiki/RGBE_image_format
  131456. *
  131457. * @param buffer The binary file stored in an array buffer.
  131458. * @param size The expected size of the extracted cubemap.
  131459. * @return The Cube Map information.
  131460. */
  131461. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131462. /**
  131463. * Returns the pixels data extracted from an RGBE texture.
  131464. * This pixels will be stored left to right up to down in the R G B order in one array.
  131465. *
  131466. * More information on this format are available here:
  131467. * https://en.wikipedia.org/wiki/RGBE_image_format
  131468. *
  131469. * @param uint8array The binary file stored in an array buffer.
  131470. * @param hdrInfo The header information of the file.
  131471. * @return The pixels data in RGB right to left up to down order.
  131472. */
  131473. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131474. private static RGBE_ReadPixels_RLE;
  131475. }
  131476. }
  131477. declare module BABYLON {
  131478. /**
  131479. * This represents a texture coming from an HDR input.
  131480. *
  131481. * The only supported format is currently panorama picture stored in RGBE format.
  131482. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131483. */
  131484. export class HDRCubeTexture extends BaseTexture {
  131485. private static _facesMapping;
  131486. private _generateHarmonics;
  131487. private _noMipmap;
  131488. private _textureMatrix;
  131489. private _size;
  131490. private _onLoad;
  131491. private _onError;
  131492. /**
  131493. * The texture URL.
  131494. */
  131495. url: string;
  131496. /**
  131497. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131498. */
  131499. coordinatesMode: number;
  131500. protected _isBlocking: boolean;
  131501. /**
  131502. * Sets wether or not the texture is blocking during loading.
  131503. */
  131504. set isBlocking(value: boolean);
  131505. /**
  131506. * Gets wether or not the texture is blocking during loading.
  131507. */
  131508. get isBlocking(): boolean;
  131509. protected _rotationY: number;
  131510. /**
  131511. * Sets texture matrix rotation angle around Y axis in radians.
  131512. */
  131513. set rotationY(value: number);
  131514. /**
  131515. * Gets texture matrix rotation angle around Y axis radians.
  131516. */
  131517. get rotationY(): number;
  131518. /**
  131519. * Gets or sets the center of the bounding box associated with the cube texture
  131520. * It must define where the camera used to render the texture was set
  131521. */
  131522. boundingBoxPosition: Vector3;
  131523. private _boundingBoxSize;
  131524. /**
  131525. * Gets or sets the size of the bounding box associated with the cube texture
  131526. * When defined, the cubemap will switch to local mode
  131527. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131528. * @example https://www.babylonjs-playground.com/#RNASML
  131529. */
  131530. set boundingBoxSize(value: Vector3);
  131531. get boundingBoxSize(): Vector3;
  131532. /**
  131533. * Instantiates an HDRTexture from the following parameters.
  131534. *
  131535. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131536. * @param sceneOrEngine The scene or engine the texture will be used in
  131537. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131538. * @param noMipmap Forces to not generate the mipmap if true
  131539. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131540. * @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)
  131541. * @param reserved Reserved flag for internal use.
  131542. */
  131543. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  131544. /**
  131545. * Get the current class name of the texture useful for serialization or dynamic coding.
  131546. * @returns "HDRCubeTexture"
  131547. */
  131548. getClassName(): string;
  131549. /**
  131550. * Occurs when the file is raw .hdr file.
  131551. */
  131552. private loadTexture;
  131553. clone(): HDRCubeTexture;
  131554. delayLoad(): void;
  131555. /**
  131556. * Get the texture reflection matrix used to rotate/transform the reflection.
  131557. * @returns the reflection matrix
  131558. */
  131559. getReflectionTextureMatrix(): Matrix;
  131560. /**
  131561. * Set the texture reflection matrix used to rotate/transform the reflection.
  131562. * @param value Define the reflection matrix to set
  131563. */
  131564. setReflectionTextureMatrix(value: Matrix): void;
  131565. /**
  131566. * Parses a JSON representation of an HDR Texture in order to create the texture
  131567. * @param parsedTexture Define the JSON representation
  131568. * @param scene Define the scene the texture should be created in
  131569. * @param rootUrl Define the root url in case we need to load relative dependencies
  131570. * @returns the newly created texture after parsing
  131571. */
  131572. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131573. serialize(): any;
  131574. }
  131575. }
  131576. declare module BABYLON {
  131577. /**
  131578. * Class used to control physics engine
  131579. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131580. */
  131581. export class PhysicsEngine implements IPhysicsEngine {
  131582. private _physicsPlugin;
  131583. /**
  131584. * Global value used to control the smallest number supported by the simulation
  131585. */
  131586. static Epsilon: number;
  131587. private _impostors;
  131588. private _joints;
  131589. private _subTimeStep;
  131590. /**
  131591. * Gets the gravity vector used by the simulation
  131592. */
  131593. gravity: Vector3;
  131594. /**
  131595. * Factory used to create the default physics plugin.
  131596. * @returns The default physics plugin
  131597. */
  131598. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131599. /**
  131600. * Creates a new Physics Engine
  131601. * @param gravity defines the gravity vector used by the simulation
  131602. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131603. */
  131604. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131605. /**
  131606. * Sets the gravity vector used by the simulation
  131607. * @param gravity defines the gravity vector to use
  131608. */
  131609. setGravity(gravity: Vector3): void;
  131610. /**
  131611. * Set the time step of the physics engine.
  131612. * Default is 1/60.
  131613. * To slow it down, enter 1/600 for example.
  131614. * To speed it up, 1/30
  131615. * @param newTimeStep defines the new timestep to apply to this world.
  131616. */
  131617. setTimeStep(newTimeStep?: number): void;
  131618. /**
  131619. * Get the time step of the physics engine.
  131620. * @returns the current time step
  131621. */
  131622. getTimeStep(): number;
  131623. /**
  131624. * Set the sub time step of the physics engine.
  131625. * Default is 0 meaning there is no sub steps
  131626. * To increase physics resolution precision, set a small value (like 1 ms)
  131627. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131628. */
  131629. setSubTimeStep(subTimeStep?: number): void;
  131630. /**
  131631. * Get the sub time step of the physics engine.
  131632. * @returns the current sub time step
  131633. */
  131634. getSubTimeStep(): number;
  131635. /**
  131636. * Release all resources
  131637. */
  131638. dispose(): void;
  131639. /**
  131640. * Gets the name of the current physics plugin
  131641. * @returns the name of the plugin
  131642. */
  131643. getPhysicsPluginName(): string;
  131644. /**
  131645. * Adding a new impostor for the impostor tracking.
  131646. * This will be done by the impostor itself.
  131647. * @param impostor the impostor to add
  131648. */
  131649. addImpostor(impostor: PhysicsImpostor): void;
  131650. /**
  131651. * Remove an impostor from the engine.
  131652. * This impostor and its mesh will not longer be updated by the physics engine.
  131653. * @param impostor the impostor to remove
  131654. */
  131655. removeImpostor(impostor: PhysicsImpostor): void;
  131656. /**
  131657. * Add a joint to the physics engine
  131658. * @param mainImpostor defines the main impostor to which the joint is added.
  131659. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131660. * @param joint defines the joint that will connect both impostors.
  131661. */
  131662. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131663. /**
  131664. * Removes a joint from the simulation
  131665. * @param mainImpostor defines the impostor used with the joint
  131666. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131667. * @param joint defines the joint to remove
  131668. */
  131669. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131670. /**
  131671. * Called by the scene. No need to call it.
  131672. * @param delta defines the timespam between frames
  131673. */
  131674. _step(delta: number): void;
  131675. /**
  131676. * Gets the current plugin used to run the simulation
  131677. * @returns current plugin
  131678. */
  131679. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131680. /**
  131681. * Gets the list of physic impostors
  131682. * @returns an array of PhysicsImpostor
  131683. */
  131684. getImpostors(): Array<PhysicsImpostor>;
  131685. /**
  131686. * Gets the impostor for a physics enabled object
  131687. * @param object defines the object impersonated by the impostor
  131688. * @returns the PhysicsImpostor or null if not found
  131689. */
  131690. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131691. /**
  131692. * Gets the impostor for a physics body object
  131693. * @param body defines physics body used by the impostor
  131694. * @returns the PhysicsImpostor or null if not found
  131695. */
  131696. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131697. /**
  131698. * Does a raycast in the physics world
  131699. * @param from when should the ray start?
  131700. * @param to when should the ray end?
  131701. * @returns PhysicsRaycastResult
  131702. */
  131703. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131704. }
  131705. }
  131706. declare module BABYLON {
  131707. /** @hidden */
  131708. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131709. private _useDeltaForWorldStep;
  131710. world: any;
  131711. name: string;
  131712. private _physicsMaterials;
  131713. private _fixedTimeStep;
  131714. private _cannonRaycastResult;
  131715. private _raycastResult;
  131716. private _physicsBodysToRemoveAfterStep;
  131717. BJSCANNON: any;
  131718. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131719. setGravity(gravity: Vector3): void;
  131720. setTimeStep(timeStep: number): void;
  131721. getTimeStep(): number;
  131722. executeStep(delta: number): void;
  131723. private _removeMarkedPhysicsBodiesFromWorld;
  131724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131727. private _processChildMeshes;
  131728. removePhysicsBody(impostor: PhysicsImpostor): void;
  131729. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131730. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131731. private _addMaterial;
  131732. private _checkWithEpsilon;
  131733. private _createShape;
  131734. private _createHeightmap;
  131735. private _minus90X;
  131736. private _plus90X;
  131737. private _tmpPosition;
  131738. private _tmpDeltaPosition;
  131739. private _tmpUnityRotation;
  131740. private _updatePhysicsBodyTransformation;
  131741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131743. isSupported(): boolean;
  131744. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131745. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131746. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131747. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131748. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131749. getBodyMass(impostor: PhysicsImpostor): number;
  131750. getBodyFriction(impostor: PhysicsImpostor): number;
  131751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131752. getBodyRestitution(impostor: PhysicsImpostor): number;
  131753. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131754. sleepBody(impostor: PhysicsImpostor): void;
  131755. wakeUpBody(impostor: PhysicsImpostor): void;
  131756. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131757. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131758. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131759. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131760. getRadius(impostor: PhysicsImpostor): number;
  131761. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131762. dispose(): void;
  131763. private _extendNamespace;
  131764. /**
  131765. * Does a raycast in the physics world
  131766. * @param from when should the ray start?
  131767. * @param to when should the ray end?
  131768. * @returns PhysicsRaycastResult
  131769. */
  131770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131771. }
  131772. }
  131773. declare module BABYLON {
  131774. /** @hidden */
  131775. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131776. private _useDeltaForWorldStep;
  131777. world: any;
  131778. name: string;
  131779. BJSOIMO: any;
  131780. private _raycastResult;
  131781. private _fixedTimeStep;
  131782. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131783. setGravity(gravity: Vector3): void;
  131784. setTimeStep(timeStep: number): void;
  131785. getTimeStep(): number;
  131786. private _tmpImpostorsArray;
  131787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131788. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131789. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131790. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131791. private _tmpPositionVector;
  131792. removePhysicsBody(impostor: PhysicsImpostor): void;
  131793. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131794. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131795. isSupported(): boolean;
  131796. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131797. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131799. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131800. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131801. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131803. getBodyMass(impostor: PhysicsImpostor): number;
  131804. getBodyFriction(impostor: PhysicsImpostor): number;
  131805. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131806. getBodyRestitution(impostor: PhysicsImpostor): number;
  131807. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131808. sleepBody(impostor: PhysicsImpostor): void;
  131809. wakeUpBody(impostor: PhysicsImpostor): void;
  131810. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131811. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131812. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131813. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131814. getRadius(impostor: PhysicsImpostor): number;
  131815. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131816. dispose(): void;
  131817. /**
  131818. * Does a raycast in the physics world
  131819. * @param from when should the ray start?
  131820. * @param to when should the ray end?
  131821. * @returns PhysicsRaycastResult
  131822. */
  131823. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131824. }
  131825. }
  131826. declare module BABYLON {
  131827. /**
  131828. * Class containing static functions to help procedurally build meshes
  131829. */
  131830. export class RibbonBuilder {
  131831. /**
  131832. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131833. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131834. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131835. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131836. * * 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
  131837. * * 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
  131838. * * 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
  131839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131842. * * 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
  131843. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131844. * * 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
  131845. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131847. * @param name defines the name of the mesh
  131848. * @param options defines the options used to create the mesh
  131849. * @param scene defines the hosting scene
  131850. * @returns the ribbon mesh
  131851. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131852. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131853. */
  131854. static CreateRibbon(name: string, options: {
  131855. pathArray: Vector3[][];
  131856. closeArray?: boolean;
  131857. closePath?: boolean;
  131858. offset?: number;
  131859. updatable?: boolean;
  131860. sideOrientation?: number;
  131861. frontUVs?: Vector4;
  131862. backUVs?: Vector4;
  131863. instance?: Mesh;
  131864. invertUV?: boolean;
  131865. uvs?: Vector2[];
  131866. colors?: Color4[];
  131867. }, scene?: Nullable<Scene>): Mesh;
  131868. }
  131869. }
  131870. declare module BABYLON {
  131871. /**
  131872. * Class containing static functions to help procedurally build meshes
  131873. */
  131874. export class ShapeBuilder {
  131875. /**
  131876. * 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.
  131877. * * 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.
  131878. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131879. * * 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.
  131880. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131881. * * 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
  131882. * * 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
  131883. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131888. * @param name defines the name of the mesh
  131889. * @param options defines the options used to create the mesh
  131890. * @param scene defines the hosting scene
  131891. * @returns the extruded shape mesh
  131892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131894. */
  131895. static ExtrudeShape(name: string, options: {
  131896. shape: Vector3[];
  131897. path: Vector3[];
  131898. scale?: number;
  131899. rotation?: number;
  131900. cap?: number;
  131901. updatable?: boolean;
  131902. sideOrientation?: number;
  131903. frontUVs?: Vector4;
  131904. backUVs?: Vector4;
  131905. instance?: Mesh;
  131906. invertUV?: boolean;
  131907. }, scene?: Nullable<Scene>): Mesh;
  131908. /**
  131909. * Creates an custom extruded shape mesh.
  131910. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131911. * * 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.
  131912. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131913. * * 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
  131914. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131915. * * 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
  131916. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131917. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131918. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131919. * * 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
  131920. * * 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
  131921. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131924. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131926. * @param name defines the name of the mesh
  131927. * @param options defines the options used to create the mesh
  131928. * @param scene defines the hosting scene
  131929. * @returns the custom extruded shape mesh
  131930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131933. */
  131934. static ExtrudeShapeCustom(name: string, options: {
  131935. shape: Vector3[];
  131936. path: Vector3[];
  131937. scaleFunction?: any;
  131938. rotationFunction?: any;
  131939. ribbonCloseArray?: boolean;
  131940. ribbonClosePath?: boolean;
  131941. cap?: number;
  131942. updatable?: boolean;
  131943. sideOrientation?: number;
  131944. frontUVs?: Vector4;
  131945. backUVs?: Vector4;
  131946. instance?: Mesh;
  131947. invertUV?: boolean;
  131948. }, scene?: Nullable<Scene>): Mesh;
  131949. private static _ExtrudeShapeGeneric;
  131950. }
  131951. }
  131952. declare module BABYLON {
  131953. /**
  131954. * AmmoJS Physics plugin
  131955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131956. * @see https://github.com/kripken/ammo.js/
  131957. */
  131958. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  131959. private _useDeltaForWorldStep;
  131960. /**
  131961. * Reference to the Ammo library
  131962. */
  131963. bjsAMMO: any;
  131964. /**
  131965. * Created ammoJS world which physics bodies are added to
  131966. */
  131967. world: any;
  131968. /**
  131969. * Name of the plugin
  131970. */
  131971. name: string;
  131972. private _timeStep;
  131973. private _fixedTimeStep;
  131974. private _maxSteps;
  131975. private _tmpQuaternion;
  131976. private _tmpAmmoTransform;
  131977. private _tmpAmmoQuaternion;
  131978. private _tmpAmmoConcreteContactResultCallback;
  131979. private _collisionConfiguration;
  131980. private _dispatcher;
  131981. private _overlappingPairCache;
  131982. private _solver;
  131983. private _softBodySolver;
  131984. private _tmpAmmoVectorA;
  131985. private _tmpAmmoVectorB;
  131986. private _tmpAmmoVectorC;
  131987. private _tmpAmmoVectorD;
  131988. private _tmpContactCallbackResult;
  131989. private _tmpAmmoVectorRCA;
  131990. private _tmpAmmoVectorRCB;
  131991. private _raycastResult;
  131992. private static readonly DISABLE_COLLISION_FLAG;
  131993. private static readonly KINEMATIC_FLAG;
  131994. private static readonly DISABLE_DEACTIVATION_FLAG;
  131995. /**
  131996. * Initializes the ammoJS plugin
  131997. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  131998. * @param ammoInjection can be used to inject your own ammo reference
  131999. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  132000. */
  132001. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  132002. /**
  132003. * Sets the gravity of the physics world (m/(s^2))
  132004. * @param gravity Gravity to set
  132005. */
  132006. setGravity(gravity: Vector3): void;
  132007. /**
  132008. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  132009. * @param timeStep timestep to use in seconds
  132010. */
  132011. setTimeStep(timeStep: number): void;
  132012. /**
  132013. * 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)
  132014. * @param fixedTimeStep fixedTimeStep to use in seconds
  132015. */
  132016. setFixedTimeStep(fixedTimeStep: number): void;
  132017. /**
  132018. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  132019. * @param maxSteps the maximum number of steps by the physics engine per frame
  132020. */
  132021. setMaxSteps(maxSteps: number): void;
  132022. /**
  132023. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  132024. * @returns the current timestep in seconds
  132025. */
  132026. getTimeStep(): number;
  132027. /**
  132028. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  132029. */
  132030. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  132031. private _isImpostorInContact;
  132032. private _isImpostorPairInContact;
  132033. private _stepSimulation;
  132034. /**
  132035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  132036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  132037. * After the step the babylon meshes are set to the position of the physics imposters
  132038. * @param delta amount of time to step forward
  132039. * @param impostors array of imposters to update before/after the step
  132040. */
  132041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  132042. /**
  132043. * Update babylon mesh to match physics world object
  132044. * @param impostor imposter to match
  132045. */
  132046. private _afterSoftStep;
  132047. /**
  132048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132049. * @param impostor imposter to match
  132050. */
  132051. private _ropeStep;
  132052. /**
  132053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  132054. * @param impostor imposter to match
  132055. */
  132056. private _softbodyOrClothStep;
  132057. private _tmpMatrix;
  132058. /**
  132059. * Applies an impulse on the imposter
  132060. * @param impostor imposter to apply impulse to
  132061. * @param force amount of force to be applied to the imposter
  132062. * @param contactPoint the location to apply the impulse on the imposter
  132063. */
  132064. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132065. /**
  132066. * Applies a force on the imposter
  132067. * @param impostor imposter to apply force
  132068. * @param force amount of force to be applied to the imposter
  132069. * @param contactPoint the location to apply the force on the imposter
  132070. */
  132071. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  132072. /**
  132073. * Creates a physics body using the plugin
  132074. * @param impostor the imposter to create the physics body on
  132075. */
  132076. generatePhysicsBody(impostor: PhysicsImpostor): void;
  132077. /**
  132078. * Removes the physics body from the imposter and disposes of the body's memory
  132079. * @param impostor imposter to remove the physics body from
  132080. */
  132081. removePhysicsBody(impostor: PhysicsImpostor): void;
  132082. /**
  132083. * Generates a joint
  132084. * @param impostorJoint the imposter joint to create the joint with
  132085. */
  132086. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  132087. /**
  132088. * Removes a joint
  132089. * @param impostorJoint the imposter joint to remove the joint from
  132090. */
  132091. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  132092. private _addMeshVerts;
  132093. /**
  132094. * Initialise the soft body vertices to match its object's (mesh) vertices
  132095. * Softbody vertices (nodes) are in world space and to match this
  132096. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  132097. * @param impostor to create the softbody for
  132098. */
  132099. private _softVertexData;
  132100. /**
  132101. * Create an impostor's soft body
  132102. * @param impostor to create the softbody for
  132103. */
  132104. private _createSoftbody;
  132105. /**
  132106. * Create cloth for an impostor
  132107. * @param impostor to create the softbody for
  132108. */
  132109. private _createCloth;
  132110. /**
  132111. * Create rope for an impostor
  132112. * @param impostor to create the softbody for
  132113. */
  132114. private _createRope;
  132115. /**
  132116. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  132117. * @param impostor to create the custom physics shape for
  132118. */
  132119. private _createCustom;
  132120. private _addHullVerts;
  132121. private _createShape;
  132122. /**
  132123. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  132124. * @param impostor imposter containing the physics body and babylon object
  132125. */
  132126. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  132127. /**
  132128. * Sets the babylon object's position/rotation from the physics body's position/rotation
  132129. * @param impostor imposter containing the physics body and babylon object
  132130. * @param newPosition new position
  132131. * @param newRotation new rotation
  132132. */
  132133. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  132134. /**
  132135. * If this plugin is supported
  132136. * @returns true if its supported
  132137. */
  132138. isSupported(): boolean;
  132139. /**
  132140. * Sets the linear velocity of the physics body
  132141. * @param impostor imposter to set the velocity on
  132142. * @param velocity velocity to set
  132143. */
  132144. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132145. /**
  132146. * Sets the angular velocity of the physics body
  132147. * @param impostor imposter to set the velocity on
  132148. * @param velocity velocity to set
  132149. */
  132150. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  132151. /**
  132152. * gets the linear velocity
  132153. * @param impostor imposter to get linear velocity from
  132154. * @returns linear velocity
  132155. */
  132156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132157. /**
  132158. * gets the angular velocity
  132159. * @param impostor imposter to get angular velocity from
  132160. * @returns angular velocity
  132161. */
  132162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  132163. /**
  132164. * Sets the mass of physics body
  132165. * @param impostor imposter to set the mass on
  132166. * @param mass mass to set
  132167. */
  132168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  132169. /**
  132170. * Gets the mass of the physics body
  132171. * @param impostor imposter to get the mass from
  132172. * @returns mass
  132173. */
  132174. getBodyMass(impostor: PhysicsImpostor): number;
  132175. /**
  132176. * Gets friction of the impostor
  132177. * @param impostor impostor to get friction from
  132178. * @returns friction value
  132179. */
  132180. getBodyFriction(impostor: PhysicsImpostor): number;
  132181. /**
  132182. * Sets friction of the impostor
  132183. * @param impostor impostor to set friction on
  132184. * @param friction friction value
  132185. */
  132186. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  132187. /**
  132188. * Gets restitution of the impostor
  132189. * @param impostor impostor to get restitution from
  132190. * @returns restitution value
  132191. */
  132192. getBodyRestitution(impostor: PhysicsImpostor): number;
  132193. /**
  132194. * Sets resitution of the impostor
  132195. * @param impostor impostor to set resitution on
  132196. * @param restitution resitution value
  132197. */
  132198. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  132199. /**
  132200. * Gets pressure inside the impostor
  132201. * @param impostor impostor to get pressure from
  132202. * @returns pressure value
  132203. */
  132204. getBodyPressure(impostor: PhysicsImpostor): number;
  132205. /**
  132206. * Sets pressure inside a soft body impostor
  132207. * Cloth and rope must remain 0 pressure
  132208. * @param impostor impostor to set pressure on
  132209. * @param pressure pressure value
  132210. */
  132211. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  132212. /**
  132213. * Gets stiffness of the impostor
  132214. * @param impostor impostor to get stiffness from
  132215. * @returns pressure value
  132216. */
  132217. getBodyStiffness(impostor: PhysicsImpostor): number;
  132218. /**
  132219. * Sets stiffness of the impostor
  132220. * @param impostor impostor to set stiffness on
  132221. * @param stiffness stiffness value from 0 to 1
  132222. */
  132223. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  132224. /**
  132225. * Gets velocityIterations of the impostor
  132226. * @param impostor impostor to get velocity iterations from
  132227. * @returns velocityIterations value
  132228. */
  132229. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  132230. /**
  132231. * Sets velocityIterations of the impostor
  132232. * @param impostor impostor to set velocity iterations on
  132233. * @param velocityIterations velocityIterations value
  132234. */
  132235. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132236. /**
  132237. * Gets positionIterations of the impostor
  132238. * @param impostor impostor to get position iterations from
  132239. * @returns positionIterations value
  132240. */
  132241. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132242. /**
  132243. * Sets positionIterations of the impostor
  132244. * @param impostor impostor to set position on
  132245. * @param positionIterations positionIterations value
  132246. */
  132247. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132248. /**
  132249. * Append an anchor to a cloth object
  132250. * @param impostor is the cloth impostor to add anchor to
  132251. * @param otherImpostor is the rigid impostor to anchor to
  132252. * @param width ratio across width from 0 to 1
  132253. * @param height ratio up height from 0 to 1
  132254. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132255. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132256. */
  132257. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132258. /**
  132259. * Append an hook to a rope object
  132260. * @param impostor is the rope impostor to add hook to
  132261. * @param otherImpostor is the rigid impostor to hook to
  132262. * @param length ratio along the rope from 0 to 1
  132263. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132264. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132265. */
  132266. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132267. /**
  132268. * Sleeps the physics body and stops it from being active
  132269. * @param impostor impostor to sleep
  132270. */
  132271. sleepBody(impostor: PhysicsImpostor): void;
  132272. /**
  132273. * Activates the physics body
  132274. * @param impostor impostor to activate
  132275. */
  132276. wakeUpBody(impostor: PhysicsImpostor): void;
  132277. /**
  132278. * Updates the distance parameters of the joint
  132279. * @param joint joint to update
  132280. * @param maxDistance maximum distance of the joint
  132281. * @param minDistance minimum distance of the joint
  132282. */
  132283. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132284. /**
  132285. * Sets a motor on the joint
  132286. * @param joint joint to set motor on
  132287. * @param speed speed of the motor
  132288. * @param maxForce maximum force of the motor
  132289. * @param motorIndex index of the motor
  132290. */
  132291. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132292. /**
  132293. * Sets the motors limit
  132294. * @param joint joint to set limit on
  132295. * @param upperLimit upper limit
  132296. * @param lowerLimit lower limit
  132297. */
  132298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132299. /**
  132300. * Syncs the position and rotation of a mesh with the impostor
  132301. * @param mesh mesh to sync
  132302. * @param impostor impostor to update the mesh with
  132303. */
  132304. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132305. /**
  132306. * Gets the radius of the impostor
  132307. * @param impostor impostor to get radius from
  132308. * @returns the radius
  132309. */
  132310. getRadius(impostor: PhysicsImpostor): number;
  132311. /**
  132312. * Gets the box size of the impostor
  132313. * @param impostor impostor to get box size from
  132314. * @param result the resulting box size
  132315. */
  132316. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132317. /**
  132318. * Disposes of the impostor
  132319. */
  132320. dispose(): void;
  132321. /**
  132322. * Does a raycast in the physics world
  132323. * @param from when should the ray start?
  132324. * @param to when should the ray end?
  132325. * @returns PhysicsRaycastResult
  132326. */
  132327. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132328. }
  132329. }
  132330. declare module BABYLON {
  132331. interface AbstractScene {
  132332. /**
  132333. * The list of reflection probes added to the scene
  132334. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132335. */
  132336. reflectionProbes: Array<ReflectionProbe>;
  132337. /**
  132338. * Removes the given reflection probe from this scene.
  132339. * @param toRemove The reflection probe to remove
  132340. * @returns The index of the removed reflection probe
  132341. */
  132342. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132343. /**
  132344. * Adds the given reflection probe to this scene.
  132345. * @param newReflectionProbe The reflection probe to add
  132346. */
  132347. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132348. }
  132349. /**
  132350. * Class used to generate realtime reflection / refraction cube textures
  132351. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132352. */
  132353. export class ReflectionProbe {
  132354. /** defines the name of the probe */
  132355. name: string;
  132356. private _scene;
  132357. private _renderTargetTexture;
  132358. private _projectionMatrix;
  132359. private _viewMatrix;
  132360. private _target;
  132361. private _add;
  132362. private _attachedMesh;
  132363. private _invertYAxis;
  132364. /** Gets or sets probe position (center of the cube map) */
  132365. position: Vector3;
  132366. /**
  132367. * Creates a new reflection probe
  132368. * @param name defines the name of the probe
  132369. * @param size defines the texture resolution (for each face)
  132370. * @param scene defines the hosting scene
  132371. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132372. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132373. */
  132374. constructor(
  132375. /** defines the name of the probe */
  132376. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132377. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132378. get samples(): number;
  132379. set samples(value: number);
  132380. /** Gets or sets the refresh rate to use (on every frame by default) */
  132381. get refreshRate(): number;
  132382. set refreshRate(value: number);
  132383. /**
  132384. * Gets the hosting scene
  132385. * @returns a Scene
  132386. */
  132387. getScene(): Scene;
  132388. /** Gets the internal CubeTexture used to render to */
  132389. get cubeTexture(): RenderTargetTexture;
  132390. /** Gets the list of meshes to render */
  132391. get renderList(): Nullable<AbstractMesh[]>;
  132392. /**
  132393. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132394. * @param mesh defines the mesh to attach to
  132395. */
  132396. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132397. /**
  132398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132399. * @param renderingGroupId The rendering group id corresponding to its index
  132400. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132401. */
  132402. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132403. /**
  132404. * Clean all associated resources
  132405. */
  132406. dispose(): void;
  132407. /**
  132408. * Converts the reflection probe information to a readable string for debug purpose.
  132409. * @param fullDetails Supports for multiple levels of logging within scene loading
  132410. * @returns the human readable reflection probe info
  132411. */
  132412. toString(fullDetails?: boolean): string;
  132413. /**
  132414. * Get the class name of the relfection probe.
  132415. * @returns "ReflectionProbe"
  132416. */
  132417. getClassName(): string;
  132418. /**
  132419. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132420. * @returns The JSON representation of the texture
  132421. */
  132422. serialize(): any;
  132423. /**
  132424. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132425. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132426. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132427. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132428. * @returns The parsed reflection probe if successful
  132429. */
  132430. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132431. }
  132432. }
  132433. declare module BABYLON {
  132434. /** @hidden */
  132435. export var _BabylonLoaderRegistered: boolean;
  132436. /**
  132437. * Helps setting up some configuration for the babylon file loader.
  132438. */
  132439. export class BabylonFileLoaderConfiguration {
  132440. /**
  132441. * The loader does not allow injecting custom physix engine into the plugins.
  132442. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132443. * So you could set this variable to your engine import to make it work.
  132444. */
  132445. static LoaderInjectedPhysicsEngine: any;
  132446. }
  132447. }
  132448. declare module BABYLON {
  132449. /**
  132450. * The Physically based simple base material of BJS.
  132451. *
  132452. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132453. * It is used as the base class for both the specGloss and metalRough conventions.
  132454. */
  132455. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132456. /**
  132457. * Number of Simultaneous lights allowed on the material.
  132458. */
  132459. maxSimultaneousLights: number;
  132460. /**
  132461. * If sets to true, disables all the lights affecting the material.
  132462. */
  132463. disableLighting: boolean;
  132464. /**
  132465. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132466. */
  132467. environmentTexture: BaseTexture;
  132468. /**
  132469. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132470. */
  132471. invertNormalMapX: boolean;
  132472. /**
  132473. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132474. */
  132475. invertNormalMapY: boolean;
  132476. /**
  132477. * Normal map used in the model.
  132478. */
  132479. normalTexture: BaseTexture;
  132480. /**
  132481. * Emissivie color used to self-illuminate the model.
  132482. */
  132483. emissiveColor: Color3;
  132484. /**
  132485. * Emissivie texture used to self-illuminate the model.
  132486. */
  132487. emissiveTexture: BaseTexture;
  132488. /**
  132489. * Occlusion Channel Strenght.
  132490. */
  132491. occlusionStrength: number;
  132492. /**
  132493. * Occlusion Texture of the material (adding extra occlusion effects).
  132494. */
  132495. occlusionTexture: BaseTexture;
  132496. /**
  132497. * Defines the alpha limits in alpha test mode.
  132498. */
  132499. alphaCutOff: number;
  132500. /**
  132501. * Gets the current double sided mode.
  132502. */
  132503. get doubleSided(): boolean;
  132504. /**
  132505. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132506. */
  132507. set doubleSided(value: boolean);
  132508. /**
  132509. * Stores the pre-calculated light information of a mesh in a texture.
  132510. */
  132511. lightmapTexture: BaseTexture;
  132512. /**
  132513. * If true, the light map contains occlusion information instead of lighting info.
  132514. */
  132515. useLightmapAsShadowmap: boolean;
  132516. /**
  132517. * Instantiates a new PBRMaterial instance.
  132518. *
  132519. * @param name The material name
  132520. * @param scene The scene the material will be use in.
  132521. */
  132522. constructor(name: string, scene: Scene);
  132523. getClassName(): string;
  132524. }
  132525. }
  132526. declare module BABYLON {
  132527. /**
  132528. * The PBR material of BJS following the metal roughness convention.
  132529. *
  132530. * This fits to the PBR convention in the GLTF definition:
  132531. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132532. */
  132533. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132534. /**
  132535. * The base color has two different interpretations depending on the value of metalness.
  132536. * When the material is a metal, the base color is the specific measured reflectance value
  132537. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132538. * of the material.
  132539. */
  132540. baseColor: Color3;
  132541. /**
  132542. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132543. * well as opacity information in the alpha channel.
  132544. */
  132545. baseTexture: BaseTexture;
  132546. /**
  132547. * Specifies the metallic scalar value of the material.
  132548. * Can also be used to scale the metalness values of the metallic texture.
  132549. */
  132550. metallic: number;
  132551. /**
  132552. * Specifies the roughness scalar value of the material.
  132553. * Can also be used to scale the roughness values of the metallic texture.
  132554. */
  132555. roughness: number;
  132556. /**
  132557. * Texture containing both the metallic value in the B channel and the
  132558. * roughness value in the G channel to keep better precision.
  132559. */
  132560. metallicRoughnessTexture: BaseTexture;
  132561. /**
  132562. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132563. *
  132564. * @param name The material name
  132565. * @param scene The scene the material will be use in.
  132566. */
  132567. constructor(name: string, scene: Scene);
  132568. /**
  132569. * Return the currrent class name of the material.
  132570. */
  132571. getClassName(): string;
  132572. /**
  132573. * Makes a duplicate of the current material.
  132574. * @param name - name to use for the new material.
  132575. */
  132576. clone(name: string): PBRMetallicRoughnessMaterial;
  132577. /**
  132578. * Serialize the material to a parsable JSON object.
  132579. */
  132580. serialize(): any;
  132581. /**
  132582. * Parses a JSON object correponding to the serialize function.
  132583. */
  132584. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132585. }
  132586. }
  132587. declare module BABYLON {
  132588. /**
  132589. * The PBR material of BJS following the specular glossiness convention.
  132590. *
  132591. * This fits to the PBR convention in the GLTF definition:
  132592. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132593. */
  132594. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132595. /**
  132596. * Specifies the diffuse color of the material.
  132597. */
  132598. diffuseColor: Color3;
  132599. /**
  132600. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132601. * channel.
  132602. */
  132603. diffuseTexture: BaseTexture;
  132604. /**
  132605. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132606. */
  132607. specularColor: Color3;
  132608. /**
  132609. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132610. */
  132611. glossiness: number;
  132612. /**
  132613. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132614. */
  132615. specularGlossinessTexture: BaseTexture;
  132616. /**
  132617. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132618. *
  132619. * @param name The material name
  132620. * @param scene The scene the material will be use in.
  132621. */
  132622. constructor(name: string, scene: Scene);
  132623. /**
  132624. * Return the currrent class name of the material.
  132625. */
  132626. getClassName(): string;
  132627. /**
  132628. * Makes a duplicate of the current material.
  132629. * @param name - name to use for the new material.
  132630. */
  132631. clone(name: string): PBRSpecularGlossinessMaterial;
  132632. /**
  132633. * Serialize the material to a parsable JSON object.
  132634. */
  132635. serialize(): any;
  132636. /**
  132637. * Parses a JSON object correponding to the serialize function.
  132638. */
  132639. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132640. }
  132641. }
  132642. declare module BABYLON {
  132643. /**
  132644. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132645. * It can help converting any input color in a desired output one. This can then be used to create effects
  132646. * from sepia, black and white to sixties or futuristic rendering...
  132647. *
  132648. * The only supported format is currently 3dl.
  132649. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132650. */
  132651. export class ColorGradingTexture extends BaseTexture {
  132652. /**
  132653. * The texture URL.
  132654. */
  132655. url: string;
  132656. /**
  132657. * Empty line regex stored for GC.
  132658. */
  132659. private static _noneEmptyLineRegex;
  132660. private _textureMatrix;
  132661. private _onLoad;
  132662. /**
  132663. * Instantiates a ColorGradingTexture from the following parameters.
  132664. *
  132665. * @param url The location of the color gradind data (currently only supporting 3dl)
  132666. * @param sceneOrEngine The scene or engine the texture will be used in
  132667. * @param onLoad defines a callback triggered when the texture has been loaded
  132668. */
  132669. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132670. /**
  132671. * Fires the onload event from the constructor if requested.
  132672. */
  132673. private _triggerOnLoad;
  132674. /**
  132675. * Returns the texture matrix used in most of the material.
  132676. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132677. */
  132678. getTextureMatrix(): Matrix;
  132679. /**
  132680. * Occurs when the file being loaded is a .3dl LUT file.
  132681. */
  132682. private load3dlTexture;
  132683. /**
  132684. * Starts the loading process of the texture.
  132685. */
  132686. private loadTexture;
  132687. /**
  132688. * Clones the color gradind texture.
  132689. */
  132690. clone(): ColorGradingTexture;
  132691. /**
  132692. * Called during delayed load for textures.
  132693. */
  132694. delayLoad(): void;
  132695. /**
  132696. * Parses a color grading texture serialized by Babylon.
  132697. * @param parsedTexture The texture information being parsedTexture
  132698. * @param scene The scene to load the texture in
  132699. * @param rootUrl The root url of the data assets to load
  132700. * @return A color gradind texture
  132701. */
  132702. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132703. /**
  132704. * Serializes the LUT texture to json format.
  132705. */
  132706. serialize(): any;
  132707. }
  132708. }
  132709. declare module BABYLON {
  132710. /**
  132711. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132712. */
  132713. export class EquiRectangularCubeTexture extends BaseTexture {
  132714. /** The six faces of the cube. */
  132715. private static _FacesMapping;
  132716. private _noMipmap;
  132717. private _onLoad;
  132718. private _onError;
  132719. /** The size of the cubemap. */
  132720. private _size;
  132721. /** The buffer of the image. */
  132722. private _buffer;
  132723. /** The width of the input image. */
  132724. private _width;
  132725. /** The height of the input image. */
  132726. private _height;
  132727. /** The URL to the image. */
  132728. url: string;
  132729. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132730. coordinatesMode: number;
  132731. /**
  132732. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132733. * @param url The location of the image
  132734. * @param scene The scene the texture will be used in
  132735. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132736. * @param noMipmap Forces to not generate the mipmap if true
  132737. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132738. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132739. * @param onLoad — defines a callback called when texture is loaded
  132740. * @param onError — defines a callback called if there is an error
  132741. */
  132742. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132743. /**
  132744. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132745. */
  132746. private loadImage;
  132747. /**
  132748. * Convert the image buffer into a cubemap and create a CubeTexture.
  132749. */
  132750. private loadTexture;
  132751. /**
  132752. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132753. * @param buffer The ArrayBuffer that should be converted.
  132754. * @returns The buffer as Float32Array.
  132755. */
  132756. private getFloat32ArrayFromArrayBuffer;
  132757. /**
  132758. * Get the current class name of the texture useful for serialization or dynamic coding.
  132759. * @returns "EquiRectangularCubeTexture"
  132760. */
  132761. getClassName(): string;
  132762. /**
  132763. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132764. * @returns A clone of the current EquiRectangularCubeTexture.
  132765. */
  132766. clone(): EquiRectangularCubeTexture;
  132767. }
  132768. }
  132769. declare module BABYLON {
  132770. /**
  132771. * Based on jsTGALoader - Javascript loader for TGA file
  132772. * By Vincent Thibault
  132773. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132774. */
  132775. export class TGATools {
  132776. private static _TYPE_INDEXED;
  132777. private static _TYPE_RGB;
  132778. private static _TYPE_GREY;
  132779. private static _TYPE_RLE_INDEXED;
  132780. private static _TYPE_RLE_RGB;
  132781. private static _TYPE_RLE_GREY;
  132782. private static _ORIGIN_MASK;
  132783. private static _ORIGIN_SHIFT;
  132784. private static _ORIGIN_BL;
  132785. private static _ORIGIN_BR;
  132786. private static _ORIGIN_UL;
  132787. private static _ORIGIN_UR;
  132788. /**
  132789. * Gets the header of a TGA file
  132790. * @param data defines the TGA data
  132791. * @returns the header
  132792. */
  132793. static GetTGAHeader(data: Uint8Array): any;
  132794. /**
  132795. * Uploads TGA content to a Babylon Texture
  132796. * @hidden
  132797. */
  132798. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132799. /** @hidden */
  132800. 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;
  132801. /** @hidden */
  132802. 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;
  132803. /** @hidden */
  132804. 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;
  132805. /** @hidden */
  132806. 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;
  132807. /** @hidden */
  132808. 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;
  132809. /** @hidden */
  132810. 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;
  132811. }
  132812. }
  132813. declare module BABYLON {
  132814. /**
  132815. * Implementation of the TGA Texture Loader.
  132816. * @hidden
  132817. */
  132818. export class _TGATextureLoader implements IInternalTextureLoader {
  132819. /**
  132820. * Defines wether the loader supports cascade loading the different faces.
  132821. */
  132822. readonly supportCascades: boolean;
  132823. /**
  132824. * This returns if the loader support the current file information.
  132825. * @param extension defines the file extension of the file being loaded
  132826. * @returns true if the loader can load the specified file
  132827. */
  132828. canLoad(extension: string): boolean;
  132829. /**
  132830. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132831. * @param data contains the texture data
  132832. * @param texture defines the BabylonJS internal texture
  132833. * @param createPolynomials will be true if polynomials have been requested
  132834. * @param onLoad defines the callback to trigger once the texture is ready
  132835. * @param onError defines the callback to trigger in case of error
  132836. */
  132837. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132838. /**
  132839. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132840. * @param data contains the texture data
  132841. * @param texture defines the BabylonJS internal texture
  132842. * @param callback defines the method to call once ready to upload
  132843. */
  132844. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132845. }
  132846. }
  132847. declare module BABYLON {
  132848. /**
  132849. * Info about the .basis files
  132850. */
  132851. class BasisFileInfo {
  132852. /**
  132853. * If the file has alpha
  132854. */
  132855. hasAlpha: boolean;
  132856. /**
  132857. * Info about each image of the basis file
  132858. */
  132859. images: Array<{
  132860. levels: Array<{
  132861. width: number;
  132862. height: number;
  132863. transcodedPixels: ArrayBufferView;
  132864. }>;
  132865. }>;
  132866. }
  132867. /**
  132868. * Result of transcoding a basis file
  132869. */
  132870. class TranscodeResult {
  132871. /**
  132872. * Info about the .basis file
  132873. */
  132874. fileInfo: BasisFileInfo;
  132875. /**
  132876. * Format to use when loading the file
  132877. */
  132878. format: number;
  132879. }
  132880. /**
  132881. * Configuration options for the Basis transcoder
  132882. */
  132883. export class BasisTranscodeConfiguration {
  132884. /**
  132885. * Supported compression formats used to determine the supported output format of the transcoder
  132886. */
  132887. supportedCompressionFormats?: {
  132888. /**
  132889. * etc1 compression format
  132890. */
  132891. etc1?: boolean;
  132892. /**
  132893. * s3tc compression format
  132894. */
  132895. s3tc?: boolean;
  132896. /**
  132897. * pvrtc compression format
  132898. */
  132899. pvrtc?: boolean;
  132900. /**
  132901. * etc2 compression format
  132902. */
  132903. etc2?: boolean;
  132904. };
  132905. /**
  132906. * If mipmap levels should be loaded for transcoded images (Default: true)
  132907. */
  132908. loadMipmapLevels?: boolean;
  132909. /**
  132910. * Index of a single image to load (Default: all images)
  132911. */
  132912. loadSingleImage?: number;
  132913. }
  132914. /**
  132915. * Used to load .Basis files
  132916. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132917. */
  132918. export class BasisTools {
  132919. private static _IgnoreSupportedFormats;
  132920. /**
  132921. * URL to use when loading the basis transcoder
  132922. */
  132923. static JSModuleURL: string;
  132924. /**
  132925. * URL to use when loading the wasm module for the transcoder
  132926. */
  132927. static WasmModuleURL: string;
  132928. /**
  132929. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132930. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132931. * @returns internal format corresponding to the Basis format
  132932. */
  132933. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132934. private static _WorkerPromise;
  132935. private static _Worker;
  132936. private static _actionId;
  132937. private static _CreateWorkerAsync;
  132938. /**
  132939. * Transcodes a loaded image file to compressed pixel data
  132940. * @param data image data to transcode
  132941. * @param config configuration options for the transcoding
  132942. * @returns a promise resulting in the transcoded image
  132943. */
  132944. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  132945. /**
  132946. * Loads a texture from the transcode result
  132947. * @param texture texture load to
  132948. * @param transcodeResult the result of transcoding the basis file to load from
  132949. */
  132950. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  132951. }
  132952. }
  132953. declare module BABYLON {
  132954. /**
  132955. * Loader for .basis file format
  132956. */
  132957. export class _BasisTextureLoader implements IInternalTextureLoader {
  132958. /**
  132959. * Defines whether the loader supports cascade loading the different faces.
  132960. */
  132961. readonly supportCascades: boolean;
  132962. /**
  132963. * This returns if the loader support the current file information.
  132964. * @param extension defines the file extension of the file being loaded
  132965. * @returns true if the loader can load the specified file
  132966. */
  132967. canLoad(extension: string): boolean;
  132968. /**
  132969. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132970. * @param data contains the texture data
  132971. * @param texture defines the BabylonJS internal texture
  132972. * @param createPolynomials will be true if polynomials have been requested
  132973. * @param onLoad defines the callback to trigger once the texture is ready
  132974. * @param onError defines the callback to trigger in case of error
  132975. */
  132976. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132977. /**
  132978. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132979. * @param data contains the texture data
  132980. * @param texture defines the BabylonJS internal texture
  132981. * @param callback defines the method to call once ready to upload
  132982. */
  132983. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132984. }
  132985. }
  132986. declare module BABYLON {
  132987. /**
  132988. * 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.
  132989. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132991. */
  132992. export class CustomProceduralTexture extends ProceduralTexture {
  132993. private _animate;
  132994. private _time;
  132995. private _config;
  132996. private _texturePath;
  132997. /**
  132998. * Instantiates a new Custom Procedural Texture.
  132999. * 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.
  133000. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  133001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  133002. * @param name Define the name of the texture
  133003. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  133004. * @param size Define the size of the texture to create
  133005. * @param scene Define the scene the texture belongs to
  133006. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  133007. * @param generateMipMaps Define if the texture should creates mip maps or not
  133008. */
  133009. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133010. private _loadJson;
  133011. /**
  133012. * Is the texture ready to be used ? (rendered at least once)
  133013. * @returns true if ready, otherwise, false.
  133014. */
  133015. isReady(): boolean;
  133016. /**
  133017. * Render the texture to its associated render target.
  133018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  133019. */
  133020. render(useCameraPostProcess?: boolean): void;
  133021. /**
  133022. * Update the list of dependant textures samplers in the shader.
  133023. */
  133024. updateTextures(): void;
  133025. /**
  133026. * Update the uniform values of the procedural texture in the shader.
  133027. */
  133028. updateShaderUniforms(): void;
  133029. /**
  133030. * Define if the texture animates or not.
  133031. */
  133032. get animate(): boolean;
  133033. set animate(value: boolean);
  133034. }
  133035. }
  133036. declare module BABYLON {
  133037. /** @hidden */
  133038. export var noisePixelShader: {
  133039. name: string;
  133040. shader: string;
  133041. };
  133042. }
  133043. declare module BABYLON {
  133044. /**
  133045. * Class used to generate noise procedural textures
  133046. */
  133047. export class NoiseProceduralTexture extends ProceduralTexture {
  133048. private _time;
  133049. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  133050. brightness: number;
  133051. /** Defines the number of octaves to process */
  133052. octaves: number;
  133053. /** Defines the level of persistence (0.8 by default) */
  133054. persistence: number;
  133055. /** Gets or sets animation speed factor (default is 1) */
  133056. animationSpeedFactor: number;
  133057. /**
  133058. * Creates a new NoiseProceduralTexture
  133059. * @param name defines the name fo the texture
  133060. * @param size defines the size of the texture (default is 256)
  133061. * @param scene defines the hosting scene
  133062. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  133063. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  133064. */
  133065. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  133066. private _updateShaderUniforms;
  133067. protected _getDefines(): string;
  133068. /** Generate the current state of the procedural texture */
  133069. render(useCameraPostProcess?: boolean): void;
  133070. /**
  133071. * Serializes this noise procedural texture
  133072. * @returns a serialized noise procedural texture object
  133073. */
  133074. serialize(): any;
  133075. /**
  133076. * Clone the texture.
  133077. * @returns the cloned texture
  133078. */
  133079. clone(): NoiseProceduralTexture;
  133080. /**
  133081. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  133082. * @param parsedTexture defines parsed texture data
  133083. * @param scene defines the current scene
  133084. * @param rootUrl defines the root URL containing noise procedural texture information
  133085. * @returns a parsed NoiseProceduralTexture
  133086. */
  133087. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  133088. }
  133089. }
  133090. declare module BABYLON {
  133091. /**
  133092. * Raw cube texture where the raw buffers are passed in
  133093. */
  133094. export class RawCubeTexture extends CubeTexture {
  133095. /**
  133096. * Creates a cube texture where the raw buffers are passed in.
  133097. * @param scene defines the scene the texture is attached to
  133098. * @param data defines the array of data to use to create each face
  133099. * @param size defines the size of the textures
  133100. * @param format defines the format of the data
  133101. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  133102. * @param generateMipMaps defines if the engine should generate the mip levels
  133103. * @param invertY defines if data must be stored with Y axis inverted
  133104. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  133105. * @param compression defines the compression used (null by default)
  133106. */
  133107. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  133108. /**
  133109. * Updates the raw cube texture.
  133110. * @param data defines the data to store
  133111. * @param format defines the data format
  133112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  133113. * @param invertY defines if data must be stored with Y axis inverted
  133114. * @param compression defines the compression used (null by default)
  133115. * @param level defines which level of the texture to update
  133116. */
  133117. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  133118. /**
  133119. * Updates a raw cube texture with RGBD encoded data.
  133120. * @param data defines the array of data [mipmap][face] to use to create each face
  133121. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  133122. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133123. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133124. * @returns a promsie that resolves when the operation is complete
  133125. */
  133126. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  133127. /**
  133128. * Clones the raw cube texture.
  133129. * @return a new cube texture
  133130. */
  133131. clone(): CubeTexture;
  133132. /** @hidden */
  133133. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133134. }
  133135. }
  133136. declare module BABYLON {
  133137. /**
  133138. * Class used to store 3D textures containing user data
  133139. */
  133140. export class RawTexture3D extends Texture {
  133141. /** Gets or sets the texture format to use */
  133142. format: number;
  133143. /**
  133144. * Create a new RawTexture3D
  133145. * @param data defines the data of the texture
  133146. * @param width defines the width of the texture
  133147. * @param height defines the height of the texture
  133148. * @param depth defines the depth of the texture
  133149. * @param format defines the texture format to use
  133150. * @param scene defines the hosting scene
  133151. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133152. * @param invertY defines if texture must be stored with Y axis inverted
  133153. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133154. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133155. */
  133156. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133157. /** Gets or sets the texture format to use */
  133158. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133159. /**
  133160. * Update the texture with new data
  133161. * @param data defines the data to store in the texture
  133162. */
  133163. update(data: ArrayBufferView): void;
  133164. }
  133165. }
  133166. declare module BABYLON {
  133167. /**
  133168. * Class used to store 2D array textures containing user data
  133169. */
  133170. export class RawTexture2DArray extends Texture {
  133171. /** Gets or sets the texture format to use */
  133172. format: number;
  133173. /**
  133174. * Create a new RawTexture2DArray
  133175. * @param data defines the data of the texture
  133176. * @param width defines the width of the texture
  133177. * @param height defines the height of the texture
  133178. * @param depth defines the number of layers of the texture
  133179. * @param format defines the texture format to use
  133180. * @param scene defines the hosting scene
  133181. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  133182. * @param invertY defines if texture must be stored with Y axis inverted
  133183. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133184. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  133185. */
  133186. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  133187. /** Gets or sets the texture format to use */
  133188. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  133189. /**
  133190. * Update the texture with new data
  133191. * @param data defines the data to store in the texture
  133192. */
  133193. update(data: ArrayBufferView): void;
  133194. }
  133195. }
  133196. declare module BABYLON {
  133197. /**
  133198. * Creates a refraction texture used by refraction channel of the standard material.
  133199. * It is like a mirror but to see through a material.
  133200. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133201. */
  133202. export class RefractionTexture extends RenderTargetTexture {
  133203. /**
  133204. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  133205. * 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.
  133206. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133207. */
  133208. refractionPlane: Plane;
  133209. /**
  133210. * Define how deep under the surface we should see.
  133211. */
  133212. depth: number;
  133213. /**
  133214. * Creates a refraction texture used by refraction channel of the standard material.
  133215. * It is like a mirror but to see through a material.
  133216. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133217. * @param name Define the texture name
  133218. * @param size Define the size of the underlying texture
  133219. * @param scene Define the scene the refraction belongs to
  133220. * @param generateMipMaps Define if we need to generate mips level for the refraction
  133221. */
  133222. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  133223. /**
  133224. * Clone the refraction texture.
  133225. * @returns the cloned texture
  133226. */
  133227. clone(): RefractionTexture;
  133228. /**
  133229. * Serialize the texture to a JSON representation you could use in Parse later on
  133230. * @returns the serialized JSON representation
  133231. */
  133232. serialize(): any;
  133233. }
  133234. }
  133235. declare module BABYLON {
  133236. /**
  133237. * Defines the options related to the creation of an HtmlElementTexture
  133238. */
  133239. export interface IHtmlElementTextureOptions {
  133240. /**
  133241. * Defines wether mip maps should be created or not.
  133242. */
  133243. generateMipMaps?: boolean;
  133244. /**
  133245. * Defines the sampling mode of the texture.
  133246. */
  133247. samplingMode?: number;
  133248. /**
  133249. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133250. */
  133251. engine: Nullable<ThinEngine>;
  133252. /**
  133253. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133254. */
  133255. scene: Nullable<Scene>;
  133256. }
  133257. /**
  133258. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133259. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133260. * is automatically managed.
  133261. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133262. * in your application.
  133263. *
  133264. * As the update is not automatic, you need to call them manually.
  133265. */
  133266. export class HtmlElementTexture extends BaseTexture {
  133267. /**
  133268. * The texture URL.
  133269. */
  133270. element: HTMLVideoElement | HTMLCanvasElement;
  133271. private static readonly DefaultOptions;
  133272. private _textureMatrix;
  133273. private _isVideo;
  133274. private _generateMipMaps;
  133275. private _samplingMode;
  133276. /**
  133277. * Instantiates a HtmlElementTexture from the following parameters.
  133278. *
  133279. * @param name Defines the name of the texture
  133280. * @param element Defines the video or canvas the texture is filled with
  133281. * @param options Defines the other none mandatory texture creation options
  133282. */
  133283. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133284. private _createInternalTexture;
  133285. /**
  133286. * Returns the texture matrix used in most of the material.
  133287. */
  133288. getTextureMatrix(): Matrix;
  133289. /**
  133290. * Updates the content of the texture.
  133291. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133292. */
  133293. update(invertY?: Nullable<boolean>): void;
  133294. }
  133295. }
  133296. declare module BABYLON {
  133297. /**
  133298. * Defines the basic options interface of a TexturePacker Frame
  133299. */
  133300. export interface ITexturePackerFrame {
  133301. /**
  133302. * The frame ID
  133303. */
  133304. id: number;
  133305. /**
  133306. * The frames Scale
  133307. */
  133308. scale: Vector2;
  133309. /**
  133310. * The Frames offset
  133311. */
  133312. offset: Vector2;
  133313. }
  133314. /**
  133315. * This is a support class for frame Data on texture packer sets.
  133316. */
  133317. export class TexturePackerFrame implements ITexturePackerFrame {
  133318. /**
  133319. * The frame ID
  133320. */
  133321. id: number;
  133322. /**
  133323. * The frames Scale
  133324. */
  133325. scale: Vector2;
  133326. /**
  133327. * The Frames offset
  133328. */
  133329. offset: Vector2;
  133330. /**
  133331. * Initializes a texture package frame.
  133332. * @param id The numerical frame identifier
  133333. * @param scale Scalar Vector2 for UV frame
  133334. * @param offset Vector2 for the frame position in UV units.
  133335. * @returns TexturePackerFrame
  133336. */
  133337. constructor(id: number, scale: Vector2, offset: Vector2);
  133338. }
  133339. }
  133340. declare module BABYLON {
  133341. /**
  133342. * Defines the basic options interface of a TexturePacker
  133343. */
  133344. export interface ITexturePackerOptions {
  133345. /**
  133346. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133347. */
  133348. map?: string[];
  133349. /**
  133350. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133351. */
  133352. uvsIn?: string;
  133353. /**
  133354. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133355. */
  133356. uvsOut?: string;
  133357. /**
  133358. * number representing the layout style. Defaults to LAYOUT_STRIP
  133359. */
  133360. layout?: number;
  133361. /**
  133362. * number of columns if using custom column count layout(2). This defaults to 4.
  133363. */
  133364. colnum?: number;
  133365. /**
  133366. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133367. */
  133368. updateInputMeshes?: boolean;
  133369. /**
  133370. * boolean flag to dispose all the source textures. Defaults to true.
  133371. */
  133372. disposeSources?: boolean;
  133373. /**
  133374. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133375. */
  133376. fillBlanks?: boolean;
  133377. /**
  133378. * string value representing the context fill style color. Defaults to 'black'.
  133379. */
  133380. customFillColor?: string;
  133381. /**
  133382. * Width and Height Value of each Frame in the TexturePacker Sets
  133383. */
  133384. frameSize?: number;
  133385. /**
  133386. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133387. */
  133388. paddingRatio?: number;
  133389. /**
  133390. * Number that declares the fill method for the padding gutter.
  133391. */
  133392. paddingMode?: number;
  133393. /**
  133394. * If in SUBUV_COLOR padding mode what color to use.
  133395. */
  133396. paddingColor?: Color3 | Color4;
  133397. }
  133398. /**
  133399. * Defines the basic interface of a TexturePacker JSON File
  133400. */
  133401. export interface ITexturePackerJSON {
  133402. /**
  133403. * The frame ID
  133404. */
  133405. name: string;
  133406. /**
  133407. * The base64 channel data
  133408. */
  133409. sets: any;
  133410. /**
  133411. * The options of the Packer
  133412. */
  133413. options: ITexturePackerOptions;
  133414. /**
  133415. * The frame data of the Packer
  133416. */
  133417. frames: Array<number>;
  133418. }
  133419. /**
  133420. * This is a support class that generates a series of packed texture sets.
  133421. * @see https://doc.babylonjs.com/babylon101/materials
  133422. */
  133423. export class TexturePacker {
  133424. /** Packer Layout Constant 0 */
  133425. static readonly LAYOUT_STRIP: number;
  133426. /** Packer Layout Constant 1 */
  133427. static readonly LAYOUT_POWER2: number;
  133428. /** Packer Layout Constant 2 */
  133429. static readonly LAYOUT_COLNUM: number;
  133430. /** Packer Layout Constant 0 */
  133431. static readonly SUBUV_WRAP: number;
  133432. /** Packer Layout Constant 1 */
  133433. static readonly SUBUV_EXTEND: number;
  133434. /** Packer Layout Constant 2 */
  133435. static readonly SUBUV_COLOR: number;
  133436. /** The Name of the Texture Package */
  133437. name: string;
  133438. /** The scene scope of the TexturePacker */
  133439. scene: Scene;
  133440. /** The Meshes to target */
  133441. meshes: AbstractMesh[];
  133442. /** Arguments passed with the Constructor */
  133443. options: ITexturePackerOptions;
  133444. /** The promise that is started upon initialization */
  133445. promise: Nullable<Promise<TexturePacker | string>>;
  133446. /** The Container object for the channel sets that are generated */
  133447. sets: object;
  133448. /** The Container array for the frames that are generated */
  133449. frames: TexturePackerFrame[];
  133450. /** The expected number of textures the system is parsing. */
  133451. private _expecting;
  133452. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133453. private _paddingValue;
  133454. /**
  133455. * Initializes a texture package series from an array of meshes or a single mesh.
  133456. * @param name The name of the package
  133457. * @param meshes The target meshes to compose the package from
  133458. * @param options The arguments that texture packer should follow while building.
  133459. * @param scene The scene which the textures are scoped to.
  133460. * @returns TexturePacker
  133461. */
  133462. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133463. /**
  133464. * Starts the package process
  133465. * @param resolve The promises resolution function
  133466. * @returns TexturePacker
  133467. */
  133468. private _createFrames;
  133469. /**
  133470. * Calculates the Size of the Channel Sets
  133471. * @returns Vector2
  133472. */
  133473. private _calculateSize;
  133474. /**
  133475. * Calculates the UV data for the frames.
  133476. * @param baseSize the base frameSize
  133477. * @param padding the base frame padding
  133478. * @param dtSize size of the Dynamic Texture for that channel
  133479. * @param dtUnits is 1/dtSize
  133480. * @param update flag to update the input meshes
  133481. */
  133482. private _calculateMeshUVFrames;
  133483. /**
  133484. * Calculates the frames Offset.
  133485. * @param index of the frame
  133486. * @returns Vector2
  133487. */
  133488. private _getFrameOffset;
  133489. /**
  133490. * Updates a Mesh to the frame data
  133491. * @param mesh that is the target
  133492. * @param frameID or the frame index
  133493. */
  133494. private _updateMeshUV;
  133495. /**
  133496. * Updates a Meshes materials to use the texture packer channels
  133497. * @param m is the mesh to target
  133498. * @param force all channels on the packer to be set.
  133499. */
  133500. private _updateTextureReferences;
  133501. /**
  133502. * Public method to set a Mesh to a frame
  133503. * @param m that is the target
  133504. * @param frameID or the frame index
  133505. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133506. */
  133507. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133508. /**
  133509. * Starts the async promise to compile the texture packer.
  133510. * @returns Promise<void>
  133511. */
  133512. processAsync(): Promise<void>;
  133513. /**
  133514. * Disposes all textures associated with this packer
  133515. */
  133516. dispose(): void;
  133517. /**
  133518. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133519. * @param imageType is the image type to use.
  133520. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133521. */
  133522. download(imageType?: string, quality?: number): void;
  133523. /**
  133524. * Public method to load a texturePacker JSON file.
  133525. * @param data of the JSON file in string format.
  133526. */
  133527. updateFromJSON(data: string): void;
  133528. }
  133529. }
  133530. declare module BABYLON {
  133531. /**
  133532. * Enum used to define the target of a block
  133533. */
  133534. export enum NodeMaterialBlockTargets {
  133535. /** Vertex shader */
  133536. Vertex = 1,
  133537. /** Fragment shader */
  133538. Fragment = 2,
  133539. /** Neutral */
  133540. Neutral = 4,
  133541. /** Vertex and Fragment */
  133542. VertexAndFragment = 3
  133543. }
  133544. }
  133545. declare module BABYLON {
  133546. /**
  133547. * Defines the kind of connection point for node based material
  133548. */
  133549. export enum NodeMaterialBlockConnectionPointTypes {
  133550. /** Float */
  133551. Float = 1,
  133552. /** Int */
  133553. Int = 2,
  133554. /** Vector2 */
  133555. Vector2 = 4,
  133556. /** Vector3 */
  133557. Vector3 = 8,
  133558. /** Vector4 */
  133559. Vector4 = 16,
  133560. /** Color3 */
  133561. Color3 = 32,
  133562. /** Color4 */
  133563. Color4 = 64,
  133564. /** Matrix */
  133565. Matrix = 128,
  133566. /** Custom object */
  133567. Object = 256,
  133568. /** Detect type based on connection */
  133569. AutoDetect = 1024,
  133570. /** Output type that will be defined by input type */
  133571. BasedOnInput = 2048
  133572. }
  133573. }
  133574. declare module BABYLON {
  133575. /**
  133576. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133577. */
  133578. export enum NodeMaterialBlockConnectionPointMode {
  133579. /** Value is an uniform */
  133580. Uniform = 0,
  133581. /** Value is a mesh attribute */
  133582. Attribute = 1,
  133583. /** Value is a varying between vertex and fragment shaders */
  133584. Varying = 2,
  133585. /** Mode is undefined */
  133586. Undefined = 3
  133587. }
  133588. }
  133589. declare module BABYLON {
  133590. /**
  133591. * Enum used to define system values e.g. values automatically provided by the system
  133592. */
  133593. export enum NodeMaterialSystemValues {
  133594. /** World */
  133595. World = 1,
  133596. /** View */
  133597. View = 2,
  133598. /** Projection */
  133599. Projection = 3,
  133600. /** ViewProjection */
  133601. ViewProjection = 4,
  133602. /** WorldView */
  133603. WorldView = 5,
  133604. /** WorldViewProjection */
  133605. WorldViewProjection = 6,
  133606. /** CameraPosition */
  133607. CameraPosition = 7,
  133608. /** Fog Color */
  133609. FogColor = 8,
  133610. /** Delta time */
  133611. DeltaTime = 9
  133612. }
  133613. }
  133614. declare module BABYLON {
  133615. /**
  133616. * Enum used to define the material modes
  133617. */
  133618. export enum NodeMaterialModes {
  133619. /** Regular material */
  133620. Material = 0,
  133621. /** For post process */
  133622. PostProcess = 1
  133623. }
  133624. }
  133625. declare module BABYLON {
  133626. /**
  133627. * Root class for all node material optimizers
  133628. */
  133629. export class NodeMaterialOptimizer {
  133630. /**
  133631. * Function used to optimize a NodeMaterial graph
  133632. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133633. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133634. */
  133635. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133636. }
  133637. }
  133638. declare module BABYLON {
  133639. /**
  133640. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133641. */
  133642. export class TransformBlock extends NodeMaterialBlock {
  133643. /**
  133644. * Defines the value to use to complement W value to transform it to a Vector4
  133645. */
  133646. complementW: number;
  133647. /**
  133648. * Defines the value to use to complement z value to transform it to a Vector4
  133649. */
  133650. complementZ: number;
  133651. /**
  133652. * Creates a new TransformBlock
  133653. * @param name defines the block name
  133654. */
  133655. constructor(name: string);
  133656. /**
  133657. * Gets the current class name
  133658. * @returns the class name
  133659. */
  133660. getClassName(): string;
  133661. /**
  133662. * Gets the vector input
  133663. */
  133664. get vector(): NodeMaterialConnectionPoint;
  133665. /**
  133666. * Gets the output component
  133667. */
  133668. get output(): NodeMaterialConnectionPoint;
  133669. /**
  133670. * Gets the xyz output component
  133671. */
  133672. get xyz(): NodeMaterialConnectionPoint;
  133673. /**
  133674. * Gets the matrix transform input
  133675. */
  133676. get transform(): NodeMaterialConnectionPoint;
  133677. protected _buildBlock(state: NodeMaterialBuildState): this;
  133678. serialize(): any;
  133679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133680. protected _dumpPropertiesCode(): string;
  133681. }
  133682. }
  133683. declare module BABYLON {
  133684. /**
  133685. * Block used to output the vertex position
  133686. */
  133687. export class VertexOutputBlock extends NodeMaterialBlock {
  133688. /**
  133689. * Creates a new VertexOutputBlock
  133690. * @param name defines the block name
  133691. */
  133692. constructor(name: string);
  133693. /**
  133694. * Gets the current class name
  133695. * @returns the class name
  133696. */
  133697. getClassName(): string;
  133698. /**
  133699. * Gets the vector input component
  133700. */
  133701. get vector(): NodeMaterialConnectionPoint;
  133702. protected _buildBlock(state: NodeMaterialBuildState): this;
  133703. }
  133704. }
  133705. declare module BABYLON {
  133706. /**
  133707. * Block used to output the final color
  133708. */
  133709. export class FragmentOutputBlock extends NodeMaterialBlock {
  133710. /**
  133711. * Create a new FragmentOutputBlock
  133712. * @param name defines the block name
  133713. */
  133714. constructor(name: string);
  133715. /**
  133716. * Gets the current class name
  133717. * @returns the class name
  133718. */
  133719. getClassName(): string;
  133720. /**
  133721. * Gets the rgba input component
  133722. */
  133723. get rgba(): NodeMaterialConnectionPoint;
  133724. /**
  133725. * Gets the rgb input component
  133726. */
  133727. get rgb(): NodeMaterialConnectionPoint;
  133728. /**
  133729. * Gets the a input component
  133730. */
  133731. get a(): NodeMaterialConnectionPoint;
  133732. protected _buildBlock(state: NodeMaterialBuildState): this;
  133733. }
  133734. }
  133735. declare module BABYLON {
  133736. /**
  133737. * Base block used to read a reflection texture from a sampler
  133738. */
  133739. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133740. /** @hidden */
  133741. _define3DName: string;
  133742. /** @hidden */
  133743. _defineCubicName: string;
  133744. /** @hidden */
  133745. _defineExplicitName: string;
  133746. /** @hidden */
  133747. _defineProjectionName: string;
  133748. /** @hidden */
  133749. _defineLocalCubicName: string;
  133750. /** @hidden */
  133751. _defineSphericalName: string;
  133752. /** @hidden */
  133753. _definePlanarName: string;
  133754. /** @hidden */
  133755. _defineEquirectangularName: string;
  133756. /** @hidden */
  133757. _defineMirroredEquirectangularFixedName: string;
  133758. /** @hidden */
  133759. _defineEquirectangularFixedName: string;
  133760. /** @hidden */
  133761. _defineSkyboxName: string;
  133762. /** @hidden */
  133763. _defineOppositeZ: string;
  133764. /** @hidden */
  133765. _cubeSamplerName: string;
  133766. /** @hidden */
  133767. _2DSamplerName: string;
  133768. protected _positionUVWName: string;
  133769. protected _directionWName: string;
  133770. protected _reflectionVectorName: string;
  133771. /** @hidden */
  133772. _reflectionCoordsName: string;
  133773. /** @hidden */
  133774. _reflectionMatrixName: string;
  133775. protected _reflectionColorName: string;
  133776. /**
  133777. * Gets or sets the texture associated with the node
  133778. */
  133779. texture: Nullable<BaseTexture>;
  133780. /**
  133781. * Create a new ReflectionTextureBaseBlock
  133782. * @param name defines the block name
  133783. */
  133784. constructor(name: string);
  133785. /**
  133786. * Gets the current class name
  133787. * @returns the class name
  133788. */
  133789. getClassName(): string;
  133790. /**
  133791. * Gets the world position input component
  133792. */
  133793. abstract get position(): NodeMaterialConnectionPoint;
  133794. /**
  133795. * Gets the world position input component
  133796. */
  133797. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133798. /**
  133799. * Gets the world normal input component
  133800. */
  133801. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133802. /**
  133803. * Gets the world input component
  133804. */
  133805. abstract get world(): NodeMaterialConnectionPoint;
  133806. /**
  133807. * Gets the camera (or eye) position component
  133808. */
  133809. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133810. /**
  133811. * Gets the view input component
  133812. */
  133813. abstract get view(): NodeMaterialConnectionPoint;
  133814. protected _getTexture(): Nullable<BaseTexture>;
  133815. autoConfigure(material: NodeMaterial): void;
  133816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133817. isReady(): boolean;
  133818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133819. /**
  133820. * Gets the code to inject in the vertex shader
  133821. * @param state current state of the node material building
  133822. * @returns the shader code
  133823. */
  133824. handleVertexSide(state: NodeMaterialBuildState): string;
  133825. /**
  133826. * Handles the inits for the fragment code path
  133827. * @param state node material build state
  133828. */
  133829. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133830. /**
  133831. * Generates the reflection coords code for the fragment code path
  133832. * @param worldNormalVarName name of the world normal variable
  133833. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133834. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133835. * @returns the shader code
  133836. */
  133837. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133838. /**
  133839. * Generates the reflection color code for the fragment code path
  133840. * @param lodVarName name of the lod variable
  133841. * @param swizzleLookupTexture swizzle to use for the final color variable
  133842. * @returns the shader code
  133843. */
  133844. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133845. /**
  133846. * Generates the code corresponding to the connected output points
  133847. * @param state node material build state
  133848. * @param varName name of the variable to output
  133849. * @returns the shader code
  133850. */
  133851. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133852. protected _buildBlock(state: NodeMaterialBuildState): this;
  133853. protected _dumpPropertiesCode(): string;
  133854. serialize(): any;
  133855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133856. }
  133857. }
  133858. declare module BABYLON {
  133859. /**
  133860. * Defines a connection point to be used for points with a custom object type
  133861. */
  133862. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133863. private _blockType;
  133864. private _blockName;
  133865. private _nameForCheking?;
  133866. /**
  133867. * Creates a new connection point
  133868. * @param name defines the connection point name
  133869. * @param ownerBlock defines the block hosting this connection point
  133870. * @param direction defines the direction of the connection point
  133871. */
  133872. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  133873. /**
  133874. * Gets a number indicating if the current point can be connected to another point
  133875. * @param connectionPoint defines the other connection point
  133876. * @returns a number defining the compatibility state
  133877. */
  133878. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133879. /**
  133880. * Creates a block suitable to be used as an input for this input point.
  133881. * If null is returned, a block based on the point type will be created.
  133882. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  133883. */
  133884. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  133885. }
  133886. }
  133887. declare module BABYLON {
  133888. /**
  133889. * Enum defining the type of properties that can be edited in the property pages in the NME
  133890. */
  133891. export enum PropertyTypeForEdition {
  133892. /** property is a boolean */
  133893. Boolean = 0,
  133894. /** property is a float */
  133895. Float = 1,
  133896. /** property is a Vector2 */
  133897. Vector2 = 2,
  133898. /** property is a list of values */
  133899. List = 3
  133900. }
  133901. /**
  133902. * Interface that defines an option in a variable of type list
  133903. */
  133904. export interface IEditablePropertyListOption {
  133905. /** label of the option */
  133906. "label": string;
  133907. /** value of the option */
  133908. "value": number;
  133909. }
  133910. /**
  133911. * Interface that defines the options available for an editable property
  133912. */
  133913. export interface IEditablePropertyOption {
  133914. /** min value */
  133915. "min"?: number;
  133916. /** max value */
  133917. "max"?: number;
  133918. /** notifiers: indicates which actions to take when the property is changed */
  133919. "notifiers"?: {
  133920. /** the material should be rebuilt */
  133921. "rebuild"?: boolean;
  133922. /** the preview should be updated */
  133923. "update"?: boolean;
  133924. };
  133925. /** list of the options for a variable of type list */
  133926. "options"?: IEditablePropertyListOption[];
  133927. }
  133928. /**
  133929. * Interface that describes an editable property
  133930. */
  133931. export interface IPropertyDescriptionForEdition {
  133932. /** name of the property */
  133933. "propertyName": string;
  133934. /** display name of the property */
  133935. "displayName": string;
  133936. /** type of the property */
  133937. "type": PropertyTypeForEdition;
  133938. /** group of the property - all properties with the same group value will be displayed in a specific section */
  133939. "groupName": string;
  133940. /** options for the property */
  133941. "options": IEditablePropertyOption;
  133942. }
  133943. /**
  133944. * Decorator that flags a property in a node material block as being editable
  133945. */
  133946. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  133947. }
  133948. declare module BABYLON {
  133949. /**
  133950. * Block used to implement the refraction part of the sub surface module of the PBR material
  133951. */
  133952. export class RefractionBlock extends NodeMaterialBlock {
  133953. /** @hidden */
  133954. _define3DName: string;
  133955. /** @hidden */
  133956. _refractionMatrixName: string;
  133957. /** @hidden */
  133958. _defineLODRefractionAlpha: string;
  133959. /** @hidden */
  133960. _defineLinearSpecularRefraction: string;
  133961. /** @hidden */
  133962. _defineOppositeZ: string;
  133963. /** @hidden */
  133964. _cubeSamplerName: string;
  133965. /** @hidden */
  133966. _2DSamplerName: string;
  133967. /** @hidden */
  133968. _vRefractionMicrosurfaceInfosName: string;
  133969. /** @hidden */
  133970. _vRefractionInfosName: string;
  133971. private _scene;
  133972. /**
  133973. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133974. * Materials half opaque for instance using refraction could benefit from this control.
  133975. */
  133976. linkRefractionWithTransparency: boolean;
  133977. /**
  133978. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133979. */
  133980. invertRefractionY: boolean;
  133981. /**
  133982. * Gets or sets the texture associated with the node
  133983. */
  133984. texture: Nullable<BaseTexture>;
  133985. /**
  133986. * Create a new RefractionBlock
  133987. * @param name defines the block name
  133988. */
  133989. constructor(name: string);
  133990. /**
  133991. * Gets the current class name
  133992. * @returns the class name
  133993. */
  133994. getClassName(): string;
  133995. /**
  133996. * Gets the intensity input component
  133997. */
  133998. get intensity(): NodeMaterialConnectionPoint;
  133999. /**
  134000. * Gets the index of refraction input component
  134001. */
  134002. get indexOfRefraction(): NodeMaterialConnectionPoint;
  134003. /**
  134004. * Gets the tint at distance input component
  134005. */
  134006. get tintAtDistance(): NodeMaterialConnectionPoint;
  134007. /**
  134008. * Gets the view input component
  134009. */
  134010. get view(): NodeMaterialConnectionPoint;
  134011. /**
  134012. * Gets the refraction object output component
  134013. */
  134014. get refraction(): NodeMaterialConnectionPoint;
  134015. /**
  134016. * Returns true if the block has a texture
  134017. */
  134018. get hasTexture(): boolean;
  134019. protected _getTexture(): Nullable<BaseTexture>;
  134020. autoConfigure(material: NodeMaterial): void;
  134021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134022. isReady(): boolean;
  134023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134024. /**
  134025. * Gets the main code of the block (fragment side)
  134026. * @param state current state of the node material building
  134027. * @returns the shader code
  134028. */
  134029. getCode(state: NodeMaterialBuildState): string;
  134030. protected _buildBlock(state: NodeMaterialBuildState): this;
  134031. protected _dumpPropertiesCode(): string;
  134032. serialize(): any;
  134033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134034. }
  134035. }
  134036. declare module BABYLON {
  134037. /**
  134038. * Base block used as input for post process
  134039. */
  134040. export class CurrentScreenBlock extends NodeMaterialBlock {
  134041. private _samplerName;
  134042. private _linearDefineName;
  134043. private _gammaDefineName;
  134044. private _mainUVName;
  134045. private _tempTextureRead;
  134046. /**
  134047. * Gets or sets the texture associated with the node
  134048. */
  134049. texture: Nullable<BaseTexture>;
  134050. /**
  134051. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134052. */
  134053. convertToGammaSpace: boolean;
  134054. /**
  134055. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134056. */
  134057. convertToLinearSpace: boolean;
  134058. /**
  134059. * Create a new CurrentScreenBlock
  134060. * @param name defines the block name
  134061. */
  134062. constructor(name: string);
  134063. /**
  134064. * Gets the current class name
  134065. * @returns the class name
  134066. */
  134067. getClassName(): string;
  134068. /**
  134069. * Gets the uv input component
  134070. */
  134071. get uv(): NodeMaterialConnectionPoint;
  134072. /**
  134073. * Gets the rgba output component
  134074. */
  134075. get rgba(): NodeMaterialConnectionPoint;
  134076. /**
  134077. * Gets the rgb output component
  134078. */
  134079. get rgb(): NodeMaterialConnectionPoint;
  134080. /**
  134081. * Gets the r output component
  134082. */
  134083. get r(): NodeMaterialConnectionPoint;
  134084. /**
  134085. * Gets the g output component
  134086. */
  134087. get g(): NodeMaterialConnectionPoint;
  134088. /**
  134089. * Gets the b output component
  134090. */
  134091. get b(): NodeMaterialConnectionPoint;
  134092. /**
  134093. * Gets the a output component
  134094. */
  134095. get a(): NodeMaterialConnectionPoint;
  134096. /**
  134097. * Initialize the block and prepare the context for build
  134098. * @param state defines the state that will be used for the build
  134099. */
  134100. initialize(state: NodeMaterialBuildState): void;
  134101. get target(): NodeMaterialBlockTargets;
  134102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134103. isReady(): boolean;
  134104. private _injectVertexCode;
  134105. private _writeTextureRead;
  134106. private _writeOutput;
  134107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134108. serialize(): any;
  134109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134110. }
  134111. }
  134112. declare module BABYLON {
  134113. /**
  134114. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  134115. */
  134116. export class VectorMergerBlock extends NodeMaterialBlock {
  134117. /**
  134118. * Create a new VectorMergerBlock
  134119. * @param name defines the block name
  134120. */
  134121. constructor(name: string);
  134122. /**
  134123. * Gets the current class name
  134124. * @returns the class name
  134125. */
  134126. getClassName(): string;
  134127. /**
  134128. * Gets the xyz component (input)
  134129. */
  134130. get xyzIn(): NodeMaterialConnectionPoint;
  134131. /**
  134132. * Gets the xy component (input)
  134133. */
  134134. get xyIn(): NodeMaterialConnectionPoint;
  134135. /**
  134136. * Gets the x component (input)
  134137. */
  134138. get x(): NodeMaterialConnectionPoint;
  134139. /**
  134140. * Gets the y component (input)
  134141. */
  134142. get y(): NodeMaterialConnectionPoint;
  134143. /**
  134144. * Gets the z component (input)
  134145. */
  134146. get z(): NodeMaterialConnectionPoint;
  134147. /**
  134148. * Gets the w component (input)
  134149. */
  134150. get w(): NodeMaterialConnectionPoint;
  134151. /**
  134152. * Gets the xyzw component (output)
  134153. */
  134154. get xyzw(): NodeMaterialConnectionPoint;
  134155. /**
  134156. * Gets the xyz component (output)
  134157. */
  134158. get xyzOut(): NodeMaterialConnectionPoint;
  134159. /**
  134160. * Gets the xy component (output)
  134161. */
  134162. get xyOut(): NodeMaterialConnectionPoint;
  134163. /**
  134164. * Gets the xy component (output)
  134165. * @deprecated Please use xyOut instead.
  134166. */
  134167. get xy(): NodeMaterialConnectionPoint;
  134168. /**
  134169. * Gets the xyz component (output)
  134170. * @deprecated Please use xyzOut instead.
  134171. */
  134172. get xyz(): NodeMaterialConnectionPoint;
  134173. protected _buildBlock(state: NodeMaterialBuildState): this;
  134174. }
  134175. }
  134176. declare module BABYLON {
  134177. /**
  134178. * Block used to remap a float from a range to a new one
  134179. */
  134180. export class RemapBlock extends NodeMaterialBlock {
  134181. /**
  134182. * Gets or sets the source range
  134183. */
  134184. sourceRange: Vector2;
  134185. /**
  134186. * Gets or sets the target range
  134187. */
  134188. targetRange: Vector2;
  134189. /**
  134190. * Creates a new RemapBlock
  134191. * @param name defines the block name
  134192. */
  134193. constructor(name: string);
  134194. /**
  134195. * Gets the current class name
  134196. * @returns the class name
  134197. */
  134198. getClassName(): string;
  134199. /**
  134200. * Gets the input component
  134201. */
  134202. get input(): NodeMaterialConnectionPoint;
  134203. /**
  134204. * Gets the source min input component
  134205. */
  134206. get sourceMin(): NodeMaterialConnectionPoint;
  134207. /**
  134208. * Gets the source max input component
  134209. */
  134210. get sourceMax(): NodeMaterialConnectionPoint;
  134211. /**
  134212. * Gets the target min input component
  134213. */
  134214. get targetMin(): NodeMaterialConnectionPoint;
  134215. /**
  134216. * Gets the target max input component
  134217. */
  134218. get targetMax(): NodeMaterialConnectionPoint;
  134219. /**
  134220. * Gets the output component
  134221. */
  134222. get output(): NodeMaterialConnectionPoint;
  134223. protected _buildBlock(state: NodeMaterialBuildState): this;
  134224. protected _dumpPropertiesCode(): string;
  134225. serialize(): any;
  134226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134227. }
  134228. }
  134229. declare module BABYLON {
  134230. /**
  134231. * Block used to multiply 2 values
  134232. */
  134233. export class MultiplyBlock extends NodeMaterialBlock {
  134234. /**
  134235. * Creates a new MultiplyBlock
  134236. * @param name defines the block name
  134237. */
  134238. constructor(name: string);
  134239. /**
  134240. * Gets the current class name
  134241. * @returns the class name
  134242. */
  134243. getClassName(): string;
  134244. /**
  134245. * Gets the left operand input component
  134246. */
  134247. get left(): NodeMaterialConnectionPoint;
  134248. /**
  134249. * Gets the right operand input component
  134250. */
  134251. get right(): NodeMaterialConnectionPoint;
  134252. /**
  134253. * Gets the output component
  134254. */
  134255. get output(): NodeMaterialConnectionPoint;
  134256. protected _buildBlock(state: NodeMaterialBuildState): this;
  134257. }
  134258. }
  134259. declare module BABYLON {
  134260. /**
  134261. * Interface used to configure the node material editor
  134262. */
  134263. export interface INodeMaterialEditorOptions {
  134264. /** Define the URl to load node editor script */
  134265. editorURL?: string;
  134266. }
  134267. /** @hidden */
  134268. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  134269. NORMAL: boolean;
  134270. TANGENT: boolean;
  134271. UV1: boolean;
  134272. /** BONES */
  134273. NUM_BONE_INFLUENCERS: number;
  134274. BonesPerMesh: number;
  134275. BONETEXTURE: boolean;
  134276. /** MORPH TARGETS */
  134277. MORPHTARGETS: boolean;
  134278. MORPHTARGETS_NORMAL: boolean;
  134279. MORPHTARGETS_TANGENT: boolean;
  134280. MORPHTARGETS_UV: boolean;
  134281. NUM_MORPH_INFLUENCERS: number;
  134282. /** IMAGE PROCESSING */
  134283. IMAGEPROCESSING: boolean;
  134284. VIGNETTE: boolean;
  134285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134286. VIGNETTEBLENDMODEOPAQUE: boolean;
  134287. TONEMAPPING: boolean;
  134288. TONEMAPPING_ACES: boolean;
  134289. CONTRAST: boolean;
  134290. EXPOSURE: boolean;
  134291. COLORCURVES: boolean;
  134292. COLORGRADING: boolean;
  134293. COLORGRADING3D: boolean;
  134294. SAMPLER3DGREENDEPTH: boolean;
  134295. SAMPLER3DBGRMAP: boolean;
  134296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134297. /** MISC. */
  134298. BUMPDIRECTUV: number;
  134299. constructor();
  134300. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  134301. }
  134302. /**
  134303. * Class used to configure NodeMaterial
  134304. */
  134305. export interface INodeMaterialOptions {
  134306. /**
  134307. * Defines if blocks should emit comments
  134308. */
  134309. emitComments: boolean;
  134310. }
  134311. /**
  134312. * Class used to create a node based material built by assembling shader blocks
  134313. */
  134314. export class NodeMaterial extends PushMaterial {
  134315. private static _BuildIdGenerator;
  134316. private _options;
  134317. private _vertexCompilationState;
  134318. private _fragmentCompilationState;
  134319. private _sharedData;
  134320. private _buildId;
  134321. private _buildWasSuccessful;
  134322. private _cachedWorldViewMatrix;
  134323. private _cachedWorldViewProjectionMatrix;
  134324. private _optimizers;
  134325. private _animationFrame;
  134326. /** Define the Url to load node editor script */
  134327. static EditorURL: string;
  134328. /** Define the Url to load snippets */
  134329. static SnippetUrl: string;
  134330. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  134331. static IgnoreTexturesAtLoadTime: boolean;
  134332. private BJSNODEMATERIALEDITOR;
  134333. /** Get the inspector from bundle or global */
  134334. private _getGlobalNodeMaterialEditor;
  134335. /**
  134336. * Snippet ID if the material was created from the snippet server
  134337. */
  134338. snippetId: string;
  134339. /**
  134340. * Gets or sets data used by visual editor
  134341. * @see https://nme.babylonjs.com
  134342. */
  134343. editorData: any;
  134344. /**
  134345. * 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)
  134346. */
  134347. ignoreAlpha: boolean;
  134348. /**
  134349. * Defines the maximum number of lights that can be used in the material
  134350. */
  134351. maxSimultaneousLights: number;
  134352. /**
  134353. * Observable raised when the material is built
  134354. */
  134355. onBuildObservable: Observable<NodeMaterial>;
  134356. /**
  134357. * Gets or sets the root nodes of the material vertex shader
  134358. */
  134359. _vertexOutputNodes: NodeMaterialBlock[];
  134360. /**
  134361. * Gets or sets the root nodes of the material fragment (pixel) shader
  134362. */
  134363. _fragmentOutputNodes: NodeMaterialBlock[];
  134364. /** Gets or sets options to control the node material overall behavior */
  134365. get options(): INodeMaterialOptions;
  134366. set options(options: INodeMaterialOptions);
  134367. /**
  134368. * Default configuration related to image processing available in the standard Material.
  134369. */
  134370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134371. /**
  134372. * Gets the image processing configuration used either in this material.
  134373. */
  134374. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134375. /**
  134376. * Sets the Default image processing configuration used either in the this material.
  134377. *
  134378. * If sets to null, the scene one is in use.
  134379. */
  134380. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134381. /**
  134382. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  134383. */
  134384. attachedBlocks: NodeMaterialBlock[];
  134385. /**
  134386. * Specifies the mode of the node material
  134387. * @hidden
  134388. */
  134389. _mode: NodeMaterialModes;
  134390. /**
  134391. * Gets the mode property
  134392. */
  134393. get mode(): NodeMaterialModes;
  134394. /**
  134395. * Create a new node based material
  134396. * @param name defines the material name
  134397. * @param scene defines the hosting scene
  134398. * @param options defines creation option
  134399. */
  134400. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  134401. /**
  134402. * Gets the current class name of the material e.g. "NodeMaterial"
  134403. * @returns the class name
  134404. */
  134405. getClassName(): string;
  134406. /**
  134407. * Keep track of the image processing observer to allow dispose and replace.
  134408. */
  134409. private _imageProcessingObserver;
  134410. /**
  134411. * Attaches a new image processing configuration to the Standard Material.
  134412. * @param configuration
  134413. */
  134414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134415. /**
  134416. * Get a block by its name
  134417. * @param name defines the name of the block to retrieve
  134418. * @returns the required block or null if not found
  134419. */
  134420. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  134421. /**
  134422. * Get a block by its name
  134423. * @param predicate defines the predicate used to find the good candidate
  134424. * @returns the required block or null if not found
  134425. */
  134426. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  134427. /**
  134428. * Get an input block by its name
  134429. * @param predicate defines the predicate used to find the good candidate
  134430. * @returns the required input block or null if not found
  134431. */
  134432. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  134433. /**
  134434. * Gets the list of input blocks attached to this material
  134435. * @returns an array of InputBlocks
  134436. */
  134437. getInputBlocks(): InputBlock[];
  134438. /**
  134439. * Adds a new optimizer to the list of optimizers
  134440. * @param optimizer defines the optimizers to add
  134441. * @returns the current material
  134442. */
  134443. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134444. /**
  134445. * Remove an optimizer from the list of optimizers
  134446. * @param optimizer defines the optimizers to remove
  134447. * @returns the current material
  134448. */
  134449. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  134450. /**
  134451. * Add a new block to the list of output nodes
  134452. * @param node defines the node to add
  134453. * @returns the current material
  134454. */
  134455. addOutputNode(node: NodeMaterialBlock): this;
  134456. /**
  134457. * Remove a block from the list of root nodes
  134458. * @param node defines the node to remove
  134459. * @returns the current material
  134460. */
  134461. removeOutputNode(node: NodeMaterialBlock): this;
  134462. private _addVertexOutputNode;
  134463. private _removeVertexOutputNode;
  134464. private _addFragmentOutputNode;
  134465. private _removeFragmentOutputNode;
  134466. /**
  134467. * Specifies if the material will require alpha blending
  134468. * @returns a boolean specifying if alpha blending is needed
  134469. */
  134470. needAlphaBlending(): boolean;
  134471. /**
  134472. * Specifies if this material should be rendered in alpha test mode
  134473. * @returns a boolean specifying if an alpha test is needed.
  134474. */
  134475. needAlphaTesting(): boolean;
  134476. private _initializeBlock;
  134477. private _resetDualBlocks;
  134478. /**
  134479. * Remove a block from the current node material
  134480. * @param block defines the block to remove
  134481. */
  134482. removeBlock(block: NodeMaterialBlock): void;
  134483. /**
  134484. * Build the material and generates the inner effect
  134485. * @param verbose defines if the build should log activity
  134486. */
  134487. build(verbose?: boolean): void;
  134488. /**
  134489. * Runs an otpimization phase to try to improve the shader code
  134490. */
  134491. optimize(): void;
  134492. private _prepareDefinesForAttributes;
  134493. /**
  134494. * Create a post process from the material
  134495. * @param camera The camera to apply the render pass to.
  134496. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  134497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134498. * @param engine The engine which the post process will be applied. (default: current engine)
  134499. * @param reusable If the post process can be reused on the same frame. (default: false)
  134500. * @param textureType Type of textures used when performing the post process. (default: 0)
  134501. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  134502. * @returns the post process created
  134503. */
  134504. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  134505. private _processDefines;
  134506. /**
  134507. * Get if the submesh is ready to be used and all its information available.
  134508. * Child classes can use it to update shaders
  134509. * @param mesh defines the mesh to check
  134510. * @param subMesh defines which submesh to check
  134511. * @param useInstances specifies that instances should be used
  134512. * @returns a boolean indicating that the submesh is ready or not
  134513. */
  134514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134515. /**
  134516. * Get a string representing the shaders built by the current node graph
  134517. */
  134518. get compiledShaders(): string;
  134519. /**
  134520. * Binds the world matrix to the material
  134521. * @param world defines the world transformation matrix
  134522. */
  134523. bindOnlyWorldMatrix(world: Matrix): void;
  134524. /**
  134525. * Binds the submesh to this material by preparing the effect and shader to draw
  134526. * @param world defines the world transformation matrix
  134527. * @param mesh defines the mesh containing the submesh
  134528. * @param subMesh defines the submesh to bind the material to
  134529. */
  134530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134531. /**
  134532. * Gets the active textures from the material
  134533. * @returns an array of textures
  134534. */
  134535. getActiveTextures(): BaseTexture[];
  134536. /**
  134537. * Gets the list of texture blocks
  134538. * @returns an array of texture blocks
  134539. */
  134540. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  134541. /**
  134542. * Specifies if the material uses a texture
  134543. * @param texture defines the texture to check against the material
  134544. * @returns a boolean specifying if the material uses the texture
  134545. */
  134546. hasTexture(texture: BaseTexture): boolean;
  134547. /**
  134548. * Disposes the material
  134549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134552. */
  134553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134554. /** Creates the node editor window. */
  134555. private _createNodeEditor;
  134556. /**
  134557. * Launch the node material editor
  134558. * @param config Define the configuration of the editor
  134559. * @return a promise fulfilled when the node editor is visible
  134560. */
  134561. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134562. /**
  134563. * Clear the current material
  134564. */
  134565. clear(): void;
  134566. /**
  134567. * Clear the current material and set it to a default state
  134568. */
  134569. setToDefault(): void;
  134570. /**
  134571. * Clear the current material and set it to a default state for post process
  134572. */
  134573. setToDefaultPostProcess(): void;
  134574. /**
  134575. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134576. * @param url defines the url to load from
  134577. * @returns a promise that will fullfil when the material is fully loaded
  134578. */
  134579. loadAsync(url: string): Promise<void>;
  134580. private _gatherBlocks;
  134581. /**
  134582. * Generate a string containing the code declaration required to create an equivalent of this material
  134583. * @returns a string
  134584. */
  134585. generateCode(): string;
  134586. /**
  134587. * Serializes this material in a JSON representation
  134588. * @returns the serialized material object
  134589. */
  134590. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134591. private _restoreConnections;
  134592. /**
  134593. * Clear the current graph and load a new one from a serialization object
  134594. * @param source defines the JSON representation of the material
  134595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134596. */
  134597. loadFromSerialization(source: any, rootUrl?: string): void;
  134598. /**
  134599. * Makes a duplicate of the current material.
  134600. * @param name - name to use for the new material.
  134601. */
  134602. clone(name: string): NodeMaterial;
  134603. /**
  134604. * Creates a node material from parsed material data
  134605. * @param source defines the JSON representation of the material
  134606. * @param scene defines the hosting scene
  134607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134608. * @returns a new node material
  134609. */
  134610. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134611. /**
  134612. * Creates a node material from a snippet saved in a remote file
  134613. * @param name defines the name of the material to create
  134614. * @param url defines the url to load from
  134615. * @param scene defines the hosting scene
  134616. * @returns a promise that will resolve to the new node material
  134617. */
  134618. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134619. /**
  134620. * Creates a node material from a snippet saved by the node material editor
  134621. * @param snippetId defines the snippet to load
  134622. * @param scene defines the hosting scene
  134623. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134624. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134625. * @returns a promise that will resolve to the new node material
  134626. */
  134627. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134628. /**
  134629. * Creates a new node material set to default basic configuration
  134630. * @param name defines the name of the material
  134631. * @param scene defines the hosting scene
  134632. * @returns a new NodeMaterial
  134633. */
  134634. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134635. }
  134636. }
  134637. declare module BABYLON {
  134638. /**
  134639. * Block used to read a texture from a sampler
  134640. */
  134641. export class TextureBlock extends NodeMaterialBlock {
  134642. private _defineName;
  134643. private _linearDefineName;
  134644. private _gammaDefineName;
  134645. private _tempTextureRead;
  134646. private _samplerName;
  134647. private _transformedUVName;
  134648. private _textureTransformName;
  134649. private _textureInfoName;
  134650. private _mainUVName;
  134651. private _mainUVDefineName;
  134652. /**
  134653. * Gets or sets the texture associated with the node
  134654. */
  134655. texture: Nullable<Texture>;
  134656. /**
  134657. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134658. */
  134659. convertToGammaSpace: boolean;
  134660. /**
  134661. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134662. */
  134663. convertToLinearSpace: boolean;
  134664. /**
  134665. * Create a new TextureBlock
  134666. * @param name defines the block name
  134667. */
  134668. constructor(name: string);
  134669. /**
  134670. * Gets the current class name
  134671. * @returns the class name
  134672. */
  134673. getClassName(): string;
  134674. /**
  134675. * Gets the uv input component
  134676. */
  134677. get uv(): NodeMaterialConnectionPoint;
  134678. /**
  134679. * Gets the rgba output component
  134680. */
  134681. get rgba(): NodeMaterialConnectionPoint;
  134682. /**
  134683. * Gets the rgb output component
  134684. */
  134685. get rgb(): NodeMaterialConnectionPoint;
  134686. /**
  134687. * Gets the r output component
  134688. */
  134689. get r(): NodeMaterialConnectionPoint;
  134690. /**
  134691. * Gets the g output component
  134692. */
  134693. get g(): NodeMaterialConnectionPoint;
  134694. /**
  134695. * Gets the b output component
  134696. */
  134697. get b(): NodeMaterialConnectionPoint;
  134698. /**
  134699. * Gets the a output component
  134700. */
  134701. get a(): NodeMaterialConnectionPoint;
  134702. get target(): NodeMaterialBlockTargets;
  134703. autoConfigure(material: NodeMaterial): void;
  134704. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134706. isReady(): boolean;
  134707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134708. private get _isMixed();
  134709. private _injectVertexCode;
  134710. private _writeTextureRead;
  134711. private _writeOutput;
  134712. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134713. protected _dumpPropertiesCode(): string;
  134714. serialize(): any;
  134715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134716. }
  134717. }
  134718. declare module BABYLON {
  134719. /**
  134720. * Class used to store shared data between 2 NodeMaterialBuildState
  134721. */
  134722. export class NodeMaterialBuildStateSharedData {
  134723. /**
  134724. * Gets the list of emitted varyings
  134725. */
  134726. temps: string[];
  134727. /**
  134728. * Gets the list of emitted varyings
  134729. */
  134730. varyings: string[];
  134731. /**
  134732. * Gets the varying declaration string
  134733. */
  134734. varyingDeclaration: string;
  134735. /**
  134736. * Input blocks
  134737. */
  134738. inputBlocks: InputBlock[];
  134739. /**
  134740. * Input blocks
  134741. */
  134742. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  134743. /**
  134744. * Bindable blocks (Blocks that need to set data to the effect)
  134745. */
  134746. bindableBlocks: NodeMaterialBlock[];
  134747. /**
  134748. * List of blocks that can provide a compilation fallback
  134749. */
  134750. blocksWithFallbacks: NodeMaterialBlock[];
  134751. /**
  134752. * List of blocks that can provide a define update
  134753. */
  134754. blocksWithDefines: NodeMaterialBlock[];
  134755. /**
  134756. * List of blocks that can provide a repeatable content
  134757. */
  134758. repeatableContentBlocks: NodeMaterialBlock[];
  134759. /**
  134760. * List of blocks that can provide a dynamic list of uniforms
  134761. */
  134762. dynamicUniformBlocks: NodeMaterialBlock[];
  134763. /**
  134764. * List of blocks that can block the isReady function for the material
  134765. */
  134766. blockingBlocks: NodeMaterialBlock[];
  134767. /**
  134768. * Gets the list of animated inputs
  134769. */
  134770. animatedInputs: InputBlock[];
  134771. /**
  134772. * Build Id used to avoid multiple recompilations
  134773. */
  134774. buildId: number;
  134775. /** List of emitted variables */
  134776. variableNames: {
  134777. [key: string]: number;
  134778. };
  134779. /** List of emitted defines */
  134780. defineNames: {
  134781. [key: string]: number;
  134782. };
  134783. /** Should emit comments? */
  134784. emitComments: boolean;
  134785. /** Emit build activity */
  134786. verbose: boolean;
  134787. /** Gets or sets the hosting scene */
  134788. scene: Scene;
  134789. /**
  134790. * Gets the compilation hints emitted at compilation time
  134791. */
  134792. hints: {
  134793. needWorldViewMatrix: boolean;
  134794. needWorldViewProjectionMatrix: boolean;
  134795. needAlphaBlending: boolean;
  134796. needAlphaTesting: boolean;
  134797. };
  134798. /**
  134799. * List of compilation checks
  134800. */
  134801. checks: {
  134802. emitVertex: boolean;
  134803. emitFragment: boolean;
  134804. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134805. };
  134806. /** Creates a new shared data */
  134807. constructor();
  134808. /**
  134809. * Emits console errors and exceptions if there is a failing check
  134810. */
  134811. emitErrors(): void;
  134812. }
  134813. }
  134814. declare module BABYLON {
  134815. /**
  134816. * Class used to store node based material build state
  134817. */
  134818. export class NodeMaterialBuildState {
  134819. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134820. supportUniformBuffers: boolean;
  134821. /**
  134822. * Gets the list of emitted attributes
  134823. */
  134824. attributes: string[];
  134825. /**
  134826. * Gets the list of emitted uniforms
  134827. */
  134828. uniforms: string[];
  134829. /**
  134830. * Gets the list of emitted constants
  134831. */
  134832. constants: string[];
  134833. /**
  134834. * Gets the list of emitted samplers
  134835. */
  134836. samplers: string[];
  134837. /**
  134838. * Gets the list of emitted functions
  134839. */
  134840. functions: {
  134841. [key: string]: string;
  134842. };
  134843. /**
  134844. * Gets the list of emitted extensions
  134845. */
  134846. extensions: {
  134847. [key: string]: string;
  134848. };
  134849. /**
  134850. * Gets the target of the compilation state
  134851. */
  134852. target: NodeMaterialBlockTargets;
  134853. /**
  134854. * Gets the list of emitted counters
  134855. */
  134856. counters: {
  134857. [key: string]: number;
  134858. };
  134859. /**
  134860. * Shared data between multiple NodeMaterialBuildState instances
  134861. */
  134862. sharedData: NodeMaterialBuildStateSharedData;
  134863. /** @hidden */
  134864. _vertexState: NodeMaterialBuildState;
  134865. /** @hidden */
  134866. _attributeDeclaration: string;
  134867. /** @hidden */
  134868. _uniformDeclaration: string;
  134869. /** @hidden */
  134870. _constantDeclaration: string;
  134871. /** @hidden */
  134872. _samplerDeclaration: string;
  134873. /** @hidden */
  134874. _varyingTransfer: string;
  134875. /** @hidden */
  134876. _injectAtEnd: string;
  134877. private _repeatableContentAnchorIndex;
  134878. /** @hidden */
  134879. _builtCompilationString: string;
  134880. /**
  134881. * Gets the emitted compilation strings
  134882. */
  134883. compilationString: string;
  134884. /**
  134885. * Finalize the compilation strings
  134886. * @param state defines the current compilation state
  134887. */
  134888. finalize(state: NodeMaterialBuildState): void;
  134889. /** @hidden */
  134890. get _repeatableContentAnchor(): string;
  134891. /** @hidden */
  134892. _getFreeVariableName(prefix: string): string;
  134893. /** @hidden */
  134894. _getFreeDefineName(prefix: string): string;
  134895. /** @hidden */
  134896. _excludeVariableName(name: string): void;
  134897. /** @hidden */
  134898. _emit2DSampler(name: string): void;
  134899. /** @hidden */
  134900. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  134901. /** @hidden */
  134902. _emitExtension(name: string, extension: string, define?: string): void;
  134903. /** @hidden */
  134904. _emitFunction(name: string, code: string, comments: string): void;
  134905. /** @hidden */
  134906. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  134907. replaceStrings?: {
  134908. search: RegExp;
  134909. replace: string;
  134910. }[];
  134911. repeatKey?: string;
  134912. }): string;
  134913. /** @hidden */
  134914. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  134915. repeatKey?: string;
  134916. removeAttributes?: boolean;
  134917. removeUniforms?: boolean;
  134918. removeVaryings?: boolean;
  134919. removeIfDef?: boolean;
  134920. replaceStrings?: {
  134921. search: RegExp;
  134922. replace: string;
  134923. }[];
  134924. }, storeKey?: string): void;
  134925. /** @hidden */
  134926. _registerTempVariable(name: string): boolean;
  134927. /** @hidden */
  134928. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  134929. /** @hidden */
  134930. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  134931. /** @hidden */
  134932. _emitFloat(value: number): string;
  134933. }
  134934. }
  134935. declare module BABYLON {
  134936. /**
  134937. * Defines a block that can be used inside a node based material
  134938. */
  134939. export class NodeMaterialBlock {
  134940. private _buildId;
  134941. private _buildTarget;
  134942. private _target;
  134943. private _isFinalMerger;
  134944. private _isInput;
  134945. protected _isUnique: boolean;
  134946. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  134947. inputsAreExclusive: boolean;
  134948. /** @hidden */
  134949. _codeVariableName: string;
  134950. /** @hidden */
  134951. _inputs: NodeMaterialConnectionPoint[];
  134952. /** @hidden */
  134953. _outputs: NodeMaterialConnectionPoint[];
  134954. /** @hidden */
  134955. _preparationId: number;
  134956. /**
  134957. * Gets or sets the name of the block
  134958. */
  134959. name: string;
  134960. /**
  134961. * Gets or sets the unique id of the node
  134962. */
  134963. uniqueId: number;
  134964. /**
  134965. * Gets or sets the comments associated with this block
  134966. */
  134967. comments: string;
  134968. /**
  134969. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  134970. */
  134971. get isUnique(): boolean;
  134972. /**
  134973. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  134974. */
  134975. get isFinalMerger(): boolean;
  134976. /**
  134977. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  134978. */
  134979. get isInput(): boolean;
  134980. /**
  134981. * Gets or sets the build Id
  134982. */
  134983. get buildId(): number;
  134984. set buildId(value: number);
  134985. /**
  134986. * Gets or sets the target of the block
  134987. */
  134988. get target(): NodeMaterialBlockTargets;
  134989. set target(value: NodeMaterialBlockTargets);
  134990. /**
  134991. * Gets the list of input points
  134992. */
  134993. get inputs(): NodeMaterialConnectionPoint[];
  134994. /** Gets the list of output points */
  134995. get outputs(): NodeMaterialConnectionPoint[];
  134996. /**
  134997. * Find an input by its name
  134998. * @param name defines the name of the input to look for
  134999. * @returns the input or null if not found
  135000. */
  135001. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135002. /**
  135003. * Find an output by its name
  135004. * @param name defines the name of the outputto look for
  135005. * @returns the output or null if not found
  135006. */
  135007. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  135008. /**
  135009. * Creates a new NodeMaterialBlock
  135010. * @param name defines the block name
  135011. * @param target defines the target of that block (Vertex by default)
  135012. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  135013. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  135014. */
  135015. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  135016. /**
  135017. * Initialize the block and prepare the context for build
  135018. * @param state defines the state that will be used for the build
  135019. */
  135020. initialize(state: NodeMaterialBuildState): void;
  135021. /**
  135022. * Bind data to effect. Will only be called for blocks with isBindable === true
  135023. * @param effect defines the effect to bind data to
  135024. * @param nodeMaterial defines the hosting NodeMaterial
  135025. * @param mesh defines the mesh that will be rendered
  135026. * @param subMesh defines the submesh that will be rendered
  135027. */
  135028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  135029. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  135030. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  135031. protected _writeFloat(value: number): string;
  135032. /**
  135033. * Gets the current class name e.g. "NodeMaterialBlock"
  135034. * @returns the class name
  135035. */
  135036. getClassName(): string;
  135037. /**
  135038. * Register a new input. Must be called inside a block constructor
  135039. * @param name defines the connection point name
  135040. * @param type defines the connection point type
  135041. * @param isOptional defines a boolean indicating that this input can be omitted
  135042. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135043. * @param point an already created connection point. If not provided, create a new one
  135044. * @returns the current block
  135045. */
  135046. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135047. /**
  135048. * Register a new output. Must be called inside a block constructor
  135049. * @param name defines the connection point name
  135050. * @param type defines the connection point type
  135051. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  135052. * @param point an already created connection point. If not provided, create a new one
  135053. * @returns the current block
  135054. */
  135055. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  135056. /**
  135057. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  135058. * @param forOutput defines an optional connection point to check compatibility with
  135059. * @returns the first available input or null
  135060. */
  135061. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  135062. /**
  135063. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  135064. * @param forBlock defines an optional block to check compatibility with
  135065. * @returns the first available input or null
  135066. */
  135067. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  135068. /**
  135069. * Gets the sibling of the given output
  135070. * @param current defines the current output
  135071. * @returns the next output in the list or null
  135072. */
  135073. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  135074. /**
  135075. * Connect current block with another block
  135076. * @param other defines the block to connect with
  135077. * @param options define the various options to help pick the right connections
  135078. * @returns the current block
  135079. */
  135080. connectTo(other: NodeMaterialBlock, options?: {
  135081. input?: string;
  135082. output?: string;
  135083. outputSwizzle?: string;
  135084. }): this | undefined;
  135085. protected _buildBlock(state: NodeMaterialBuildState): void;
  135086. /**
  135087. * Add uniforms, samplers and uniform buffers at compilation time
  135088. * @param state defines the state to update
  135089. * @param nodeMaterial defines the node material requesting the update
  135090. * @param defines defines the material defines to update
  135091. * @param uniformBuffers defines the list of uniform buffer names
  135092. */
  135093. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135094. /**
  135095. * Add potential fallbacks if shader compilation fails
  135096. * @param mesh defines the mesh to be rendered
  135097. * @param fallbacks defines the current prioritized list of fallbacks
  135098. */
  135099. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135100. /**
  135101. * Initialize defines for shader compilation
  135102. * @param mesh defines the mesh to be rendered
  135103. * @param nodeMaterial defines the node material requesting the update
  135104. * @param defines defines the material defines to update
  135105. * @param useInstances specifies that instances should be used
  135106. */
  135107. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135108. /**
  135109. * Update defines for shader compilation
  135110. * @param mesh defines the mesh to be rendered
  135111. * @param nodeMaterial defines the node material requesting the update
  135112. * @param defines defines the material defines to update
  135113. * @param useInstances specifies that instances should be used
  135114. */
  135115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135116. /**
  135117. * Lets the block try to connect some inputs automatically
  135118. * @param material defines the hosting NodeMaterial
  135119. */
  135120. autoConfigure(material: NodeMaterial): void;
  135121. /**
  135122. * Function called when a block is declared as repeatable content generator
  135123. * @param vertexShaderState defines the current compilation state for the vertex shader
  135124. * @param fragmentShaderState defines the current compilation state for the fragment shader
  135125. * @param mesh defines the mesh to be rendered
  135126. * @param defines defines the material defines to update
  135127. */
  135128. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135129. /**
  135130. * Checks if the block is ready
  135131. * @param mesh defines the mesh to be rendered
  135132. * @param nodeMaterial defines the node material requesting the update
  135133. * @param defines defines the material defines to update
  135134. * @param useInstances specifies that instances should be used
  135135. * @returns true if the block is ready
  135136. */
  135137. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  135138. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  135139. private _processBuild;
  135140. /**
  135141. * Compile the current node and generate the shader code
  135142. * @param state defines the current compilation state (uniforms, samplers, current string)
  135143. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  135144. * @returns true if already built
  135145. */
  135146. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  135147. protected _inputRename(name: string): string;
  135148. protected _outputRename(name: string): string;
  135149. protected _dumpPropertiesCode(): string;
  135150. /** @hidden */
  135151. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  135152. /** @hidden */
  135153. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  135154. /**
  135155. * Clone the current block to a new identical block
  135156. * @param scene defines the hosting scene
  135157. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  135158. * @returns a copy of the current block
  135159. */
  135160. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  135161. /**
  135162. * Serializes this block in a JSON representation
  135163. * @returns the serialized block object
  135164. */
  135165. serialize(): any;
  135166. /** @hidden */
  135167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135168. private _deserializePortDisplayNames;
  135169. /**
  135170. * Release resources
  135171. */
  135172. dispose(): void;
  135173. }
  135174. }
  135175. declare module BABYLON {
  135176. /**
  135177. * Enum defining the type of animations supported by InputBlock
  135178. */
  135179. export enum AnimatedInputBlockTypes {
  135180. /** No animation */
  135181. None = 0,
  135182. /** Time based animation. Will only work for floats */
  135183. Time = 1
  135184. }
  135185. }
  135186. declare module BABYLON {
  135187. /**
  135188. * Block used to expose an input value
  135189. */
  135190. export class InputBlock extends NodeMaterialBlock {
  135191. private _mode;
  135192. private _associatedVariableName;
  135193. private _storedValue;
  135194. private _valueCallback;
  135195. private _type;
  135196. private _animationType;
  135197. /** Gets or set a value used to limit the range of float values */
  135198. min: number;
  135199. /** Gets or set a value used to limit the range of float values */
  135200. max: number;
  135201. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  135202. isBoolean: boolean;
  135203. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  135204. matrixMode: number;
  135205. /** @hidden */
  135206. _systemValue: Nullable<NodeMaterialSystemValues>;
  135207. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  135208. visibleInInspector: boolean;
  135209. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  135210. isConstant: boolean;
  135211. /** Gets or sets the group to use to display this block in the Inspector */
  135212. groupInInspector: string;
  135213. /** Gets an observable raised when the value is changed */
  135214. onValueChangedObservable: Observable<InputBlock>;
  135215. /**
  135216. * Gets or sets the connection point type (default is float)
  135217. */
  135218. get type(): NodeMaterialBlockConnectionPointTypes;
  135219. /**
  135220. * Creates a new InputBlock
  135221. * @param name defines the block name
  135222. * @param target defines the target of that block (Vertex by default)
  135223. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  135224. */
  135225. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  135226. /**
  135227. * Gets the output component
  135228. */
  135229. get output(): NodeMaterialConnectionPoint;
  135230. /**
  135231. * Set the source of this connection point to a vertex attribute
  135232. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  135233. * @returns the current connection point
  135234. */
  135235. setAsAttribute(attributeName?: string): InputBlock;
  135236. /**
  135237. * Set the source of this connection point to a system value
  135238. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  135239. * @returns the current connection point
  135240. */
  135241. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  135242. /**
  135243. * Gets or sets the value of that point.
  135244. * Please note that this value will be ignored if valueCallback is defined
  135245. */
  135246. get value(): any;
  135247. set value(value: any);
  135248. /**
  135249. * Gets or sets a callback used to get the value of that point.
  135250. * Please note that setting this value will force the connection point to ignore the value property
  135251. */
  135252. get valueCallback(): () => any;
  135253. set valueCallback(value: () => any);
  135254. /**
  135255. * Gets or sets the associated variable name in the shader
  135256. */
  135257. get associatedVariableName(): string;
  135258. set associatedVariableName(value: string);
  135259. /** Gets or sets the type of animation applied to the input */
  135260. get animationType(): AnimatedInputBlockTypes;
  135261. set animationType(value: AnimatedInputBlockTypes);
  135262. /**
  135263. * Gets a boolean indicating that this connection point not defined yet
  135264. */
  135265. get isUndefined(): boolean;
  135266. /**
  135267. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  135268. * In this case the connection point name must be the name of the uniform to use.
  135269. * Can only be set on inputs
  135270. */
  135271. get isUniform(): boolean;
  135272. set isUniform(value: boolean);
  135273. /**
  135274. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  135275. * In this case the connection point name must be the name of the attribute to use
  135276. * Can only be set on inputs
  135277. */
  135278. get isAttribute(): boolean;
  135279. set isAttribute(value: boolean);
  135280. /**
  135281. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  135282. * Can only be set on exit points
  135283. */
  135284. get isVarying(): boolean;
  135285. set isVarying(value: boolean);
  135286. /**
  135287. * Gets a boolean indicating that the current connection point is a system value
  135288. */
  135289. get isSystemValue(): boolean;
  135290. /**
  135291. * Gets or sets the current well known value or null if not defined as a system value
  135292. */
  135293. get systemValue(): Nullable<NodeMaterialSystemValues>;
  135294. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  135295. /**
  135296. * Gets the current class name
  135297. * @returns the class name
  135298. */
  135299. getClassName(): string;
  135300. /**
  135301. * Animate the input if animationType !== None
  135302. * @param scene defines the rendering scene
  135303. */
  135304. animate(scene: Scene): void;
  135305. private _emitDefine;
  135306. initialize(state: NodeMaterialBuildState): void;
  135307. /**
  135308. * Set the input block to its default value (based on its type)
  135309. */
  135310. setDefaultValue(): void;
  135311. private _emitConstant;
  135312. private _emit;
  135313. /** @hidden */
  135314. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  135315. /** @hidden */
  135316. _transmit(effect: Effect, scene: Scene): void;
  135317. protected _buildBlock(state: NodeMaterialBuildState): void;
  135318. protected _dumpPropertiesCode(): string;
  135319. dispose(): void;
  135320. serialize(): any;
  135321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135322. }
  135323. }
  135324. declare module BABYLON {
  135325. /**
  135326. * Enum used to define the compatibility state between two connection points
  135327. */
  135328. export enum NodeMaterialConnectionPointCompatibilityStates {
  135329. /** Points are compatibles */
  135330. Compatible = 0,
  135331. /** Points are incompatible because of their types */
  135332. TypeIncompatible = 1,
  135333. /** Points are incompatible because of their targets (vertex vs fragment) */
  135334. TargetIncompatible = 2
  135335. }
  135336. /**
  135337. * Defines the direction of a connection point
  135338. */
  135339. export enum NodeMaterialConnectionPointDirection {
  135340. /** Input */
  135341. Input = 0,
  135342. /** Output */
  135343. Output = 1
  135344. }
  135345. /**
  135346. * Defines a connection point for a block
  135347. */
  135348. export class NodeMaterialConnectionPoint {
  135349. /** @hidden */
  135350. _ownerBlock: NodeMaterialBlock;
  135351. /** @hidden */
  135352. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  135353. private _endpoints;
  135354. private _associatedVariableName;
  135355. private _direction;
  135356. /** @hidden */
  135357. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135358. /** @hidden */
  135359. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  135360. private _type;
  135361. /** @hidden */
  135362. _enforceAssociatedVariableName: boolean;
  135363. /** Gets the direction of the point */
  135364. get direction(): NodeMaterialConnectionPointDirection;
  135365. /** Indicates that this connection point needs dual validation before being connected to another point */
  135366. needDualDirectionValidation: boolean;
  135367. /**
  135368. * Gets or sets the additional types supported by this connection point
  135369. */
  135370. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135371. /**
  135372. * Gets or sets the additional types excluded by this connection point
  135373. */
  135374. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  135375. /**
  135376. * Observable triggered when this point is connected
  135377. */
  135378. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  135379. /**
  135380. * Gets or sets the associated variable name in the shader
  135381. */
  135382. get associatedVariableName(): string;
  135383. set associatedVariableName(value: string);
  135384. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  135385. get innerType(): NodeMaterialBlockConnectionPointTypes;
  135386. /**
  135387. * Gets or sets the connection point type (default is float)
  135388. */
  135389. get type(): NodeMaterialBlockConnectionPointTypes;
  135390. set type(value: NodeMaterialBlockConnectionPointTypes);
  135391. /**
  135392. * Gets or sets the connection point name
  135393. */
  135394. name: string;
  135395. /**
  135396. * Gets or sets the connection point name
  135397. */
  135398. displayName: string;
  135399. /**
  135400. * Gets or sets a boolean indicating that this connection point can be omitted
  135401. */
  135402. isOptional: boolean;
  135403. /**
  135404. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  135405. */
  135406. define: string;
  135407. /** @hidden */
  135408. _prioritizeVertex: boolean;
  135409. private _target;
  135410. /** Gets or sets the target of that connection point */
  135411. get target(): NodeMaterialBlockTargets;
  135412. set target(value: NodeMaterialBlockTargets);
  135413. /**
  135414. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  135415. */
  135416. get isConnected(): boolean;
  135417. /**
  135418. * Gets a boolean indicating that the current point is connected to an input block
  135419. */
  135420. get isConnectedToInputBlock(): boolean;
  135421. /**
  135422. * Gets a the connected input block (if any)
  135423. */
  135424. get connectInputBlock(): Nullable<InputBlock>;
  135425. /** Get the other side of the connection (if any) */
  135426. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  135427. /** Get the block that owns this connection point */
  135428. get ownerBlock(): NodeMaterialBlock;
  135429. /** Get the block connected on the other side of this connection (if any) */
  135430. get sourceBlock(): Nullable<NodeMaterialBlock>;
  135431. /** Get the block connected on the endpoints of this connection (if any) */
  135432. get connectedBlocks(): Array<NodeMaterialBlock>;
  135433. /** Gets the list of connected endpoints */
  135434. get endpoints(): NodeMaterialConnectionPoint[];
  135435. /** Gets a boolean indicating if that output point is connected to at least one input */
  135436. get hasEndpoints(): boolean;
  135437. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  135438. get isConnectedInVertexShader(): boolean;
  135439. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  135440. get isConnectedInFragmentShader(): boolean;
  135441. /**
  135442. * Creates a block suitable to be used as an input for this input point.
  135443. * If null is returned, a block based on the point type will be created.
  135444. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  135445. */
  135446. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  135447. /**
  135448. * Creates a new connection point
  135449. * @param name defines the connection point name
  135450. * @param ownerBlock defines the block hosting this connection point
  135451. * @param direction defines the direction of the connection point
  135452. */
  135453. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  135454. /**
  135455. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  135456. * @returns the class name
  135457. */
  135458. getClassName(): string;
  135459. /**
  135460. * Gets a boolean indicating if the current point can be connected to another point
  135461. * @param connectionPoint defines the other connection point
  135462. * @returns a boolean
  135463. */
  135464. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  135465. /**
  135466. * Gets a number indicating if the current point can be connected to another point
  135467. * @param connectionPoint defines the other connection point
  135468. * @returns a number defining the compatibility state
  135469. */
  135470. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  135471. /**
  135472. * Connect this point to another connection point
  135473. * @param connectionPoint defines the other connection point
  135474. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  135475. * @returns the current connection point
  135476. */
  135477. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  135478. /**
  135479. * Disconnect this point from one of his endpoint
  135480. * @param endpoint defines the other connection point
  135481. * @returns the current connection point
  135482. */
  135483. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135484. /**
  135485. * Serializes this point in a JSON representation
  135486. * @param isInput defines if the connection point is an input (default is true)
  135487. * @returns the serialized point object
  135488. */
  135489. serialize(isInput?: boolean): any;
  135490. /**
  135491. * Release resources
  135492. */
  135493. dispose(): void;
  135494. }
  135495. }
  135496. declare module BABYLON {
  135497. /**
  135498. * Block used to add support for vertex skinning (bones)
  135499. */
  135500. export class BonesBlock extends NodeMaterialBlock {
  135501. /**
  135502. * Creates a new BonesBlock
  135503. * @param name defines the block name
  135504. */
  135505. constructor(name: string);
  135506. /**
  135507. * Initialize the block and prepare the context for build
  135508. * @param state defines the state that will be used for the build
  135509. */
  135510. initialize(state: NodeMaterialBuildState): void;
  135511. /**
  135512. * Gets the current class name
  135513. * @returns the class name
  135514. */
  135515. getClassName(): string;
  135516. /**
  135517. * Gets the matrix indices input component
  135518. */
  135519. get matricesIndices(): NodeMaterialConnectionPoint;
  135520. /**
  135521. * Gets the matrix weights input component
  135522. */
  135523. get matricesWeights(): NodeMaterialConnectionPoint;
  135524. /**
  135525. * Gets the extra matrix indices input component
  135526. */
  135527. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135528. /**
  135529. * Gets the extra matrix weights input component
  135530. */
  135531. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135532. /**
  135533. * Gets the world input component
  135534. */
  135535. get world(): NodeMaterialConnectionPoint;
  135536. /**
  135537. * Gets the output component
  135538. */
  135539. get output(): NodeMaterialConnectionPoint;
  135540. autoConfigure(material: NodeMaterial): void;
  135541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135544. protected _buildBlock(state: NodeMaterialBuildState): this;
  135545. }
  135546. }
  135547. declare module BABYLON {
  135548. /**
  135549. * Block used to add support for instances
  135550. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135551. */
  135552. export class InstancesBlock extends NodeMaterialBlock {
  135553. /**
  135554. * Creates a new InstancesBlock
  135555. * @param name defines the block name
  135556. */
  135557. constructor(name: string);
  135558. /**
  135559. * Gets the current class name
  135560. * @returns the class name
  135561. */
  135562. getClassName(): string;
  135563. /**
  135564. * Gets the first world row input component
  135565. */
  135566. get world0(): NodeMaterialConnectionPoint;
  135567. /**
  135568. * Gets the second world row input component
  135569. */
  135570. get world1(): NodeMaterialConnectionPoint;
  135571. /**
  135572. * Gets the third world row input component
  135573. */
  135574. get world2(): NodeMaterialConnectionPoint;
  135575. /**
  135576. * Gets the forth world row input component
  135577. */
  135578. get world3(): NodeMaterialConnectionPoint;
  135579. /**
  135580. * Gets the world input component
  135581. */
  135582. get world(): NodeMaterialConnectionPoint;
  135583. /**
  135584. * Gets the output component
  135585. */
  135586. get output(): NodeMaterialConnectionPoint;
  135587. /**
  135588. * Gets the isntanceID component
  135589. */
  135590. get instanceID(): NodeMaterialConnectionPoint;
  135591. autoConfigure(material: NodeMaterial): void;
  135592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135593. protected _buildBlock(state: NodeMaterialBuildState): this;
  135594. }
  135595. }
  135596. declare module BABYLON {
  135597. /**
  135598. * Block used to add morph targets support to vertex shader
  135599. */
  135600. export class MorphTargetsBlock extends NodeMaterialBlock {
  135601. private _repeatableContentAnchor;
  135602. /**
  135603. * Create a new MorphTargetsBlock
  135604. * @param name defines the block name
  135605. */
  135606. constructor(name: string);
  135607. /**
  135608. * Gets the current class name
  135609. * @returns the class name
  135610. */
  135611. getClassName(): string;
  135612. /**
  135613. * Gets the position input component
  135614. */
  135615. get position(): NodeMaterialConnectionPoint;
  135616. /**
  135617. * Gets the normal input component
  135618. */
  135619. get normal(): NodeMaterialConnectionPoint;
  135620. /**
  135621. * Gets the tangent input component
  135622. */
  135623. get tangent(): NodeMaterialConnectionPoint;
  135624. /**
  135625. * Gets the tangent input component
  135626. */
  135627. get uv(): NodeMaterialConnectionPoint;
  135628. /**
  135629. * Gets the position output component
  135630. */
  135631. get positionOutput(): NodeMaterialConnectionPoint;
  135632. /**
  135633. * Gets the normal output component
  135634. */
  135635. get normalOutput(): NodeMaterialConnectionPoint;
  135636. /**
  135637. * Gets the tangent output component
  135638. */
  135639. get tangentOutput(): NodeMaterialConnectionPoint;
  135640. /**
  135641. * Gets the tangent output component
  135642. */
  135643. get uvOutput(): NodeMaterialConnectionPoint;
  135644. initialize(state: NodeMaterialBuildState): void;
  135645. autoConfigure(material: NodeMaterial): void;
  135646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135648. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135649. protected _buildBlock(state: NodeMaterialBuildState): this;
  135650. }
  135651. }
  135652. declare module BABYLON {
  135653. /**
  135654. * Block used to get data information from a light
  135655. */
  135656. export class LightInformationBlock extends NodeMaterialBlock {
  135657. private _lightDataUniformName;
  135658. private _lightColorUniformName;
  135659. private _lightTypeDefineName;
  135660. /**
  135661. * Gets or sets the light associated with this block
  135662. */
  135663. light: Nullable<Light>;
  135664. /**
  135665. * Creates a new LightInformationBlock
  135666. * @param name defines the block name
  135667. */
  135668. constructor(name: string);
  135669. /**
  135670. * Gets the current class name
  135671. * @returns the class name
  135672. */
  135673. getClassName(): string;
  135674. /**
  135675. * Gets the world position input component
  135676. */
  135677. get worldPosition(): NodeMaterialConnectionPoint;
  135678. /**
  135679. * Gets the direction output component
  135680. */
  135681. get direction(): NodeMaterialConnectionPoint;
  135682. /**
  135683. * Gets the direction output component
  135684. */
  135685. get color(): NodeMaterialConnectionPoint;
  135686. /**
  135687. * Gets the direction output component
  135688. */
  135689. get intensity(): NodeMaterialConnectionPoint;
  135690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135692. protected _buildBlock(state: NodeMaterialBuildState): this;
  135693. serialize(): any;
  135694. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135695. }
  135696. }
  135697. declare module BABYLON {
  135698. /**
  135699. * Block used to add image processing support to fragment shader
  135700. */
  135701. export class ImageProcessingBlock extends NodeMaterialBlock {
  135702. /**
  135703. * Create a new ImageProcessingBlock
  135704. * @param name defines the block name
  135705. */
  135706. constructor(name: string);
  135707. /**
  135708. * Gets the current class name
  135709. * @returns the class name
  135710. */
  135711. getClassName(): string;
  135712. /**
  135713. * Gets the color input component
  135714. */
  135715. get color(): NodeMaterialConnectionPoint;
  135716. /**
  135717. * Gets the output component
  135718. */
  135719. get output(): NodeMaterialConnectionPoint;
  135720. /**
  135721. * Initialize the block and prepare the context for build
  135722. * @param state defines the state that will be used for the build
  135723. */
  135724. initialize(state: NodeMaterialBuildState): void;
  135725. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135728. protected _buildBlock(state: NodeMaterialBuildState): this;
  135729. }
  135730. }
  135731. declare module BABYLON {
  135732. /**
  135733. * Block used to pertub normals based on a normal map
  135734. */
  135735. export class PerturbNormalBlock extends NodeMaterialBlock {
  135736. private _tangentSpaceParameterName;
  135737. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135738. invertX: boolean;
  135739. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135740. invertY: boolean;
  135741. /**
  135742. * Create a new PerturbNormalBlock
  135743. * @param name defines the block name
  135744. */
  135745. constructor(name: string);
  135746. /**
  135747. * Gets the current class name
  135748. * @returns the class name
  135749. */
  135750. getClassName(): string;
  135751. /**
  135752. * Gets the world position input component
  135753. */
  135754. get worldPosition(): NodeMaterialConnectionPoint;
  135755. /**
  135756. * Gets the world normal input component
  135757. */
  135758. get worldNormal(): NodeMaterialConnectionPoint;
  135759. /**
  135760. * Gets the world tangent input component
  135761. */
  135762. get worldTangent(): NodeMaterialConnectionPoint;
  135763. /**
  135764. * Gets the uv input component
  135765. */
  135766. get uv(): NodeMaterialConnectionPoint;
  135767. /**
  135768. * Gets the normal map color input component
  135769. */
  135770. get normalMapColor(): NodeMaterialConnectionPoint;
  135771. /**
  135772. * Gets the strength input component
  135773. */
  135774. get strength(): NodeMaterialConnectionPoint;
  135775. /**
  135776. * Gets the output component
  135777. */
  135778. get output(): NodeMaterialConnectionPoint;
  135779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135781. autoConfigure(material: NodeMaterial): void;
  135782. protected _buildBlock(state: NodeMaterialBuildState): this;
  135783. protected _dumpPropertiesCode(): string;
  135784. serialize(): any;
  135785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135786. }
  135787. }
  135788. declare module BABYLON {
  135789. /**
  135790. * Block used to discard a pixel if a value is smaller than a cutoff
  135791. */
  135792. export class DiscardBlock extends NodeMaterialBlock {
  135793. /**
  135794. * Create a new DiscardBlock
  135795. * @param name defines the block name
  135796. */
  135797. constructor(name: string);
  135798. /**
  135799. * Gets the current class name
  135800. * @returns the class name
  135801. */
  135802. getClassName(): string;
  135803. /**
  135804. * Gets the color input component
  135805. */
  135806. get value(): NodeMaterialConnectionPoint;
  135807. /**
  135808. * Gets the cutoff input component
  135809. */
  135810. get cutoff(): NodeMaterialConnectionPoint;
  135811. protected _buildBlock(state: NodeMaterialBuildState): this;
  135812. }
  135813. }
  135814. declare module BABYLON {
  135815. /**
  135816. * Block used to test if the fragment shader is front facing
  135817. */
  135818. export class FrontFacingBlock extends NodeMaterialBlock {
  135819. /**
  135820. * Creates a new FrontFacingBlock
  135821. * @param name defines the block name
  135822. */
  135823. constructor(name: string);
  135824. /**
  135825. * Gets the current class name
  135826. * @returns the class name
  135827. */
  135828. getClassName(): string;
  135829. /**
  135830. * Gets the output component
  135831. */
  135832. get output(): NodeMaterialConnectionPoint;
  135833. protected _buildBlock(state: NodeMaterialBuildState): this;
  135834. }
  135835. }
  135836. declare module BABYLON {
  135837. /**
  135838. * Block used to get the derivative value on x and y of a given input
  135839. */
  135840. export class DerivativeBlock extends NodeMaterialBlock {
  135841. /**
  135842. * Create a new DerivativeBlock
  135843. * @param name defines the block name
  135844. */
  135845. constructor(name: string);
  135846. /**
  135847. * Gets the current class name
  135848. * @returns the class name
  135849. */
  135850. getClassName(): string;
  135851. /**
  135852. * Gets the input component
  135853. */
  135854. get input(): NodeMaterialConnectionPoint;
  135855. /**
  135856. * Gets the derivative output on x
  135857. */
  135858. get dx(): NodeMaterialConnectionPoint;
  135859. /**
  135860. * Gets the derivative output on y
  135861. */
  135862. get dy(): NodeMaterialConnectionPoint;
  135863. protected _buildBlock(state: NodeMaterialBuildState): this;
  135864. }
  135865. }
  135866. declare module BABYLON {
  135867. /**
  135868. * Block used to add support for scene fog
  135869. */
  135870. export class FogBlock extends NodeMaterialBlock {
  135871. private _fogDistanceName;
  135872. private _fogParameters;
  135873. /**
  135874. * Create a new FogBlock
  135875. * @param name defines the block name
  135876. */
  135877. constructor(name: string);
  135878. /**
  135879. * Gets the current class name
  135880. * @returns the class name
  135881. */
  135882. getClassName(): string;
  135883. /**
  135884. * Gets the world position input component
  135885. */
  135886. get worldPosition(): NodeMaterialConnectionPoint;
  135887. /**
  135888. * Gets the view input component
  135889. */
  135890. get view(): NodeMaterialConnectionPoint;
  135891. /**
  135892. * Gets the color input component
  135893. */
  135894. get input(): NodeMaterialConnectionPoint;
  135895. /**
  135896. * Gets the fog color input component
  135897. */
  135898. get fogColor(): NodeMaterialConnectionPoint;
  135899. /**
  135900. * Gets the output component
  135901. */
  135902. get output(): NodeMaterialConnectionPoint;
  135903. autoConfigure(material: NodeMaterial): void;
  135904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135906. protected _buildBlock(state: NodeMaterialBuildState): this;
  135907. }
  135908. }
  135909. declare module BABYLON {
  135910. /**
  135911. * Block used to add light in the fragment shader
  135912. */
  135913. export class LightBlock extends NodeMaterialBlock {
  135914. private _lightId;
  135915. /**
  135916. * Gets or sets the light associated with this block
  135917. */
  135918. light: Nullable<Light>;
  135919. /**
  135920. * Create a new LightBlock
  135921. * @param name defines the block name
  135922. */
  135923. constructor(name: string);
  135924. /**
  135925. * Gets the current class name
  135926. * @returns the class name
  135927. */
  135928. getClassName(): string;
  135929. /**
  135930. * Gets the world position input component
  135931. */
  135932. get worldPosition(): NodeMaterialConnectionPoint;
  135933. /**
  135934. * Gets the world normal input component
  135935. */
  135936. get worldNormal(): NodeMaterialConnectionPoint;
  135937. /**
  135938. * Gets the camera (or eye) position component
  135939. */
  135940. get cameraPosition(): NodeMaterialConnectionPoint;
  135941. /**
  135942. * Gets the glossiness component
  135943. */
  135944. get glossiness(): NodeMaterialConnectionPoint;
  135945. /**
  135946. * Gets the glossinness power component
  135947. */
  135948. get glossPower(): NodeMaterialConnectionPoint;
  135949. /**
  135950. * Gets the diffuse color component
  135951. */
  135952. get diffuseColor(): NodeMaterialConnectionPoint;
  135953. /**
  135954. * Gets the specular color component
  135955. */
  135956. get specularColor(): NodeMaterialConnectionPoint;
  135957. /**
  135958. * Gets the diffuse output component
  135959. */
  135960. get diffuseOutput(): NodeMaterialConnectionPoint;
  135961. /**
  135962. * Gets the specular output component
  135963. */
  135964. get specularOutput(): NodeMaterialConnectionPoint;
  135965. /**
  135966. * Gets the shadow output component
  135967. */
  135968. get shadow(): NodeMaterialConnectionPoint;
  135969. autoConfigure(material: NodeMaterial): void;
  135970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135971. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135972. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135973. private _injectVertexCode;
  135974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135975. serialize(): any;
  135976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135977. }
  135978. }
  135979. declare module BABYLON {
  135980. /**
  135981. * Block used to read a reflection texture from a sampler
  135982. */
  135983. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  135984. /**
  135985. * Create a new ReflectionTextureBlock
  135986. * @param name defines the block name
  135987. */
  135988. constructor(name: string);
  135989. /**
  135990. * Gets the current class name
  135991. * @returns the class name
  135992. */
  135993. getClassName(): string;
  135994. /**
  135995. * Gets the world position input component
  135996. */
  135997. get position(): NodeMaterialConnectionPoint;
  135998. /**
  135999. * Gets the world position input component
  136000. */
  136001. get worldPosition(): NodeMaterialConnectionPoint;
  136002. /**
  136003. * Gets the world normal input component
  136004. */
  136005. get worldNormal(): NodeMaterialConnectionPoint;
  136006. /**
  136007. * Gets the world input component
  136008. */
  136009. get world(): NodeMaterialConnectionPoint;
  136010. /**
  136011. * Gets the camera (or eye) position component
  136012. */
  136013. get cameraPosition(): NodeMaterialConnectionPoint;
  136014. /**
  136015. * Gets the view input component
  136016. */
  136017. get view(): NodeMaterialConnectionPoint;
  136018. /**
  136019. * Gets the rgb output component
  136020. */
  136021. get rgb(): NodeMaterialConnectionPoint;
  136022. /**
  136023. * Gets the r output component
  136024. */
  136025. get r(): NodeMaterialConnectionPoint;
  136026. /**
  136027. * Gets the g output component
  136028. */
  136029. get g(): NodeMaterialConnectionPoint;
  136030. /**
  136031. * Gets the b output component
  136032. */
  136033. get b(): NodeMaterialConnectionPoint;
  136034. autoConfigure(material: NodeMaterial): void;
  136035. protected _buildBlock(state: NodeMaterialBuildState): this;
  136036. }
  136037. }
  136038. declare module BABYLON {
  136039. /**
  136040. * Block used to add 2 vectors
  136041. */
  136042. export class AddBlock extends NodeMaterialBlock {
  136043. /**
  136044. * Creates a new AddBlock
  136045. * @param name defines the block name
  136046. */
  136047. constructor(name: string);
  136048. /**
  136049. * Gets the current class name
  136050. * @returns the class name
  136051. */
  136052. getClassName(): string;
  136053. /**
  136054. * Gets the left operand input component
  136055. */
  136056. get left(): NodeMaterialConnectionPoint;
  136057. /**
  136058. * Gets the right operand input component
  136059. */
  136060. get right(): NodeMaterialConnectionPoint;
  136061. /**
  136062. * Gets the output component
  136063. */
  136064. get output(): NodeMaterialConnectionPoint;
  136065. protected _buildBlock(state: NodeMaterialBuildState): this;
  136066. }
  136067. }
  136068. declare module BABYLON {
  136069. /**
  136070. * Block used to scale a vector by a float
  136071. */
  136072. export class ScaleBlock extends NodeMaterialBlock {
  136073. /**
  136074. * Creates a new ScaleBlock
  136075. * @param name defines the block name
  136076. */
  136077. constructor(name: string);
  136078. /**
  136079. * Gets the current class name
  136080. * @returns the class name
  136081. */
  136082. getClassName(): string;
  136083. /**
  136084. * Gets the input component
  136085. */
  136086. get input(): NodeMaterialConnectionPoint;
  136087. /**
  136088. * Gets the factor input component
  136089. */
  136090. get factor(): NodeMaterialConnectionPoint;
  136091. /**
  136092. * Gets the output component
  136093. */
  136094. get output(): NodeMaterialConnectionPoint;
  136095. protected _buildBlock(state: NodeMaterialBuildState): this;
  136096. }
  136097. }
  136098. declare module BABYLON {
  136099. /**
  136100. * Block used to clamp a float
  136101. */
  136102. export class ClampBlock extends NodeMaterialBlock {
  136103. /** Gets or sets the minimum range */
  136104. minimum: number;
  136105. /** Gets or sets the maximum range */
  136106. maximum: number;
  136107. /**
  136108. * Creates a new ClampBlock
  136109. * @param name defines the block name
  136110. */
  136111. constructor(name: string);
  136112. /**
  136113. * Gets the current class name
  136114. * @returns the class name
  136115. */
  136116. getClassName(): string;
  136117. /**
  136118. * Gets the value input component
  136119. */
  136120. get value(): NodeMaterialConnectionPoint;
  136121. /**
  136122. * Gets the output component
  136123. */
  136124. get output(): NodeMaterialConnectionPoint;
  136125. protected _buildBlock(state: NodeMaterialBuildState): this;
  136126. protected _dumpPropertiesCode(): string;
  136127. serialize(): any;
  136128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136129. }
  136130. }
  136131. declare module BABYLON {
  136132. /**
  136133. * Block used to apply a cross product between 2 vectors
  136134. */
  136135. export class CrossBlock extends NodeMaterialBlock {
  136136. /**
  136137. * Creates a new CrossBlock
  136138. * @param name defines the block name
  136139. */
  136140. constructor(name: string);
  136141. /**
  136142. * Gets the current class name
  136143. * @returns the class name
  136144. */
  136145. getClassName(): string;
  136146. /**
  136147. * Gets the left operand input component
  136148. */
  136149. get left(): NodeMaterialConnectionPoint;
  136150. /**
  136151. * Gets the right operand input component
  136152. */
  136153. get right(): NodeMaterialConnectionPoint;
  136154. /**
  136155. * Gets the output component
  136156. */
  136157. get output(): NodeMaterialConnectionPoint;
  136158. protected _buildBlock(state: NodeMaterialBuildState): this;
  136159. }
  136160. }
  136161. declare module BABYLON {
  136162. /**
  136163. * Block used to apply a dot product between 2 vectors
  136164. */
  136165. export class DotBlock extends NodeMaterialBlock {
  136166. /**
  136167. * Creates a new DotBlock
  136168. * @param name defines the block name
  136169. */
  136170. constructor(name: string);
  136171. /**
  136172. * Gets the current class name
  136173. * @returns the class name
  136174. */
  136175. getClassName(): string;
  136176. /**
  136177. * Gets the left operand input component
  136178. */
  136179. get left(): NodeMaterialConnectionPoint;
  136180. /**
  136181. * Gets the right operand input component
  136182. */
  136183. get right(): NodeMaterialConnectionPoint;
  136184. /**
  136185. * Gets the output component
  136186. */
  136187. get output(): NodeMaterialConnectionPoint;
  136188. protected _buildBlock(state: NodeMaterialBuildState): this;
  136189. }
  136190. }
  136191. declare module BABYLON {
  136192. /**
  136193. * Block used to normalize a vector
  136194. */
  136195. export class NormalizeBlock extends NodeMaterialBlock {
  136196. /**
  136197. * Creates a new NormalizeBlock
  136198. * @param name defines the block name
  136199. */
  136200. constructor(name: string);
  136201. /**
  136202. * Gets the current class name
  136203. * @returns the class name
  136204. */
  136205. getClassName(): string;
  136206. /**
  136207. * Gets the input component
  136208. */
  136209. get input(): NodeMaterialConnectionPoint;
  136210. /**
  136211. * Gets the output component
  136212. */
  136213. get output(): NodeMaterialConnectionPoint;
  136214. protected _buildBlock(state: NodeMaterialBuildState): this;
  136215. }
  136216. }
  136217. declare module BABYLON {
  136218. /**
  136219. * Operations supported by the Trigonometry block
  136220. */
  136221. export enum TrigonometryBlockOperations {
  136222. /** Cos */
  136223. Cos = 0,
  136224. /** Sin */
  136225. Sin = 1,
  136226. /** Abs */
  136227. Abs = 2,
  136228. /** Exp */
  136229. Exp = 3,
  136230. /** Exp2 */
  136231. Exp2 = 4,
  136232. /** Round */
  136233. Round = 5,
  136234. /** Floor */
  136235. Floor = 6,
  136236. /** Ceiling */
  136237. Ceiling = 7,
  136238. /** Square root */
  136239. Sqrt = 8,
  136240. /** Log */
  136241. Log = 9,
  136242. /** Tangent */
  136243. Tan = 10,
  136244. /** Arc tangent */
  136245. ArcTan = 11,
  136246. /** Arc cosinus */
  136247. ArcCos = 12,
  136248. /** Arc sinus */
  136249. ArcSin = 13,
  136250. /** Fraction */
  136251. Fract = 14,
  136252. /** Sign */
  136253. Sign = 15,
  136254. /** To radians (from degrees) */
  136255. Radians = 16,
  136256. /** To degrees (from radians) */
  136257. Degrees = 17
  136258. }
  136259. /**
  136260. * Block used to apply trigonometry operation to floats
  136261. */
  136262. export class TrigonometryBlock extends NodeMaterialBlock {
  136263. /**
  136264. * Gets or sets the operation applied by the block
  136265. */
  136266. operation: TrigonometryBlockOperations;
  136267. /**
  136268. * Creates a new TrigonometryBlock
  136269. * @param name defines the block name
  136270. */
  136271. constructor(name: string);
  136272. /**
  136273. * Gets the current class name
  136274. * @returns the class name
  136275. */
  136276. getClassName(): string;
  136277. /**
  136278. * Gets the input component
  136279. */
  136280. get input(): NodeMaterialConnectionPoint;
  136281. /**
  136282. * Gets the output component
  136283. */
  136284. get output(): NodeMaterialConnectionPoint;
  136285. protected _buildBlock(state: NodeMaterialBuildState): this;
  136286. serialize(): any;
  136287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136288. protected _dumpPropertiesCode(): string;
  136289. }
  136290. }
  136291. declare module BABYLON {
  136292. /**
  136293. * Block used to create a Color3/4 out of individual inputs (one for each component)
  136294. */
  136295. export class ColorMergerBlock extends NodeMaterialBlock {
  136296. /**
  136297. * Create a new ColorMergerBlock
  136298. * @param name defines the block name
  136299. */
  136300. constructor(name: string);
  136301. /**
  136302. * Gets the current class name
  136303. * @returns the class name
  136304. */
  136305. getClassName(): string;
  136306. /**
  136307. * Gets the rgb component (input)
  136308. */
  136309. get rgbIn(): NodeMaterialConnectionPoint;
  136310. /**
  136311. * Gets the r component (input)
  136312. */
  136313. get r(): NodeMaterialConnectionPoint;
  136314. /**
  136315. * Gets the g component (input)
  136316. */
  136317. get g(): NodeMaterialConnectionPoint;
  136318. /**
  136319. * Gets the b component (input)
  136320. */
  136321. get b(): NodeMaterialConnectionPoint;
  136322. /**
  136323. * Gets the a component (input)
  136324. */
  136325. get a(): NodeMaterialConnectionPoint;
  136326. /**
  136327. * Gets the rgba component (output)
  136328. */
  136329. get rgba(): NodeMaterialConnectionPoint;
  136330. /**
  136331. * Gets the rgb component (output)
  136332. */
  136333. get rgbOut(): NodeMaterialConnectionPoint;
  136334. /**
  136335. * Gets the rgb component (output)
  136336. * @deprecated Please use rgbOut instead.
  136337. */
  136338. get rgb(): NodeMaterialConnectionPoint;
  136339. protected _buildBlock(state: NodeMaterialBuildState): this;
  136340. }
  136341. }
  136342. declare module BABYLON {
  136343. /**
  136344. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136345. */
  136346. export class ColorSplitterBlock extends NodeMaterialBlock {
  136347. /**
  136348. * Create a new ColorSplitterBlock
  136349. * @param name defines the block name
  136350. */
  136351. constructor(name: string);
  136352. /**
  136353. * Gets the current class name
  136354. * @returns the class name
  136355. */
  136356. getClassName(): string;
  136357. /**
  136358. * Gets the rgba component (input)
  136359. */
  136360. get rgba(): NodeMaterialConnectionPoint;
  136361. /**
  136362. * Gets the rgb component (input)
  136363. */
  136364. get rgbIn(): NodeMaterialConnectionPoint;
  136365. /**
  136366. * Gets the rgb component (output)
  136367. */
  136368. get rgbOut(): NodeMaterialConnectionPoint;
  136369. /**
  136370. * Gets the r component (output)
  136371. */
  136372. get r(): NodeMaterialConnectionPoint;
  136373. /**
  136374. * Gets the g component (output)
  136375. */
  136376. get g(): NodeMaterialConnectionPoint;
  136377. /**
  136378. * Gets the b component (output)
  136379. */
  136380. get b(): NodeMaterialConnectionPoint;
  136381. /**
  136382. * Gets the a component (output)
  136383. */
  136384. get a(): NodeMaterialConnectionPoint;
  136385. protected _inputRename(name: string): string;
  136386. protected _outputRename(name: string): string;
  136387. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136388. }
  136389. }
  136390. declare module BABYLON {
  136391. /**
  136392. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136393. */
  136394. export class VectorSplitterBlock extends NodeMaterialBlock {
  136395. /**
  136396. * Create a new VectorSplitterBlock
  136397. * @param name defines the block name
  136398. */
  136399. constructor(name: string);
  136400. /**
  136401. * Gets the current class name
  136402. * @returns the class name
  136403. */
  136404. getClassName(): string;
  136405. /**
  136406. * Gets the xyzw component (input)
  136407. */
  136408. get xyzw(): NodeMaterialConnectionPoint;
  136409. /**
  136410. * Gets the xyz component (input)
  136411. */
  136412. get xyzIn(): NodeMaterialConnectionPoint;
  136413. /**
  136414. * Gets the xy component (input)
  136415. */
  136416. get xyIn(): NodeMaterialConnectionPoint;
  136417. /**
  136418. * Gets the xyz component (output)
  136419. */
  136420. get xyzOut(): NodeMaterialConnectionPoint;
  136421. /**
  136422. * Gets the xy component (output)
  136423. */
  136424. get xyOut(): NodeMaterialConnectionPoint;
  136425. /**
  136426. * Gets the x component (output)
  136427. */
  136428. get x(): NodeMaterialConnectionPoint;
  136429. /**
  136430. * Gets the y component (output)
  136431. */
  136432. get y(): NodeMaterialConnectionPoint;
  136433. /**
  136434. * Gets the z component (output)
  136435. */
  136436. get z(): NodeMaterialConnectionPoint;
  136437. /**
  136438. * Gets the w component (output)
  136439. */
  136440. get w(): NodeMaterialConnectionPoint;
  136441. protected _inputRename(name: string): string;
  136442. protected _outputRename(name: string): string;
  136443. protected _buildBlock(state: NodeMaterialBuildState): this;
  136444. }
  136445. }
  136446. declare module BABYLON {
  136447. /**
  136448. * Block used to lerp between 2 values
  136449. */
  136450. export class LerpBlock extends NodeMaterialBlock {
  136451. /**
  136452. * Creates a new LerpBlock
  136453. * @param name defines the block name
  136454. */
  136455. constructor(name: string);
  136456. /**
  136457. * Gets the current class name
  136458. * @returns the class name
  136459. */
  136460. getClassName(): string;
  136461. /**
  136462. * Gets the left operand input component
  136463. */
  136464. get left(): NodeMaterialConnectionPoint;
  136465. /**
  136466. * Gets the right operand input component
  136467. */
  136468. get right(): NodeMaterialConnectionPoint;
  136469. /**
  136470. * Gets the gradient operand input component
  136471. */
  136472. get gradient(): NodeMaterialConnectionPoint;
  136473. /**
  136474. * Gets the output component
  136475. */
  136476. get output(): NodeMaterialConnectionPoint;
  136477. protected _buildBlock(state: NodeMaterialBuildState): this;
  136478. }
  136479. }
  136480. declare module BABYLON {
  136481. /**
  136482. * Block used to divide 2 vectors
  136483. */
  136484. export class DivideBlock extends NodeMaterialBlock {
  136485. /**
  136486. * Creates a new DivideBlock
  136487. * @param name defines the block name
  136488. */
  136489. constructor(name: string);
  136490. /**
  136491. * Gets the current class name
  136492. * @returns the class name
  136493. */
  136494. getClassName(): string;
  136495. /**
  136496. * Gets the left operand input component
  136497. */
  136498. get left(): NodeMaterialConnectionPoint;
  136499. /**
  136500. * Gets the right operand input component
  136501. */
  136502. get right(): NodeMaterialConnectionPoint;
  136503. /**
  136504. * Gets the output component
  136505. */
  136506. get output(): NodeMaterialConnectionPoint;
  136507. protected _buildBlock(state: NodeMaterialBuildState): this;
  136508. }
  136509. }
  136510. declare module BABYLON {
  136511. /**
  136512. * Block used to subtract 2 vectors
  136513. */
  136514. export class SubtractBlock extends NodeMaterialBlock {
  136515. /**
  136516. * Creates a new SubtractBlock
  136517. * @param name defines the block name
  136518. */
  136519. constructor(name: string);
  136520. /**
  136521. * Gets the current class name
  136522. * @returns the class name
  136523. */
  136524. getClassName(): string;
  136525. /**
  136526. * Gets the left operand input component
  136527. */
  136528. get left(): NodeMaterialConnectionPoint;
  136529. /**
  136530. * Gets the right operand input component
  136531. */
  136532. get right(): NodeMaterialConnectionPoint;
  136533. /**
  136534. * Gets the output component
  136535. */
  136536. get output(): NodeMaterialConnectionPoint;
  136537. protected _buildBlock(state: NodeMaterialBuildState): this;
  136538. }
  136539. }
  136540. declare module BABYLON {
  136541. /**
  136542. * Block used to step a value
  136543. */
  136544. export class StepBlock extends NodeMaterialBlock {
  136545. /**
  136546. * Creates a new StepBlock
  136547. * @param name defines the block name
  136548. */
  136549. constructor(name: string);
  136550. /**
  136551. * Gets the current class name
  136552. * @returns the class name
  136553. */
  136554. getClassName(): string;
  136555. /**
  136556. * Gets the value operand input component
  136557. */
  136558. get value(): NodeMaterialConnectionPoint;
  136559. /**
  136560. * Gets the edge operand input component
  136561. */
  136562. get edge(): NodeMaterialConnectionPoint;
  136563. /**
  136564. * Gets the output component
  136565. */
  136566. get output(): NodeMaterialConnectionPoint;
  136567. protected _buildBlock(state: NodeMaterialBuildState): this;
  136568. }
  136569. }
  136570. declare module BABYLON {
  136571. /**
  136572. * Block used to get the opposite (1 - x) of a value
  136573. */
  136574. export class OneMinusBlock extends NodeMaterialBlock {
  136575. /**
  136576. * Creates a new OneMinusBlock
  136577. * @param name defines the block name
  136578. */
  136579. constructor(name: string);
  136580. /**
  136581. * Gets the current class name
  136582. * @returns the class name
  136583. */
  136584. getClassName(): string;
  136585. /**
  136586. * Gets the input component
  136587. */
  136588. get input(): NodeMaterialConnectionPoint;
  136589. /**
  136590. * Gets the output component
  136591. */
  136592. get output(): NodeMaterialConnectionPoint;
  136593. protected _buildBlock(state: NodeMaterialBuildState): this;
  136594. }
  136595. }
  136596. declare module BABYLON {
  136597. /**
  136598. * Block used to get the view direction
  136599. */
  136600. export class ViewDirectionBlock extends NodeMaterialBlock {
  136601. /**
  136602. * Creates a new ViewDirectionBlock
  136603. * @param name defines the block name
  136604. */
  136605. constructor(name: string);
  136606. /**
  136607. * Gets the current class name
  136608. * @returns the class name
  136609. */
  136610. getClassName(): string;
  136611. /**
  136612. * Gets the world position component
  136613. */
  136614. get worldPosition(): NodeMaterialConnectionPoint;
  136615. /**
  136616. * Gets the camera position component
  136617. */
  136618. get cameraPosition(): NodeMaterialConnectionPoint;
  136619. /**
  136620. * Gets the output component
  136621. */
  136622. get output(): NodeMaterialConnectionPoint;
  136623. autoConfigure(material: NodeMaterial): void;
  136624. protected _buildBlock(state: NodeMaterialBuildState): this;
  136625. }
  136626. }
  136627. declare module BABYLON {
  136628. /**
  136629. * Block used to compute fresnel value
  136630. */
  136631. export class FresnelBlock extends NodeMaterialBlock {
  136632. /**
  136633. * Create a new FresnelBlock
  136634. * @param name defines the block name
  136635. */
  136636. constructor(name: string);
  136637. /**
  136638. * Gets the current class name
  136639. * @returns the class name
  136640. */
  136641. getClassName(): string;
  136642. /**
  136643. * Gets the world normal input component
  136644. */
  136645. get worldNormal(): NodeMaterialConnectionPoint;
  136646. /**
  136647. * Gets the view direction input component
  136648. */
  136649. get viewDirection(): NodeMaterialConnectionPoint;
  136650. /**
  136651. * Gets the bias input component
  136652. */
  136653. get bias(): NodeMaterialConnectionPoint;
  136654. /**
  136655. * Gets the camera (or eye) position component
  136656. */
  136657. get power(): NodeMaterialConnectionPoint;
  136658. /**
  136659. * Gets the fresnel output component
  136660. */
  136661. get fresnel(): NodeMaterialConnectionPoint;
  136662. autoConfigure(material: NodeMaterial): void;
  136663. protected _buildBlock(state: NodeMaterialBuildState): this;
  136664. }
  136665. }
  136666. declare module BABYLON {
  136667. /**
  136668. * Block used to get the max of 2 values
  136669. */
  136670. export class MaxBlock extends NodeMaterialBlock {
  136671. /**
  136672. * Creates a new MaxBlock
  136673. * @param name defines the block name
  136674. */
  136675. constructor(name: string);
  136676. /**
  136677. * Gets the current class name
  136678. * @returns the class name
  136679. */
  136680. getClassName(): string;
  136681. /**
  136682. * Gets the left operand input component
  136683. */
  136684. get left(): NodeMaterialConnectionPoint;
  136685. /**
  136686. * Gets the right operand input component
  136687. */
  136688. get right(): NodeMaterialConnectionPoint;
  136689. /**
  136690. * Gets the output component
  136691. */
  136692. get output(): NodeMaterialConnectionPoint;
  136693. protected _buildBlock(state: NodeMaterialBuildState): this;
  136694. }
  136695. }
  136696. declare module BABYLON {
  136697. /**
  136698. * Block used to get the min of 2 values
  136699. */
  136700. export class MinBlock extends NodeMaterialBlock {
  136701. /**
  136702. * Creates a new MinBlock
  136703. * @param name defines the block name
  136704. */
  136705. constructor(name: string);
  136706. /**
  136707. * Gets the current class name
  136708. * @returns the class name
  136709. */
  136710. getClassName(): string;
  136711. /**
  136712. * Gets the left operand input component
  136713. */
  136714. get left(): NodeMaterialConnectionPoint;
  136715. /**
  136716. * Gets the right operand input component
  136717. */
  136718. get right(): NodeMaterialConnectionPoint;
  136719. /**
  136720. * Gets the output component
  136721. */
  136722. get output(): NodeMaterialConnectionPoint;
  136723. protected _buildBlock(state: NodeMaterialBuildState): this;
  136724. }
  136725. }
  136726. declare module BABYLON {
  136727. /**
  136728. * Block used to get the distance between 2 values
  136729. */
  136730. export class DistanceBlock extends NodeMaterialBlock {
  136731. /**
  136732. * Creates a new DistanceBlock
  136733. * @param name defines the block name
  136734. */
  136735. constructor(name: string);
  136736. /**
  136737. * Gets the current class name
  136738. * @returns the class name
  136739. */
  136740. getClassName(): string;
  136741. /**
  136742. * Gets the left operand input component
  136743. */
  136744. get left(): NodeMaterialConnectionPoint;
  136745. /**
  136746. * Gets the right operand input component
  136747. */
  136748. get right(): NodeMaterialConnectionPoint;
  136749. /**
  136750. * Gets the output component
  136751. */
  136752. get output(): NodeMaterialConnectionPoint;
  136753. protected _buildBlock(state: NodeMaterialBuildState): this;
  136754. }
  136755. }
  136756. declare module BABYLON {
  136757. /**
  136758. * Block used to get the length of a vector
  136759. */
  136760. export class LengthBlock extends NodeMaterialBlock {
  136761. /**
  136762. * Creates a new LengthBlock
  136763. * @param name defines the block name
  136764. */
  136765. constructor(name: string);
  136766. /**
  136767. * Gets the current class name
  136768. * @returns the class name
  136769. */
  136770. getClassName(): string;
  136771. /**
  136772. * Gets the value input component
  136773. */
  136774. get value(): NodeMaterialConnectionPoint;
  136775. /**
  136776. * Gets the output component
  136777. */
  136778. get output(): NodeMaterialConnectionPoint;
  136779. protected _buildBlock(state: NodeMaterialBuildState): this;
  136780. }
  136781. }
  136782. declare module BABYLON {
  136783. /**
  136784. * Block used to get negative version of a value (i.e. x * -1)
  136785. */
  136786. export class NegateBlock extends NodeMaterialBlock {
  136787. /**
  136788. * Creates a new NegateBlock
  136789. * @param name defines the block name
  136790. */
  136791. constructor(name: string);
  136792. /**
  136793. * Gets the current class name
  136794. * @returns the class name
  136795. */
  136796. getClassName(): string;
  136797. /**
  136798. * Gets the value input component
  136799. */
  136800. get value(): NodeMaterialConnectionPoint;
  136801. /**
  136802. * Gets the output component
  136803. */
  136804. get output(): NodeMaterialConnectionPoint;
  136805. protected _buildBlock(state: NodeMaterialBuildState): this;
  136806. }
  136807. }
  136808. declare module BABYLON {
  136809. /**
  136810. * Block used to get the value of the first parameter raised to the power of the second
  136811. */
  136812. export class PowBlock extends NodeMaterialBlock {
  136813. /**
  136814. * Creates a new PowBlock
  136815. * @param name defines the block name
  136816. */
  136817. constructor(name: string);
  136818. /**
  136819. * Gets the current class name
  136820. * @returns the class name
  136821. */
  136822. getClassName(): string;
  136823. /**
  136824. * Gets the value operand input component
  136825. */
  136826. get value(): NodeMaterialConnectionPoint;
  136827. /**
  136828. * Gets the power operand input component
  136829. */
  136830. get power(): NodeMaterialConnectionPoint;
  136831. /**
  136832. * Gets the output component
  136833. */
  136834. get output(): NodeMaterialConnectionPoint;
  136835. protected _buildBlock(state: NodeMaterialBuildState): this;
  136836. }
  136837. }
  136838. declare module BABYLON {
  136839. /**
  136840. * Block used to get a random number
  136841. */
  136842. export class RandomNumberBlock extends NodeMaterialBlock {
  136843. /**
  136844. * Creates a new RandomNumberBlock
  136845. * @param name defines the block name
  136846. */
  136847. constructor(name: string);
  136848. /**
  136849. * Gets the current class name
  136850. * @returns the class name
  136851. */
  136852. getClassName(): string;
  136853. /**
  136854. * Gets the seed input component
  136855. */
  136856. get seed(): NodeMaterialConnectionPoint;
  136857. /**
  136858. * Gets the output component
  136859. */
  136860. get output(): NodeMaterialConnectionPoint;
  136861. protected _buildBlock(state: NodeMaterialBuildState): this;
  136862. }
  136863. }
  136864. declare module BABYLON {
  136865. /**
  136866. * Block used to compute arc tangent of 2 values
  136867. */
  136868. export class ArcTan2Block extends NodeMaterialBlock {
  136869. /**
  136870. * Creates a new ArcTan2Block
  136871. * @param name defines the block name
  136872. */
  136873. constructor(name: string);
  136874. /**
  136875. * Gets the current class name
  136876. * @returns the class name
  136877. */
  136878. getClassName(): string;
  136879. /**
  136880. * Gets the x operand input component
  136881. */
  136882. get x(): NodeMaterialConnectionPoint;
  136883. /**
  136884. * Gets the y operand input component
  136885. */
  136886. get y(): NodeMaterialConnectionPoint;
  136887. /**
  136888. * Gets the output component
  136889. */
  136890. get output(): NodeMaterialConnectionPoint;
  136891. protected _buildBlock(state: NodeMaterialBuildState): this;
  136892. }
  136893. }
  136894. declare module BABYLON {
  136895. /**
  136896. * Block used to smooth step a value
  136897. */
  136898. export class SmoothStepBlock extends NodeMaterialBlock {
  136899. /**
  136900. * Creates a new SmoothStepBlock
  136901. * @param name defines the block name
  136902. */
  136903. constructor(name: string);
  136904. /**
  136905. * Gets the current class name
  136906. * @returns the class name
  136907. */
  136908. getClassName(): string;
  136909. /**
  136910. * Gets the value operand input component
  136911. */
  136912. get value(): NodeMaterialConnectionPoint;
  136913. /**
  136914. * Gets the first edge operand input component
  136915. */
  136916. get edge0(): NodeMaterialConnectionPoint;
  136917. /**
  136918. * Gets the second edge operand input component
  136919. */
  136920. get edge1(): NodeMaterialConnectionPoint;
  136921. /**
  136922. * Gets the output component
  136923. */
  136924. get output(): NodeMaterialConnectionPoint;
  136925. protected _buildBlock(state: NodeMaterialBuildState): this;
  136926. }
  136927. }
  136928. declare module BABYLON {
  136929. /**
  136930. * Block used to get the reciprocal (1 / x) of a value
  136931. */
  136932. export class ReciprocalBlock extends NodeMaterialBlock {
  136933. /**
  136934. * Creates a new ReciprocalBlock
  136935. * @param name defines the block name
  136936. */
  136937. constructor(name: string);
  136938. /**
  136939. * Gets the current class name
  136940. * @returns the class name
  136941. */
  136942. getClassName(): string;
  136943. /**
  136944. * Gets the input component
  136945. */
  136946. get input(): NodeMaterialConnectionPoint;
  136947. /**
  136948. * Gets the output component
  136949. */
  136950. get output(): NodeMaterialConnectionPoint;
  136951. protected _buildBlock(state: NodeMaterialBuildState): this;
  136952. }
  136953. }
  136954. declare module BABYLON {
  136955. /**
  136956. * Block used to replace a color by another one
  136957. */
  136958. export class ReplaceColorBlock extends NodeMaterialBlock {
  136959. /**
  136960. * Creates a new ReplaceColorBlock
  136961. * @param name defines the block name
  136962. */
  136963. constructor(name: string);
  136964. /**
  136965. * Gets the current class name
  136966. * @returns the class name
  136967. */
  136968. getClassName(): string;
  136969. /**
  136970. * Gets the value input component
  136971. */
  136972. get value(): NodeMaterialConnectionPoint;
  136973. /**
  136974. * Gets the reference input component
  136975. */
  136976. get reference(): NodeMaterialConnectionPoint;
  136977. /**
  136978. * Gets the distance input component
  136979. */
  136980. get distance(): NodeMaterialConnectionPoint;
  136981. /**
  136982. * Gets the replacement input component
  136983. */
  136984. get replacement(): NodeMaterialConnectionPoint;
  136985. /**
  136986. * Gets the output component
  136987. */
  136988. get output(): NodeMaterialConnectionPoint;
  136989. protected _buildBlock(state: NodeMaterialBuildState): this;
  136990. }
  136991. }
  136992. declare module BABYLON {
  136993. /**
  136994. * Block used to posterize a value
  136995. * @see https://en.wikipedia.org/wiki/Posterization
  136996. */
  136997. export class PosterizeBlock extends NodeMaterialBlock {
  136998. /**
  136999. * Creates a new PosterizeBlock
  137000. * @param name defines the block name
  137001. */
  137002. constructor(name: string);
  137003. /**
  137004. * Gets the current class name
  137005. * @returns the class name
  137006. */
  137007. getClassName(): string;
  137008. /**
  137009. * Gets the value input component
  137010. */
  137011. get value(): NodeMaterialConnectionPoint;
  137012. /**
  137013. * Gets the steps input component
  137014. */
  137015. get steps(): NodeMaterialConnectionPoint;
  137016. /**
  137017. * Gets the output component
  137018. */
  137019. get output(): NodeMaterialConnectionPoint;
  137020. protected _buildBlock(state: NodeMaterialBuildState): this;
  137021. }
  137022. }
  137023. declare module BABYLON {
  137024. /**
  137025. * Operations supported by the Wave block
  137026. */
  137027. export enum WaveBlockKind {
  137028. /** SawTooth */
  137029. SawTooth = 0,
  137030. /** Square */
  137031. Square = 1,
  137032. /** Triangle */
  137033. Triangle = 2
  137034. }
  137035. /**
  137036. * Block used to apply wave operation to floats
  137037. */
  137038. export class WaveBlock extends NodeMaterialBlock {
  137039. /**
  137040. * Gets or sets the kibnd of wave to be applied by the block
  137041. */
  137042. kind: WaveBlockKind;
  137043. /**
  137044. * Creates a new WaveBlock
  137045. * @param name defines the block name
  137046. */
  137047. constructor(name: string);
  137048. /**
  137049. * Gets the current class name
  137050. * @returns the class name
  137051. */
  137052. getClassName(): string;
  137053. /**
  137054. * Gets the input component
  137055. */
  137056. get input(): NodeMaterialConnectionPoint;
  137057. /**
  137058. * Gets the output component
  137059. */
  137060. get output(): NodeMaterialConnectionPoint;
  137061. protected _buildBlock(state: NodeMaterialBuildState): this;
  137062. serialize(): any;
  137063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137064. }
  137065. }
  137066. declare module BABYLON {
  137067. /**
  137068. * Class used to store a color step for the GradientBlock
  137069. */
  137070. export class GradientBlockColorStep {
  137071. /**
  137072. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137073. */
  137074. step: number;
  137075. /**
  137076. * Gets or sets the color associated with this step
  137077. */
  137078. color: Color3;
  137079. /**
  137080. * Creates a new GradientBlockColorStep
  137081. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  137082. * @param color defines the color associated with this step
  137083. */
  137084. constructor(
  137085. /**
  137086. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  137087. */
  137088. step: number,
  137089. /**
  137090. * Gets or sets the color associated with this step
  137091. */
  137092. color: Color3);
  137093. }
  137094. /**
  137095. * Block used to return a color from a gradient based on an input value between 0 and 1
  137096. */
  137097. export class GradientBlock extends NodeMaterialBlock {
  137098. /**
  137099. * Gets or sets the list of color steps
  137100. */
  137101. colorSteps: GradientBlockColorStep[];
  137102. /**
  137103. * Creates a new GradientBlock
  137104. * @param name defines the block name
  137105. */
  137106. constructor(name: string);
  137107. /**
  137108. * Gets the current class name
  137109. * @returns the class name
  137110. */
  137111. getClassName(): string;
  137112. /**
  137113. * Gets the gradient input component
  137114. */
  137115. get gradient(): NodeMaterialConnectionPoint;
  137116. /**
  137117. * Gets the output component
  137118. */
  137119. get output(): NodeMaterialConnectionPoint;
  137120. private _writeColorConstant;
  137121. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137122. serialize(): any;
  137123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137124. protected _dumpPropertiesCode(): string;
  137125. }
  137126. }
  137127. declare module BABYLON {
  137128. /**
  137129. * Block used to normalize lerp between 2 values
  137130. */
  137131. export class NLerpBlock extends NodeMaterialBlock {
  137132. /**
  137133. * Creates a new NLerpBlock
  137134. * @param name defines the block name
  137135. */
  137136. constructor(name: string);
  137137. /**
  137138. * Gets the current class name
  137139. * @returns the class name
  137140. */
  137141. getClassName(): string;
  137142. /**
  137143. * Gets the left operand input component
  137144. */
  137145. get left(): NodeMaterialConnectionPoint;
  137146. /**
  137147. * Gets the right operand input component
  137148. */
  137149. get right(): NodeMaterialConnectionPoint;
  137150. /**
  137151. * Gets the gradient operand input component
  137152. */
  137153. get gradient(): NodeMaterialConnectionPoint;
  137154. /**
  137155. * Gets the output component
  137156. */
  137157. get output(): NodeMaterialConnectionPoint;
  137158. protected _buildBlock(state: NodeMaterialBuildState): this;
  137159. }
  137160. }
  137161. declare module BABYLON {
  137162. /**
  137163. * block used to Generate a Worley Noise 3D Noise Pattern
  137164. */
  137165. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  137166. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137167. manhattanDistance: boolean;
  137168. /**
  137169. * Creates a new WorleyNoise3DBlock
  137170. * @param name defines the block name
  137171. */
  137172. constructor(name: string);
  137173. /**
  137174. * Gets the current class name
  137175. * @returns the class name
  137176. */
  137177. getClassName(): string;
  137178. /**
  137179. * Gets the seed input component
  137180. */
  137181. get seed(): NodeMaterialConnectionPoint;
  137182. /**
  137183. * Gets the jitter input component
  137184. */
  137185. get jitter(): NodeMaterialConnectionPoint;
  137186. /**
  137187. * Gets the output component
  137188. */
  137189. get output(): NodeMaterialConnectionPoint;
  137190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137191. /**
  137192. * Exposes the properties to the UI?
  137193. */
  137194. protected _dumpPropertiesCode(): string;
  137195. /**
  137196. * Exposes the properties to the Seralize?
  137197. */
  137198. serialize(): any;
  137199. /**
  137200. * Exposes the properties to the deseralize?
  137201. */
  137202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137203. }
  137204. }
  137205. declare module BABYLON {
  137206. /**
  137207. * block used to Generate a Simplex Perlin 3d Noise Pattern
  137208. */
  137209. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  137210. /**
  137211. * Creates a new SimplexPerlin3DBlock
  137212. * @param name defines the block name
  137213. */
  137214. constructor(name: string);
  137215. /**
  137216. * Gets the current class name
  137217. * @returns the class name
  137218. */
  137219. getClassName(): string;
  137220. /**
  137221. * Gets the seed operand input component
  137222. */
  137223. get seed(): NodeMaterialConnectionPoint;
  137224. /**
  137225. * Gets the output component
  137226. */
  137227. get output(): NodeMaterialConnectionPoint;
  137228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137229. }
  137230. }
  137231. declare module BABYLON {
  137232. /**
  137233. * Block used to blend normals
  137234. */
  137235. export class NormalBlendBlock extends NodeMaterialBlock {
  137236. /**
  137237. * Creates a new NormalBlendBlock
  137238. * @param name defines the block name
  137239. */
  137240. constructor(name: string);
  137241. /**
  137242. * Gets the current class name
  137243. * @returns the class name
  137244. */
  137245. getClassName(): string;
  137246. /**
  137247. * Gets the first input component
  137248. */
  137249. get normalMap0(): NodeMaterialConnectionPoint;
  137250. /**
  137251. * Gets the second input component
  137252. */
  137253. get normalMap1(): NodeMaterialConnectionPoint;
  137254. /**
  137255. * Gets the output component
  137256. */
  137257. get output(): NodeMaterialConnectionPoint;
  137258. protected _buildBlock(state: NodeMaterialBuildState): this;
  137259. }
  137260. }
  137261. declare module BABYLON {
  137262. /**
  137263. * Block used to rotate a 2d vector by a given angle
  137264. */
  137265. export class Rotate2dBlock extends NodeMaterialBlock {
  137266. /**
  137267. * Creates a new Rotate2dBlock
  137268. * @param name defines the block name
  137269. */
  137270. constructor(name: string);
  137271. /**
  137272. * Gets the current class name
  137273. * @returns the class name
  137274. */
  137275. getClassName(): string;
  137276. /**
  137277. * Gets the input vector
  137278. */
  137279. get input(): NodeMaterialConnectionPoint;
  137280. /**
  137281. * Gets the input angle
  137282. */
  137283. get angle(): NodeMaterialConnectionPoint;
  137284. /**
  137285. * Gets the output component
  137286. */
  137287. get output(): NodeMaterialConnectionPoint;
  137288. autoConfigure(material: NodeMaterial): void;
  137289. protected _buildBlock(state: NodeMaterialBuildState): this;
  137290. }
  137291. }
  137292. declare module BABYLON {
  137293. /**
  137294. * Block used to get the reflected vector from a direction and a normal
  137295. */
  137296. export class ReflectBlock extends NodeMaterialBlock {
  137297. /**
  137298. * Creates a new ReflectBlock
  137299. * @param name defines the block name
  137300. */
  137301. constructor(name: string);
  137302. /**
  137303. * Gets the current class name
  137304. * @returns the class name
  137305. */
  137306. getClassName(): string;
  137307. /**
  137308. * Gets the incident component
  137309. */
  137310. get incident(): NodeMaterialConnectionPoint;
  137311. /**
  137312. * Gets the normal component
  137313. */
  137314. get normal(): NodeMaterialConnectionPoint;
  137315. /**
  137316. * Gets the output component
  137317. */
  137318. get output(): NodeMaterialConnectionPoint;
  137319. protected _buildBlock(state: NodeMaterialBuildState): this;
  137320. }
  137321. }
  137322. declare module BABYLON {
  137323. /**
  137324. * Block used to get the refracted vector from a direction and a normal
  137325. */
  137326. export class RefractBlock extends NodeMaterialBlock {
  137327. /**
  137328. * Creates a new RefractBlock
  137329. * @param name defines the block name
  137330. */
  137331. constructor(name: string);
  137332. /**
  137333. * Gets the current class name
  137334. * @returns the class name
  137335. */
  137336. getClassName(): string;
  137337. /**
  137338. * Gets the incident component
  137339. */
  137340. get incident(): NodeMaterialConnectionPoint;
  137341. /**
  137342. * Gets the normal component
  137343. */
  137344. get normal(): NodeMaterialConnectionPoint;
  137345. /**
  137346. * Gets the index of refraction component
  137347. */
  137348. get ior(): NodeMaterialConnectionPoint;
  137349. /**
  137350. * Gets the output component
  137351. */
  137352. get output(): NodeMaterialConnectionPoint;
  137353. protected _buildBlock(state: NodeMaterialBuildState): this;
  137354. }
  137355. }
  137356. declare module BABYLON {
  137357. /**
  137358. * Block used to desaturate a color
  137359. */
  137360. export class DesaturateBlock extends NodeMaterialBlock {
  137361. /**
  137362. * Creates a new DesaturateBlock
  137363. * @param name defines the block name
  137364. */
  137365. constructor(name: string);
  137366. /**
  137367. * Gets the current class name
  137368. * @returns the class name
  137369. */
  137370. getClassName(): string;
  137371. /**
  137372. * Gets the color operand input component
  137373. */
  137374. get color(): NodeMaterialConnectionPoint;
  137375. /**
  137376. * Gets the level operand input component
  137377. */
  137378. get level(): NodeMaterialConnectionPoint;
  137379. /**
  137380. * Gets the output component
  137381. */
  137382. get output(): NodeMaterialConnectionPoint;
  137383. protected _buildBlock(state: NodeMaterialBuildState): this;
  137384. }
  137385. }
  137386. declare module BABYLON {
  137387. /**
  137388. * Block used to implement the ambient occlusion module of the PBR material
  137389. */
  137390. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137391. /**
  137392. * Create a new AmbientOcclusionBlock
  137393. * @param name defines the block name
  137394. */
  137395. constructor(name: string);
  137396. /**
  137397. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137398. */
  137399. useAmbientInGrayScale: boolean;
  137400. /**
  137401. * Initialize the block and prepare the context for build
  137402. * @param state defines the state that will be used for the build
  137403. */
  137404. initialize(state: NodeMaterialBuildState): void;
  137405. /**
  137406. * Gets the current class name
  137407. * @returns the class name
  137408. */
  137409. getClassName(): string;
  137410. /**
  137411. * Gets the texture input component
  137412. */
  137413. get texture(): NodeMaterialConnectionPoint;
  137414. /**
  137415. * Gets the texture intensity component
  137416. */
  137417. get intensity(): NodeMaterialConnectionPoint;
  137418. /**
  137419. * Gets the direct light intensity input component
  137420. */
  137421. get directLightIntensity(): NodeMaterialConnectionPoint;
  137422. /**
  137423. * Gets the ambient occlusion object output component
  137424. */
  137425. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137426. /**
  137427. * Gets the main code of the block (fragment side)
  137428. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137429. * @returns the shader code
  137430. */
  137431. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137433. protected _buildBlock(state: NodeMaterialBuildState): this;
  137434. protected _dumpPropertiesCode(): string;
  137435. serialize(): any;
  137436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137437. }
  137438. }
  137439. declare module BABYLON {
  137440. /**
  137441. * Block used to implement the reflection module of the PBR material
  137442. */
  137443. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137444. /** @hidden */
  137445. _defineLODReflectionAlpha: string;
  137446. /** @hidden */
  137447. _defineLinearSpecularReflection: string;
  137448. private _vEnvironmentIrradianceName;
  137449. /** @hidden */
  137450. _vReflectionMicrosurfaceInfosName: string;
  137451. /** @hidden */
  137452. _vReflectionInfosName: string;
  137453. private _scene;
  137454. /**
  137455. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137456. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137457. * It's less burden on the user side in the editor part.
  137458. */
  137459. /** @hidden */
  137460. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137461. /** @hidden */
  137462. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137463. /** @hidden */
  137464. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137465. /**
  137466. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137467. * diffuse part of the IBL.
  137468. */
  137469. useSphericalHarmonics: boolean;
  137470. /**
  137471. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137472. */
  137473. forceIrradianceInFragment: boolean;
  137474. /**
  137475. * Create a new ReflectionBlock
  137476. * @param name defines the block name
  137477. */
  137478. constructor(name: string);
  137479. /**
  137480. * Gets the current class name
  137481. * @returns the class name
  137482. */
  137483. getClassName(): string;
  137484. /**
  137485. * Gets the position input component
  137486. */
  137487. get position(): NodeMaterialConnectionPoint;
  137488. /**
  137489. * Gets the world position input component
  137490. */
  137491. get worldPosition(): NodeMaterialConnectionPoint;
  137492. /**
  137493. * Gets the world normal input component
  137494. */
  137495. get worldNormal(): NodeMaterialConnectionPoint;
  137496. /**
  137497. * Gets the world input component
  137498. */
  137499. get world(): NodeMaterialConnectionPoint;
  137500. /**
  137501. * Gets the camera (or eye) position component
  137502. */
  137503. get cameraPosition(): NodeMaterialConnectionPoint;
  137504. /**
  137505. * Gets the view input component
  137506. */
  137507. get view(): NodeMaterialConnectionPoint;
  137508. /**
  137509. * Gets the color input component
  137510. */
  137511. get color(): NodeMaterialConnectionPoint;
  137512. /**
  137513. * Gets the reflection object output component
  137514. */
  137515. get reflection(): NodeMaterialConnectionPoint;
  137516. /**
  137517. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137518. */
  137519. get hasTexture(): boolean;
  137520. /**
  137521. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137522. */
  137523. get reflectionColor(): string;
  137524. protected _getTexture(): Nullable<BaseTexture>;
  137525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137527. /**
  137528. * Gets the code to inject in the vertex shader
  137529. * @param state current state of the node material building
  137530. * @returns the shader code
  137531. */
  137532. handleVertexSide(state: NodeMaterialBuildState): string;
  137533. /**
  137534. * Gets the main code of the block (fragment side)
  137535. * @param state current state of the node material building
  137536. * @param normalVarName name of the existing variable corresponding to the normal
  137537. * @returns the shader code
  137538. */
  137539. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137540. protected _buildBlock(state: NodeMaterialBuildState): this;
  137541. protected _dumpPropertiesCode(): string;
  137542. serialize(): any;
  137543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137544. }
  137545. }
  137546. declare module BABYLON {
  137547. /**
  137548. * Block used to implement the sheen module of the PBR material
  137549. */
  137550. export class SheenBlock extends NodeMaterialBlock {
  137551. /**
  137552. * Create a new SheenBlock
  137553. * @param name defines the block name
  137554. */
  137555. constructor(name: string);
  137556. /**
  137557. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137558. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137559. * making it easier to setup and tweak the effect
  137560. */
  137561. albedoScaling: boolean;
  137562. /**
  137563. * Defines if the sheen is linked to the sheen color.
  137564. */
  137565. linkSheenWithAlbedo: boolean;
  137566. /**
  137567. * Initialize the block and prepare the context for build
  137568. * @param state defines the state that will be used for the build
  137569. */
  137570. initialize(state: NodeMaterialBuildState): void;
  137571. /**
  137572. * Gets the current class name
  137573. * @returns the class name
  137574. */
  137575. getClassName(): string;
  137576. /**
  137577. * Gets the intensity input component
  137578. */
  137579. get intensity(): NodeMaterialConnectionPoint;
  137580. /**
  137581. * Gets the color input component
  137582. */
  137583. get color(): NodeMaterialConnectionPoint;
  137584. /**
  137585. * Gets the roughness input component
  137586. */
  137587. get roughness(): NodeMaterialConnectionPoint;
  137588. /**
  137589. * Gets the texture input component
  137590. */
  137591. get texture(): NodeMaterialConnectionPoint;
  137592. /**
  137593. * Gets the sheen object output component
  137594. */
  137595. get sheen(): NodeMaterialConnectionPoint;
  137596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137597. /**
  137598. * Gets the main code of the block (fragment side)
  137599. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137600. * @returns the shader code
  137601. */
  137602. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137603. protected _buildBlock(state: NodeMaterialBuildState): this;
  137604. protected _dumpPropertiesCode(): string;
  137605. serialize(): any;
  137606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137607. }
  137608. }
  137609. declare module BABYLON {
  137610. /**
  137611. * Block used to implement the reflectivity module of the PBR material
  137612. */
  137613. export class ReflectivityBlock extends NodeMaterialBlock {
  137614. /**
  137615. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137616. */
  137617. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137618. /**
  137619. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137620. */
  137621. useMetallnessFromMetallicTextureBlue: boolean;
  137622. /**
  137623. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137624. */
  137625. useRoughnessFromMetallicTextureAlpha: boolean;
  137626. /**
  137627. * Specifies if the metallic texture contains the roughness information in its green channel.
  137628. */
  137629. useRoughnessFromMetallicTextureGreen: boolean;
  137630. /**
  137631. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137632. */
  137633. useMetallicF0FactorFromMetallicTexture: boolean;
  137634. /**
  137635. * Create a new ReflectivityBlock
  137636. * @param name defines the block name
  137637. */
  137638. constructor(name: string);
  137639. /**
  137640. * Initialize the block and prepare the context for build
  137641. * @param state defines the state that will be used for the build
  137642. */
  137643. initialize(state: NodeMaterialBuildState): void;
  137644. /**
  137645. * Gets the current class name
  137646. * @returns the class name
  137647. */
  137648. getClassName(): string;
  137649. /**
  137650. * Gets the metallic input component
  137651. */
  137652. get metallic(): NodeMaterialConnectionPoint;
  137653. /**
  137654. * Gets the roughness input component
  137655. */
  137656. get roughness(): NodeMaterialConnectionPoint;
  137657. /**
  137658. * Gets the texture input component
  137659. */
  137660. get texture(): NodeMaterialConnectionPoint;
  137661. /**
  137662. * Gets the reflectivity object output component
  137663. */
  137664. get reflectivity(): NodeMaterialConnectionPoint;
  137665. /**
  137666. * Gets the main code of the block (fragment side)
  137667. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137668. * @returns the shader code
  137669. */
  137670. getCode(aoIntensityVarName: string): string;
  137671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137672. protected _buildBlock(state: NodeMaterialBuildState): this;
  137673. protected _dumpPropertiesCode(): string;
  137674. serialize(): any;
  137675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137676. }
  137677. }
  137678. declare module BABYLON {
  137679. /**
  137680. * Block used to implement the anisotropy module of the PBR material
  137681. */
  137682. export class AnisotropyBlock extends NodeMaterialBlock {
  137683. /**
  137684. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137685. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137686. * It's less burden on the user side in the editor part.
  137687. */
  137688. /** @hidden */
  137689. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137690. /** @hidden */
  137691. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137692. /**
  137693. * Create a new AnisotropyBlock
  137694. * @param name defines the block name
  137695. */
  137696. constructor(name: string);
  137697. /**
  137698. * Initialize the block and prepare the context for build
  137699. * @param state defines the state that will be used for the build
  137700. */
  137701. initialize(state: NodeMaterialBuildState): void;
  137702. /**
  137703. * Gets the current class name
  137704. * @returns the class name
  137705. */
  137706. getClassName(): string;
  137707. /**
  137708. * Gets the intensity input component
  137709. */
  137710. get intensity(): NodeMaterialConnectionPoint;
  137711. /**
  137712. * Gets the direction input component
  137713. */
  137714. get direction(): NodeMaterialConnectionPoint;
  137715. /**
  137716. * Gets the texture input component
  137717. */
  137718. get texture(): NodeMaterialConnectionPoint;
  137719. /**
  137720. * Gets the uv input component
  137721. */
  137722. get uv(): NodeMaterialConnectionPoint;
  137723. /**
  137724. * Gets the worldTangent input component
  137725. */
  137726. get worldTangent(): NodeMaterialConnectionPoint;
  137727. /**
  137728. * Gets the anisotropy object output component
  137729. */
  137730. get anisotropy(): NodeMaterialConnectionPoint;
  137731. private _generateTBNSpace;
  137732. /**
  137733. * Gets the main code of the block (fragment side)
  137734. * @param state current state of the node material building
  137735. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137736. * @returns the shader code
  137737. */
  137738. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137740. protected _buildBlock(state: NodeMaterialBuildState): this;
  137741. }
  137742. }
  137743. declare module BABYLON {
  137744. /**
  137745. * Block used to implement the clear coat module of the PBR material
  137746. */
  137747. export class ClearCoatBlock extends NodeMaterialBlock {
  137748. private _scene;
  137749. /**
  137750. * Create a new ClearCoatBlock
  137751. * @param name defines the block name
  137752. */
  137753. constructor(name: string);
  137754. /**
  137755. * Initialize the block and prepare the context for build
  137756. * @param state defines the state that will be used for the build
  137757. */
  137758. initialize(state: NodeMaterialBuildState): void;
  137759. /**
  137760. * Gets the current class name
  137761. * @returns the class name
  137762. */
  137763. getClassName(): string;
  137764. /**
  137765. * Gets the intensity input component
  137766. */
  137767. get intensity(): NodeMaterialConnectionPoint;
  137768. /**
  137769. * Gets the roughness input component
  137770. */
  137771. get roughness(): NodeMaterialConnectionPoint;
  137772. /**
  137773. * Gets the ior input component
  137774. */
  137775. get ior(): NodeMaterialConnectionPoint;
  137776. /**
  137777. * Gets the texture input component
  137778. */
  137779. get texture(): NodeMaterialConnectionPoint;
  137780. /**
  137781. * Gets the bump texture input component
  137782. */
  137783. get bumpTexture(): NodeMaterialConnectionPoint;
  137784. /**
  137785. * Gets the uv input component
  137786. */
  137787. get uv(): NodeMaterialConnectionPoint;
  137788. /**
  137789. * Gets the tint color input component
  137790. */
  137791. get tintColor(): NodeMaterialConnectionPoint;
  137792. /**
  137793. * Gets the tint "at distance" input component
  137794. */
  137795. get tintAtDistance(): NodeMaterialConnectionPoint;
  137796. /**
  137797. * Gets the tint thickness input component
  137798. */
  137799. get tintThickness(): NodeMaterialConnectionPoint;
  137800. /**
  137801. * Gets the tint texture input component
  137802. */
  137803. get tintTexture(): NodeMaterialConnectionPoint;
  137804. /**
  137805. * Gets the world tangent input component
  137806. */
  137807. get worldTangent(): NodeMaterialConnectionPoint;
  137808. /**
  137809. * Gets the clear coat object output component
  137810. */
  137811. get clearcoat(): NodeMaterialConnectionPoint;
  137812. autoConfigure(material: NodeMaterial): void;
  137813. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137814. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137815. private _generateTBNSpace;
  137816. /**
  137817. * Gets the main code of the block (fragment side)
  137818. * @param state current state of the node material building
  137819. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137820. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137821. * @param worldPosVarName name of the variable holding the world position
  137822. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137823. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137824. * @param worldNormalVarName name of the variable holding the world normal
  137825. * @returns the shader code
  137826. */
  137827. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137828. protected _buildBlock(state: NodeMaterialBuildState): this;
  137829. }
  137830. }
  137831. declare module BABYLON {
  137832. /**
  137833. * Block used to implement the sub surface module of the PBR material
  137834. */
  137835. export class SubSurfaceBlock extends NodeMaterialBlock {
  137836. /**
  137837. * Create a new SubSurfaceBlock
  137838. * @param name defines the block name
  137839. */
  137840. constructor(name: string);
  137841. /**
  137842. * Stores the intensity of the different subsurface effects in the thickness texture.
  137843. * * the green channel is the translucency intensity.
  137844. * * the blue channel is the scattering intensity.
  137845. * * the alpha channel is the refraction intensity.
  137846. */
  137847. useMaskFromThicknessTexture: boolean;
  137848. /**
  137849. * Initialize the block and prepare the context for build
  137850. * @param state defines the state that will be used for the build
  137851. */
  137852. initialize(state: NodeMaterialBuildState): void;
  137853. /**
  137854. * Gets the current class name
  137855. * @returns the class name
  137856. */
  137857. getClassName(): string;
  137858. /**
  137859. * Gets the min thickness input component
  137860. */
  137861. get minThickness(): NodeMaterialConnectionPoint;
  137862. /**
  137863. * Gets the max thickness input component
  137864. */
  137865. get maxThickness(): NodeMaterialConnectionPoint;
  137866. /**
  137867. * Gets the thickness texture component
  137868. */
  137869. get thicknessTexture(): NodeMaterialConnectionPoint;
  137870. /**
  137871. * Gets the tint color input component
  137872. */
  137873. get tintColor(): NodeMaterialConnectionPoint;
  137874. /**
  137875. * Gets the translucency intensity input component
  137876. */
  137877. get translucencyIntensity(): NodeMaterialConnectionPoint;
  137878. /**
  137879. * Gets the translucency diffusion distance input component
  137880. */
  137881. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  137882. /**
  137883. * Gets the refraction object parameters
  137884. */
  137885. get refraction(): NodeMaterialConnectionPoint;
  137886. /**
  137887. * Gets the sub surface object output component
  137888. */
  137889. get subsurface(): NodeMaterialConnectionPoint;
  137890. autoConfigure(material: NodeMaterial): void;
  137891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137892. /**
  137893. * Gets the main code of the block (fragment side)
  137894. * @param state current state of the node material building
  137895. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  137896. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137897. * @param worldPosVarName name of the variable holding the world position
  137898. * @returns the shader code
  137899. */
  137900. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  137901. protected _buildBlock(state: NodeMaterialBuildState): this;
  137902. }
  137903. }
  137904. declare module BABYLON {
  137905. /**
  137906. * Block used to implement the PBR metallic/roughness model
  137907. */
  137908. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  137909. /**
  137910. * Gets or sets the light associated with this block
  137911. */
  137912. light: Nullable<Light>;
  137913. private _lightId;
  137914. private _scene;
  137915. private _environmentBRDFTexture;
  137916. private _environmentBrdfSamplerName;
  137917. private _vNormalWName;
  137918. private _invertNormalName;
  137919. /**
  137920. * Create a new ReflectionBlock
  137921. * @param name defines the block name
  137922. */
  137923. constructor(name: string);
  137924. /**
  137925. * Intensity of the direct lights e.g. the four lights available in your scene.
  137926. * This impacts both the direct diffuse and specular highlights.
  137927. */
  137928. directIntensity: number;
  137929. /**
  137930. * Intensity of the environment e.g. how much the environment will light the object
  137931. * either through harmonics for rough material or through the refelction for shiny ones.
  137932. */
  137933. environmentIntensity: number;
  137934. /**
  137935. * This is a special control allowing the reduction of the specular highlights coming from the
  137936. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137937. */
  137938. specularIntensity: number;
  137939. /**
  137940. * Defines the falloff type used in this material.
  137941. * It by default is Physical.
  137942. */
  137943. lightFalloff: number;
  137944. /**
  137945. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137946. */
  137947. useAlphaFromAlbedoTexture: boolean;
  137948. /**
  137949. * Specifies that alpha test should be used
  137950. */
  137951. useAlphaTest: boolean;
  137952. /**
  137953. * Defines the alpha limits in alpha test mode.
  137954. */
  137955. alphaTestCutoff: number;
  137956. /**
  137957. * Specifies that alpha blending should be used
  137958. */
  137959. useAlphaBlending: boolean;
  137960. /**
  137961. * Defines if the alpha value should be determined via the rgb values.
  137962. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  137963. */
  137964. opacityRGB: boolean;
  137965. /**
  137966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  137967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137968. */
  137969. useRadianceOverAlpha: boolean;
  137970. /**
  137971. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  137972. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137973. */
  137974. useSpecularOverAlpha: boolean;
  137975. /**
  137976. * Enables specular anti aliasing in the PBR shader.
  137977. * It will both interacts on the Geometry for analytical and IBL lighting.
  137978. * It also prefilter the roughness map based on the bump values.
  137979. */
  137980. enableSpecularAntiAliasing: boolean;
  137981. /**
  137982. * Defines if the material uses energy conservation.
  137983. */
  137984. useEnergyConservation: boolean;
  137985. /**
  137986. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137987. * too much the area relying on ambient texture to define their ambient occlusion.
  137988. */
  137989. useRadianceOcclusion: boolean;
  137990. /**
  137991. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137992. * makes the reflect vector face the model (under horizon).
  137993. */
  137994. useHorizonOcclusion: boolean;
  137995. /**
  137996. * If set to true, no lighting calculations will be applied.
  137997. */
  137998. unlit: boolean;
  137999. /**
  138000. * Force normal to face away from face.
  138001. */
  138002. forceNormalForward: boolean;
  138003. /**
  138004. * Defines the material debug mode.
  138005. * It helps seeing only some components of the material while troubleshooting.
  138006. */
  138007. debugMode: number;
  138008. /**
  138009. * Specify from where on screen the debug mode should start.
  138010. * The value goes from -1 (full screen) to 1 (not visible)
  138011. * It helps with side by side comparison against the final render
  138012. * This defaults to 0
  138013. */
  138014. debugLimit: number;
  138015. /**
  138016. * As the default viewing range might not be enough (if the ambient is really small for instance)
  138017. * You can use the factor to better multiply the final value.
  138018. */
  138019. debugFactor: number;
  138020. /**
  138021. * Initialize the block and prepare the context for build
  138022. * @param state defines the state that will be used for the build
  138023. */
  138024. initialize(state: NodeMaterialBuildState): void;
  138025. /**
  138026. * Gets the current class name
  138027. * @returns the class name
  138028. */
  138029. getClassName(): string;
  138030. /**
  138031. * Gets the world position input component
  138032. */
  138033. get worldPosition(): NodeMaterialConnectionPoint;
  138034. /**
  138035. * Gets the world normal input component
  138036. */
  138037. get worldNormal(): NodeMaterialConnectionPoint;
  138038. /**
  138039. * Gets the perturbed normal input component
  138040. */
  138041. get perturbedNormal(): NodeMaterialConnectionPoint;
  138042. /**
  138043. * Gets the camera position input component
  138044. */
  138045. get cameraPosition(): NodeMaterialConnectionPoint;
  138046. /**
  138047. * Gets the base color input component
  138048. */
  138049. get baseColor(): NodeMaterialConnectionPoint;
  138050. /**
  138051. * Gets the base texture input component
  138052. */
  138053. get baseTexture(): NodeMaterialConnectionPoint;
  138054. /**
  138055. * Gets the opacity texture input component
  138056. */
  138057. get opacityTexture(): NodeMaterialConnectionPoint;
  138058. /**
  138059. * Gets the ambient color input component
  138060. */
  138061. get ambientColor(): NodeMaterialConnectionPoint;
  138062. /**
  138063. * Gets the reflectivity object parameters
  138064. */
  138065. get reflectivity(): NodeMaterialConnectionPoint;
  138066. /**
  138067. * Gets the ambient occlusion object parameters
  138068. */
  138069. get ambientOcclusion(): NodeMaterialConnectionPoint;
  138070. /**
  138071. * Gets the reflection object parameters
  138072. */
  138073. get reflection(): NodeMaterialConnectionPoint;
  138074. /**
  138075. * Gets the sheen object parameters
  138076. */
  138077. get sheen(): NodeMaterialConnectionPoint;
  138078. /**
  138079. * Gets the clear coat object parameters
  138080. */
  138081. get clearcoat(): NodeMaterialConnectionPoint;
  138082. /**
  138083. * Gets the sub surface object parameters
  138084. */
  138085. get subsurface(): NodeMaterialConnectionPoint;
  138086. /**
  138087. * Gets the anisotropy object parameters
  138088. */
  138089. get anisotropy(): NodeMaterialConnectionPoint;
  138090. /**
  138091. * Gets the ambient output component
  138092. */
  138093. get ambient(): NodeMaterialConnectionPoint;
  138094. /**
  138095. * Gets the diffuse output component
  138096. */
  138097. get diffuse(): NodeMaterialConnectionPoint;
  138098. /**
  138099. * Gets the specular output component
  138100. */
  138101. get specular(): NodeMaterialConnectionPoint;
  138102. /**
  138103. * Gets the sheen output component
  138104. */
  138105. get sheenDir(): NodeMaterialConnectionPoint;
  138106. /**
  138107. * Gets the clear coat output component
  138108. */
  138109. get clearcoatDir(): NodeMaterialConnectionPoint;
  138110. /**
  138111. * Gets the indirect diffuse output component
  138112. */
  138113. get diffuseIndirect(): NodeMaterialConnectionPoint;
  138114. /**
  138115. * Gets the indirect specular output component
  138116. */
  138117. get specularIndirect(): NodeMaterialConnectionPoint;
  138118. /**
  138119. * Gets the indirect sheen output component
  138120. */
  138121. get sheenIndirect(): NodeMaterialConnectionPoint;
  138122. /**
  138123. * Gets the indirect clear coat output component
  138124. */
  138125. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  138126. /**
  138127. * Gets the refraction output component
  138128. */
  138129. get refraction(): NodeMaterialConnectionPoint;
  138130. /**
  138131. * Gets the global lighting output component
  138132. */
  138133. get lighting(): NodeMaterialConnectionPoint;
  138134. /**
  138135. * Gets the shadow output component
  138136. */
  138137. get shadow(): NodeMaterialConnectionPoint;
  138138. /**
  138139. * Gets the alpha output component
  138140. */
  138141. get alpha(): NodeMaterialConnectionPoint;
  138142. autoConfigure(material: NodeMaterial): void;
  138143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138144. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138146. private _injectVertexCode;
  138147. /**
  138148. * Gets the code corresponding to the albedo/opacity module
  138149. * @returns the shader code
  138150. */
  138151. getAlbedoOpacityCode(): string;
  138152. protected _buildBlock(state: NodeMaterialBuildState): this;
  138153. protected _dumpPropertiesCode(): string;
  138154. serialize(): any;
  138155. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138156. }
  138157. }
  138158. declare module BABYLON {
  138159. /**
  138160. * Effect Render Options
  138161. */
  138162. export interface IEffectRendererOptions {
  138163. /**
  138164. * Defines the vertices positions.
  138165. */
  138166. positions?: number[];
  138167. /**
  138168. * Defines the indices.
  138169. */
  138170. indices?: number[];
  138171. }
  138172. /**
  138173. * Helper class to render one or more effects.
  138174. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138175. */
  138176. export class EffectRenderer {
  138177. private engine;
  138178. private static _DefaultOptions;
  138179. private _vertexBuffers;
  138180. private _indexBuffer;
  138181. private _fullscreenViewport;
  138182. /**
  138183. * Creates an effect renderer
  138184. * @param engine the engine to use for rendering
  138185. * @param options defines the options of the effect renderer
  138186. */
  138187. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138188. /**
  138189. * Sets the current viewport in normalized coordinates 0-1
  138190. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138191. */
  138192. setViewport(viewport?: Viewport): void;
  138193. /**
  138194. * Binds the embedded attributes buffer to the effect.
  138195. * @param effect Defines the effect to bind the attributes for
  138196. */
  138197. bindBuffers(effect: Effect): void;
  138198. /**
  138199. * Sets the current effect wrapper to use during draw.
  138200. * The effect needs to be ready before calling this api.
  138201. * This also sets the default full screen position attribute.
  138202. * @param effectWrapper Defines the effect to draw with
  138203. */
  138204. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138205. /**
  138206. * Draws a full screen quad.
  138207. */
  138208. draw(): void;
  138209. private isRenderTargetTexture;
  138210. /**
  138211. * renders one or more effects to a specified texture
  138212. * @param effectWrapper the effect to renderer
  138213. * @param outputTexture texture to draw to, if null it will render to the screen.
  138214. */
  138215. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138216. /**
  138217. * Disposes of the effect renderer
  138218. */
  138219. dispose(): void;
  138220. }
  138221. /**
  138222. * Options to create an EffectWrapper
  138223. */
  138224. interface EffectWrapperCreationOptions {
  138225. /**
  138226. * Engine to use to create the effect
  138227. */
  138228. engine: ThinEngine;
  138229. /**
  138230. * Fragment shader for the effect
  138231. */
  138232. fragmentShader: string;
  138233. /**
  138234. * Vertex shader for the effect
  138235. */
  138236. vertexShader?: string;
  138237. /**
  138238. * Attributes to use in the shader
  138239. */
  138240. attributeNames?: Array<string>;
  138241. /**
  138242. * Uniforms to use in the shader
  138243. */
  138244. uniformNames?: Array<string>;
  138245. /**
  138246. * Texture sampler names to use in the shader
  138247. */
  138248. samplerNames?: Array<string>;
  138249. /**
  138250. * The friendly name of the effect displayed in Spector.
  138251. */
  138252. name?: string;
  138253. }
  138254. /**
  138255. * Wraps an effect to be used for rendering
  138256. */
  138257. export class EffectWrapper {
  138258. /**
  138259. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138260. */
  138261. onApplyObservable: Observable<{}>;
  138262. /**
  138263. * The underlying effect
  138264. */
  138265. effect: Effect;
  138266. /**
  138267. * Creates an effect to be renderer
  138268. * @param creationOptions options to create the effect
  138269. */
  138270. constructor(creationOptions: EffectWrapperCreationOptions);
  138271. /**
  138272. * Disposes of the effect wrapper
  138273. */
  138274. dispose(): void;
  138275. }
  138276. }
  138277. declare module BABYLON {
  138278. /**
  138279. * Helper class to push actions to a pool of workers.
  138280. */
  138281. export class WorkerPool implements IDisposable {
  138282. private _workerInfos;
  138283. private _pendingActions;
  138284. /**
  138285. * Constructor
  138286. * @param workers Array of workers to use for actions
  138287. */
  138288. constructor(workers: Array<Worker>);
  138289. /**
  138290. * Terminates all workers and clears any pending actions.
  138291. */
  138292. dispose(): void;
  138293. /**
  138294. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138295. * pended until a worker has completed its action.
  138296. * @param action The action to perform. Call onComplete when the action is complete.
  138297. */
  138298. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138299. private _execute;
  138300. }
  138301. }
  138302. declare module BABYLON {
  138303. /**
  138304. * Configuration for Draco compression
  138305. */
  138306. export interface IDracoCompressionConfiguration {
  138307. /**
  138308. * Configuration for the decoder.
  138309. */
  138310. decoder: {
  138311. /**
  138312. * The url to the WebAssembly module.
  138313. */
  138314. wasmUrl?: string;
  138315. /**
  138316. * The url to the WebAssembly binary.
  138317. */
  138318. wasmBinaryUrl?: string;
  138319. /**
  138320. * The url to the fallback JavaScript module.
  138321. */
  138322. fallbackUrl?: string;
  138323. };
  138324. }
  138325. /**
  138326. * Draco compression (https://google.github.io/draco/)
  138327. *
  138328. * This class wraps the Draco module.
  138329. *
  138330. * **Encoder**
  138331. *
  138332. * The encoder is not currently implemented.
  138333. *
  138334. * **Decoder**
  138335. *
  138336. * 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.
  138337. *
  138338. * To update the configuration, use the following code:
  138339. * ```javascript
  138340. * DracoCompression.Configuration = {
  138341. * decoder: {
  138342. * wasmUrl: "<url to the WebAssembly library>",
  138343. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138344. * fallbackUrl: "<url to the fallback JavaScript library>",
  138345. * }
  138346. * };
  138347. * ```
  138348. *
  138349. * 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.
  138350. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138351. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138352. *
  138353. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138354. * ```javascript
  138355. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138356. * ```
  138357. *
  138358. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138359. */
  138360. export class DracoCompression implements IDisposable {
  138361. private _workerPoolPromise?;
  138362. private _decoderModulePromise?;
  138363. /**
  138364. * The configuration. Defaults to the following urls:
  138365. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138366. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138367. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138368. */
  138369. static Configuration: IDracoCompressionConfiguration;
  138370. /**
  138371. * Returns true if the decoder configuration is available.
  138372. */
  138373. static get DecoderAvailable(): boolean;
  138374. /**
  138375. * Default number of workers to create when creating the draco compression object.
  138376. */
  138377. static DefaultNumWorkers: number;
  138378. private static GetDefaultNumWorkers;
  138379. private static _Default;
  138380. /**
  138381. * Default instance for the draco compression object.
  138382. */
  138383. static get Default(): DracoCompression;
  138384. /**
  138385. * Constructor
  138386. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138387. */
  138388. constructor(numWorkers?: number);
  138389. /**
  138390. * Stop all async operations and release resources.
  138391. */
  138392. dispose(): void;
  138393. /**
  138394. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138395. * @returns a promise that resolves when ready
  138396. */
  138397. whenReadyAsync(): Promise<void>;
  138398. /**
  138399. * Decode Draco compressed mesh data to vertex data.
  138400. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138401. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138402. * @returns A promise that resolves with the decoded vertex data
  138403. */
  138404. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138405. [kind: string]: number;
  138406. }): Promise<VertexData>;
  138407. }
  138408. }
  138409. declare module BABYLON {
  138410. /**
  138411. * Class for building Constructive Solid Geometry
  138412. */
  138413. export class CSG {
  138414. private polygons;
  138415. /**
  138416. * The world matrix
  138417. */
  138418. matrix: Matrix;
  138419. /**
  138420. * Stores the position
  138421. */
  138422. position: Vector3;
  138423. /**
  138424. * Stores the rotation
  138425. */
  138426. rotation: Vector3;
  138427. /**
  138428. * Stores the rotation quaternion
  138429. */
  138430. rotationQuaternion: Nullable<Quaternion>;
  138431. /**
  138432. * Stores the scaling vector
  138433. */
  138434. scaling: Vector3;
  138435. /**
  138436. * Convert the Mesh to CSG
  138437. * @param mesh The Mesh to convert to CSG
  138438. * @returns A new CSG from the Mesh
  138439. */
  138440. static FromMesh(mesh: Mesh): CSG;
  138441. /**
  138442. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138443. * @param polygons Polygons used to construct a CSG solid
  138444. */
  138445. private static FromPolygons;
  138446. /**
  138447. * Clones, or makes a deep copy, of the CSG
  138448. * @returns A new CSG
  138449. */
  138450. clone(): CSG;
  138451. /**
  138452. * Unions this CSG with another CSG
  138453. * @param csg The CSG to union against this CSG
  138454. * @returns The unioned CSG
  138455. */
  138456. union(csg: CSG): CSG;
  138457. /**
  138458. * Unions this CSG with another CSG in place
  138459. * @param csg The CSG to union against this CSG
  138460. */
  138461. unionInPlace(csg: CSG): void;
  138462. /**
  138463. * Subtracts this CSG with another CSG
  138464. * @param csg The CSG to subtract against this CSG
  138465. * @returns A new CSG
  138466. */
  138467. subtract(csg: CSG): CSG;
  138468. /**
  138469. * Subtracts this CSG with another CSG in place
  138470. * @param csg The CSG to subtact against this CSG
  138471. */
  138472. subtractInPlace(csg: CSG): void;
  138473. /**
  138474. * Intersect this CSG with another CSG
  138475. * @param csg The CSG to intersect against this CSG
  138476. * @returns A new CSG
  138477. */
  138478. intersect(csg: CSG): CSG;
  138479. /**
  138480. * Intersects this CSG with another CSG in place
  138481. * @param csg The CSG to intersect against this CSG
  138482. */
  138483. intersectInPlace(csg: CSG): void;
  138484. /**
  138485. * Return a new CSG solid with solid and empty space switched. This solid is
  138486. * not modified.
  138487. * @returns A new CSG solid with solid and empty space switched
  138488. */
  138489. inverse(): CSG;
  138490. /**
  138491. * Inverses the CSG in place
  138492. */
  138493. inverseInPlace(): void;
  138494. /**
  138495. * This is used to keep meshes transformations so they can be restored
  138496. * when we build back a Babylon Mesh
  138497. * NB : All CSG operations are performed in world coordinates
  138498. * @param csg The CSG to copy the transform attributes from
  138499. * @returns This CSG
  138500. */
  138501. copyTransformAttributes(csg: CSG): CSG;
  138502. /**
  138503. * Build Raw mesh from CSG
  138504. * Coordinates here are in world space
  138505. * @param name The name of the mesh geometry
  138506. * @param scene The Scene
  138507. * @param keepSubMeshes Specifies if the submeshes should be kept
  138508. * @returns A new Mesh
  138509. */
  138510. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138511. /**
  138512. * Build Mesh from CSG taking material and transforms into account
  138513. * @param name The name of the Mesh
  138514. * @param material The material of the Mesh
  138515. * @param scene The Scene
  138516. * @param keepSubMeshes Specifies if submeshes should be kept
  138517. * @returns The new Mesh
  138518. */
  138519. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138520. }
  138521. }
  138522. declare module BABYLON {
  138523. /**
  138524. * Class used to create a trail following a mesh
  138525. */
  138526. export class TrailMesh extends Mesh {
  138527. private _generator;
  138528. private _autoStart;
  138529. private _running;
  138530. private _diameter;
  138531. private _length;
  138532. private _sectionPolygonPointsCount;
  138533. private _sectionVectors;
  138534. private _sectionNormalVectors;
  138535. private _beforeRenderObserver;
  138536. /**
  138537. * @constructor
  138538. * @param name The value used by scene.getMeshByName() to do a lookup.
  138539. * @param generator The mesh or transform node to generate a trail.
  138540. * @param scene The scene to add this mesh to.
  138541. * @param diameter Diameter of trailing mesh. Default is 1.
  138542. * @param length Length of trailing mesh. Default is 60.
  138543. * @param autoStart Automatically start trailing mesh. Default true.
  138544. */
  138545. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138546. /**
  138547. * "TrailMesh"
  138548. * @returns "TrailMesh"
  138549. */
  138550. getClassName(): string;
  138551. private _createMesh;
  138552. /**
  138553. * Start trailing mesh.
  138554. */
  138555. start(): void;
  138556. /**
  138557. * Stop trailing mesh.
  138558. */
  138559. stop(): void;
  138560. /**
  138561. * Update trailing mesh geometry.
  138562. */
  138563. update(): void;
  138564. /**
  138565. * Returns a new TrailMesh object.
  138566. * @param name is a string, the name given to the new mesh
  138567. * @param newGenerator use new generator object for cloned trail mesh
  138568. * @returns a new mesh
  138569. */
  138570. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138571. /**
  138572. * Serializes this trail mesh
  138573. * @param serializationObject object to write serialization to
  138574. */
  138575. serialize(serializationObject: any): void;
  138576. /**
  138577. * Parses a serialized trail mesh
  138578. * @param parsedMesh the serialized mesh
  138579. * @param scene the scene to create the trail mesh in
  138580. * @returns the created trail mesh
  138581. */
  138582. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138583. }
  138584. }
  138585. declare module BABYLON {
  138586. /**
  138587. * Class containing static functions to help procedurally build meshes
  138588. */
  138589. export class TiledBoxBuilder {
  138590. /**
  138591. * Creates a box mesh
  138592. * 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)
  138593. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138597. * @param name defines the name of the mesh
  138598. * @param options defines the options used to create the mesh
  138599. * @param scene defines the hosting scene
  138600. * @returns the box mesh
  138601. */
  138602. static CreateTiledBox(name: string, options: {
  138603. pattern?: number;
  138604. width?: number;
  138605. height?: number;
  138606. depth?: number;
  138607. tileSize?: number;
  138608. tileWidth?: number;
  138609. tileHeight?: number;
  138610. alignHorizontal?: number;
  138611. alignVertical?: number;
  138612. faceUV?: Vector4[];
  138613. faceColors?: Color4[];
  138614. sideOrientation?: number;
  138615. updatable?: boolean;
  138616. }, scene?: Nullable<Scene>): Mesh;
  138617. }
  138618. }
  138619. declare module BABYLON {
  138620. /**
  138621. * Class containing static functions to help procedurally build meshes
  138622. */
  138623. export class TorusKnotBuilder {
  138624. /**
  138625. * Creates a torus knot mesh
  138626. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138627. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138628. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138629. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138633. * @param name defines the name of the mesh
  138634. * @param options defines the options used to create the mesh
  138635. * @param scene defines the hosting scene
  138636. * @returns the torus knot mesh
  138637. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138638. */
  138639. static CreateTorusKnot(name: string, options: {
  138640. radius?: number;
  138641. tube?: number;
  138642. radialSegments?: number;
  138643. tubularSegments?: number;
  138644. p?: number;
  138645. q?: number;
  138646. updatable?: boolean;
  138647. sideOrientation?: number;
  138648. frontUVs?: Vector4;
  138649. backUVs?: Vector4;
  138650. }, scene: any): Mesh;
  138651. }
  138652. }
  138653. declare module BABYLON {
  138654. /**
  138655. * Polygon
  138656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138657. */
  138658. export class Polygon {
  138659. /**
  138660. * Creates a rectangle
  138661. * @param xmin bottom X coord
  138662. * @param ymin bottom Y coord
  138663. * @param xmax top X coord
  138664. * @param ymax top Y coord
  138665. * @returns points that make the resulting rectation
  138666. */
  138667. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138668. /**
  138669. * Creates a circle
  138670. * @param radius radius of circle
  138671. * @param cx scale in x
  138672. * @param cy scale in y
  138673. * @param numberOfSides number of sides that make up the circle
  138674. * @returns points that make the resulting circle
  138675. */
  138676. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138677. /**
  138678. * Creates a polygon from input string
  138679. * @param input Input polygon data
  138680. * @returns the parsed points
  138681. */
  138682. static Parse(input: string): Vector2[];
  138683. /**
  138684. * Starts building a polygon from x and y coordinates
  138685. * @param x x coordinate
  138686. * @param y y coordinate
  138687. * @returns the started path2
  138688. */
  138689. static StartingAt(x: number, y: number): Path2;
  138690. }
  138691. /**
  138692. * Builds a polygon
  138693. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138694. */
  138695. export class PolygonMeshBuilder {
  138696. private _points;
  138697. private _outlinepoints;
  138698. private _holes;
  138699. private _name;
  138700. private _scene;
  138701. private _epoints;
  138702. private _eholes;
  138703. private _addToepoint;
  138704. /**
  138705. * Babylon reference to the earcut plugin.
  138706. */
  138707. bjsEarcut: any;
  138708. /**
  138709. * Creates a PolygonMeshBuilder
  138710. * @param name name of the builder
  138711. * @param contours Path of the polygon
  138712. * @param scene scene to add to when creating the mesh
  138713. * @param earcutInjection can be used to inject your own earcut reference
  138714. */
  138715. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138716. /**
  138717. * Adds a whole within the polygon
  138718. * @param hole Array of points defining the hole
  138719. * @returns this
  138720. */
  138721. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138722. /**
  138723. * Creates the polygon
  138724. * @param updatable If the mesh should be updatable
  138725. * @param depth The depth of the mesh created
  138726. * @returns the created mesh
  138727. */
  138728. build(updatable?: boolean, depth?: number): Mesh;
  138729. /**
  138730. * Creates the polygon
  138731. * @param depth The depth of the mesh created
  138732. * @returns the created VertexData
  138733. */
  138734. buildVertexData(depth?: number): VertexData;
  138735. /**
  138736. * Adds a side to the polygon
  138737. * @param positions points that make the polygon
  138738. * @param normals normals of the polygon
  138739. * @param uvs uvs of the polygon
  138740. * @param indices indices of the polygon
  138741. * @param bounds bounds of the polygon
  138742. * @param points points of the polygon
  138743. * @param depth depth of the polygon
  138744. * @param flip flip of the polygon
  138745. */
  138746. private addSide;
  138747. }
  138748. }
  138749. declare module BABYLON {
  138750. /**
  138751. * Class containing static functions to help procedurally build meshes
  138752. */
  138753. export class PolygonBuilder {
  138754. /**
  138755. * Creates a polygon mesh
  138756. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138757. * * 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
  138758. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  138761. * * Remember you can only change the shape positions, not their number when updating a polygon
  138762. * @param name defines the name of the mesh
  138763. * @param options defines the options used to create the mesh
  138764. * @param scene defines the hosting scene
  138765. * @param earcutInjection can be used to inject your own earcut reference
  138766. * @returns the polygon mesh
  138767. */
  138768. static CreatePolygon(name: string, options: {
  138769. shape: Vector3[];
  138770. holes?: Vector3[][];
  138771. depth?: number;
  138772. faceUV?: Vector4[];
  138773. faceColors?: Color4[];
  138774. updatable?: boolean;
  138775. sideOrientation?: number;
  138776. frontUVs?: Vector4;
  138777. backUVs?: Vector4;
  138778. wrap?: boolean;
  138779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138780. /**
  138781. * Creates an extruded polygon mesh, with depth in the Y direction.
  138782. * * 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)
  138783. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138784. * @param name defines the name of the mesh
  138785. * @param options defines the options used to create the mesh
  138786. * @param scene defines the hosting scene
  138787. * @param earcutInjection can be used to inject your own earcut reference
  138788. * @returns the polygon mesh
  138789. */
  138790. static ExtrudePolygon(name: string, options: {
  138791. shape: Vector3[];
  138792. holes?: Vector3[][];
  138793. depth?: number;
  138794. faceUV?: Vector4[];
  138795. faceColors?: Color4[];
  138796. updatable?: boolean;
  138797. sideOrientation?: number;
  138798. frontUVs?: Vector4;
  138799. backUVs?: Vector4;
  138800. wrap?: boolean;
  138801. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138802. }
  138803. }
  138804. declare module BABYLON {
  138805. /**
  138806. * Class containing static functions to help procedurally build meshes
  138807. */
  138808. export class LatheBuilder {
  138809. /**
  138810. * Creates lathe mesh.
  138811. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138812. * * 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
  138813. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138814. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138815. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138816. * * 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
  138817. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138818. * * 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
  138819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138823. * @param name defines the name of the mesh
  138824. * @param options defines the options used to create the mesh
  138825. * @param scene defines the hosting scene
  138826. * @returns the lathe mesh
  138827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138828. */
  138829. static CreateLathe(name: string, options: {
  138830. shape: Vector3[];
  138831. radius?: number;
  138832. tessellation?: number;
  138833. clip?: number;
  138834. arc?: number;
  138835. closed?: boolean;
  138836. updatable?: boolean;
  138837. sideOrientation?: number;
  138838. frontUVs?: Vector4;
  138839. backUVs?: Vector4;
  138840. cap?: number;
  138841. invertUV?: boolean;
  138842. }, scene?: Nullable<Scene>): Mesh;
  138843. }
  138844. }
  138845. declare module BABYLON {
  138846. /**
  138847. * Class containing static functions to help procedurally build meshes
  138848. */
  138849. export class TiledPlaneBuilder {
  138850. /**
  138851. * Creates a tiled plane mesh
  138852. * * The parameter `pattern` will, depending on value, do nothing or
  138853. * * * flip (reflect about central vertical) alternate tiles across and up
  138854. * * * flip every tile on alternate rows
  138855. * * * rotate (180 degs) alternate tiles across and up
  138856. * * * rotate every tile on alternate rows
  138857. * * * flip and rotate alternate tiles across and up
  138858. * * * flip and rotate every tile on alternate rows
  138859. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138860. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138862. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138863. * * 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)
  138864. * * 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)
  138865. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138866. * @param name defines the name of the mesh
  138867. * @param options defines the options used to create the mesh
  138868. * @param scene defines the hosting scene
  138869. * @returns the box mesh
  138870. */
  138871. static CreateTiledPlane(name: string, options: {
  138872. pattern?: number;
  138873. tileSize?: number;
  138874. tileWidth?: number;
  138875. tileHeight?: number;
  138876. size?: number;
  138877. width?: number;
  138878. height?: number;
  138879. alignHorizontal?: number;
  138880. alignVertical?: number;
  138881. sideOrientation?: number;
  138882. frontUVs?: Vector4;
  138883. backUVs?: Vector4;
  138884. updatable?: boolean;
  138885. }, scene?: Nullable<Scene>): Mesh;
  138886. }
  138887. }
  138888. declare module BABYLON {
  138889. /**
  138890. * Class containing static functions to help procedurally build meshes
  138891. */
  138892. export class TubeBuilder {
  138893. /**
  138894. * Creates a tube mesh.
  138895. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138896. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138897. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138898. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138899. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138900. * * 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)
  138901. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138902. * * 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
  138903. * * 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
  138904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138908. * @param name defines the name of the mesh
  138909. * @param options defines the options used to create the mesh
  138910. * @param scene defines the hosting scene
  138911. * @returns the tube mesh
  138912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138913. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138914. */
  138915. static CreateTube(name: string, options: {
  138916. path: Vector3[];
  138917. radius?: number;
  138918. tessellation?: number;
  138919. radiusFunction?: {
  138920. (i: number, distance: number): number;
  138921. };
  138922. cap?: number;
  138923. arc?: number;
  138924. updatable?: boolean;
  138925. sideOrientation?: number;
  138926. frontUVs?: Vector4;
  138927. backUVs?: Vector4;
  138928. instance?: Mesh;
  138929. invertUV?: boolean;
  138930. }, scene?: Nullable<Scene>): Mesh;
  138931. }
  138932. }
  138933. declare module BABYLON {
  138934. /**
  138935. * Class containing static functions to help procedurally build meshes
  138936. */
  138937. export class IcoSphereBuilder {
  138938. /**
  138939. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138940. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138941. * * 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`)
  138942. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138943. * * 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
  138944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138947. * @param name defines the name of the mesh
  138948. * @param options defines the options used to create the mesh
  138949. * @param scene defines the hosting scene
  138950. * @returns the icosahedron mesh
  138951. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138952. */
  138953. static CreateIcoSphere(name: string, options: {
  138954. radius?: number;
  138955. radiusX?: number;
  138956. radiusY?: number;
  138957. radiusZ?: number;
  138958. flat?: boolean;
  138959. subdivisions?: number;
  138960. sideOrientation?: number;
  138961. frontUVs?: Vector4;
  138962. backUVs?: Vector4;
  138963. updatable?: boolean;
  138964. }, scene?: Nullable<Scene>): Mesh;
  138965. }
  138966. }
  138967. declare module BABYLON {
  138968. /**
  138969. * Class containing static functions to help procedurally build meshes
  138970. */
  138971. export class DecalBuilder {
  138972. /**
  138973. * Creates a decal mesh.
  138974. * 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
  138975. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  138976. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  138977. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  138978. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  138979. * @param name defines the name of the mesh
  138980. * @param sourceMesh defines the mesh where the decal must be applied
  138981. * @param options defines the options used to create the mesh
  138982. * @param scene defines the hosting scene
  138983. * @returns the decal mesh
  138984. * @see https://doc.babylonjs.com/how_to/decals
  138985. */
  138986. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  138987. position?: Vector3;
  138988. normal?: Vector3;
  138989. size?: Vector3;
  138990. angle?: number;
  138991. }): Mesh;
  138992. }
  138993. }
  138994. declare module BABYLON {
  138995. /**
  138996. * Class containing static functions to help procedurally build meshes
  138997. */
  138998. export class MeshBuilder {
  138999. /**
  139000. * Creates a box mesh
  139001. * * The parameter `size` sets the size (float) of each box side (default 1)
  139002. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  139003. * * 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)
  139004. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139008. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  139009. * @param name defines the name of the mesh
  139010. * @param options defines the options used to create the mesh
  139011. * @param scene defines the hosting scene
  139012. * @returns the box mesh
  139013. */
  139014. static CreateBox(name: string, options: {
  139015. size?: number;
  139016. width?: number;
  139017. height?: number;
  139018. depth?: number;
  139019. faceUV?: Vector4[];
  139020. faceColors?: Color4[];
  139021. sideOrientation?: number;
  139022. frontUVs?: Vector4;
  139023. backUVs?: Vector4;
  139024. wrap?: boolean;
  139025. topBaseAt?: number;
  139026. bottomBaseAt?: number;
  139027. updatable?: boolean;
  139028. }, scene?: Nullable<Scene>): Mesh;
  139029. /**
  139030. * Creates a tiled box mesh
  139031. * * faceTiles sets the pattern, tile size and number of tiles for a face
  139032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139033. * @param name defines the name of the mesh
  139034. * @param options defines the options used to create the mesh
  139035. * @param scene defines the hosting scene
  139036. * @returns the tiled box mesh
  139037. */
  139038. static CreateTiledBox(name: string, options: {
  139039. pattern?: number;
  139040. size?: number;
  139041. width?: number;
  139042. height?: number;
  139043. depth: number;
  139044. tileSize?: number;
  139045. tileWidth?: number;
  139046. tileHeight?: number;
  139047. faceUV?: Vector4[];
  139048. faceColors?: Color4[];
  139049. alignHorizontal?: number;
  139050. alignVertical?: number;
  139051. sideOrientation?: number;
  139052. updatable?: boolean;
  139053. }, scene?: Nullable<Scene>): Mesh;
  139054. /**
  139055. * Creates a sphere mesh
  139056. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139057. * * 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`)
  139058. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139059. * * 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
  139060. * * 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)
  139061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139064. * @param name defines the name of the mesh
  139065. * @param options defines the options used to create the mesh
  139066. * @param scene defines the hosting scene
  139067. * @returns the sphere mesh
  139068. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139069. */
  139070. static CreateSphere(name: string, options: {
  139071. segments?: number;
  139072. diameter?: number;
  139073. diameterX?: number;
  139074. diameterY?: number;
  139075. diameterZ?: number;
  139076. arc?: number;
  139077. slice?: number;
  139078. sideOrientation?: number;
  139079. frontUVs?: Vector4;
  139080. backUVs?: Vector4;
  139081. updatable?: boolean;
  139082. }, scene?: Nullable<Scene>): Mesh;
  139083. /**
  139084. * Creates a plane polygonal mesh. By default, this is a disc
  139085. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  139086. * * 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
  139087. * * 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
  139088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139091. * @param name defines the name of the mesh
  139092. * @param options defines the options used to create the mesh
  139093. * @param scene defines the hosting scene
  139094. * @returns the plane polygonal mesh
  139095. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  139096. */
  139097. static CreateDisc(name: string, options: {
  139098. radius?: number;
  139099. tessellation?: number;
  139100. arc?: number;
  139101. updatable?: boolean;
  139102. sideOrientation?: number;
  139103. frontUVs?: Vector4;
  139104. backUVs?: Vector4;
  139105. }, scene?: Nullable<Scene>): Mesh;
  139106. /**
  139107. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  139108. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  139109. * * 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`)
  139110. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  139111. * * 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
  139112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139115. * @param name defines the name of the mesh
  139116. * @param options defines the options used to create the mesh
  139117. * @param scene defines the hosting scene
  139118. * @returns the icosahedron mesh
  139119. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  139120. */
  139121. static CreateIcoSphere(name: string, options: {
  139122. radius?: number;
  139123. radiusX?: number;
  139124. radiusY?: number;
  139125. radiusZ?: number;
  139126. flat?: boolean;
  139127. subdivisions?: number;
  139128. sideOrientation?: number;
  139129. frontUVs?: Vector4;
  139130. backUVs?: Vector4;
  139131. updatable?: boolean;
  139132. }, scene?: Nullable<Scene>): Mesh;
  139133. /**
  139134. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139135. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  139136. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  139137. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  139138. * * 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
  139139. * * 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
  139140. * * 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
  139141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139143. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139144. * * 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
  139145. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  139146. * * 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
  139147. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  139148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139149. * @param name defines the name of the mesh
  139150. * @param options defines the options used to create the mesh
  139151. * @param scene defines the hosting scene
  139152. * @returns the ribbon mesh
  139153. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  139154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139155. */
  139156. static CreateRibbon(name: string, options: {
  139157. pathArray: Vector3[][];
  139158. closeArray?: boolean;
  139159. closePath?: boolean;
  139160. offset?: number;
  139161. updatable?: boolean;
  139162. sideOrientation?: number;
  139163. frontUVs?: Vector4;
  139164. backUVs?: Vector4;
  139165. instance?: Mesh;
  139166. invertUV?: boolean;
  139167. uvs?: Vector2[];
  139168. colors?: Color4[];
  139169. }, scene?: Nullable<Scene>): Mesh;
  139170. /**
  139171. * Creates a cylinder or a cone mesh
  139172. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  139173. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  139174. * * 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.
  139175. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  139176. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  139177. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  139178. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  139179. * * 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).
  139180. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  139181. * * 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).
  139182. * * 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
  139183. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  139184. * * 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
  139185. * * 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.
  139186. * * If `enclose` is false, a ring surface is one element.
  139187. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  139188. * * 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
  139189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139192. * @param name defines the name of the mesh
  139193. * @param options defines the options used to create the mesh
  139194. * @param scene defines the hosting scene
  139195. * @returns the cylinder mesh
  139196. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  139197. */
  139198. static CreateCylinder(name: string, options: {
  139199. height?: number;
  139200. diameterTop?: number;
  139201. diameterBottom?: number;
  139202. diameter?: number;
  139203. tessellation?: number;
  139204. subdivisions?: number;
  139205. arc?: number;
  139206. faceColors?: Color4[];
  139207. faceUV?: Vector4[];
  139208. updatable?: boolean;
  139209. hasRings?: boolean;
  139210. enclose?: boolean;
  139211. cap?: number;
  139212. sideOrientation?: number;
  139213. frontUVs?: Vector4;
  139214. backUVs?: Vector4;
  139215. }, scene?: Nullable<Scene>): Mesh;
  139216. /**
  139217. * Creates a torus mesh
  139218. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  139219. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  139220. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  139221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139224. * @param name defines the name of the mesh
  139225. * @param options defines the options used to create the mesh
  139226. * @param scene defines the hosting scene
  139227. * @returns the torus mesh
  139228. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  139229. */
  139230. static CreateTorus(name: string, options: {
  139231. diameter?: number;
  139232. thickness?: number;
  139233. tessellation?: number;
  139234. updatable?: boolean;
  139235. sideOrientation?: number;
  139236. frontUVs?: Vector4;
  139237. backUVs?: Vector4;
  139238. }, scene?: Nullable<Scene>): Mesh;
  139239. /**
  139240. * Creates a torus knot mesh
  139241. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  139242. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  139243. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  139244. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  139245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139248. * @param name defines the name of the mesh
  139249. * @param options defines the options used to create the mesh
  139250. * @param scene defines the hosting scene
  139251. * @returns the torus knot mesh
  139252. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  139253. */
  139254. static CreateTorusKnot(name: string, options: {
  139255. radius?: number;
  139256. tube?: number;
  139257. radialSegments?: number;
  139258. tubularSegments?: number;
  139259. p?: number;
  139260. q?: number;
  139261. updatable?: boolean;
  139262. sideOrientation?: number;
  139263. frontUVs?: Vector4;
  139264. backUVs?: Vector4;
  139265. }, scene?: Nullable<Scene>): Mesh;
  139266. /**
  139267. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  139268. * * 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
  139269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  139270. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  139271. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  139272. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  139273. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  139274. * * 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
  139275. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  139276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  139278. * @param name defines the name of the new line system
  139279. * @param options defines the options used to create the line system
  139280. * @param scene defines the hosting scene
  139281. * @returns a new line system mesh
  139282. */
  139283. static CreateLineSystem(name: string, options: {
  139284. lines: Vector3[][];
  139285. updatable?: boolean;
  139286. instance?: Nullable<LinesMesh>;
  139287. colors?: Nullable<Color4[][]>;
  139288. useVertexAlpha?: boolean;
  139289. }, scene: Nullable<Scene>): LinesMesh;
  139290. /**
  139291. * Creates a line mesh
  139292. * 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
  139293. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139294. * * The parameter `points` is an array successive Vector3
  139295. * * 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
  139296. * * The optional parameter `colors` is an array of successive Color4, one per line point
  139297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  139298. * * When updating an instance, remember that only point positions can change, not the number of points
  139299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  139301. * @param name defines the name of the new line system
  139302. * @param options defines the options used to create the line system
  139303. * @param scene defines the hosting scene
  139304. * @returns a new line mesh
  139305. */
  139306. static CreateLines(name: string, options: {
  139307. points: Vector3[];
  139308. updatable?: boolean;
  139309. instance?: Nullable<LinesMesh>;
  139310. colors?: Color4[];
  139311. useVertexAlpha?: boolean;
  139312. }, scene?: Nullable<Scene>): LinesMesh;
  139313. /**
  139314. * Creates a dashed line mesh
  139315. * * 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
  139316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  139317. * * The parameter `points` is an array successive Vector3
  139318. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  139319. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  139320. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  139321. * * 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
  139322. * * When updating an instance, remember that only point positions can change, not the number of points
  139323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139324. * @param name defines the name of the mesh
  139325. * @param options defines the options used to create the mesh
  139326. * @param scene defines the hosting scene
  139327. * @returns the dashed line mesh
  139328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  139329. */
  139330. static CreateDashedLines(name: string, options: {
  139331. points: Vector3[];
  139332. dashSize?: number;
  139333. gapSize?: number;
  139334. dashNb?: number;
  139335. updatable?: boolean;
  139336. instance?: LinesMesh;
  139337. }, scene?: Nullable<Scene>): LinesMesh;
  139338. /**
  139339. * 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.
  139340. * * 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.
  139341. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139342. * * 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.
  139343. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139344. * * 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
  139345. * * 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
  139346. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  139350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139351. * @param name defines the name of the mesh
  139352. * @param options defines the options used to create the mesh
  139353. * @param scene defines the hosting scene
  139354. * @returns the extruded shape mesh
  139355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139357. */
  139358. static ExtrudeShape(name: string, options: {
  139359. shape: Vector3[];
  139360. path: Vector3[];
  139361. scale?: number;
  139362. rotation?: number;
  139363. cap?: number;
  139364. updatable?: boolean;
  139365. sideOrientation?: number;
  139366. frontUVs?: Vector4;
  139367. backUVs?: Vector4;
  139368. instance?: Mesh;
  139369. invertUV?: boolean;
  139370. }, scene?: Nullable<Scene>): Mesh;
  139371. /**
  139372. * Creates an custom extruded shape mesh.
  139373. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139374. * * 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.
  139375. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139376. * * 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
  139377. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139378. * * 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
  139379. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139380. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139381. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139382. * * 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
  139383. * * 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
  139384. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139387. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139389. * @param name defines the name of the mesh
  139390. * @param options defines the options used to create the mesh
  139391. * @param scene defines the hosting scene
  139392. * @returns the custom extruded shape mesh
  139393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139396. */
  139397. static ExtrudeShapeCustom(name: string, options: {
  139398. shape: Vector3[];
  139399. path: Vector3[];
  139400. scaleFunction?: any;
  139401. rotationFunction?: any;
  139402. ribbonCloseArray?: boolean;
  139403. ribbonClosePath?: boolean;
  139404. cap?: number;
  139405. updatable?: boolean;
  139406. sideOrientation?: number;
  139407. frontUVs?: Vector4;
  139408. backUVs?: Vector4;
  139409. instance?: Mesh;
  139410. invertUV?: boolean;
  139411. }, scene?: Nullable<Scene>): Mesh;
  139412. /**
  139413. * Creates lathe mesh.
  139414. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139415. * * 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
  139416. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139417. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139418. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139419. * * 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
  139420. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139421. * * 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
  139422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139426. * @param name defines the name of the mesh
  139427. * @param options defines the options used to create the mesh
  139428. * @param scene defines the hosting scene
  139429. * @returns the lathe mesh
  139430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139431. */
  139432. static CreateLathe(name: string, options: {
  139433. shape: Vector3[];
  139434. radius?: number;
  139435. tessellation?: number;
  139436. clip?: number;
  139437. arc?: number;
  139438. closed?: boolean;
  139439. updatable?: boolean;
  139440. sideOrientation?: number;
  139441. frontUVs?: Vector4;
  139442. backUVs?: Vector4;
  139443. cap?: number;
  139444. invertUV?: boolean;
  139445. }, scene?: Nullable<Scene>): Mesh;
  139446. /**
  139447. * Creates a tiled plane mesh
  139448. * * You can set a limited pattern arrangement with the tiles
  139449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139452. * @param name defines the name of the mesh
  139453. * @param options defines the options used to create the mesh
  139454. * @param scene defines the hosting scene
  139455. * @returns the plane mesh
  139456. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139457. */
  139458. static CreateTiledPlane(name: string, options: {
  139459. pattern?: number;
  139460. tileSize?: number;
  139461. tileWidth?: number;
  139462. tileHeight?: number;
  139463. size?: number;
  139464. width?: number;
  139465. height?: number;
  139466. alignHorizontal?: number;
  139467. alignVertical?: number;
  139468. sideOrientation?: number;
  139469. frontUVs?: Vector4;
  139470. backUVs?: Vector4;
  139471. updatable?: boolean;
  139472. }, scene?: Nullable<Scene>): Mesh;
  139473. /**
  139474. * Creates a plane mesh
  139475. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139476. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139477. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139481. * @param name defines the name of the mesh
  139482. * @param options defines the options used to create the mesh
  139483. * @param scene defines the hosting scene
  139484. * @returns the plane mesh
  139485. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139486. */
  139487. static CreatePlane(name: string, options: {
  139488. size?: number;
  139489. width?: number;
  139490. height?: number;
  139491. sideOrientation?: number;
  139492. frontUVs?: Vector4;
  139493. backUVs?: Vector4;
  139494. updatable?: boolean;
  139495. sourcePlane?: Plane;
  139496. }, scene?: Nullable<Scene>): Mesh;
  139497. /**
  139498. * Creates a ground mesh
  139499. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139500. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139502. * @param name defines the name of the mesh
  139503. * @param options defines the options used to create the mesh
  139504. * @param scene defines the hosting scene
  139505. * @returns the ground mesh
  139506. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139507. */
  139508. static CreateGround(name: string, options: {
  139509. width?: number;
  139510. height?: number;
  139511. subdivisions?: number;
  139512. subdivisionsX?: number;
  139513. subdivisionsY?: number;
  139514. updatable?: boolean;
  139515. }, scene?: Nullable<Scene>): Mesh;
  139516. /**
  139517. * Creates a tiled ground mesh
  139518. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139519. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139520. * * 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
  139521. * * 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
  139522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139523. * @param name defines the name of the mesh
  139524. * @param options defines the options used to create the mesh
  139525. * @param scene defines the hosting scene
  139526. * @returns the tiled ground mesh
  139527. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139528. */
  139529. static CreateTiledGround(name: string, options: {
  139530. xmin: number;
  139531. zmin: number;
  139532. xmax: number;
  139533. zmax: number;
  139534. subdivisions?: {
  139535. w: number;
  139536. h: number;
  139537. };
  139538. precision?: {
  139539. w: number;
  139540. h: number;
  139541. };
  139542. updatable?: boolean;
  139543. }, scene?: Nullable<Scene>): Mesh;
  139544. /**
  139545. * Creates a ground mesh from a height map
  139546. * * The parameter `url` sets the URL of the height map image resource.
  139547. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139548. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139549. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139550. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139551. * * 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.
  139552. * * 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).
  139553. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139555. * @param name defines the name of the mesh
  139556. * @param url defines the url to the height map
  139557. * @param options defines the options used to create the mesh
  139558. * @param scene defines the hosting scene
  139559. * @returns the ground mesh
  139560. * @see https://doc.babylonjs.com/babylon101/height_map
  139561. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139562. */
  139563. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139564. width?: number;
  139565. height?: number;
  139566. subdivisions?: number;
  139567. minHeight?: number;
  139568. maxHeight?: number;
  139569. colorFilter?: Color3;
  139570. alphaFilter?: number;
  139571. updatable?: boolean;
  139572. onReady?: (mesh: GroundMesh) => void;
  139573. }, scene?: Nullable<Scene>): GroundMesh;
  139574. /**
  139575. * Creates a polygon mesh
  139576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139577. * * 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
  139578. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  139581. * * Remember you can only change the shape positions, not their number when updating a polygon
  139582. * @param name defines the name of the mesh
  139583. * @param options defines the options used to create the mesh
  139584. * @param scene defines the hosting scene
  139585. * @param earcutInjection can be used to inject your own earcut reference
  139586. * @returns the polygon mesh
  139587. */
  139588. static CreatePolygon(name: string, options: {
  139589. shape: Vector3[];
  139590. holes?: Vector3[][];
  139591. depth?: number;
  139592. faceUV?: Vector4[];
  139593. faceColors?: Color4[];
  139594. updatable?: boolean;
  139595. sideOrientation?: number;
  139596. frontUVs?: Vector4;
  139597. backUVs?: Vector4;
  139598. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139599. /**
  139600. * Creates an extruded polygon mesh, with depth in the Y direction.
  139601. * * 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)
  139602. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139603. * @param name defines the name of the mesh
  139604. * @param options defines the options used to create the mesh
  139605. * @param scene defines the hosting scene
  139606. * @param earcutInjection can be used to inject your own earcut reference
  139607. * @returns the polygon mesh
  139608. */
  139609. static ExtrudePolygon(name: string, options: {
  139610. shape: Vector3[];
  139611. holes?: Vector3[][];
  139612. depth?: number;
  139613. faceUV?: Vector4[];
  139614. faceColors?: Color4[];
  139615. updatable?: boolean;
  139616. sideOrientation?: number;
  139617. frontUVs?: Vector4;
  139618. backUVs?: Vector4;
  139619. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139620. /**
  139621. * Creates a tube mesh.
  139622. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139623. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139624. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139625. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139626. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139627. * * 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)
  139628. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139629. * * 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
  139630. * * 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
  139631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139635. * @param name defines the name of the mesh
  139636. * @param options defines the options used to create the mesh
  139637. * @param scene defines the hosting scene
  139638. * @returns the tube mesh
  139639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139640. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139641. */
  139642. static CreateTube(name: string, options: {
  139643. path: Vector3[];
  139644. radius?: number;
  139645. tessellation?: number;
  139646. radiusFunction?: {
  139647. (i: number, distance: number): number;
  139648. };
  139649. cap?: number;
  139650. arc?: number;
  139651. updatable?: boolean;
  139652. sideOrientation?: number;
  139653. frontUVs?: Vector4;
  139654. backUVs?: Vector4;
  139655. instance?: Mesh;
  139656. invertUV?: boolean;
  139657. }, scene?: Nullable<Scene>): Mesh;
  139658. /**
  139659. * Creates a polyhedron mesh
  139660. * * 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
  139661. * * The parameter `size` (positive float, default 1) sets the polygon size
  139662. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139663. * * 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`
  139664. * * 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
  139665. * * 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)`)
  139666. * * 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
  139667. * * 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
  139668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139671. * @param name defines the name of the mesh
  139672. * @param options defines the options used to create the mesh
  139673. * @param scene defines the hosting scene
  139674. * @returns the polyhedron mesh
  139675. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139676. */
  139677. static CreatePolyhedron(name: string, options: {
  139678. type?: number;
  139679. size?: number;
  139680. sizeX?: number;
  139681. sizeY?: number;
  139682. sizeZ?: number;
  139683. custom?: any;
  139684. faceUV?: Vector4[];
  139685. faceColors?: Color4[];
  139686. flat?: boolean;
  139687. updatable?: boolean;
  139688. sideOrientation?: number;
  139689. frontUVs?: Vector4;
  139690. backUVs?: Vector4;
  139691. }, scene?: Nullable<Scene>): Mesh;
  139692. /**
  139693. * Creates a decal mesh.
  139694. * 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
  139695. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139696. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139697. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139698. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139699. * @param name defines the name of the mesh
  139700. * @param sourceMesh defines the mesh where the decal must be applied
  139701. * @param options defines the options used to create the mesh
  139702. * @param scene defines the hosting scene
  139703. * @returns the decal mesh
  139704. * @see https://doc.babylonjs.com/how_to/decals
  139705. */
  139706. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139707. position?: Vector3;
  139708. normal?: Vector3;
  139709. size?: Vector3;
  139710. angle?: number;
  139711. }): Mesh;
  139712. }
  139713. }
  139714. declare module BABYLON {
  139715. /**
  139716. * A simplifier interface for future simplification implementations
  139717. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139718. */
  139719. export interface ISimplifier {
  139720. /**
  139721. * Simplification of a given mesh according to the given settings.
  139722. * Since this requires computation, it is assumed that the function runs async.
  139723. * @param settings The settings of the simplification, including quality and distance
  139724. * @param successCallback A callback that will be called after the mesh was simplified.
  139725. * @param errorCallback in case of an error, this callback will be called. optional.
  139726. */
  139727. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139728. }
  139729. /**
  139730. * Expected simplification settings.
  139731. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139732. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139733. */
  139734. export interface ISimplificationSettings {
  139735. /**
  139736. * Gets or sets the expected quality
  139737. */
  139738. quality: number;
  139739. /**
  139740. * Gets or sets the distance when this optimized version should be used
  139741. */
  139742. distance: number;
  139743. /**
  139744. * Gets an already optimized mesh
  139745. */
  139746. optimizeMesh?: boolean;
  139747. }
  139748. /**
  139749. * Class used to specify simplification options
  139750. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139751. */
  139752. export class SimplificationSettings implements ISimplificationSettings {
  139753. /** expected quality */
  139754. quality: number;
  139755. /** distance when this optimized version should be used */
  139756. distance: number;
  139757. /** already optimized mesh */
  139758. optimizeMesh?: boolean | undefined;
  139759. /**
  139760. * Creates a SimplificationSettings
  139761. * @param quality expected quality
  139762. * @param distance distance when this optimized version should be used
  139763. * @param optimizeMesh already optimized mesh
  139764. */
  139765. constructor(
  139766. /** expected quality */
  139767. quality: number,
  139768. /** distance when this optimized version should be used */
  139769. distance: number,
  139770. /** already optimized mesh */
  139771. optimizeMesh?: boolean | undefined);
  139772. }
  139773. /**
  139774. * Interface used to define a simplification task
  139775. */
  139776. export interface ISimplificationTask {
  139777. /**
  139778. * Array of settings
  139779. */
  139780. settings: Array<ISimplificationSettings>;
  139781. /**
  139782. * Simplification type
  139783. */
  139784. simplificationType: SimplificationType;
  139785. /**
  139786. * Mesh to simplify
  139787. */
  139788. mesh: Mesh;
  139789. /**
  139790. * Callback called on success
  139791. */
  139792. successCallback?: () => void;
  139793. /**
  139794. * Defines if parallel processing can be used
  139795. */
  139796. parallelProcessing: boolean;
  139797. }
  139798. /**
  139799. * Queue used to order the simplification tasks
  139800. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139801. */
  139802. export class SimplificationQueue {
  139803. private _simplificationArray;
  139804. /**
  139805. * Gets a boolean indicating that the process is still running
  139806. */
  139807. running: boolean;
  139808. /**
  139809. * Creates a new queue
  139810. */
  139811. constructor();
  139812. /**
  139813. * Adds a new simplification task
  139814. * @param task defines a task to add
  139815. */
  139816. addTask(task: ISimplificationTask): void;
  139817. /**
  139818. * Execute next task
  139819. */
  139820. executeNext(): void;
  139821. /**
  139822. * Execute a simplification task
  139823. * @param task defines the task to run
  139824. */
  139825. runSimplification(task: ISimplificationTask): void;
  139826. private getSimplifier;
  139827. }
  139828. /**
  139829. * The implemented types of simplification
  139830. * At the moment only Quadratic Error Decimation is implemented
  139831. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139832. */
  139833. export enum SimplificationType {
  139834. /** Quadratic error decimation */
  139835. QUADRATIC = 0
  139836. }
  139837. /**
  139838. * An implementation of the Quadratic Error simplification algorithm.
  139839. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139840. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139841. * @author RaananW
  139842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139843. */
  139844. export class QuadraticErrorSimplification implements ISimplifier {
  139845. private _mesh;
  139846. private triangles;
  139847. private vertices;
  139848. private references;
  139849. private _reconstructedMesh;
  139850. /** Gets or sets the number pf sync interations */
  139851. syncIterations: number;
  139852. /** Gets or sets the aggressiveness of the simplifier */
  139853. aggressiveness: number;
  139854. /** Gets or sets the number of allowed iterations for decimation */
  139855. decimationIterations: number;
  139856. /** Gets or sets the espilon to use for bounding box computation */
  139857. boundingBoxEpsilon: number;
  139858. /**
  139859. * Creates a new QuadraticErrorSimplification
  139860. * @param _mesh defines the target mesh
  139861. */
  139862. constructor(_mesh: Mesh);
  139863. /**
  139864. * Simplification of a given mesh according to the given settings.
  139865. * Since this requires computation, it is assumed that the function runs async.
  139866. * @param settings The settings of the simplification, including quality and distance
  139867. * @param successCallback A callback that will be called after the mesh was simplified.
  139868. */
  139869. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  139870. private runDecimation;
  139871. private initWithMesh;
  139872. private init;
  139873. private reconstructMesh;
  139874. private initDecimatedMesh;
  139875. private isFlipped;
  139876. private updateTriangles;
  139877. private identifyBorder;
  139878. private updateMesh;
  139879. private vertexError;
  139880. private calculateError;
  139881. }
  139882. }
  139883. declare module BABYLON {
  139884. interface Scene {
  139885. /** @hidden (Backing field) */
  139886. _simplificationQueue: SimplificationQueue;
  139887. /**
  139888. * Gets or sets the simplification queue attached to the scene
  139889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139890. */
  139891. simplificationQueue: SimplificationQueue;
  139892. }
  139893. interface Mesh {
  139894. /**
  139895. * Simplify the mesh according to the given array of settings.
  139896. * Function will return immediately and will simplify async
  139897. * @param settings a collection of simplification settings
  139898. * @param parallelProcessing should all levels calculate parallel or one after the other
  139899. * @param simplificationType the type of simplification to run
  139900. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  139901. * @returns the current mesh
  139902. */
  139903. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  139904. }
  139905. /**
  139906. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  139907. * created in a scene
  139908. */
  139909. export class SimplicationQueueSceneComponent implements ISceneComponent {
  139910. /**
  139911. * The component name helpfull to identify the component in the list of scene components.
  139912. */
  139913. readonly name: string;
  139914. /**
  139915. * The scene the component belongs to.
  139916. */
  139917. scene: Scene;
  139918. /**
  139919. * Creates a new instance of the component for the given scene
  139920. * @param scene Defines the scene to register the component in
  139921. */
  139922. constructor(scene: Scene);
  139923. /**
  139924. * Registers the component in a given scene
  139925. */
  139926. register(): void;
  139927. /**
  139928. * Rebuilds the elements related to this component in case of
  139929. * context lost for instance.
  139930. */
  139931. rebuild(): void;
  139932. /**
  139933. * Disposes the component and the associated ressources
  139934. */
  139935. dispose(): void;
  139936. private _beforeCameraUpdate;
  139937. }
  139938. }
  139939. declare module BABYLON {
  139940. /**
  139941. * Navigation plugin interface to add navigation constrained by a navigation mesh
  139942. */
  139943. export interface INavigationEnginePlugin {
  139944. /**
  139945. * plugin name
  139946. */
  139947. name: string;
  139948. /**
  139949. * Creates a navigation mesh
  139950. * @param meshes array of all the geometry used to compute the navigatio mesh
  139951. * @param parameters bunch of parameters used to filter geometry
  139952. */
  139953. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139954. /**
  139955. * Create a navigation mesh debug mesh
  139956. * @param scene is where the mesh will be added
  139957. * @returns debug display mesh
  139958. */
  139959. createDebugNavMesh(scene: Scene): Mesh;
  139960. /**
  139961. * Get a navigation mesh constrained position, closest to the parameter position
  139962. * @param position world position
  139963. * @returns the closest point to position constrained by the navigation mesh
  139964. */
  139965. getClosestPoint(position: Vector3): Vector3;
  139966. /**
  139967. * Get a navigation mesh constrained position, closest to the parameter position
  139968. * @param position world position
  139969. * @param result output the closest point to position constrained by the navigation mesh
  139970. */
  139971. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139972. /**
  139973. * Get a navigation mesh constrained position, within a particular radius
  139974. * @param position world position
  139975. * @param maxRadius the maximum distance to the constrained world position
  139976. * @returns the closest point to position constrained by the navigation mesh
  139977. */
  139978. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139979. /**
  139980. * Get a navigation mesh constrained position, within a particular radius
  139981. * @param position world position
  139982. * @param maxRadius the maximum distance to the constrained world position
  139983. * @param result output the closest point to position constrained by the navigation mesh
  139984. */
  139985. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139986. /**
  139987. * Compute the final position from a segment made of destination-position
  139988. * @param position world position
  139989. * @param destination world position
  139990. * @returns the resulting point along the navmesh
  139991. */
  139992. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139993. /**
  139994. * Compute the final position from a segment made of destination-position
  139995. * @param position world position
  139996. * @param destination world position
  139997. * @param result output the resulting point along the navmesh
  139998. */
  139999. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140000. /**
  140001. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140002. * @param start world position
  140003. * @param end world position
  140004. * @returns array containing world position composing the path
  140005. */
  140006. computePath(start: Vector3, end: Vector3): Vector3[];
  140007. /**
  140008. * If this plugin is supported
  140009. * @returns true if plugin is supported
  140010. */
  140011. isSupported(): boolean;
  140012. /**
  140013. * Create a new Crowd so you can add agents
  140014. * @param maxAgents the maximum agent count in the crowd
  140015. * @param maxAgentRadius the maximum radius an agent can have
  140016. * @param scene to attach the crowd to
  140017. * @returns the crowd you can add agents to
  140018. */
  140019. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140020. /**
  140021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140022. * The queries will try to find a solution within those bounds
  140023. * default is (1,1,1)
  140024. * @param extent x,y,z value that define the extent around the queries point of reference
  140025. */
  140026. setDefaultQueryExtent(extent: Vector3): void;
  140027. /**
  140028. * Get the Bounding box extent specified by setDefaultQueryExtent
  140029. * @returns the box extent values
  140030. */
  140031. getDefaultQueryExtent(): Vector3;
  140032. /**
  140033. * build the navmesh from a previously saved state using getNavmeshData
  140034. * @param data the Uint8Array returned by getNavmeshData
  140035. */
  140036. buildFromNavmeshData(data: Uint8Array): void;
  140037. /**
  140038. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140039. * @returns data the Uint8Array that can be saved and reused
  140040. */
  140041. getNavmeshData(): Uint8Array;
  140042. /**
  140043. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140044. * @param result output the box extent values
  140045. */
  140046. getDefaultQueryExtentToRef(result: Vector3): void;
  140047. /**
  140048. * Release all resources
  140049. */
  140050. dispose(): void;
  140051. }
  140052. /**
  140053. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  140054. */
  140055. export interface ICrowd {
  140056. /**
  140057. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140058. * You can attach anything to that node. The node position is updated in the scene update tick.
  140059. * @param pos world position that will be constrained by the navigation mesh
  140060. * @param parameters agent parameters
  140061. * @param transform hooked to the agent that will be update by the scene
  140062. * @returns agent index
  140063. */
  140064. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140065. /**
  140066. * Returns the agent position in world space
  140067. * @param index agent index returned by addAgent
  140068. * @returns world space position
  140069. */
  140070. getAgentPosition(index: number): Vector3;
  140071. /**
  140072. * Gets the agent position result in world space
  140073. * @param index agent index returned by addAgent
  140074. * @param result output world space position
  140075. */
  140076. getAgentPositionToRef(index: number, result: Vector3): void;
  140077. /**
  140078. * Gets the agent velocity in world space
  140079. * @param index agent index returned by addAgent
  140080. * @returns world space velocity
  140081. */
  140082. getAgentVelocity(index: number): Vector3;
  140083. /**
  140084. * Gets the agent velocity result in world space
  140085. * @param index agent index returned by addAgent
  140086. * @param result output world space velocity
  140087. */
  140088. getAgentVelocityToRef(index: number, result: Vector3): void;
  140089. /**
  140090. * remove a particular agent previously created
  140091. * @param index agent index returned by addAgent
  140092. */
  140093. removeAgent(index: number): void;
  140094. /**
  140095. * get the list of all agents attached to this crowd
  140096. * @returns list of agent indices
  140097. */
  140098. getAgents(): number[];
  140099. /**
  140100. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140101. * @param deltaTime in seconds
  140102. */
  140103. update(deltaTime: number): void;
  140104. /**
  140105. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140106. * @param index agent index returned by addAgent
  140107. * @param destination targeted world position
  140108. */
  140109. agentGoto(index: number, destination: Vector3): void;
  140110. /**
  140111. * Teleport the agent to a new position
  140112. * @param index agent index returned by addAgent
  140113. * @param destination targeted world position
  140114. */
  140115. agentTeleport(index: number, destination: Vector3): void;
  140116. /**
  140117. * Update agent parameters
  140118. * @param index agent index returned by addAgent
  140119. * @param parameters agent parameters
  140120. */
  140121. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140122. /**
  140123. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140124. * The queries will try to find a solution within those bounds
  140125. * default is (1,1,1)
  140126. * @param extent x,y,z value that define the extent around the queries point of reference
  140127. */
  140128. setDefaultQueryExtent(extent: Vector3): void;
  140129. /**
  140130. * Get the Bounding box extent specified by setDefaultQueryExtent
  140131. * @returns the box extent values
  140132. */
  140133. getDefaultQueryExtent(): Vector3;
  140134. /**
  140135. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140136. * @param result output the box extent values
  140137. */
  140138. getDefaultQueryExtentToRef(result: Vector3): void;
  140139. /**
  140140. * Release all resources
  140141. */
  140142. dispose(): void;
  140143. }
  140144. /**
  140145. * Configures an agent
  140146. */
  140147. export interface IAgentParameters {
  140148. /**
  140149. * Agent radius. [Limit: >= 0]
  140150. */
  140151. radius: number;
  140152. /**
  140153. * Agent height. [Limit: > 0]
  140154. */
  140155. height: number;
  140156. /**
  140157. * Maximum allowed acceleration. [Limit: >= 0]
  140158. */
  140159. maxAcceleration: number;
  140160. /**
  140161. * Maximum allowed speed. [Limit: >= 0]
  140162. */
  140163. maxSpeed: number;
  140164. /**
  140165. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  140166. */
  140167. collisionQueryRange: number;
  140168. /**
  140169. * The path visibility optimization range. [Limit: > 0]
  140170. */
  140171. pathOptimizationRange: number;
  140172. /**
  140173. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  140174. */
  140175. separationWeight: number;
  140176. }
  140177. /**
  140178. * Configures the navigation mesh creation
  140179. */
  140180. export interface INavMeshParameters {
  140181. /**
  140182. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  140183. */
  140184. cs: number;
  140185. /**
  140186. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  140187. */
  140188. ch: number;
  140189. /**
  140190. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  140191. */
  140192. walkableSlopeAngle: number;
  140193. /**
  140194. * Minimum floor to 'ceiling' height that will still allow the floor area to
  140195. * be considered walkable. [Limit: >= 3] [Units: vx]
  140196. */
  140197. walkableHeight: number;
  140198. /**
  140199. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  140200. */
  140201. walkableClimb: number;
  140202. /**
  140203. * The distance to erode/shrink the walkable area of the heightfield away from
  140204. * obstructions. [Limit: >=0] [Units: vx]
  140205. */
  140206. walkableRadius: number;
  140207. /**
  140208. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  140209. */
  140210. maxEdgeLen: number;
  140211. /**
  140212. * The maximum distance a simplfied contour's border edges should deviate
  140213. * the original raw contour. [Limit: >=0] [Units: vx]
  140214. */
  140215. maxSimplificationError: number;
  140216. /**
  140217. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  140218. */
  140219. minRegionArea: number;
  140220. /**
  140221. * Any regions with a span count smaller than this value will, if possible,
  140222. * be merged with larger regions. [Limit: >=0] [Units: vx]
  140223. */
  140224. mergeRegionArea: number;
  140225. /**
  140226. * The maximum number of vertices allowed for polygons generated during the
  140227. * contour to polygon conversion process. [Limit: >= 3]
  140228. */
  140229. maxVertsPerPoly: number;
  140230. /**
  140231. * Sets the sampling distance to use when generating the detail mesh.
  140232. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  140233. */
  140234. detailSampleDist: number;
  140235. /**
  140236. * The maximum distance the detail mesh surface should deviate from heightfield
  140237. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  140238. */
  140239. detailSampleMaxError: number;
  140240. }
  140241. }
  140242. declare module BABYLON {
  140243. /**
  140244. * RecastJS navigation plugin
  140245. */
  140246. export class RecastJSPlugin implements INavigationEnginePlugin {
  140247. /**
  140248. * Reference to the Recast library
  140249. */
  140250. bjsRECAST: any;
  140251. /**
  140252. * plugin name
  140253. */
  140254. name: string;
  140255. /**
  140256. * the first navmesh created. We might extend this to support multiple navmeshes
  140257. */
  140258. navMesh: any;
  140259. /**
  140260. * Initializes the recastJS plugin
  140261. * @param recastInjection can be used to inject your own recast reference
  140262. */
  140263. constructor(recastInjection?: any);
  140264. /**
  140265. * Creates a navigation mesh
  140266. * @param meshes array of all the geometry used to compute the navigatio mesh
  140267. * @param parameters bunch of parameters used to filter geometry
  140268. */
  140269. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  140270. /**
  140271. * Create a navigation mesh debug mesh
  140272. * @param scene is where the mesh will be added
  140273. * @returns debug display mesh
  140274. */
  140275. createDebugNavMesh(scene: Scene): Mesh;
  140276. /**
  140277. * Get a navigation mesh constrained position, closest to the parameter position
  140278. * @param position world position
  140279. * @returns the closest point to position constrained by the navigation mesh
  140280. */
  140281. getClosestPoint(position: Vector3): Vector3;
  140282. /**
  140283. * Get a navigation mesh constrained position, closest to the parameter position
  140284. * @param position world position
  140285. * @param result output the closest point to position constrained by the navigation mesh
  140286. */
  140287. getClosestPointToRef(position: Vector3, result: Vector3): void;
  140288. /**
  140289. * Get a navigation mesh constrained position, within a particular radius
  140290. * @param position world position
  140291. * @param maxRadius the maximum distance to the constrained world position
  140292. * @returns the closest point to position constrained by the navigation mesh
  140293. */
  140294. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  140295. /**
  140296. * Get a navigation mesh constrained position, within a particular radius
  140297. * @param position world position
  140298. * @param maxRadius the maximum distance to the constrained world position
  140299. * @param result output the closest point to position constrained by the navigation mesh
  140300. */
  140301. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  140302. /**
  140303. * Compute the final position from a segment made of destination-position
  140304. * @param position world position
  140305. * @param destination world position
  140306. * @returns the resulting point along the navmesh
  140307. */
  140308. moveAlong(position: Vector3, destination: Vector3): Vector3;
  140309. /**
  140310. * Compute the final position from a segment made of destination-position
  140311. * @param position world position
  140312. * @param destination world position
  140313. * @param result output the resulting point along the navmesh
  140314. */
  140315. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  140316. /**
  140317. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  140318. * @param start world position
  140319. * @param end world position
  140320. * @returns array containing world position composing the path
  140321. */
  140322. computePath(start: Vector3, end: Vector3): Vector3[];
  140323. /**
  140324. * Create a new Crowd so you can add agents
  140325. * @param maxAgents the maximum agent count in the crowd
  140326. * @param maxAgentRadius the maximum radius an agent can have
  140327. * @param scene to attach the crowd to
  140328. * @returns the crowd you can add agents to
  140329. */
  140330. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140331. /**
  140332. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140333. * The queries will try to find a solution within those bounds
  140334. * default is (1,1,1)
  140335. * @param extent x,y,z value that define the extent around the queries point of reference
  140336. */
  140337. setDefaultQueryExtent(extent: Vector3): void;
  140338. /**
  140339. * Get the Bounding box extent specified by setDefaultQueryExtent
  140340. * @returns the box extent values
  140341. */
  140342. getDefaultQueryExtent(): Vector3;
  140343. /**
  140344. * build the navmesh from a previously saved state using getNavmeshData
  140345. * @param data the Uint8Array returned by getNavmeshData
  140346. */
  140347. buildFromNavmeshData(data: Uint8Array): void;
  140348. /**
  140349. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140350. * @returns data the Uint8Array that can be saved and reused
  140351. */
  140352. getNavmeshData(): Uint8Array;
  140353. /**
  140354. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140355. * @param result output the box extent values
  140356. */
  140357. getDefaultQueryExtentToRef(result: Vector3): void;
  140358. /**
  140359. * Disposes
  140360. */
  140361. dispose(): void;
  140362. /**
  140363. * If this plugin is supported
  140364. * @returns true if plugin is supported
  140365. */
  140366. isSupported(): boolean;
  140367. }
  140368. /**
  140369. * Recast detour crowd implementation
  140370. */
  140371. export class RecastJSCrowd implements ICrowd {
  140372. /**
  140373. * Recast/detour plugin
  140374. */
  140375. bjsRECASTPlugin: RecastJSPlugin;
  140376. /**
  140377. * Link to the detour crowd
  140378. */
  140379. recastCrowd: any;
  140380. /**
  140381. * One transform per agent
  140382. */
  140383. transforms: TransformNode[];
  140384. /**
  140385. * All agents created
  140386. */
  140387. agents: number[];
  140388. /**
  140389. * Link to the scene is kept to unregister the crowd from the scene
  140390. */
  140391. private _scene;
  140392. /**
  140393. * Observer for crowd updates
  140394. */
  140395. private _onBeforeAnimationsObserver;
  140396. /**
  140397. * Constructor
  140398. * @param plugin recastJS plugin
  140399. * @param maxAgents the maximum agent count in the crowd
  140400. * @param maxAgentRadius the maximum radius an agent can have
  140401. * @param scene to attach the crowd to
  140402. * @returns the crowd you can add agents to
  140403. */
  140404. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140405. /**
  140406. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140407. * You can attach anything to that node. The node position is updated in the scene update tick.
  140408. * @param pos world position that will be constrained by the navigation mesh
  140409. * @param parameters agent parameters
  140410. * @param transform hooked to the agent that will be update by the scene
  140411. * @returns agent index
  140412. */
  140413. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140414. /**
  140415. * Returns the agent position in world space
  140416. * @param index agent index returned by addAgent
  140417. * @returns world space position
  140418. */
  140419. getAgentPosition(index: number): Vector3;
  140420. /**
  140421. * Returns the agent position result in world space
  140422. * @param index agent index returned by addAgent
  140423. * @param result output world space position
  140424. */
  140425. getAgentPositionToRef(index: number, result: Vector3): void;
  140426. /**
  140427. * Returns the agent velocity in world space
  140428. * @param index agent index returned by addAgent
  140429. * @returns world space velocity
  140430. */
  140431. getAgentVelocity(index: number): Vector3;
  140432. /**
  140433. * Returns the agent velocity result in world space
  140434. * @param index agent index returned by addAgent
  140435. * @param result output world space velocity
  140436. */
  140437. getAgentVelocityToRef(index: number, result: Vector3): void;
  140438. /**
  140439. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140440. * @param index agent index returned by addAgent
  140441. * @param destination targeted world position
  140442. */
  140443. agentGoto(index: number, destination: Vector3): void;
  140444. /**
  140445. * Teleport the agent to a new position
  140446. * @param index agent index returned by addAgent
  140447. * @param destination targeted world position
  140448. */
  140449. agentTeleport(index: number, destination: Vector3): void;
  140450. /**
  140451. * Update agent parameters
  140452. * @param index agent index returned by addAgent
  140453. * @param parameters agent parameters
  140454. */
  140455. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140456. /**
  140457. * remove a particular agent previously created
  140458. * @param index agent index returned by addAgent
  140459. */
  140460. removeAgent(index: number): void;
  140461. /**
  140462. * get the list of all agents attached to this crowd
  140463. * @returns list of agent indices
  140464. */
  140465. getAgents(): number[];
  140466. /**
  140467. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140468. * @param deltaTime in seconds
  140469. */
  140470. update(deltaTime: number): void;
  140471. /**
  140472. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140473. * The queries will try to find a solution within those bounds
  140474. * default is (1,1,1)
  140475. * @param extent x,y,z value that define the extent around the queries point of reference
  140476. */
  140477. setDefaultQueryExtent(extent: Vector3): void;
  140478. /**
  140479. * Get the Bounding box extent specified by setDefaultQueryExtent
  140480. * @returns the box extent values
  140481. */
  140482. getDefaultQueryExtent(): Vector3;
  140483. /**
  140484. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140485. * @param result output the box extent values
  140486. */
  140487. getDefaultQueryExtentToRef(result: Vector3): void;
  140488. /**
  140489. * Release all resources
  140490. */
  140491. dispose(): void;
  140492. }
  140493. }
  140494. declare module BABYLON {
  140495. /**
  140496. * Class used to enable access to IndexedDB
  140497. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140498. */
  140499. export class Database implements IOfflineProvider {
  140500. private _callbackManifestChecked;
  140501. private _currentSceneUrl;
  140502. private _db;
  140503. private _enableSceneOffline;
  140504. private _enableTexturesOffline;
  140505. private _manifestVersionFound;
  140506. private _mustUpdateRessources;
  140507. private _hasReachedQuota;
  140508. private _isSupported;
  140509. private _idbFactory;
  140510. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140511. private static IsUASupportingBlobStorage;
  140512. /**
  140513. * Gets a boolean indicating if Database storate is enabled (off by default)
  140514. */
  140515. static IDBStorageEnabled: boolean;
  140516. /**
  140517. * Gets a boolean indicating if scene must be saved in the database
  140518. */
  140519. get enableSceneOffline(): boolean;
  140520. /**
  140521. * Gets a boolean indicating if textures must be saved in the database
  140522. */
  140523. get enableTexturesOffline(): boolean;
  140524. /**
  140525. * Creates a new Database
  140526. * @param urlToScene defines the url to load the scene
  140527. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140528. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140529. */
  140530. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140531. private static _ParseURL;
  140532. private static _ReturnFullUrlLocation;
  140533. private _checkManifestFile;
  140534. /**
  140535. * Open the database and make it available
  140536. * @param successCallback defines the callback to call on success
  140537. * @param errorCallback defines the callback to call on error
  140538. */
  140539. open(successCallback: () => void, errorCallback: () => void): void;
  140540. /**
  140541. * Loads an image from the database
  140542. * @param url defines the url to load from
  140543. * @param image defines the target DOM image
  140544. */
  140545. loadImage(url: string, image: HTMLImageElement): void;
  140546. private _loadImageFromDBAsync;
  140547. private _saveImageIntoDBAsync;
  140548. private _checkVersionFromDB;
  140549. private _loadVersionFromDBAsync;
  140550. private _saveVersionIntoDBAsync;
  140551. /**
  140552. * Loads a file from database
  140553. * @param url defines the URL to load from
  140554. * @param sceneLoaded defines a callback to call on success
  140555. * @param progressCallBack defines a callback to call when progress changed
  140556. * @param errorCallback defines a callback to call on error
  140557. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140558. */
  140559. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140560. private _loadFileAsync;
  140561. private _saveFileAsync;
  140562. /**
  140563. * Validates if xhr data is correct
  140564. * @param xhr defines the request to validate
  140565. * @param dataType defines the expected data type
  140566. * @returns true if data is correct
  140567. */
  140568. private static _ValidateXHRData;
  140569. }
  140570. }
  140571. declare module BABYLON {
  140572. /** @hidden */
  140573. export var gpuUpdateParticlesPixelShader: {
  140574. name: string;
  140575. shader: string;
  140576. };
  140577. }
  140578. declare module BABYLON {
  140579. /** @hidden */
  140580. export var gpuUpdateParticlesVertexShader: {
  140581. name: string;
  140582. shader: string;
  140583. };
  140584. }
  140585. declare module BABYLON {
  140586. /** @hidden */
  140587. export var clipPlaneFragmentDeclaration2: {
  140588. name: string;
  140589. shader: string;
  140590. };
  140591. }
  140592. declare module BABYLON {
  140593. /** @hidden */
  140594. export var gpuRenderParticlesPixelShader: {
  140595. name: string;
  140596. shader: string;
  140597. };
  140598. }
  140599. declare module BABYLON {
  140600. /** @hidden */
  140601. export var clipPlaneVertexDeclaration2: {
  140602. name: string;
  140603. shader: string;
  140604. };
  140605. }
  140606. declare module BABYLON {
  140607. /** @hidden */
  140608. export var gpuRenderParticlesVertexShader: {
  140609. name: string;
  140610. shader: string;
  140611. };
  140612. }
  140613. declare module BABYLON {
  140614. /**
  140615. * This represents a GPU particle system in Babylon
  140616. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140617. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140618. */
  140619. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140620. /**
  140621. * The layer mask we are rendering the particles through.
  140622. */
  140623. layerMask: number;
  140624. private _capacity;
  140625. private _activeCount;
  140626. private _currentActiveCount;
  140627. private _accumulatedCount;
  140628. private _renderEffect;
  140629. private _updateEffect;
  140630. private _buffer0;
  140631. private _buffer1;
  140632. private _spriteBuffer;
  140633. private _updateVAO;
  140634. private _renderVAO;
  140635. private _targetIndex;
  140636. private _sourceBuffer;
  140637. private _targetBuffer;
  140638. private _engine;
  140639. private _currentRenderId;
  140640. private _started;
  140641. private _stopped;
  140642. private _timeDelta;
  140643. private _randomTexture;
  140644. private _randomTexture2;
  140645. private _attributesStrideSize;
  140646. private _updateEffectOptions;
  140647. private _randomTextureSize;
  140648. private _actualFrame;
  140649. private readonly _rawTextureWidth;
  140650. /**
  140651. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140652. */
  140653. static get IsSupported(): boolean;
  140654. /**
  140655. * An event triggered when the system is disposed.
  140656. */
  140657. onDisposeObservable: Observable<GPUParticleSystem>;
  140658. /**
  140659. * Gets the maximum number of particles active at the same time.
  140660. * @returns The max number of active particles.
  140661. */
  140662. getCapacity(): number;
  140663. /**
  140664. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140665. * to override the particles.
  140666. */
  140667. forceDepthWrite: boolean;
  140668. /**
  140669. * Gets or set the number of active particles
  140670. */
  140671. get activeParticleCount(): number;
  140672. set activeParticleCount(value: number);
  140673. private _preWarmDone;
  140674. /**
  140675. * Specifies if the particles are updated in emitter local space or world space.
  140676. */
  140677. isLocal: boolean;
  140678. /**
  140679. * Is this system ready to be used/rendered
  140680. * @return true if the system is ready
  140681. */
  140682. isReady(): boolean;
  140683. /**
  140684. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140685. * @returns True if it has been started, otherwise false.
  140686. */
  140687. isStarted(): boolean;
  140688. /**
  140689. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140690. * @returns True if it has been stopped, otherwise false.
  140691. */
  140692. isStopped(): boolean;
  140693. /**
  140694. * Gets a boolean indicating that the system is stopping
  140695. * @returns true if the system is currently stopping
  140696. */
  140697. isStopping(): boolean;
  140698. /**
  140699. * Gets the number of particles active at the same time.
  140700. * @returns The number of active particles.
  140701. */
  140702. getActiveCount(): number;
  140703. /**
  140704. * Starts the particle system and begins to emit
  140705. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140706. */
  140707. start(delay?: number): void;
  140708. /**
  140709. * Stops the particle system.
  140710. */
  140711. stop(): void;
  140712. /**
  140713. * Remove all active particles
  140714. */
  140715. reset(): void;
  140716. /**
  140717. * Returns the string "GPUParticleSystem"
  140718. * @returns a string containing the class name
  140719. */
  140720. getClassName(): string;
  140721. private _colorGradientsTexture;
  140722. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140723. /**
  140724. * Adds a new color gradient
  140725. * @param gradient defines the gradient to use (between 0 and 1)
  140726. * @param color1 defines the color to affect to the specified gradient
  140727. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140728. * @returns the current particle system
  140729. */
  140730. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140731. private _refreshColorGradient;
  140732. /** Force the system to rebuild all gradients that need to be resync */
  140733. forceRefreshGradients(): void;
  140734. /**
  140735. * Remove a specific color gradient
  140736. * @param gradient defines the gradient to remove
  140737. * @returns the current particle system
  140738. */
  140739. removeColorGradient(gradient: number): GPUParticleSystem;
  140740. private _angularSpeedGradientsTexture;
  140741. private _sizeGradientsTexture;
  140742. private _velocityGradientsTexture;
  140743. private _limitVelocityGradientsTexture;
  140744. private _dragGradientsTexture;
  140745. private _addFactorGradient;
  140746. /**
  140747. * Adds a new size gradient
  140748. * @param gradient defines the gradient to use (between 0 and 1)
  140749. * @param factor defines the size factor to affect to the specified gradient
  140750. * @returns the current particle system
  140751. */
  140752. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140753. /**
  140754. * Remove a specific size gradient
  140755. * @param gradient defines the gradient to remove
  140756. * @returns the current particle system
  140757. */
  140758. removeSizeGradient(gradient: number): GPUParticleSystem;
  140759. private _refreshFactorGradient;
  140760. /**
  140761. * Adds a new angular speed gradient
  140762. * @param gradient defines the gradient to use (between 0 and 1)
  140763. * @param factor defines the angular speed to affect to the specified gradient
  140764. * @returns the current particle system
  140765. */
  140766. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140767. /**
  140768. * Remove a specific angular speed gradient
  140769. * @param gradient defines the gradient to remove
  140770. * @returns the current particle system
  140771. */
  140772. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140773. /**
  140774. * Adds a new velocity gradient
  140775. * @param gradient defines the gradient to use (between 0 and 1)
  140776. * @param factor defines the velocity to affect to the specified gradient
  140777. * @returns the current particle system
  140778. */
  140779. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140780. /**
  140781. * Remove a specific velocity gradient
  140782. * @param gradient defines the gradient to remove
  140783. * @returns the current particle system
  140784. */
  140785. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140786. /**
  140787. * Adds a new limit velocity gradient
  140788. * @param gradient defines the gradient to use (between 0 and 1)
  140789. * @param factor defines the limit velocity value to affect to the specified gradient
  140790. * @returns the current particle system
  140791. */
  140792. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140793. /**
  140794. * Remove a specific limit velocity gradient
  140795. * @param gradient defines the gradient to remove
  140796. * @returns the current particle system
  140797. */
  140798. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140799. /**
  140800. * Adds a new drag gradient
  140801. * @param gradient defines the gradient to use (between 0 and 1)
  140802. * @param factor defines the drag value to affect to the specified gradient
  140803. * @returns the current particle system
  140804. */
  140805. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140806. /**
  140807. * Remove a specific drag gradient
  140808. * @param gradient defines the gradient to remove
  140809. * @returns the current particle system
  140810. */
  140811. removeDragGradient(gradient: number): GPUParticleSystem;
  140812. /**
  140813. * Not supported by GPUParticleSystem
  140814. * @param gradient defines the gradient to use (between 0 and 1)
  140815. * @param factor defines the emit rate value to affect to the specified gradient
  140816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140817. * @returns the current particle system
  140818. */
  140819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140820. /**
  140821. * Not supported by GPUParticleSystem
  140822. * @param gradient defines the gradient to remove
  140823. * @returns the current particle system
  140824. */
  140825. removeEmitRateGradient(gradient: number): IParticleSystem;
  140826. /**
  140827. * Not supported by GPUParticleSystem
  140828. * @param gradient defines the gradient to use (between 0 and 1)
  140829. * @param factor defines the start size value to affect to the specified gradient
  140830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140831. * @returns the current particle system
  140832. */
  140833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140834. /**
  140835. * Not supported by GPUParticleSystem
  140836. * @param gradient defines the gradient to remove
  140837. * @returns the current particle system
  140838. */
  140839. removeStartSizeGradient(gradient: number): IParticleSystem;
  140840. /**
  140841. * Not supported by GPUParticleSystem
  140842. * @param gradient defines the gradient to use (between 0 and 1)
  140843. * @param min defines the color remap minimal range
  140844. * @param max defines the color remap maximal range
  140845. * @returns the current particle system
  140846. */
  140847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140848. /**
  140849. * Not supported by GPUParticleSystem
  140850. * @param gradient defines the gradient to remove
  140851. * @returns the current particle system
  140852. */
  140853. removeColorRemapGradient(): IParticleSystem;
  140854. /**
  140855. * Not supported by GPUParticleSystem
  140856. * @param gradient defines the gradient to use (between 0 and 1)
  140857. * @param min defines the alpha remap minimal range
  140858. * @param max defines the alpha remap maximal range
  140859. * @returns the current particle system
  140860. */
  140861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140862. /**
  140863. * Not supported by GPUParticleSystem
  140864. * @param gradient defines the gradient to remove
  140865. * @returns the current particle system
  140866. */
  140867. removeAlphaRemapGradient(): IParticleSystem;
  140868. /**
  140869. * Not supported by GPUParticleSystem
  140870. * @param gradient defines the gradient to use (between 0 and 1)
  140871. * @param color defines the color to affect to the specified gradient
  140872. * @returns the current particle system
  140873. */
  140874. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  140875. /**
  140876. * Not supported by GPUParticleSystem
  140877. * @param gradient defines the gradient to remove
  140878. * @returns the current particle system
  140879. */
  140880. removeRampGradient(): IParticleSystem;
  140881. /**
  140882. * Not supported by GPUParticleSystem
  140883. * @returns the list of ramp gradients
  140884. */
  140885. getRampGradients(): Nullable<Array<Color3Gradient>>;
  140886. /**
  140887. * Not supported by GPUParticleSystem
  140888. * Gets or sets a boolean indicating that ramp gradients must be used
  140889. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  140890. */
  140891. get useRampGradients(): boolean;
  140892. set useRampGradients(value: boolean);
  140893. /**
  140894. * Not supported by GPUParticleSystem
  140895. * @param gradient defines the gradient to use (between 0 and 1)
  140896. * @param factor defines the life time factor to affect to the specified gradient
  140897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140898. * @returns the current particle system
  140899. */
  140900. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140901. /**
  140902. * Not supported by GPUParticleSystem
  140903. * @param gradient defines the gradient to remove
  140904. * @returns the current particle system
  140905. */
  140906. removeLifeTimeGradient(gradient: number): IParticleSystem;
  140907. /**
  140908. * Instantiates a GPU particle system.
  140909. * 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.
  140910. * @param name The name of the particle system
  140911. * @param options The options used to create the system
  140912. * @param scene The scene the particle system belongs to
  140913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  140914. */
  140915. constructor(name: string, options: Partial<{
  140916. capacity: number;
  140917. randomTextureSize: number;
  140918. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  140919. protected _reset(): void;
  140920. private _createUpdateVAO;
  140921. private _createRenderVAO;
  140922. private _initialize;
  140923. /** @hidden */
  140924. _recreateUpdateEffect(): void;
  140925. /** @hidden */
  140926. _recreateRenderEffect(): void;
  140927. /**
  140928. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  140929. * @param preWarm defines if we are in the pre-warmimg phase
  140930. */
  140931. animate(preWarm?: boolean): void;
  140932. private _createFactorGradientTexture;
  140933. private _createSizeGradientTexture;
  140934. private _createAngularSpeedGradientTexture;
  140935. private _createVelocityGradientTexture;
  140936. private _createLimitVelocityGradientTexture;
  140937. private _createDragGradientTexture;
  140938. private _createColorGradientTexture;
  140939. /**
  140940. * Renders the particle system in its current state
  140941. * @param preWarm defines if the system should only update the particles but not render them
  140942. * @returns the current number of particles
  140943. */
  140944. render(preWarm?: boolean): number;
  140945. /**
  140946. * Rebuilds the particle system
  140947. */
  140948. rebuild(): void;
  140949. private _releaseBuffers;
  140950. private _releaseVAOs;
  140951. /**
  140952. * Disposes the particle system and free the associated resources
  140953. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  140954. */
  140955. dispose(disposeTexture?: boolean): void;
  140956. /**
  140957. * Clones the particle system.
  140958. * @param name The name of the cloned object
  140959. * @param newEmitter The new emitter to use
  140960. * @returns the cloned particle system
  140961. */
  140962. clone(name: string, newEmitter: any): GPUParticleSystem;
  140963. /**
  140964. * Serializes the particle system to a JSON object
  140965. * @param serializeTexture defines if the texture must be serialized as well
  140966. * @returns the JSON object
  140967. */
  140968. serialize(serializeTexture?: boolean): any;
  140969. /**
  140970. * Parses a JSON object to create a GPU particle system.
  140971. * @param parsedParticleSystem The JSON object to parse
  140972. * @param scene The scene to create the particle system in
  140973. * @param rootUrl The root url to use to load external dependencies like texture
  140974. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  140975. * @returns the parsed GPU particle system
  140976. */
  140977. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  140978. }
  140979. }
  140980. declare module BABYLON {
  140981. /**
  140982. * Represents a set of particle systems working together to create a specific effect
  140983. */
  140984. export class ParticleSystemSet implements IDisposable {
  140985. /**
  140986. * Gets or sets base Assets URL
  140987. */
  140988. static BaseAssetsUrl: string;
  140989. private _emitterCreationOptions;
  140990. private _emitterNode;
  140991. /**
  140992. * Gets the particle system list
  140993. */
  140994. systems: IParticleSystem[];
  140995. /**
  140996. * Gets the emitter node used with this set
  140997. */
  140998. get emitterNode(): Nullable<TransformNode>;
  140999. /**
  141000. * Creates a new emitter mesh as a sphere
  141001. * @param options defines the options used to create the sphere
  141002. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  141003. * @param scene defines the hosting scene
  141004. */
  141005. setEmitterAsSphere(options: {
  141006. diameter: number;
  141007. segments: number;
  141008. color: Color3;
  141009. }, renderingGroupId: number, scene: Scene): void;
  141010. /**
  141011. * Starts all particle systems of the set
  141012. * @param emitter defines an optional mesh to use as emitter for the particle systems
  141013. */
  141014. start(emitter?: AbstractMesh): void;
  141015. /**
  141016. * Release all associated resources
  141017. */
  141018. dispose(): void;
  141019. /**
  141020. * Serialize the set into a JSON compatible object
  141021. * @param serializeTexture defines if the texture must be serialized as well
  141022. * @returns a JSON compatible representation of the set
  141023. */
  141024. serialize(serializeTexture?: boolean): any;
  141025. /**
  141026. * Parse a new ParticleSystemSet from a serialized source
  141027. * @param data defines a JSON compatible representation of the set
  141028. * @param scene defines the hosting scene
  141029. * @param gpu defines if we want GPU particles or CPU particles
  141030. * @returns a new ParticleSystemSet
  141031. */
  141032. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  141033. }
  141034. }
  141035. declare module BABYLON {
  141036. /**
  141037. * This class is made for on one-liner static method to help creating particle system set.
  141038. */
  141039. export class ParticleHelper {
  141040. /**
  141041. * Gets or sets base Assets URL
  141042. */
  141043. static BaseAssetsUrl: string;
  141044. /** Define the Url to load snippets */
  141045. static SnippetUrl: string;
  141046. /**
  141047. * Create a default particle system that you can tweak
  141048. * @param emitter defines the emitter to use
  141049. * @param capacity defines the system capacity (default is 500 particles)
  141050. * @param scene defines the hosting scene
  141051. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  141052. * @returns the new Particle system
  141053. */
  141054. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  141055. /**
  141056. * This is the main static method (one-liner) of this helper to create different particle systems
  141057. * @param type This string represents the type to the particle system to create
  141058. * @param scene The scene where the particle system should live
  141059. * @param gpu If the system will use gpu
  141060. * @returns the ParticleSystemSet created
  141061. */
  141062. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  141063. /**
  141064. * Static function used to export a particle system to a ParticleSystemSet variable.
  141065. * Please note that the emitter shape is not exported
  141066. * @param systems defines the particle systems to export
  141067. * @returns the created particle system set
  141068. */
  141069. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  141070. /**
  141071. * Creates a particle system from a snippet saved in a remote file
  141072. * @param name defines the name of the particle system to create
  141073. * @param url defines the url to load from
  141074. * @param scene defines the hosting scene
  141075. * @param gpu If the system will use gpu
  141076. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141077. * @returns a promise that will resolve to the new particle system
  141078. */
  141079. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141080. /**
  141081. * Creates a particle system from a snippet saved by the particle system editor
  141082. * @param snippetId defines the snippet to load
  141083. * @param scene defines the hosting scene
  141084. * @param gpu If the system will use gpu
  141085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  141086. * @returns a promise that will resolve to the new particle system
  141087. */
  141088. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  141089. }
  141090. }
  141091. declare module BABYLON {
  141092. interface Engine {
  141093. /**
  141094. * Create an effect to use with particle systems.
  141095. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  141096. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  141097. * @param uniformsNames defines a list of attribute names
  141098. * @param samplers defines an array of string used to represent textures
  141099. * @param defines defines the string containing the defines to use to compile the shaders
  141100. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  141101. * @param onCompiled defines a function to call when the effect creation is successful
  141102. * @param onError defines a function to call when the effect creation has failed
  141103. * @returns the new Effect
  141104. */
  141105. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  141106. }
  141107. interface Mesh {
  141108. /**
  141109. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  141110. * @returns an array of IParticleSystem
  141111. */
  141112. getEmittedParticleSystems(): IParticleSystem[];
  141113. /**
  141114. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  141115. * @returns an array of IParticleSystem
  141116. */
  141117. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  141118. }
  141119. /**
  141120. * @hidden
  141121. */
  141122. export var _IDoNeedToBeInTheBuild: number;
  141123. }
  141124. declare module BABYLON {
  141125. /** Defines the 4 color options */
  141126. export enum PointColor {
  141127. /** color value */
  141128. Color = 2,
  141129. /** uv value */
  141130. UV = 1,
  141131. /** random value */
  141132. Random = 0,
  141133. /** stated value */
  141134. Stated = 3
  141135. }
  141136. /**
  141137. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  141138. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  141139. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  141140. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  141141. *
  141142. * Full documentation here : TO BE ENTERED
  141143. */
  141144. export class PointsCloudSystem implements IDisposable {
  141145. /**
  141146. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  141147. * Example : var p = SPS.particles[i];
  141148. */
  141149. particles: CloudPoint[];
  141150. /**
  141151. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  141152. */
  141153. nbParticles: number;
  141154. /**
  141155. * This a counter for your own usage. It's not set by any SPS functions.
  141156. */
  141157. counter: number;
  141158. /**
  141159. * The PCS name. This name is also given to the underlying mesh.
  141160. */
  141161. name: string;
  141162. /**
  141163. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  141164. */
  141165. mesh: Mesh;
  141166. /**
  141167. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  141168. * Please read :
  141169. */
  141170. vars: any;
  141171. /**
  141172. * @hidden
  141173. */
  141174. _size: number;
  141175. private _scene;
  141176. private _promises;
  141177. private _positions;
  141178. private _indices;
  141179. private _normals;
  141180. private _colors;
  141181. private _uvs;
  141182. private _indices32;
  141183. private _positions32;
  141184. private _colors32;
  141185. private _uvs32;
  141186. private _updatable;
  141187. private _isVisibilityBoxLocked;
  141188. private _alwaysVisible;
  141189. private _groups;
  141190. private _groupCounter;
  141191. private _computeParticleColor;
  141192. private _computeParticleTexture;
  141193. private _computeParticleRotation;
  141194. private _computeBoundingBox;
  141195. private _isReady;
  141196. /**
  141197. * Creates a PCS (Points Cloud System) object
  141198. * @param name (String) is the PCS name, this will be the underlying mesh name
  141199. * @param pointSize (number) is the size for each point
  141200. * @param scene (Scene) is the scene in which the PCS is added
  141201. * @param options defines the options of the PCS e.g.
  141202. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  141203. */
  141204. constructor(name: string, pointSize: number, scene: Scene, options?: {
  141205. updatable?: boolean;
  141206. });
  141207. /**
  141208. * Builds the PCS underlying mesh. Returns a standard Mesh.
  141209. * If no points were added to the PCS, the returned mesh is just a single point.
  141210. * @returns a promise for the created mesh
  141211. */
  141212. buildMeshAsync(): Promise<Mesh>;
  141213. /**
  141214. * @hidden
  141215. */
  141216. private _buildMesh;
  141217. private _addParticle;
  141218. private _randomUnitVector;
  141219. private _getColorIndicesForCoord;
  141220. private _setPointsColorOrUV;
  141221. private _colorFromTexture;
  141222. private _calculateDensity;
  141223. /**
  141224. * Adds points to the PCS in random positions within a unit sphere
  141225. * @param nb (positive integer) the number of particles to be created from this model
  141226. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  141227. * @returns the number of groups in the system
  141228. */
  141229. addPoints(nb: number, pointFunction?: any): number;
  141230. /**
  141231. * Adds points to the PCS from the surface of the model shape
  141232. * @param mesh is any Mesh object that will be used as a surface model for the points
  141233. * @param nb (positive integer) the number of particles to be created from this model
  141234. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141235. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141236. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141237. * @returns the number of groups in the system
  141238. */
  141239. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141240. /**
  141241. * Adds points to the PCS inside the model shape
  141242. * @param mesh is any Mesh object that will be used as a surface model for the points
  141243. * @param nb (positive integer) the number of particles to be created from this model
  141244. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  141245. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  141246. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  141247. * @returns the number of groups in the system
  141248. */
  141249. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  141250. /**
  141251. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  141252. * This method calls `updateParticle()` for each particle of the SPS.
  141253. * For an animated SPS, it is usually called within the render loop.
  141254. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  141255. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  141256. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  141257. * @returns the PCS.
  141258. */
  141259. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  141260. /**
  141261. * Disposes the PCS.
  141262. */
  141263. dispose(): void;
  141264. /**
  141265. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  141266. * doc :
  141267. * @returns the PCS.
  141268. */
  141269. refreshVisibleSize(): PointsCloudSystem;
  141270. /**
  141271. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  141272. * @param size the size (float) of the visibility box
  141273. * note : this doesn't lock the PCS mesh bounding box.
  141274. * doc :
  141275. */
  141276. setVisibilityBox(size: number): void;
  141277. /**
  141278. * Gets whether the PCS is always visible or not
  141279. * doc :
  141280. */
  141281. get isAlwaysVisible(): boolean;
  141282. /**
  141283. * Sets the PCS as always visible or not
  141284. * doc :
  141285. */
  141286. set isAlwaysVisible(val: boolean);
  141287. /**
  141288. * Tells to `setParticles()` to compute the particle rotations or not
  141289. * Default value : false. The PCS is faster when it's set to false
  141290. * Note : particle rotations are only applied to parent particles
  141291. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  141292. */
  141293. set computeParticleRotation(val: boolean);
  141294. /**
  141295. * Tells to `setParticles()` to compute the particle colors or not.
  141296. * Default value : true. The PCS is faster when it's set to false.
  141297. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141298. */
  141299. set computeParticleColor(val: boolean);
  141300. set computeParticleTexture(val: boolean);
  141301. /**
  141302. * Gets if `setParticles()` computes the particle colors or not.
  141303. * Default value : false. The PCS is faster when it's set to false.
  141304. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  141305. */
  141306. get computeParticleColor(): boolean;
  141307. /**
  141308. * Gets if `setParticles()` computes the particle textures or not.
  141309. * Default value : false. The PCS is faster when it's set to false.
  141310. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  141311. */
  141312. get computeParticleTexture(): boolean;
  141313. /**
  141314. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  141315. */
  141316. set computeBoundingBox(val: boolean);
  141317. /**
  141318. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  141319. */
  141320. get computeBoundingBox(): boolean;
  141321. /**
  141322. * This function does nothing. It may be overwritten to set all the particle first values.
  141323. * The PCS doesn't call this function, you may have to call it by your own.
  141324. * doc :
  141325. */
  141326. initParticles(): void;
  141327. /**
  141328. * This function does nothing. It may be overwritten to recycle a particle
  141329. * The PCS doesn't call this function, you can to call it
  141330. * doc :
  141331. * @param particle The particle to recycle
  141332. * @returns the recycled particle
  141333. */
  141334. recycleParticle(particle: CloudPoint): CloudPoint;
  141335. /**
  141336. * Updates a particle : this function should be overwritten by the user.
  141337. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141338. * doc :
  141339. * @example : just set a particle position or velocity and recycle conditions
  141340. * @param particle The particle to update
  141341. * @returns the updated particle
  141342. */
  141343. updateParticle(particle: CloudPoint): CloudPoint;
  141344. /**
  141345. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141346. * This does nothing and may be overwritten by the user.
  141347. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141348. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141349. * @param update the boolean update value actually passed to setParticles()
  141350. */
  141351. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141352. /**
  141353. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141354. * This will be passed three parameters.
  141355. * This does nothing and may be overwritten by the user.
  141356. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141357. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141358. * @param update the boolean update value actually passed to setParticles()
  141359. */
  141360. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141361. }
  141362. }
  141363. declare module BABYLON {
  141364. /**
  141365. * Represents one particle of a points cloud system.
  141366. */
  141367. export class CloudPoint {
  141368. /**
  141369. * particle global index
  141370. */
  141371. idx: number;
  141372. /**
  141373. * The color of the particle
  141374. */
  141375. color: Nullable<Color4>;
  141376. /**
  141377. * The world space position of the particle.
  141378. */
  141379. position: Vector3;
  141380. /**
  141381. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141382. */
  141383. rotation: Vector3;
  141384. /**
  141385. * The world space rotation quaternion of the particle.
  141386. */
  141387. rotationQuaternion: Nullable<Quaternion>;
  141388. /**
  141389. * The uv of the particle.
  141390. */
  141391. uv: Nullable<Vector2>;
  141392. /**
  141393. * The current speed of the particle.
  141394. */
  141395. velocity: Vector3;
  141396. /**
  141397. * The pivot point in the particle local space.
  141398. */
  141399. pivot: Vector3;
  141400. /**
  141401. * Must the particle be translated from its pivot point in its local space ?
  141402. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141403. * Default : false
  141404. */
  141405. translateFromPivot: boolean;
  141406. /**
  141407. * Index of this particle in the global "positions" array (Internal use)
  141408. * @hidden
  141409. */
  141410. _pos: number;
  141411. /**
  141412. * @hidden Index of this particle in the global "indices" array (Internal use)
  141413. */
  141414. _ind: number;
  141415. /**
  141416. * Group this particle belongs to
  141417. */
  141418. _group: PointsGroup;
  141419. /**
  141420. * Group id of this particle
  141421. */
  141422. groupId: number;
  141423. /**
  141424. * Index of the particle in its group id (Internal use)
  141425. */
  141426. idxInGroup: number;
  141427. /**
  141428. * @hidden Particle BoundingInfo object (Internal use)
  141429. */
  141430. _boundingInfo: BoundingInfo;
  141431. /**
  141432. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141433. */
  141434. _pcs: PointsCloudSystem;
  141435. /**
  141436. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141437. */
  141438. _stillInvisible: boolean;
  141439. /**
  141440. * @hidden Last computed particle rotation matrix
  141441. */
  141442. _rotationMatrix: number[];
  141443. /**
  141444. * Parent particle Id, if any.
  141445. * Default null.
  141446. */
  141447. parentId: Nullable<number>;
  141448. /**
  141449. * @hidden Internal global position in the PCS.
  141450. */
  141451. _globalPosition: Vector3;
  141452. /**
  141453. * Creates a Point Cloud object.
  141454. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141455. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141456. * @param group (PointsGroup) is the group the particle belongs to
  141457. * @param groupId (integer) is the group identifier in the PCS.
  141458. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141459. * @param pcs defines the PCS it is associated to
  141460. */
  141461. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141462. /**
  141463. * get point size
  141464. */
  141465. get size(): Vector3;
  141466. /**
  141467. * Set point size
  141468. */
  141469. set size(scale: Vector3);
  141470. /**
  141471. * Legacy support, changed quaternion to rotationQuaternion
  141472. */
  141473. get quaternion(): Nullable<Quaternion>;
  141474. /**
  141475. * Legacy support, changed quaternion to rotationQuaternion
  141476. */
  141477. set quaternion(q: Nullable<Quaternion>);
  141478. /**
  141479. * Returns a boolean. True if the particle intersects a mesh, else false
  141480. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141481. * @param target is the object (point or mesh) what the intersection is computed against
  141482. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141483. * @returns true if it intersects
  141484. */
  141485. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141486. /**
  141487. * get the rotation matrix of the particle
  141488. * @hidden
  141489. */
  141490. getRotationMatrix(m: Matrix): void;
  141491. }
  141492. /**
  141493. * Represents a group of points in a points cloud system
  141494. * * PCS internal tool, don't use it manually.
  141495. */
  141496. export class PointsGroup {
  141497. /**
  141498. * The group id
  141499. * @hidden
  141500. */
  141501. groupID: number;
  141502. /**
  141503. * image data for group (internal use)
  141504. * @hidden
  141505. */
  141506. _groupImageData: Nullable<ArrayBufferView>;
  141507. /**
  141508. * Image Width (internal use)
  141509. * @hidden
  141510. */
  141511. _groupImgWidth: number;
  141512. /**
  141513. * Image Height (internal use)
  141514. * @hidden
  141515. */
  141516. _groupImgHeight: number;
  141517. /**
  141518. * Custom position function (internal use)
  141519. * @hidden
  141520. */
  141521. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141522. /**
  141523. * density per facet for surface points
  141524. * @hidden
  141525. */
  141526. _groupDensity: number[];
  141527. /**
  141528. * Only when points are colored by texture carries pointer to texture list array
  141529. * @hidden
  141530. */
  141531. _textureNb: number;
  141532. /**
  141533. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141534. * PCS internal tool, don't use it manually.
  141535. * @hidden
  141536. */
  141537. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141538. }
  141539. }
  141540. declare module BABYLON {
  141541. interface Scene {
  141542. /** @hidden (Backing field) */
  141543. _physicsEngine: Nullable<IPhysicsEngine>;
  141544. /** @hidden */
  141545. _physicsTimeAccumulator: number;
  141546. /**
  141547. * Gets the current physics engine
  141548. * @returns a IPhysicsEngine or null if none attached
  141549. */
  141550. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141551. /**
  141552. * Enables physics to the current scene
  141553. * @param gravity defines the scene's gravity for the physics engine
  141554. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141555. * @return a boolean indicating if the physics engine was initialized
  141556. */
  141557. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141558. /**
  141559. * Disables and disposes the physics engine associated with the scene
  141560. */
  141561. disablePhysicsEngine(): void;
  141562. /**
  141563. * Gets a boolean indicating if there is an active physics engine
  141564. * @returns a boolean indicating if there is an active physics engine
  141565. */
  141566. isPhysicsEnabled(): boolean;
  141567. /**
  141568. * Deletes a physics compound impostor
  141569. * @param compound defines the compound to delete
  141570. */
  141571. deleteCompoundImpostor(compound: any): void;
  141572. /**
  141573. * An event triggered when physic simulation is about to be run
  141574. */
  141575. onBeforePhysicsObservable: Observable<Scene>;
  141576. /**
  141577. * An event triggered when physic simulation has been done
  141578. */
  141579. onAfterPhysicsObservable: Observable<Scene>;
  141580. }
  141581. interface AbstractMesh {
  141582. /** @hidden */
  141583. _physicsImpostor: Nullable<PhysicsImpostor>;
  141584. /**
  141585. * Gets or sets impostor used for physic simulation
  141586. * @see http://doc.babylonjs.com/features/physics_engine
  141587. */
  141588. physicsImpostor: Nullable<PhysicsImpostor>;
  141589. /**
  141590. * Gets the current physics impostor
  141591. * @see http://doc.babylonjs.com/features/physics_engine
  141592. * @returns a physics impostor or null
  141593. */
  141594. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141595. /** Apply a physic impulse to the mesh
  141596. * @param force defines the force to apply
  141597. * @param contactPoint defines where to apply the force
  141598. * @returns the current mesh
  141599. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141600. */
  141601. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141602. /**
  141603. * Creates a physic joint between two meshes
  141604. * @param otherMesh defines the other mesh to use
  141605. * @param pivot1 defines the pivot to use on this mesh
  141606. * @param pivot2 defines the pivot to use on the other mesh
  141607. * @param options defines additional options (can be plugin dependent)
  141608. * @returns the current mesh
  141609. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141610. */
  141611. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141612. /** @hidden */
  141613. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141614. }
  141615. /**
  141616. * Defines the physics engine scene component responsible to manage a physics engine
  141617. */
  141618. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141619. /**
  141620. * The component name helpful to identify the component in the list of scene components.
  141621. */
  141622. readonly name: string;
  141623. /**
  141624. * The scene the component belongs to.
  141625. */
  141626. scene: Scene;
  141627. /**
  141628. * Creates a new instance of the component for the given scene
  141629. * @param scene Defines the scene to register the component in
  141630. */
  141631. constructor(scene: Scene);
  141632. /**
  141633. * Registers the component in a given scene
  141634. */
  141635. register(): void;
  141636. /**
  141637. * Rebuilds the elements related to this component in case of
  141638. * context lost for instance.
  141639. */
  141640. rebuild(): void;
  141641. /**
  141642. * Disposes the component and the associated ressources
  141643. */
  141644. dispose(): void;
  141645. }
  141646. }
  141647. declare module BABYLON {
  141648. /**
  141649. * A helper for physics simulations
  141650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141651. */
  141652. export class PhysicsHelper {
  141653. private _scene;
  141654. private _physicsEngine;
  141655. /**
  141656. * Initializes the Physics helper
  141657. * @param scene Babylon.js scene
  141658. */
  141659. constructor(scene: Scene);
  141660. /**
  141661. * Applies a radial explosion impulse
  141662. * @param origin the origin of the explosion
  141663. * @param radiusOrEventOptions the radius or the options of radial explosion
  141664. * @param strength the explosion strength
  141665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141666. * @returns A physics radial explosion event, or null
  141667. */
  141668. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141669. /**
  141670. * Applies a radial explosion force
  141671. * @param origin the origin of the explosion
  141672. * @param radiusOrEventOptions the radius or the options of radial explosion
  141673. * @param strength the explosion strength
  141674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141675. * @returns A physics radial explosion event, or null
  141676. */
  141677. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141678. /**
  141679. * Creates a gravitational field
  141680. * @param origin the origin of the explosion
  141681. * @param radiusOrEventOptions the radius or the options of radial explosion
  141682. * @param strength the explosion strength
  141683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141684. * @returns A physics gravitational field event, or null
  141685. */
  141686. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141687. /**
  141688. * Creates a physics updraft event
  141689. * @param origin the origin of the updraft
  141690. * @param radiusOrEventOptions the radius or the options of the updraft
  141691. * @param strength the strength of the updraft
  141692. * @param height the height of the updraft
  141693. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141694. * @returns A physics updraft event, or null
  141695. */
  141696. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141697. /**
  141698. * Creates a physics vortex event
  141699. * @param origin the of the vortex
  141700. * @param radiusOrEventOptions the radius or the options of the vortex
  141701. * @param strength the strength of the vortex
  141702. * @param height the height of the vortex
  141703. * @returns a Physics vortex event, or null
  141704. * A physics vortex event or null
  141705. */
  141706. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141707. }
  141708. /**
  141709. * Represents a physics radial explosion event
  141710. */
  141711. class PhysicsRadialExplosionEvent {
  141712. private _scene;
  141713. private _options;
  141714. private _sphere;
  141715. private _dataFetched;
  141716. /**
  141717. * Initializes a radial explosioin event
  141718. * @param _scene BabylonJS scene
  141719. * @param _options The options for the vortex event
  141720. */
  141721. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141722. /**
  141723. * Returns the data related to the radial explosion event (sphere).
  141724. * @returns The radial explosion event data
  141725. */
  141726. getData(): PhysicsRadialExplosionEventData;
  141727. /**
  141728. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141729. * @param impostor A physics imposter
  141730. * @param origin the origin of the explosion
  141731. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141732. */
  141733. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141734. /**
  141735. * Triggers affecterd impostors callbacks
  141736. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141737. */
  141738. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141739. /**
  141740. * Disposes the sphere.
  141741. * @param force Specifies if the sphere should be disposed by force
  141742. */
  141743. dispose(force?: boolean): void;
  141744. /*** Helpers ***/
  141745. private _prepareSphere;
  141746. private _intersectsWithSphere;
  141747. }
  141748. /**
  141749. * Represents a gravitational field event
  141750. */
  141751. class PhysicsGravitationalFieldEvent {
  141752. private _physicsHelper;
  141753. private _scene;
  141754. private _origin;
  141755. private _options;
  141756. private _tickCallback;
  141757. private _sphere;
  141758. private _dataFetched;
  141759. /**
  141760. * Initializes the physics gravitational field event
  141761. * @param _physicsHelper A physics helper
  141762. * @param _scene BabylonJS scene
  141763. * @param _origin The origin position of the gravitational field event
  141764. * @param _options The options for the vortex event
  141765. */
  141766. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141767. /**
  141768. * Returns the data related to the gravitational field event (sphere).
  141769. * @returns A gravitational field event
  141770. */
  141771. getData(): PhysicsGravitationalFieldEventData;
  141772. /**
  141773. * Enables the gravitational field.
  141774. */
  141775. enable(): void;
  141776. /**
  141777. * Disables the gravitational field.
  141778. */
  141779. disable(): void;
  141780. /**
  141781. * Disposes the sphere.
  141782. * @param force The force to dispose from the gravitational field event
  141783. */
  141784. dispose(force?: boolean): void;
  141785. private _tick;
  141786. }
  141787. /**
  141788. * Represents a physics updraft event
  141789. */
  141790. class PhysicsUpdraftEvent {
  141791. private _scene;
  141792. private _origin;
  141793. private _options;
  141794. private _physicsEngine;
  141795. private _originTop;
  141796. private _originDirection;
  141797. private _tickCallback;
  141798. private _cylinder;
  141799. private _cylinderPosition;
  141800. private _dataFetched;
  141801. /**
  141802. * Initializes the physics updraft event
  141803. * @param _scene BabylonJS scene
  141804. * @param _origin The origin position of the updraft
  141805. * @param _options The options for the updraft event
  141806. */
  141807. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141808. /**
  141809. * Returns the data related to the updraft event (cylinder).
  141810. * @returns A physics updraft event
  141811. */
  141812. getData(): PhysicsUpdraftEventData;
  141813. /**
  141814. * Enables the updraft.
  141815. */
  141816. enable(): void;
  141817. /**
  141818. * Disables the updraft.
  141819. */
  141820. disable(): void;
  141821. /**
  141822. * Disposes the cylinder.
  141823. * @param force Specifies if the updraft should be disposed by force
  141824. */
  141825. dispose(force?: boolean): void;
  141826. private getImpostorHitData;
  141827. private _tick;
  141828. /*** Helpers ***/
  141829. private _prepareCylinder;
  141830. private _intersectsWithCylinder;
  141831. }
  141832. /**
  141833. * Represents a physics vortex event
  141834. */
  141835. class PhysicsVortexEvent {
  141836. private _scene;
  141837. private _origin;
  141838. private _options;
  141839. private _physicsEngine;
  141840. private _originTop;
  141841. private _tickCallback;
  141842. private _cylinder;
  141843. private _cylinderPosition;
  141844. private _dataFetched;
  141845. /**
  141846. * Initializes the physics vortex event
  141847. * @param _scene The BabylonJS scene
  141848. * @param _origin The origin position of the vortex
  141849. * @param _options The options for the vortex event
  141850. */
  141851. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141852. /**
  141853. * Returns the data related to the vortex event (cylinder).
  141854. * @returns The physics vortex event data
  141855. */
  141856. getData(): PhysicsVortexEventData;
  141857. /**
  141858. * Enables the vortex.
  141859. */
  141860. enable(): void;
  141861. /**
  141862. * Disables the cortex.
  141863. */
  141864. disable(): void;
  141865. /**
  141866. * Disposes the sphere.
  141867. * @param force
  141868. */
  141869. dispose(force?: boolean): void;
  141870. private getImpostorHitData;
  141871. private _tick;
  141872. /*** Helpers ***/
  141873. private _prepareCylinder;
  141874. private _intersectsWithCylinder;
  141875. }
  141876. /**
  141877. * Options fot the radial explosion event
  141878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141879. */
  141880. export class PhysicsRadialExplosionEventOptions {
  141881. /**
  141882. * The radius of the sphere for the radial explosion.
  141883. */
  141884. radius: number;
  141885. /**
  141886. * The strenth of the explosion.
  141887. */
  141888. strength: number;
  141889. /**
  141890. * The strenght of the force in correspondence to the distance of the affected object
  141891. */
  141892. falloff: PhysicsRadialImpulseFalloff;
  141893. /**
  141894. * Sphere options for the radial explosion.
  141895. */
  141896. sphere: {
  141897. segments: number;
  141898. diameter: number;
  141899. };
  141900. /**
  141901. * Sphere options for the radial explosion.
  141902. */
  141903. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  141904. }
  141905. /**
  141906. * Options fot the updraft event
  141907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141908. */
  141909. export class PhysicsUpdraftEventOptions {
  141910. /**
  141911. * The radius of the cylinder for the vortex
  141912. */
  141913. radius: number;
  141914. /**
  141915. * The strenth of the updraft.
  141916. */
  141917. strength: number;
  141918. /**
  141919. * The height of the cylinder for the updraft.
  141920. */
  141921. height: number;
  141922. /**
  141923. * The mode for the the updraft.
  141924. */
  141925. updraftMode: PhysicsUpdraftMode;
  141926. }
  141927. /**
  141928. * Options fot the vortex event
  141929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141930. */
  141931. export class PhysicsVortexEventOptions {
  141932. /**
  141933. * The radius of the cylinder for the vortex
  141934. */
  141935. radius: number;
  141936. /**
  141937. * The strenth of the vortex.
  141938. */
  141939. strength: number;
  141940. /**
  141941. * The height of the cylinder for the vortex.
  141942. */
  141943. height: number;
  141944. /**
  141945. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  141946. */
  141947. centripetalForceThreshold: number;
  141948. /**
  141949. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  141950. */
  141951. centripetalForceMultiplier: number;
  141952. /**
  141953. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  141954. */
  141955. centrifugalForceMultiplier: number;
  141956. /**
  141957. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  141958. */
  141959. updraftForceMultiplier: number;
  141960. }
  141961. /**
  141962. * The strenght of the force in correspondence to the distance of the affected object
  141963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141964. */
  141965. export enum PhysicsRadialImpulseFalloff {
  141966. /** Defines that impulse is constant in strength across it's whole radius */
  141967. Constant = 0,
  141968. /** Defines that impulse gets weaker if it's further from the origin */
  141969. Linear = 1
  141970. }
  141971. /**
  141972. * The strength of the force in correspondence to the distance of the affected object
  141973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141974. */
  141975. export enum PhysicsUpdraftMode {
  141976. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  141977. Center = 0,
  141978. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  141979. Perpendicular = 1
  141980. }
  141981. /**
  141982. * Interface for a physics hit data
  141983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141984. */
  141985. export interface PhysicsHitData {
  141986. /**
  141987. * The force applied at the contact point
  141988. */
  141989. force: Vector3;
  141990. /**
  141991. * The contact point
  141992. */
  141993. contactPoint: Vector3;
  141994. /**
  141995. * The distance from the origin to the contact point
  141996. */
  141997. distanceFromOrigin: number;
  141998. }
  141999. /**
  142000. * Interface for radial explosion event data
  142001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142002. */
  142003. export interface PhysicsRadialExplosionEventData {
  142004. /**
  142005. * A sphere used for the radial explosion event
  142006. */
  142007. sphere: Mesh;
  142008. }
  142009. /**
  142010. * Interface for gravitational field event data
  142011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142012. */
  142013. export interface PhysicsGravitationalFieldEventData {
  142014. /**
  142015. * A sphere mesh used for the gravitational field event
  142016. */
  142017. sphere: Mesh;
  142018. }
  142019. /**
  142020. * Interface for updraft event data
  142021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142022. */
  142023. export interface PhysicsUpdraftEventData {
  142024. /**
  142025. * A cylinder used for the updraft event
  142026. */
  142027. cylinder: Mesh;
  142028. }
  142029. /**
  142030. * Interface for vortex event data
  142031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142032. */
  142033. export interface PhysicsVortexEventData {
  142034. /**
  142035. * A cylinder used for the vortex event
  142036. */
  142037. cylinder: Mesh;
  142038. }
  142039. /**
  142040. * Interface for an affected physics impostor
  142041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  142042. */
  142043. export interface PhysicsAffectedImpostorWithData {
  142044. /**
  142045. * The impostor affected by the effect
  142046. */
  142047. impostor: PhysicsImpostor;
  142048. /**
  142049. * The data about the hit/horce from the explosion
  142050. */
  142051. hitData: PhysicsHitData;
  142052. }
  142053. }
  142054. declare module BABYLON {
  142055. /** @hidden */
  142056. export var blackAndWhitePixelShader: {
  142057. name: string;
  142058. shader: string;
  142059. };
  142060. }
  142061. declare module BABYLON {
  142062. /**
  142063. * Post process used to render in black and white
  142064. */
  142065. export class BlackAndWhitePostProcess extends PostProcess {
  142066. /**
  142067. * Linear about to convert he result to black and white (default: 1)
  142068. */
  142069. degree: number;
  142070. /**
  142071. * Creates a black and white post process
  142072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  142073. * @param name The name of the effect.
  142074. * @param options The required width/height ratio to downsize to before computing the render pass.
  142075. * @param camera The camera to apply the render pass to.
  142076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142077. * @param engine The engine which the post process will be applied. (default: current engine)
  142078. * @param reusable If the post process can be reused on the same frame. (default: false)
  142079. */
  142080. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142081. }
  142082. }
  142083. declare module BABYLON {
  142084. /**
  142085. * This represents a set of one or more post processes in Babylon.
  142086. * A post process can be used to apply a shader to a texture after it is rendered.
  142087. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142088. */
  142089. export class PostProcessRenderEffect {
  142090. private _postProcesses;
  142091. private _getPostProcesses;
  142092. private _singleInstance;
  142093. private _cameras;
  142094. private _indicesForCamera;
  142095. /**
  142096. * Name of the effect
  142097. * @hidden
  142098. */
  142099. _name: string;
  142100. /**
  142101. * Instantiates a post process render effect.
  142102. * A post process can be used to apply a shader to a texture after it is rendered.
  142103. * @param engine The engine the effect is tied to
  142104. * @param name The name of the effect
  142105. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  142106. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  142107. */
  142108. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  142109. /**
  142110. * Checks if all the post processes in the effect are supported.
  142111. */
  142112. get isSupported(): boolean;
  142113. /**
  142114. * Updates the current state of the effect
  142115. * @hidden
  142116. */
  142117. _update(): void;
  142118. /**
  142119. * Attaches the effect on cameras
  142120. * @param cameras The camera to attach to.
  142121. * @hidden
  142122. */
  142123. _attachCameras(cameras: Camera): void;
  142124. /**
  142125. * Attaches the effect on cameras
  142126. * @param cameras The camera to attach to.
  142127. * @hidden
  142128. */
  142129. _attachCameras(cameras: Camera[]): void;
  142130. /**
  142131. * Detaches the effect on cameras
  142132. * @param cameras The camera to detatch from.
  142133. * @hidden
  142134. */
  142135. _detachCameras(cameras: Camera): void;
  142136. /**
  142137. * Detatches the effect on cameras
  142138. * @param cameras The camera to detatch from.
  142139. * @hidden
  142140. */
  142141. _detachCameras(cameras: Camera[]): void;
  142142. /**
  142143. * Enables the effect on given cameras
  142144. * @param cameras The camera to enable.
  142145. * @hidden
  142146. */
  142147. _enable(cameras: Camera): void;
  142148. /**
  142149. * Enables the effect on given cameras
  142150. * @param cameras The camera to enable.
  142151. * @hidden
  142152. */
  142153. _enable(cameras: Nullable<Camera[]>): void;
  142154. /**
  142155. * Disables the effect on the given cameras
  142156. * @param cameras The camera to disable.
  142157. * @hidden
  142158. */
  142159. _disable(cameras: Camera): void;
  142160. /**
  142161. * Disables the effect on the given cameras
  142162. * @param cameras The camera to disable.
  142163. * @hidden
  142164. */
  142165. _disable(cameras: Nullable<Camera[]>): void;
  142166. /**
  142167. * Gets a list of the post processes contained in the effect.
  142168. * @param camera The camera to get the post processes on.
  142169. * @returns The list of the post processes in the effect.
  142170. */
  142171. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  142172. }
  142173. }
  142174. declare module BABYLON {
  142175. /** @hidden */
  142176. export var extractHighlightsPixelShader: {
  142177. name: string;
  142178. shader: string;
  142179. };
  142180. }
  142181. declare module BABYLON {
  142182. /**
  142183. * 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.
  142184. */
  142185. export class ExtractHighlightsPostProcess extends PostProcess {
  142186. /**
  142187. * The luminance threshold, pixels below this value will be set to black.
  142188. */
  142189. threshold: number;
  142190. /** @hidden */
  142191. _exposure: number;
  142192. /**
  142193. * Post process which has the input texture to be used when performing highlight extraction
  142194. * @hidden
  142195. */
  142196. _inputPostProcess: Nullable<PostProcess>;
  142197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142198. }
  142199. }
  142200. declare module BABYLON {
  142201. /** @hidden */
  142202. export var bloomMergePixelShader: {
  142203. name: string;
  142204. shader: string;
  142205. };
  142206. }
  142207. declare module BABYLON {
  142208. /**
  142209. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142210. */
  142211. export class BloomMergePostProcess extends PostProcess {
  142212. /** Weight of the bloom to be added to the original input. */
  142213. weight: number;
  142214. /**
  142215. * Creates a new instance of @see BloomMergePostProcess
  142216. * @param name The name of the effect.
  142217. * @param originalFromInput Post process which's input will be used for the merge.
  142218. * @param blurred Blurred highlights post process which's output will be used.
  142219. * @param weight Weight of the bloom to be added to the original input.
  142220. * @param options The required width/height ratio to downsize to before computing the render pass.
  142221. * @param camera The camera to apply the render pass to.
  142222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142223. * @param engine The engine which the post process will be applied. (default: current engine)
  142224. * @param reusable If the post process can be reused on the same frame. (default: false)
  142225. * @param textureType Type of textures used when performing the post process. (default: 0)
  142226. * @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)
  142227. */
  142228. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  142229. /** Weight of the bloom to be added to the original input. */
  142230. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142231. }
  142232. }
  142233. declare module BABYLON {
  142234. /**
  142235. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  142236. */
  142237. export class BloomEffect extends PostProcessRenderEffect {
  142238. private bloomScale;
  142239. /**
  142240. * @hidden Internal
  142241. */
  142242. _effects: Array<PostProcess>;
  142243. /**
  142244. * @hidden Internal
  142245. */
  142246. _downscale: ExtractHighlightsPostProcess;
  142247. private _blurX;
  142248. private _blurY;
  142249. private _merge;
  142250. /**
  142251. * The luminance threshold to find bright areas of the image to bloom.
  142252. */
  142253. get threshold(): number;
  142254. set threshold(value: number);
  142255. /**
  142256. * The strength of the bloom.
  142257. */
  142258. get weight(): number;
  142259. set weight(value: number);
  142260. /**
  142261. * Specifies the size of the bloom blur kernel, relative to the final output size
  142262. */
  142263. get kernel(): number;
  142264. set kernel(value: number);
  142265. /**
  142266. * Creates a new instance of @see BloomEffect
  142267. * @param scene The scene the effect belongs to.
  142268. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  142269. * @param bloomKernel The size of the kernel to be used when applying the blur.
  142270. * @param bloomWeight The the strength of bloom.
  142271. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142272. * @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)
  142273. */
  142274. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  142275. /**
  142276. * Disposes each of the internal effects for a given camera.
  142277. * @param camera The camera to dispose the effect on.
  142278. */
  142279. disposeEffects(camera: Camera): void;
  142280. /**
  142281. * @hidden Internal
  142282. */
  142283. _updateEffects(): void;
  142284. /**
  142285. * Internal
  142286. * @returns if all the contained post processes are ready.
  142287. * @hidden
  142288. */
  142289. _isReady(): boolean;
  142290. }
  142291. }
  142292. declare module BABYLON {
  142293. /** @hidden */
  142294. export var chromaticAberrationPixelShader: {
  142295. name: string;
  142296. shader: string;
  142297. };
  142298. }
  142299. declare module BABYLON {
  142300. /**
  142301. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  142302. */
  142303. export class ChromaticAberrationPostProcess extends PostProcess {
  142304. /**
  142305. * The amount of seperation of rgb channels (default: 30)
  142306. */
  142307. aberrationAmount: number;
  142308. /**
  142309. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  142310. */
  142311. radialIntensity: number;
  142312. /**
  142313. * 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))
  142314. */
  142315. direction: Vector2;
  142316. /**
  142317. * 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))
  142318. */
  142319. centerPosition: Vector2;
  142320. /**
  142321. * Creates a new instance ChromaticAberrationPostProcess
  142322. * @param name The name of the effect.
  142323. * @param screenWidth The width of the screen to apply the effect on.
  142324. * @param screenHeight The height of the screen to apply the effect on.
  142325. * @param options The required width/height ratio to downsize to before computing the render pass.
  142326. * @param camera The camera to apply the render pass to.
  142327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142328. * @param engine The engine which the post process will be applied. (default: current engine)
  142329. * @param reusable If the post process can be reused on the same frame. (default: false)
  142330. * @param textureType Type of textures used when performing the post process. (default: 0)
  142331. * @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)
  142332. */
  142333. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142334. }
  142335. }
  142336. declare module BABYLON {
  142337. /** @hidden */
  142338. export var circleOfConfusionPixelShader: {
  142339. name: string;
  142340. shader: string;
  142341. };
  142342. }
  142343. declare module BABYLON {
  142344. /**
  142345. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142346. */
  142347. export class CircleOfConfusionPostProcess extends PostProcess {
  142348. /**
  142349. * 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.
  142350. */
  142351. lensSize: number;
  142352. /**
  142353. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142354. */
  142355. fStop: number;
  142356. /**
  142357. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142358. */
  142359. focusDistance: number;
  142360. /**
  142361. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142362. */
  142363. focalLength: number;
  142364. private _depthTexture;
  142365. /**
  142366. * Creates a new instance CircleOfConfusionPostProcess
  142367. * @param name The name of the effect.
  142368. * @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.
  142369. * @param options The required width/height ratio to downsize to before computing the render pass.
  142370. * @param camera The camera to apply the render pass to.
  142371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142372. * @param engine The engine which the post process will be applied. (default: current engine)
  142373. * @param reusable If the post process can be reused on the same frame. (default: false)
  142374. * @param textureType Type of textures used when performing the post process. (default: 0)
  142375. * @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)
  142376. */
  142377. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142378. /**
  142379. * 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.
  142380. */
  142381. set depthTexture(value: RenderTargetTexture);
  142382. }
  142383. }
  142384. declare module BABYLON {
  142385. /** @hidden */
  142386. export var colorCorrectionPixelShader: {
  142387. name: string;
  142388. shader: string;
  142389. };
  142390. }
  142391. declare module BABYLON {
  142392. /**
  142393. *
  142394. * This post-process allows the modification of rendered colors by using
  142395. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142396. *
  142397. * The object needs to be provided an url to a texture containing the color
  142398. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142399. * Use an image editing software to tweak the LUT to match your needs.
  142400. *
  142401. * For an example of a color LUT, see here:
  142402. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142403. * For explanations on color grading, see here:
  142404. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142405. *
  142406. */
  142407. export class ColorCorrectionPostProcess extends PostProcess {
  142408. private _colorTableTexture;
  142409. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142410. }
  142411. }
  142412. declare module BABYLON {
  142413. /** @hidden */
  142414. export var convolutionPixelShader: {
  142415. name: string;
  142416. shader: string;
  142417. };
  142418. }
  142419. declare module BABYLON {
  142420. /**
  142421. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142422. * input texture to perform effects such as edge detection or sharpening
  142423. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142424. */
  142425. export class ConvolutionPostProcess extends PostProcess {
  142426. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142427. kernel: number[];
  142428. /**
  142429. * Creates a new instance ConvolutionPostProcess
  142430. * @param name The name of the effect.
  142431. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142432. * @param options The required width/height ratio to downsize to before computing the render pass.
  142433. * @param camera The camera to apply the render pass to.
  142434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142435. * @param engine The engine which the post process will be applied. (default: current engine)
  142436. * @param reusable If the post process can be reused on the same frame. (default: false)
  142437. * @param textureType Type of textures used when performing the post process. (default: 0)
  142438. */
  142439. constructor(name: string,
  142440. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142441. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142442. /**
  142443. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142444. */
  142445. static EdgeDetect0Kernel: number[];
  142446. /**
  142447. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142448. */
  142449. static EdgeDetect1Kernel: number[];
  142450. /**
  142451. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142452. */
  142453. static EdgeDetect2Kernel: number[];
  142454. /**
  142455. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142456. */
  142457. static SharpenKernel: number[];
  142458. /**
  142459. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142460. */
  142461. static EmbossKernel: number[];
  142462. /**
  142463. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142464. */
  142465. static GaussianKernel: number[];
  142466. }
  142467. }
  142468. declare module BABYLON {
  142469. /**
  142470. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142471. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142472. * based on samples that have a large difference in distance than the center pixel.
  142473. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142474. */
  142475. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142476. direction: Vector2;
  142477. /**
  142478. * Creates a new instance CircleOfConfusionPostProcess
  142479. * @param name The name of the effect.
  142480. * @param scene The scene the effect belongs to.
  142481. * @param direction The direction the blur should be applied.
  142482. * @param kernel The size of the kernel used to blur.
  142483. * @param options The required width/height ratio to downsize to before computing the render pass.
  142484. * @param camera The camera to apply the render pass to.
  142485. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142486. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142488. * @param engine The engine which the post process will be applied. (default: current engine)
  142489. * @param reusable If the post process can be reused on the same frame. (default: false)
  142490. * @param textureType Type of textures used when performing the post process. (default: 0)
  142491. * @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)
  142492. */
  142493. 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);
  142494. }
  142495. }
  142496. declare module BABYLON {
  142497. /** @hidden */
  142498. export var depthOfFieldMergePixelShader: {
  142499. name: string;
  142500. shader: string;
  142501. };
  142502. }
  142503. declare module BABYLON {
  142504. /**
  142505. * Options to be set when merging outputs from the default pipeline.
  142506. */
  142507. export class DepthOfFieldMergePostProcessOptions {
  142508. /**
  142509. * The original image to merge on top of
  142510. */
  142511. originalFromInput: PostProcess;
  142512. /**
  142513. * Parameters to perform the merge of the depth of field effect
  142514. */
  142515. depthOfField?: {
  142516. circleOfConfusion: PostProcess;
  142517. blurSteps: Array<PostProcess>;
  142518. };
  142519. /**
  142520. * Parameters to perform the merge of bloom effect
  142521. */
  142522. bloom?: {
  142523. blurred: PostProcess;
  142524. weight: number;
  142525. };
  142526. }
  142527. /**
  142528. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142529. */
  142530. export class DepthOfFieldMergePostProcess extends PostProcess {
  142531. private blurSteps;
  142532. /**
  142533. * Creates a new instance of DepthOfFieldMergePostProcess
  142534. * @param name The name of the effect.
  142535. * @param originalFromInput Post process which's input will be used for the merge.
  142536. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142537. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142538. * @param options The required width/height ratio to downsize to before computing the render pass.
  142539. * @param camera The camera to apply the render pass to.
  142540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142541. * @param engine The engine which the post process will be applied. (default: current engine)
  142542. * @param reusable If the post process can be reused on the same frame. (default: false)
  142543. * @param textureType Type of textures used when performing the post process. (default: 0)
  142544. * @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)
  142545. */
  142546. 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);
  142547. /**
  142548. * Updates the effect with the current post process compile time values and recompiles the shader.
  142549. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142550. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142551. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142552. * @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
  142553. * @param onCompiled Called when the shader has been compiled.
  142554. * @param onError Called if there is an error when compiling a shader.
  142555. */
  142556. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142557. }
  142558. }
  142559. declare module BABYLON {
  142560. /**
  142561. * Specifies the level of max blur that should be applied when using the depth of field effect
  142562. */
  142563. export enum DepthOfFieldEffectBlurLevel {
  142564. /**
  142565. * Subtle blur
  142566. */
  142567. Low = 0,
  142568. /**
  142569. * Medium blur
  142570. */
  142571. Medium = 1,
  142572. /**
  142573. * Large blur
  142574. */
  142575. High = 2
  142576. }
  142577. /**
  142578. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142579. */
  142580. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142581. private _circleOfConfusion;
  142582. /**
  142583. * @hidden Internal, blurs from high to low
  142584. */
  142585. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142586. private _depthOfFieldBlurY;
  142587. private _dofMerge;
  142588. /**
  142589. * @hidden Internal post processes in depth of field effect
  142590. */
  142591. _effects: Array<PostProcess>;
  142592. /**
  142593. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142594. */
  142595. set focalLength(value: number);
  142596. get focalLength(): number;
  142597. /**
  142598. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142599. */
  142600. set fStop(value: number);
  142601. get fStop(): number;
  142602. /**
  142603. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142604. */
  142605. set focusDistance(value: number);
  142606. get focusDistance(): number;
  142607. /**
  142608. * 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.
  142609. */
  142610. set lensSize(value: number);
  142611. get lensSize(): number;
  142612. /**
  142613. * Creates a new instance DepthOfFieldEffect
  142614. * @param scene The scene the effect belongs to.
  142615. * @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.
  142616. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142617. * @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)
  142618. */
  142619. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142620. /**
  142621. * Get the current class name of the current effet
  142622. * @returns "DepthOfFieldEffect"
  142623. */
  142624. getClassName(): string;
  142625. /**
  142626. * 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.
  142627. */
  142628. set depthTexture(value: RenderTargetTexture);
  142629. /**
  142630. * Disposes each of the internal effects for a given camera.
  142631. * @param camera The camera to dispose the effect on.
  142632. */
  142633. disposeEffects(camera: Camera): void;
  142634. /**
  142635. * @hidden Internal
  142636. */
  142637. _updateEffects(): void;
  142638. /**
  142639. * Internal
  142640. * @returns if all the contained post processes are ready.
  142641. * @hidden
  142642. */
  142643. _isReady(): boolean;
  142644. }
  142645. }
  142646. declare module BABYLON {
  142647. /** @hidden */
  142648. export var displayPassPixelShader: {
  142649. name: string;
  142650. shader: string;
  142651. };
  142652. }
  142653. declare module BABYLON {
  142654. /**
  142655. * DisplayPassPostProcess which produces an output the same as it's input
  142656. */
  142657. export class DisplayPassPostProcess extends PostProcess {
  142658. /**
  142659. * Creates the DisplayPassPostProcess
  142660. * @param name The name of the effect.
  142661. * @param options The required width/height ratio to downsize to before computing the render pass.
  142662. * @param camera The camera to apply the render pass to.
  142663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142664. * @param engine The engine which the post process will be applied. (default: current engine)
  142665. * @param reusable If the post process can be reused on the same frame. (default: false)
  142666. */
  142667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142668. }
  142669. }
  142670. declare module BABYLON {
  142671. /** @hidden */
  142672. export var filterPixelShader: {
  142673. name: string;
  142674. shader: string;
  142675. };
  142676. }
  142677. declare module BABYLON {
  142678. /**
  142679. * Applies a kernel filter to the image
  142680. */
  142681. export class FilterPostProcess extends PostProcess {
  142682. /** The matrix to be applied to the image */
  142683. kernelMatrix: Matrix;
  142684. /**
  142685. *
  142686. * @param name The name of the effect.
  142687. * @param kernelMatrix The matrix to be applied to the image
  142688. * @param options The required width/height ratio to downsize to before computing the render pass.
  142689. * @param camera The camera to apply the render pass to.
  142690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142691. * @param engine The engine which the post process will be applied. (default: current engine)
  142692. * @param reusable If the post process can be reused on the same frame. (default: false)
  142693. */
  142694. constructor(name: string,
  142695. /** The matrix to be applied to the image */
  142696. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142697. }
  142698. }
  142699. declare module BABYLON {
  142700. /** @hidden */
  142701. export var fxaaPixelShader: {
  142702. name: string;
  142703. shader: string;
  142704. };
  142705. }
  142706. declare module BABYLON {
  142707. /** @hidden */
  142708. export var fxaaVertexShader: {
  142709. name: string;
  142710. shader: string;
  142711. };
  142712. }
  142713. declare module BABYLON {
  142714. /**
  142715. * Fxaa post process
  142716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142717. */
  142718. export class FxaaPostProcess extends PostProcess {
  142719. /** @hidden */
  142720. texelWidth: number;
  142721. /** @hidden */
  142722. texelHeight: number;
  142723. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142724. private _getDefines;
  142725. }
  142726. }
  142727. declare module BABYLON {
  142728. /** @hidden */
  142729. export var grainPixelShader: {
  142730. name: string;
  142731. shader: string;
  142732. };
  142733. }
  142734. declare module BABYLON {
  142735. /**
  142736. * The GrainPostProcess adds noise to the image at mid luminance levels
  142737. */
  142738. export class GrainPostProcess extends PostProcess {
  142739. /**
  142740. * The intensity of the grain added (default: 30)
  142741. */
  142742. intensity: number;
  142743. /**
  142744. * If the grain should be randomized on every frame
  142745. */
  142746. animated: boolean;
  142747. /**
  142748. * Creates a new instance of @see GrainPostProcess
  142749. * @param name The name of the effect.
  142750. * @param options The required width/height ratio to downsize to before computing the render pass.
  142751. * @param camera The camera to apply the render pass to.
  142752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142753. * @param engine The engine which the post process will be applied. (default: current engine)
  142754. * @param reusable If the post process can be reused on the same frame. (default: false)
  142755. * @param textureType Type of textures used when performing the post process. (default: 0)
  142756. * @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)
  142757. */
  142758. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142759. }
  142760. }
  142761. declare module BABYLON {
  142762. /** @hidden */
  142763. export var highlightsPixelShader: {
  142764. name: string;
  142765. shader: string;
  142766. };
  142767. }
  142768. declare module BABYLON {
  142769. /**
  142770. * Extracts highlights from the image
  142771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142772. */
  142773. export class HighlightsPostProcess extends PostProcess {
  142774. /**
  142775. * Extracts highlights from the image
  142776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142777. * @param name The name of the effect.
  142778. * @param options The required width/height ratio to downsize to before computing the render pass.
  142779. * @param camera The camera to apply the render pass to.
  142780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142781. * @param engine The engine which the post process will be applied. (default: current engine)
  142782. * @param reusable If the post process can be reused on the same frame. (default: false)
  142783. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142784. */
  142785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142786. }
  142787. }
  142788. declare module BABYLON {
  142789. /** @hidden */
  142790. export var mrtFragmentDeclaration: {
  142791. name: string;
  142792. shader: string;
  142793. };
  142794. }
  142795. declare module BABYLON {
  142796. /** @hidden */
  142797. export var geometryPixelShader: {
  142798. name: string;
  142799. shader: string;
  142800. };
  142801. }
  142802. declare module BABYLON {
  142803. /** @hidden */
  142804. export var geometryVertexShader: {
  142805. name: string;
  142806. shader: string;
  142807. };
  142808. }
  142809. declare module BABYLON {
  142810. /** @hidden */
  142811. interface ISavedTransformationMatrix {
  142812. world: Matrix;
  142813. viewProjection: Matrix;
  142814. }
  142815. /**
  142816. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142817. */
  142818. export class GeometryBufferRenderer {
  142819. /**
  142820. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142821. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142822. */
  142823. static readonly POSITION_TEXTURE_TYPE: number;
  142824. /**
  142825. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142826. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142827. */
  142828. static readonly VELOCITY_TEXTURE_TYPE: number;
  142829. /**
  142830. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142831. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142832. */
  142833. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142834. /**
  142835. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142836. * in order to compute objects velocities when enableVelocity is set to "true"
  142837. * @hidden
  142838. */
  142839. _previousTransformationMatrices: {
  142840. [index: number]: ISavedTransformationMatrix;
  142841. };
  142842. /**
  142843. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142844. * in order to compute objects velocities when enableVelocity is set to "true"
  142845. * @hidden
  142846. */
  142847. _previousBonesTransformationMatrices: {
  142848. [index: number]: Float32Array;
  142849. };
  142850. /**
  142851. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142852. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142853. */
  142854. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142855. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142856. renderTransparentMeshes: boolean;
  142857. private _scene;
  142858. private _multiRenderTarget;
  142859. private _ratio;
  142860. private _enablePosition;
  142861. private _enableVelocity;
  142862. private _enableReflectivity;
  142863. private _positionIndex;
  142864. private _velocityIndex;
  142865. private _reflectivityIndex;
  142866. protected _effect: Effect;
  142867. protected _cachedDefines: string;
  142868. /**
  142869. * Set the render list (meshes to be rendered) used in the G buffer.
  142870. */
  142871. set renderList(meshes: Mesh[]);
  142872. /**
  142873. * Gets wether or not G buffer are supported by the running hardware.
  142874. * This requires draw buffer supports
  142875. */
  142876. get isSupported(): boolean;
  142877. /**
  142878. * Returns the index of the given texture type in the G-Buffer textures array
  142879. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  142880. * @returns the index of the given texture type in the G-Buffer textures array
  142881. */
  142882. getTextureIndex(textureType: number): number;
  142883. /**
  142884. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  142885. */
  142886. get enablePosition(): boolean;
  142887. /**
  142888. * Sets whether or not objects positions are enabled for the G buffer.
  142889. */
  142890. set enablePosition(enable: boolean);
  142891. /**
  142892. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  142893. */
  142894. get enableVelocity(): boolean;
  142895. /**
  142896. * Sets wether or not objects velocities are enabled for the G buffer.
  142897. */
  142898. set enableVelocity(enable: boolean);
  142899. /**
  142900. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  142901. */
  142902. get enableReflectivity(): boolean;
  142903. /**
  142904. * Sets wether or not objects roughness are enabled for the G buffer.
  142905. */
  142906. set enableReflectivity(enable: boolean);
  142907. /**
  142908. * Gets the scene associated with the buffer.
  142909. */
  142910. get scene(): Scene;
  142911. /**
  142912. * Gets the ratio used by the buffer during its creation.
  142913. * How big is the buffer related to the main canvas.
  142914. */
  142915. get ratio(): number;
  142916. /** @hidden */
  142917. static _SceneComponentInitialization: (scene: Scene) => void;
  142918. /**
  142919. * Creates a new G Buffer for the scene
  142920. * @param scene The scene the buffer belongs to
  142921. * @param ratio How big is the buffer related to the main canvas.
  142922. */
  142923. constructor(scene: Scene, ratio?: number);
  142924. /**
  142925. * Checks wether everything is ready to render a submesh to the G buffer.
  142926. * @param subMesh the submesh to check readiness for
  142927. * @param useInstances is the mesh drawn using instance or not
  142928. * @returns true if ready otherwise false
  142929. */
  142930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142931. /**
  142932. * Gets the current underlying G Buffer.
  142933. * @returns the buffer
  142934. */
  142935. getGBuffer(): MultiRenderTarget;
  142936. /**
  142937. * Gets the number of samples used to render the buffer (anti aliasing).
  142938. */
  142939. get samples(): number;
  142940. /**
  142941. * Sets the number of samples used to render the buffer (anti aliasing).
  142942. */
  142943. set samples(value: number);
  142944. /**
  142945. * Disposes the renderer and frees up associated resources.
  142946. */
  142947. dispose(): void;
  142948. protected _createRenderTargets(): void;
  142949. private _copyBonesTransformationMatrices;
  142950. }
  142951. }
  142952. declare module BABYLON {
  142953. interface Scene {
  142954. /** @hidden (Backing field) */
  142955. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142956. /**
  142957. * Gets or Sets the current geometry buffer associated to the scene.
  142958. */
  142959. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142960. /**
  142961. * Enables a GeometryBufferRender and associates it with the scene
  142962. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  142963. * @returns the GeometryBufferRenderer
  142964. */
  142965. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  142966. /**
  142967. * Disables the GeometryBufferRender associated with the scene
  142968. */
  142969. disableGeometryBufferRenderer(): void;
  142970. }
  142971. /**
  142972. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  142973. * in several rendering techniques.
  142974. */
  142975. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  142976. /**
  142977. * The component name helpful to identify the component in the list of scene components.
  142978. */
  142979. readonly name: string;
  142980. /**
  142981. * The scene the component belongs to.
  142982. */
  142983. scene: Scene;
  142984. /**
  142985. * Creates a new instance of the component for the given scene
  142986. * @param scene Defines the scene to register the component in
  142987. */
  142988. constructor(scene: Scene);
  142989. /**
  142990. * Registers the component in a given scene
  142991. */
  142992. register(): void;
  142993. /**
  142994. * Rebuilds the elements related to this component in case of
  142995. * context lost for instance.
  142996. */
  142997. rebuild(): void;
  142998. /**
  142999. * Disposes the component and the associated ressources
  143000. */
  143001. dispose(): void;
  143002. private _gatherRenderTargets;
  143003. }
  143004. }
  143005. declare module BABYLON {
  143006. /** @hidden */
  143007. export var motionBlurPixelShader: {
  143008. name: string;
  143009. shader: string;
  143010. };
  143011. }
  143012. declare module BABYLON {
  143013. /**
  143014. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  143015. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  143016. * As an example, all you have to do is to create the post-process:
  143017. * var mb = new BABYLON.MotionBlurPostProcess(
  143018. * 'mb', // The name of the effect.
  143019. * scene, // The scene containing the objects to blur according to their velocity.
  143020. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  143021. * camera // The camera to apply the render pass to.
  143022. * );
  143023. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  143024. */
  143025. export class MotionBlurPostProcess extends PostProcess {
  143026. /**
  143027. * Defines how much the image is blurred by the movement. Default value is equal to 1
  143028. */
  143029. motionStrength: number;
  143030. /**
  143031. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  143032. */
  143033. get motionBlurSamples(): number;
  143034. /**
  143035. * Sets the number of iterations to be used for motion blur quality
  143036. */
  143037. set motionBlurSamples(samples: number);
  143038. private _motionBlurSamples;
  143039. private _geometryBufferRenderer;
  143040. /**
  143041. * Creates a new instance MotionBlurPostProcess
  143042. * @param name The name of the effect.
  143043. * @param scene The scene containing the objects to blur according to their velocity.
  143044. * @param options The required width/height ratio to downsize to before computing the render pass.
  143045. * @param camera The camera to apply the render pass to.
  143046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143047. * @param engine The engine which the post process will be applied. (default: current engine)
  143048. * @param reusable If the post process can be reused on the same frame. (default: false)
  143049. * @param textureType Type of textures used when performing the post process. (default: 0)
  143050. * @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)
  143051. */
  143052. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143053. /**
  143054. * Excludes the given skinned mesh from computing bones velocities.
  143055. * 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.
  143056. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  143057. */
  143058. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143059. /**
  143060. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  143061. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  143062. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  143063. */
  143064. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  143065. /**
  143066. * Disposes the post process.
  143067. * @param camera The camera to dispose the post process on.
  143068. */
  143069. dispose(camera?: Camera): void;
  143070. }
  143071. }
  143072. declare module BABYLON {
  143073. /** @hidden */
  143074. export var refractionPixelShader: {
  143075. name: string;
  143076. shader: string;
  143077. };
  143078. }
  143079. declare module BABYLON {
  143080. /**
  143081. * Post process which applies a refractin texture
  143082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143083. */
  143084. export class RefractionPostProcess extends PostProcess {
  143085. /** the base color of the refraction (used to taint the rendering) */
  143086. color: Color3;
  143087. /** simulated refraction depth */
  143088. depth: number;
  143089. /** the coefficient of the base color (0 to remove base color tainting) */
  143090. colorLevel: number;
  143091. private _refTexture;
  143092. private _ownRefractionTexture;
  143093. /**
  143094. * Gets or sets the refraction texture
  143095. * Please note that you are responsible for disposing the texture if you set it manually
  143096. */
  143097. get refractionTexture(): Texture;
  143098. set refractionTexture(value: Texture);
  143099. /**
  143100. * Initializes the RefractionPostProcess
  143101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  143102. * @param name The name of the effect.
  143103. * @param refractionTextureUrl Url of the refraction texture to use
  143104. * @param color the base color of the refraction (used to taint the rendering)
  143105. * @param depth simulated refraction depth
  143106. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  143107. * @param camera The camera to apply the render pass to.
  143108. * @param options The required width/height ratio to downsize to before computing the render pass.
  143109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143110. * @param engine The engine which the post process will be applied. (default: current engine)
  143111. * @param reusable If the post process can be reused on the same frame. (default: false)
  143112. */
  143113. constructor(name: string, refractionTextureUrl: string,
  143114. /** the base color of the refraction (used to taint the rendering) */
  143115. color: Color3,
  143116. /** simulated refraction depth */
  143117. depth: number,
  143118. /** the coefficient of the base color (0 to remove base color tainting) */
  143119. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143120. /**
  143121. * Disposes of the post process
  143122. * @param camera Camera to dispose post process on
  143123. */
  143124. dispose(camera: Camera): void;
  143125. }
  143126. }
  143127. declare module BABYLON {
  143128. /** @hidden */
  143129. export var sharpenPixelShader: {
  143130. name: string;
  143131. shader: string;
  143132. };
  143133. }
  143134. declare module BABYLON {
  143135. /**
  143136. * The SharpenPostProcess applies a sharpen kernel to every pixel
  143137. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  143138. */
  143139. export class SharpenPostProcess extends PostProcess {
  143140. /**
  143141. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  143142. */
  143143. colorAmount: number;
  143144. /**
  143145. * How much sharpness should be applied (default: 0.3)
  143146. */
  143147. edgeAmount: number;
  143148. /**
  143149. * Creates a new instance ConvolutionPostProcess
  143150. * @param name The name of the effect.
  143151. * @param options The required width/height ratio to downsize to before computing the render pass.
  143152. * @param camera The camera to apply the render pass to.
  143153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143154. * @param engine The engine which the post process will be applied. (default: current engine)
  143155. * @param reusable If the post process can be reused on the same frame. (default: false)
  143156. * @param textureType Type of textures used when performing the post process. (default: 0)
  143157. * @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)
  143158. */
  143159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143160. }
  143161. }
  143162. declare module BABYLON {
  143163. /**
  143164. * PostProcessRenderPipeline
  143165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143166. */
  143167. export class PostProcessRenderPipeline {
  143168. private engine;
  143169. private _renderEffects;
  143170. private _renderEffectsForIsolatedPass;
  143171. /**
  143172. * List of inspectable custom properties (used by the Inspector)
  143173. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  143174. */
  143175. inspectableCustomProperties: IInspectable[];
  143176. /**
  143177. * @hidden
  143178. */
  143179. protected _cameras: Camera[];
  143180. /** @hidden */
  143181. _name: string;
  143182. /**
  143183. * Gets pipeline name
  143184. */
  143185. get name(): string;
  143186. /** Gets the list of attached cameras */
  143187. get cameras(): Camera[];
  143188. /**
  143189. * Initializes a PostProcessRenderPipeline
  143190. * @param engine engine to add the pipeline to
  143191. * @param name name of the pipeline
  143192. */
  143193. constructor(engine: Engine, name: string);
  143194. /**
  143195. * Gets the class name
  143196. * @returns "PostProcessRenderPipeline"
  143197. */
  143198. getClassName(): string;
  143199. /**
  143200. * If all the render effects in the pipeline are supported
  143201. */
  143202. get isSupported(): boolean;
  143203. /**
  143204. * Adds an effect to the pipeline
  143205. * @param renderEffect the effect to add
  143206. */
  143207. addEffect(renderEffect: PostProcessRenderEffect): void;
  143208. /** @hidden */
  143209. _rebuild(): void;
  143210. /** @hidden */
  143211. _enableEffect(renderEffectName: string, cameras: Camera): void;
  143212. /** @hidden */
  143213. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  143214. /** @hidden */
  143215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143216. /** @hidden */
  143217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  143218. /** @hidden */
  143219. _attachCameras(cameras: Camera, unique: boolean): void;
  143220. /** @hidden */
  143221. _attachCameras(cameras: Camera[], unique: boolean): void;
  143222. /** @hidden */
  143223. _detachCameras(cameras: Camera): void;
  143224. /** @hidden */
  143225. _detachCameras(cameras: Nullable<Camera[]>): void;
  143226. /** @hidden */
  143227. _update(): void;
  143228. /** @hidden */
  143229. _reset(): void;
  143230. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  143231. /**
  143232. * Disposes of the pipeline
  143233. */
  143234. dispose(): void;
  143235. }
  143236. }
  143237. declare module BABYLON {
  143238. /**
  143239. * PostProcessRenderPipelineManager class
  143240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143241. */
  143242. export class PostProcessRenderPipelineManager {
  143243. private _renderPipelines;
  143244. /**
  143245. * Initializes a PostProcessRenderPipelineManager
  143246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143247. */
  143248. constructor();
  143249. /**
  143250. * Gets the list of supported render pipelines
  143251. */
  143252. get supportedPipelines(): PostProcessRenderPipeline[];
  143253. /**
  143254. * Adds a pipeline to the manager
  143255. * @param renderPipeline The pipeline to add
  143256. */
  143257. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  143258. /**
  143259. * Attaches a camera to the pipeline
  143260. * @param renderPipelineName The name of the pipeline to attach to
  143261. * @param cameras the camera to attach
  143262. * @param unique if the camera can be attached multiple times to the pipeline
  143263. */
  143264. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  143265. /**
  143266. * Detaches a camera from the pipeline
  143267. * @param renderPipelineName The name of the pipeline to detach from
  143268. * @param cameras the camera to detach
  143269. */
  143270. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  143271. /**
  143272. * Enables an effect by name on a pipeline
  143273. * @param renderPipelineName the name of the pipeline to enable the effect in
  143274. * @param renderEffectName the name of the effect to enable
  143275. * @param cameras the cameras that the effect should be enabled on
  143276. */
  143277. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143278. /**
  143279. * Disables an effect by name on a pipeline
  143280. * @param renderPipelineName the name of the pipeline to disable the effect in
  143281. * @param renderEffectName the name of the effect to disable
  143282. * @param cameras the cameras that the effect should be disabled on
  143283. */
  143284. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  143285. /**
  143286. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  143287. */
  143288. update(): void;
  143289. /** @hidden */
  143290. _rebuild(): void;
  143291. /**
  143292. * Disposes of the manager and pipelines
  143293. */
  143294. dispose(): void;
  143295. }
  143296. }
  143297. declare module BABYLON {
  143298. interface Scene {
  143299. /** @hidden (Backing field) */
  143300. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143301. /**
  143302. * Gets the postprocess render pipeline manager
  143303. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143304. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143305. */
  143306. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  143307. }
  143308. /**
  143309. * Defines the Render Pipeline scene component responsible to rendering pipelines
  143310. */
  143311. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  143312. /**
  143313. * The component name helpfull to identify the component in the list of scene components.
  143314. */
  143315. readonly name: string;
  143316. /**
  143317. * The scene the component belongs to.
  143318. */
  143319. scene: Scene;
  143320. /**
  143321. * Creates a new instance of the component for the given scene
  143322. * @param scene Defines the scene to register the component in
  143323. */
  143324. constructor(scene: Scene);
  143325. /**
  143326. * Registers the component in a given scene
  143327. */
  143328. register(): void;
  143329. /**
  143330. * Rebuilds the elements related to this component in case of
  143331. * context lost for instance.
  143332. */
  143333. rebuild(): void;
  143334. /**
  143335. * Disposes the component and the associated ressources
  143336. */
  143337. dispose(): void;
  143338. private _gatherRenderTargets;
  143339. }
  143340. }
  143341. declare module BABYLON {
  143342. /**
  143343. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143344. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143345. */
  143346. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143347. private _scene;
  143348. private _camerasToBeAttached;
  143349. /**
  143350. * ID of the sharpen post process,
  143351. */
  143352. private readonly SharpenPostProcessId;
  143353. /**
  143354. * @ignore
  143355. * ID of the image processing post process;
  143356. */
  143357. readonly ImageProcessingPostProcessId: string;
  143358. /**
  143359. * @ignore
  143360. * ID of the Fast Approximate Anti-Aliasing post process;
  143361. */
  143362. readonly FxaaPostProcessId: string;
  143363. /**
  143364. * ID of the chromatic aberration post process,
  143365. */
  143366. private readonly ChromaticAberrationPostProcessId;
  143367. /**
  143368. * ID of the grain post process
  143369. */
  143370. private readonly GrainPostProcessId;
  143371. /**
  143372. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143373. */
  143374. sharpen: SharpenPostProcess;
  143375. private _sharpenEffect;
  143376. private bloom;
  143377. /**
  143378. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143379. */
  143380. depthOfField: DepthOfFieldEffect;
  143381. /**
  143382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143383. */
  143384. fxaa: FxaaPostProcess;
  143385. /**
  143386. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143387. */
  143388. imageProcessing: ImageProcessingPostProcess;
  143389. /**
  143390. * Chromatic aberration post process which will shift rgb colors in the image
  143391. */
  143392. chromaticAberration: ChromaticAberrationPostProcess;
  143393. private _chromaticAberrationEffect;
  143394. /**
  143395. * Grain post process which add noise to the image
  143396. */
  143397. grain: GrainPostProcess;
  143398. private _grainEffect;
  143399. /**
  143400. * Glow post process which adds a glow to emissive areas of the image
  143401. */
  143402. private _glowLayer;
  143403. /**
  143404. * Animations which can be used to tweak settings over a period of time
  143405. */
  143406. animations: Animation[];
  143407. private _imageProcessingConfigurationObserver;
  143408. private _sharpenEnabled;
  143409. private _bloomEnabled;
  143410. private _depthOfFieldEnabled;
  143411. private _depthOfFieldBlurLevel;
  143412. private _fxaaEnabled;
  143413. private _imageProcessingEnabled;
  143414. private _defaultPipelineTextureType;
  143415. private _bloomScale;
  143416. private _chromaticAberrationEnabled;
  143417. private _grainEnabled;
  143418. private _buildAllowed;
  143419. /**
  143420. * Gets active scene
  143421. */
  143422. get scene(): Scene;
  143423. /**
  143424. * Enable or disable the sharpen process from the pipeline
  143425. */
  143426. set sharpenEnabled(enabled: boolean);
  143427. get sharpenEnabled(): boolean;
  143428. private _resizeObserver;
  143429. private _hardwareScaleLevel;
  143430. private _bloomKernel;
  143431. /**
  143432. * Specifies the size of the bloom blur kernel, relative to the final output size
  143433. */
  143434. get bloomKernel(): number;
  143435. set bloomKernel(value: number);
  143436. /**
  143437. * Specifies the weight of the bloom in the final rendering
  143438. */
  143439. private _bloomWeight;
  143440. /**
  143441. * Specifies the luma threshold for the area that will be blurred by the bloom
  143442. */
  143443. private _bloomThreshold;
  143444. private _hdr;
  143445. /**
  143446. * The strength of the bloom.
  143447. */
  143448. set bloomWeight(value: number);
  143449. get bloomWeight(): number;
  143450. /**
  143451. * The strength of the bloom.
  143452. */
  143453. set bloomThreshold(value: number);
  143454. get bloomThreshold(): number;
  143455. /**
  143456. * The scale of the bloom, lower value will provide better performance.
  143457. */
  143458. set bloomScale(value: number);
  143459. get bloomScale(): number;
  143460. /**
  143461. * Enable or disable the bloom from the pipeline
  143462. */
  143463. set bloomEnabled(enabled: boolean);
  143464. get bloomEnabled(): boolean;
  143465. private _rebuildBloom;
  143466. /**
  143467. * If the depth of field is enabled.
  143468. */
  143469. get depthOfFieldEnabled(): boolean;
  143470. set depthOfFieldEnabled(enabled: boolean);
  143471. /**
  143472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143473. */
  143474. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143475. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143476. /**
  143477. * If the anti aliasing is enabled.
  143478. */
  143479. set fxaaEnabled(enabled: boolean);
  143480. get fxaaEnabled(): boolean;
  143481. private _samples;
  143482. /**
  143483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143484. */
  143485. set samples(sampleCount: number);
  143486. get samples(): number;
  143487. /**
  143488. * If image processing is enabled.
  143489. */
  143490. set imageProcessingEnabled(enabled: boolean);
  143491. get imageProcessingEnabled(): boolean;
  143492. /**
  143493. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143494. */
  143495. set glowLayerEnabled(enabled: boolean);
  143496. get glowLayerEnabled(): boolean;
  143497. /**
  143498. * Gets the glow layer (or null if not defined)
  143499. */
  143500. get glowLayer(): Nullable<GlowLayer>;
  143501. /**
  143502. * Enable or disable the chromaticAberration process from the pipeline
  143503. */
  143504. set chromaticAberrationEnabled(enabled: boolean);
  143505. get chromaticAberrationEnabled(): boolean;
  143506. /**
  143507. * Enable or disable the grain process from the pipeline
  143508. */
  143509. set grainEnabled(enabled: boolean);
  143510. get grainEnabled(): boolean;
  143511. /**
  143512. * @constructor
  143513. * @param name - The rendering pipeline name (default: "")
  143514. * @param hdr - If high dynamic range textures should be used (default: true)
  143515. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143516. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143517. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143518. */
  143519. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143520. /**
  143521. * Get the class name
  143522. * @returns "DefaultRenderingPipeline"
  143523. */
  143524. getClassName(): string;
  143525. /**
  143526. * Force the compilation of the entire pipeline.
  143527. */
  143528. prepare(): void;
  143529. private _hasCleared;
  143530. private _prevPostProcess;
  143531. private _prevPrevPostProcess;
  143532. private _setAutoClearAndTextureSharing;
  143533. private _depthOfFieldSceneObserver;
  143534. private _buildPipeline;
  143535. private _disposePostProcesses;
  143536. /**
  143537. * Adds a camera to the pipeline
  143538. * @param camera the camera to be added
  143539. */
  143540. addCamera(camera: Camera): void;
  143541. /**
  143542. * Removes a camera from the pipeline
  143543. * @param camera the camera to remove
  143544. */
  143545. removeCamera(camera: Camera): void;
  143546. /**
  143547. * Dispose of the pipeline and stop all post processes
  143548. */
  143549. dispose(): void;
  143550. /**
  143551. * Serialize the rendering pipeline (Used when exporting)
  143552. * @returns the serialized object
  143553. */
  143554. serialize(): any;
  143555. /**
  143556. * Parse the serialized pipeline
  143557. * @param source Source pipeline.
  143558. * @param scene The scene to load the pipeline to.
  143559. * @param rootUrl The URL of the serialized pipeline.
  143560. * @returns An instantiated pipeline from the serialized object.
  143561. */
  143562. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143563. }
  143564. }
  143565. declare module BABYLON {
  143566. /** @hidden */
  143567. export var lensHighlightsPixelShader: {
  143568. name: string;
  143569. shader: string;
  143570. };
  143571. }
  143572. declare module BABYLON {
  143573. /** @hidden */
  143574. export var depthOfFieldPixelShader: {
  143575. name: string;
  143576. shader: string;
  143577. };
  143578. }
  143579. declare module BABYLON {
  143580. /**
  143581. * BABYLON.JS Chromatic Aberration GLSL Shader
  143582. * Author: Olivier Guyot
  143583. * Separates very slightly R, G and B colors on the edges of the screen
  143584. * Inspired by Francois Tarlier & Martins Upitis
  143585. */
  143586. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143587. /**
  143588. * @ignore
  143589. * The chromatic aberration PostProcess id in the pipeline
  143590. */
  143591. LensChromaticAberrationEffect: string;
  143592. /**
  143593. * @ignore
  143594. * The highlights enhancing PostProcess id in the pipeline
  143595. */
  143596. HighlightsEnhancingEffect: string;
  143597. /**
  143598. * @ignore
  143599. * The depth-of-field PostProcess id in the pipeline
  143600. */
  143601. LensDepthOfFieldEffect: string;
  143602. private _scene;
  143603. private _depthTexture;
  143604. private _grainTexture;
  143605. private _chromaticAberrationPostProcess;
  143606. private _highlightsPostProcess;
  143607. private _depthOfFieldPostProcess;
  143608. private _edgeBlur;
  143609. private _grainAmount;
  143610. private _chromaticAberration;
  143611. private _distortion;
  143612. private _highlightsGain;
  143613. private _highlightsThreshold;
  143614. private _dofDistance;
  143615. private _dofAperture;
  143616. private _dofDarken;
  143617. private _dofPentagon;
  143618. private _blurNoise;
  143619. /**
  143620. * @constructor
  143621. *
  143622. * Effect parameters are as follow:
  143623. * {
  143624. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143625. * edge_blur: number; // from 0 to x (1 for realism)
  143626. * distortion: number; // from 0 to x (1 for realism)
  143627. * grain_amount: number; // from 0 to 1
  143628. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143629. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143630. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143631. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143632. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143633. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143634. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143635. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143636. * }
  143637. * Note: if an effect parameter is unset, effect is disabled
  143638. *
  143639. * @param name The rendering pipeline name
  143640. * @param parameters - An object containing all parameters (see above)
  143641. * @param scene The scene linked to this pipeline
  143642. * @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)
  143643. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143644. */
  143645. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143646. /**
  143647. * Get the class name
  143648. * @returns "LensRenderingPipeline"
  143649. */
  143650. getClassName(): string;
  143651. /**
  143652. * Gets associated scene
  143653. */
  143654. get scene(): Scene;
  143655. /**
  143656. * Gets or sets the edge blur
  143657. */
  143658. get edgeBlur(): number;
  143659. set edgeBlur(value: number);
  143660. /**
  143661. * Gets or sets the grain amount
  143662. */
  143663. get grainAmount(): number;
  143664. set grainAmount(value: number);
  143665. /**
  143666. * Gets or sets the chromatic aberration amount
  143667. */
  143668. get chromaticAberration(): number;
  143669. set chromaticAberration(value: number);
  143670. /**
  143671. * Gets or sets the depth of field aperture
  143672. */
  143673. get dofAperture(): number;
  143674. set dofAperture(value: number);
  143675. /**
  143676. * Gets or sets the edge distortion
  143677. */
  143678. get edgeDistortion(): number;
  143679. set edgeDistortion(value: number);
  143680. /**
  143681. * Gets or sets the depth of field distortion
  143682. */
  143683. get dofDistortion(): number;
  143684. set dofDistortion(value: number);
  143685. /**
  143686. * Gets or sets the darken out of focus amount
  143687. */
  143688. get darkenOutOfFocus(): number;
  143689. set darkenOutOfFocus(value: number);
  143690. /**
  143691. * Gets or sets a boolean indicating if blur noise is enabled
  143692. */
  143693. get blurNoise(): boolean;
  143694. set blurNoise(value: boolean);
  143695. /**
  143696. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143697. */
  143698. get pentagonBokeh(): boolean;
  143699. set pentagonBokeh(value: boolean);
  143700. /**
  143701. * Gets or sets the highlight grain amount
  143702. */
  143703. get highlightsGain(): number;
  143704. set highlightsGain(value: number);
  143705. /**
  143706. * Gets or sets the highlight threshold
  143707. */
  143708. get highlightsThreshold(): number;
  143709. set highlightsThreshold(value: number);
  143710. /**
  143711. * Sets the amount of blur at the edges
  143712. * @param amount blur amount
  143713. */
  143714. setEdgeBlur(amount: number): void;
  143715. /**
  143716. * Sets edge blur to 0
  143717. */
  143718. disableEdgeBlur(): void;
  143719. /**
  143720. * Sets the amout of grain
  143721. * @param amount Amount of grain
  143722. */
  143723. setGrainAmount(amount: number): void;
  143724. /**
  143725. * Set grain amount to 0
  143726. */
  143727. disableGrain(): void;
  143728. /**
  143729. * Sets the chromatic aberration amount
  143730. * @param amount amount of chromatic aberration
  143731. */
  143732. setChromaticAberration(amount: number): void;
  143733. /**
  143734. * Sets chromatic aberration amount to 0
  143735. */
  143736. disableChromaticAberration(): void;
  143737. /**
  143738. * Sets the EdgeDistortion amount
  143739. * @param amount amount of EdgeDistortion
  143740. */
  143741. setEdgeDistortion(amount: number): void;
  143742. /**
  143743. * Sets edge distortion to 0
  143744. */
  143745. disableEdgeDistortion(): void;
  143746. /**
  143747. * Sets the FocusDistance amount
  143748. * @param amount amount of FocusDistance
  143749. */
  143750. setFocusDistance(amount: number): void;
  143751. /**
  143752. * Disables depth of field
  143753. */
  143754. disableDepthOfField(): void;
  143755. /**
  143756. * Sets the Aperture amount
  143757. * @param amount amount of Aperture
  143758. */
  143759. setAperture(amount: number): void;
  143760. /**
  143761. * Sets the DarkenOutOfFocus amount
  143762. * @param amount amount of DarkenOutOfFocus
  143763. */
  143764. setDarkenOutOfFocus(amount: number): void;
  143765. private _pentagonBokehIsEnabled;
  143766. /**
  143767. * Creates a pentagon bokeh effect
  143768. */
  143769. enablePentagonBokeh(): void;
  143770. /**
  143771. * Disables the pentagon bokeh effect
  143772. */
  143773. disablePentagonBokeh(): void;
  143774. /**
  143775. * Enables noise blur
  143776. */
  143777. enableNoiseBlur(): void;
  143778. /**
  143779. * Disables noise blur
  143780. */
  143781. disableNoiseBlur(): void;
  143782. /**
  143783. * Sets the HighlightsGain amount
  143784. * @param amount amount of HighlightsGain
  143785. */
  143786. setHighlightsGain(amount: number): void;
  143787. /**
  143788. * Sets the HighlightsThreshold amount
  143789. * @param amount amount of HighlightsThreshold
  143790. */
  143791. setHighlightsThreshold(amount: number): void;
  143792. /**
  143793. * Disables highlights
  143794. */
  143795. disableHighlights(): void;
  143796. /**
  143797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143799. */
  143800. dispose(disableDepthRender?: boolean): void;
  143801. private _createChromaticAberrationPostProcess;
  143802. private _createHighlightsPostProcess;
  143803. private _createDepthOfFieldPostProcess;
  143804. private _createGrainTexture;
  143805. }
  143806. }
  143807. declare module BABYLON {
  143808. /** @hidden */
  143809. export var ssao2PixelShader: {
  143810. name: string;
  143811. shader: string;
  143812. };
  143813. }
  143814. declare module BABYLON {
  143815. /** @hidden */
  143816. export var ssaoCombinePixelShader: {
  143817. name: string;
  143818. shader: string;
  143819. };
  143820. }
  143821. declare module BABYLON {
  143822. /**
  143823. * Render pipeline to produce ssao effect
  143824. */
  143825. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143826. /**
  143827. * @ignore
  143828. * The PassPostProcess id in the pipeline that contains the original scene color
  143829. */
  143830. SSAOOriginalSceneColorEffect: string;
  143831. /**
  143832. * @ignore
  143833. * The SSAO PostProcess id in the pipeline
  143834. */
  143835. SSAORenderEffect: string;
  143836. /**
  143837. * @ignore
  143838. * The horizontal blur PostProcess id in the pipeline
  143839. */
  143840. SSAOBlurHRenderEffect: string;
  143841. /**
  143842. * @ignore
  143843. * The vertical blur PostProcess id in the pipeline
  143844. */
  143845. SSAOBlurVRenderEffect: string;
  143846. /**
  143847. * @ignore
  143848. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143849. */
  143850. SSAOCombineRenderEffect: string;
  143851. /**
  143852. * The output strength of the SSAO post-process. Default value is 1.0.
  143853. */
  143854. totalStrength: number;
  143855. /**
  143856. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143857. */
  143858. maxZ: number;
  143859. /**
  143860. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143861. */
  143862. minZAspect: number;
  143863. private _samples;
  143864. /**
  143865. * Number of samples used for the SSAO calculations. Default value is 8
  143866. */
  143867. set samples(n: number);
  143868. get samples(): number;
  143869. private _textureSamples;
  143870. /**
  143871. * Number of samples to use for antialiasing
  143872. */
  143873. set textureSamples(n: number);
  143874. get textureSamples(): number;
  143875. /**
  143876. * Ratio object used for SSAO ratio and blur ratio
  143877. */
  143878. private _ratio;
  143879. /**
  143880. * Dynamically generated sphere sampler.
  143881. */
  143882. private _sampleSphere;
  143883. /**
  143884. * Blur filter offsets
  143885. */
  143886. private _samplerOffsets;
  143887. private _expensiveBlur;
  143888. /**
  143889. * If bilateral blur should be used
  143890. */
  143891. set expensiveBlur(b: boolean);
  143892. get expensiveBlur(): boolean;
  143893. /**
  143894. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  143895. */
  143896. radius: number;
  143897. /**
  143898. * The base color of the SSAO post-process
  143899. * The final result is "base + ssao" between [0, 1]
  143900. */
  143901. base: number;
  143902. /**
  143903. * Support test.
  143904. */
  143905. static get IsSupported(): boolean;
  143906. private _scene;
  143907. private _depthTexture;
  143908. private _normalTexture;
  143909. private _randomTexture;
  143910. private _originalColorPostProcess;
  143911. private _ssaoPostProcess;
  143912. private _blurHPostProcess;
  143913. private _blurVPostProcess;
  143914. private _ssaoCombinePostProcess;
  143915. /**
  143916. * Gets active scene
  143917. */
  143918. get scene(): Scene;
  143919. /**
  143920. * @constructor
  143921. * @param name The rendering pipeline name
  143922. * @param scene The scene linked to this pipeline
  143923. * @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 }
  143924. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143925. */
  143926. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143927. /**
  143928. * Get the class name
  143929. * @returns "SSAO2RenderingPipeline"
  143930. */
  143931. getClassName(): string;
  143932. /**
  143933. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143934. */
  143935. dispose(disableGeometryBufferRenderer?: boolean): void;
  143936. private _createBlurPostProcess;
  143937. /** @hidden */
  143938. _rebuild(): void;
  143939. private _bits;
  143940. private _radicalInverse_VdC;
  143941. private _hammersley;
  143942. private _hemisphereSample_uniform;
  143943. private _generateHemisphere;
  143944. private _createSSAOPostProcess;
  143945. private _createSSAOCombinePostProcess;
  143946. private _createRandomTexture;
  143947. /**
  143948. * Serialize the rendering pipeline (Used when exporting)
  143949. * @returns the serialized object
  143950. */
  143951. serialize(): any;
  143952. /**
  143953. * Parse the serialized pipeline
  143954. * @param source Source pipeline.
  143955. * @param scene The scene to load the pipeline to.
  143956. * @param rootUrl The URL of the serialized pipeline.
  143957. * @returns An instantiated pipeline from the serialized object.
  143958. */
  143959. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  143960. }
  143961. }
  143962. declare module BABYLON {
  143963. /** @hidden */
  143964. export var ssaoPixelShader: {
  143965. name: string;
  143966. shader: string;
  143967. };
  143968. }
  143969. declare module BABYLON {
  143970. /**
  143971. * Render pipeline to produce ssao effect
  143972. */
  143973. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  143974. /**
  143975. * @ignore
  143976. * The PassPostProcess id in the pipeline that contains the original scene color
  143977. */
  143978. SSAOOriginalSceneColorEffect: string;
  143979. /**
  143980. * @ignore
  143981. * The SSAO PostProcess id in the pipeline
  143982. */
  143983. SSAORenderEffect: string;
  143984. /**
  143985. * @ignore
  143986. * The horizontal blur PostProcess id in the pipeline
  143987. */
  143988. SSAOBlurHRenderEffect: string;
  143989. /**
  143990. * @ignore
  143991. * The vertical blur PostProcess id in the pipeline
  143992. */
  143993. SSAOBlurVRenderEffect: string;
  143994. /**
  143995. * @ignore
  143996. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143997. */
  143998. SSAOCombineRenderEffect: string;
  143999. /**
  144000. * The output strength of the SSAO post-process. Default value is 1.0.
  144001. */
  144002. totalStrength: number;
  144003. /**
  144004. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  144005. */
  144006. radius: number;
  144007. /**
  144008. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  144009. * Must not be equal to fallOff and superior to fallOff.
  144010. * Default value is 0.0075
  144011. */
  144012. area: number;
  144013. /**
  144014. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  144015. * Must not be equal to area and inferior to area.
  144016. * Default value is 0.000001
  144017. */
  144018. fallOff: number;
  144019. /**
  144020. * The base color of the SSAO post-process
  144021. * The final result is "base + ssao" between [0, 1]
  144022. */
  144023. base: number;
  144024. private _scene;
  144025. private _depthTexture;
  144026. private _randomTexture;
  144027. private _originalColorPostProcess;
  144028. private _ssaoPostProcess;
  144029. private _blurHPostProcess;
  144030. private _blurVPostProcess;
  144031. private _ssaoCombinePostProcess;
  144032. private _firstUpdate;
  144033. /**
  144034. * Gets active scene
  144035. */
  144036. get scene(): Scene;
  144037. /**
  144038. * @constructor
  144039. * @param name - The rendering pipeline name
  144040. * @param scene - The scene linked to this pipeline
  144041. * @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 }
  144042. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  144043. */
  144044. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  144045. /**
  144046. * Get the class name
  144047. * @returns "SSAORenderingPipeline"
  144048. */
  144049. getClassName(): string;
  144050. /**
  144051. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  144052. */
  144053. dispose(disableDepthRender?: boolean): void;
  144054. private _createBlurPostProcess;
  144055. /** @hidden */
  144056. _rebuild(): void;
  144057. private _createSSAOPostProcess;
  144058. private _createSSAOCombinePostProcess;
  144059. private _createRandomTexture;
  144060. }
  144061. }
  144062. declare module BABYLON {
  144063. /** @hidden */
  144064. export var screenSpaceReflectionPixelShader: {
  144065. name: string;
  144066. shader: string;
  144067. };
  144068. }
  144069. declare module BABYLON {
  144070. /**
  144071. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  144072. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  144073. */
  144074. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  144075. /**
  144076. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  144077. */
  144078. threshold: number;
  144079. /**
  144080. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  144081. */
  144082. strength: number;
  144083. /**
  144084. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  144085. */
  144086. reflectionSpecularFalloffExponent: number;
  144087. /**
  144088. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  144089. */
  144090. step: number;
  144091. /**
  144092. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  144093. */
  144094. roughnessFactor: number;
  144095. private _geometryBufferRenderer;
  144096. private _enableSmoothReflections;
  144097. private _reflectionSamples;
  144098. private _smoothSteps;
  144099. /**
  144100. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  144101. * @param name The name of the effect.
  144102. * @param scene The scene containing the objects to calculate reflections.
  144103. * @param options The required width/height ratio to downsize to before computing the render pass.
  144104. * @param camera The camera to apply the render pass to.
  144105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144106. * @param engine The engine which the post process will be applied. (default: current engine)
  144107. * @param reusable If the post process can be reused on the same frame. (default: false)
  144108. * @param textureType Type of textures used when performing the post process. (default: 0)
  144109. * @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)
  144110. */
  144111. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144112. /**
  144113. * Gets wether or not smoothing reflections is enabled.
  144114. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144115. */
  144116. get enableSmoothReflections(): boolean;
  144117. /**
  144118. * Sets wether or not smoothing reflections is enabled.
  144119. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  144120. */
  144121. set enableSmoothReflections(enabled: boolean);
  144122. /**
  144123. * Gets the number of samples taken while computing reflections. More samples count is high,
  144124. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144125. */
  144126. get reflectionSamples(): number;
  144127. /**
  144128. * Sets the number of samples taken while computing reflections. More samples count is high,
  144129. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  144130. */
  144131. set reflectionSamples(samples: number);
  144132. /**
  144133. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  144134. * more the post-process will require GPU power and can generate a drop in FPS.
  144135. * Default value (5.0) work pretty well in all cases but can be adjusted.
  144136. */
  144137. get smoothSteps(): number;
  144138. set smoothSteps(steps: number);
  144139. private _updateEffectDefines;
  144140. }
  144141. }
  144142. declare module BABYLON {
  144143. /** @hidden */
  144144. export var standardPixelShader: {
  144145. name: string;
  144146. shader: string;
  144147. };
  144148. }
  144149. declare module BABYLON {
  144150. /**
  144151. * Standard rendering pipeline
  144152. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144153. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  144154. */
  144155. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  144156. /**
  144157. * Public members
  144158. */
  144159. /**
  144160. * Post-process which contains the original scene color before the pipeline applies all the effects
  144161. */
  144162. originalPostProcess: Nullable<PostProcess>;
  144163. /**
  144164. * Post-process used to down scale an image x4
  144165. */
  144166. downSampleX4PostProcess: Nullable<PostProcess>;
  144167. /**
  144168. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  144169. */
  144170. brightPassPostProcess: Nullable<PostProcess>;
  144171. /**
  144172. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  144173. */
  144174. blurHPostProcesses: PostProcess[];
  144175. /**
  144176. * Post-process array storing all the vertical blur post-processes used by the pipeline
  144177. */
  144178. blurVPostProcesses: PostProcess[];
  144179. /**
  144180. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  144181. */
  144182. textureAdderPostProcess: Nullable<PostProcess>;
  144183. /**
  144184. * Post-process used to create volumetric lighting effect
  144185. */
  144186. volumetricLightPostProcess: Nullable<PostProcess>;
  144187. /**
  144188. * Post-process used to smooth the previous volumetric light post-process on the X axis
  144189. */
  144190. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  144191. /**
  144192. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  144193. */
  144194. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  144195. /**
  144196. * Post-process used to merge the volumetric light effect and the real scene color
  144197. */
  144198. volumetricLightMergePostProces: Nullable<PostProcess>;
  144199. /**
  144200. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  144201. */
  144202. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  144203. /**
  144204. * Base post-process used to calculate the average luminance of the final image for HDR
  144205. */
  144206. luminancePostProcess: Nullable<PostProcess>;
  144207. /**
  144208. * Post-processes used to create down sample post-processes in order to get
  144209. * the average luminance of the final image for HDR
  144210. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  144211. */
  144212. luminanceDownSamplePostProcesses: PostProcess[];
  144213. /**
  144214. * Post-process used to create a HDR effect (light adaptation)
  144215. */
  144216. hdrPostProcess: Nullable<PostProcess>;
  144217. /**
  144218. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  144219. */
  144220. textureAdderFinalPostProcess: Nullable<PostProcess>;
  144221. /**
  144222. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  144223. */
  144224. lensFlareFinalPostProcess: Nullable<PostProcess>;
  144225. /**
  144226. * Post-process used to merge the final HDR post-process and the real scene color
  144227. */
  144228. hdrFinalPostProcess: Nullable<PostProcess>;
  144229. /**
  144230. * Post-process used to create a lens flare effect
  144231. */
  144232. lensFlarePostProcess: Nullable<PostProcess>;
  144233. /**
  144234. * Post-process that merges the result of the lens flare post-process and the real scene color
  144235. */
  144236. lensFlareComposePostProcess: Nullable<PostProcess>;
  144237. /**
  144238. * Post-process used to create a motion blur effect
  144239. */
  144240. motionBlurPostProcess: Nullable<PostProcess>;
  144241. /**
  144242. * Post-process used to create a depth of field effect
  144243. */
  144244. depthOfFieldPostProcess: Nullable<PostProcess>;
  144245. /**
  144246. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  144247. */
  144248. fxaaPostProcess: Nullable<FxaaPostProcess>;
  144249. /**
  144250. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  144251. */
  144252. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  144253. /**
  144254. * Represents the brightness threshold in order to configure the illuminated surfaces
  144255. */
  144256. brightThreshold: number;
  144257. /**
  144258. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  144259. */
  144260. blurWidth: number;
  144261. /**
  144262. * Sets if the blur for highlighted surfaces must be only horizontal
  144263. */
  144264. horizontalBlur: boolean;
  144265. /**
  144266. * Gets the overall exposure used by the pipeline
  144267. */
  144268. get exposure(): number;
  144269. /**
  144270. * Sets the overall exposure used by the pipeline
  144271. */
  144272. set exposure(value: number);
  144273. /**
  144274. * Texture used typically to simulate "dirty" on camera lens
  144275. */
  144276. lensTexture: Nullable<Texture>;
  144277. /**
  144278. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  144279. */
  144280. volumetricLightCoefficient: number;
  144281. /**
  144282. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  144283. */
  144284. volumetricLightPower: number;
  144285. /**
  144286. * Used the set the blur intensity to smooth the volumetric lights
  144287. */
  144288. volumetricLightBlurScale: number;
  144289. /**
  144290. * Light (spot or directional) used to generate the volumetric lights rays
  144291. * The source light must have a shadow generate so the pipeline can get its
  144292. * depth map
  144293. */
  144294. sourceLight: Nullable<SpotLight | DirectionalLight>;
  144295. /**
  144296. * For eye adaptation, represents the minimum luminance the eye can see
  144297. */
  144298. hdrMinimumLuminance: number;
  144299. /**
  144300. * For eye adaptation, represents the decrease luminance speed
  144301. */
  144302. hdrDecreaseRate: number;
  144303. /**
  144304. * For eye adaptation, represents the increase luminance speed
  144305. */
  144306. hdrIncreaseRate: number;
  144307. /**
  144308. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144309. */
  144310. get hdrAutoExposure(): boolean;
  144311. /**
  144312. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  144313. */
  144314. set hdrAutoExposure(value: boolean);
  144315. /**
  144316. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  144317. */
  144318. lensColorTexture: Nullable<Texture>;
  144319. /**
  144320. * The overall strengh for the lens flare effect
  144321. */
  144322. lensFlareStrength: number;
  144323. /**
  144324. * Dispersion coefficient for lens flare ghosts
  144325. */
  144326. lensFlareGhostDispersal: number;
  144327. /**
  144328. * Main lens flare halo width
  144329. */
  144330. lensFlareHaloWidth: number;
  144331. /**
  144332. * Based on the lens distortion effect, defines how much the lens flare result
  144333. * is distorted
  144334. */
  144335. lensFlareDistortionStrength: number;
  144336. /**
  144337. * Configures the blur intensity used for for lens flare (halo)
  144338. */
  144339. lensFlareBlurWidth: number;
  144340. /**
  144341. * Lens star texture must be used to simulate rays on the flares and is available
  144342. * in the documentation
  144343. */
  144344. lensStarTexture: Nullable<Texture>;
  144345. /**
  144346. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144347. * flare effect by taking account of the dirt texture
  144348. */
  144349. lensFlareDirtTexture: Nullable<Texture>;
  144350. /**
  144351. * Represents the focal length for the depth of field effect
  144352. */
  144353. depthOfFieldDistance: number;
  144354. /**
  144355. * Represents the blur intensity for the blurred part of the depth of field effect
  144356. */
  144357. depthOfFieldBlurWidth: number;
  144358. /**
  144359. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144360. */
  144361. get motionStrength(): number;
  144362. /**
  144363. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144364. */
  144365. set motionStrength(strength: number);
  144366. /**
  144367. * Gets wether or not the motion blur post-process is object based or screen based.
  144368. */
  144369. get objectBasedMotionBlur(): boolean;
  144370. /**
  144371. * Sets wether or not the motion blur post-process should be object based or screen based
  144372. */
  144373. set objectBasedMotionBlur(value: boolean);
  144374. /**
  144375. * List of animations for the pipeline (IAnimatable implementation)
  144376. */
  144377. animations: Animation[];
  144378. /**
  144379. * Private members
  144380. */
  144381. private _scene;
  144382. private _currentDepthOfFieldSource;
  144383. private _basePostProcess;
  144384. private _fixedExposure;
  144385. private _currentExposure;
  144386. private _hdrAutoExposure;
  144387. private _hdrCurrentLuminance;
  144388. private _motionStrength;
  144389. private _isObjectBasedMotionBlur;
  144390. private _floatTextureType;
  144391. private _camerasToBeAttached;
  144392. private _ratio;
  144393. private _bloomEnabled;
  144394. private _depthOfFieldEnabled;
  144395. private _vlsEnabled;
  144396. private _lensFlareEnabled;
  144397. private _hdrEnabled;
  144398. private _motionBlurEnabled;
  144399. private _fxaaEnabled;
  144400. private _screenSpaceReflectionsEnabled;
  144401. private _motionBlurSamples;
  144402. private _volumetricLightStepsCount;
  144403. private _samples;
  144404. /**
  144405. * @ignore
  144406. * Specifies if the bloom pipeline is enabled
  144407. */
  144408. get BloomEnabled(): boolean;
  144409. set BloomEnabled(enabled: boolean);
  144410. /**
  144411. * @ignore
  144412. * Specifies if the depth of field pipeline is enabed
  144413. */
  144414. get DepthOfFieldEnabled(): boolean;
  144415. set DepthOfFieldEnabled(enabled: boolean);
  144416. /**
  144417. * @ignore
  144418. * Specifies if the lens flare pipeline is enabed
  144419. */
  144420. get LensFlareEnabled(): boolean;
  144421. set LensFlareEnabled(enabled: boolean);
  144422. /**
  144423. * @ignore
  144424. * Specifies if the HDR pipeline is enabled
  144425. */
  144426. get HDREnabled(): boolean;
  144427. set HDREnabled(enabled: boolean);
  144428. /**
  144429. * @ignore
  144430. * Specifies if the volumetric lights scattering effect is enabled
  144431. */
  144432. get VLSEnabled(): boolean;
  144433. set VLSEnabled(enabled: boolean);
  144434. /**
  144435. * @ignore
  144436. * Specifies if the motion blur effect is enabled
  144437. */
  144438. get MotionBlurEnabled(): boolean;
  144439. set MotionBlurEnabled(enabled: boolean);
  144440. /**
  144441. * Specifies if anti-aliasing is enabled
  144442. */
  144443. get fxaaEnabled(): boolean;
  144444. set fxaaEnabled(enabled: boolean);
  144445. /**
  144446. * Specifies if screen space reflections are enabled.
  144447. */
  144448. get screenSpaceReflectionsEnabled(): boolean;
  144449. set screenSpaceReflectionsEnabled(enabled: boolean);
  144450. /**
  144451. * Specifies the number of steps used to calculate the volumetric lights
  144452. * Typically in interval [50, 200]
  144453. */
  144454. get volumetricLightStepsCount(): number;
  144455. set volumetricLightStepsCount(count: number);
  144456. /**
  144457. * Specifies the number of samples used for the motion blur effect
  144458. * Typically in interval [16, 64]
  144459. */
  144460. get motionBlurSamples(): number;
  144461. set motionBlurSamples(samples: number);
  144462. /**
  144463. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144464. */
  144465. get samples(): number;
  144466. set samples(sampleCount: number);
  144467. /**
  144468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144469. * @constructor
  144470. * @param name The rendering pipeline name
  144471. * @param scene The scene linked to this pipeline
  144472. * @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)
  144473. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144474. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144475. */
  144476. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144477. private _buildPipeline;
  144478. private _createDownSampleX4PostProcess;
  144479. private _createBrightPassPostProcess;
  144480. private _createBlurPostProcesses;
  144481. private _createTextureAdderPostProcess;
  144482. private _createVolumetricLightPostProcess;
  144483. private _createLuminancePostProcesses;
  144484. private _createHdrPostProcess;
  144485. private _createLensFlarePostProcess;
  144486. private _createDepthOfFieldPostProcess;
  144487. private _createMotionBlurPostProcess;
  144488. private _getDepthTexture;
  144489. private _disposePostProcesses;
  144490. /**
  144491. * Dispose of the pipeline and stop all post processes
  144492. */
  144493. dispose(): void;
  144494. /**
  144495. * Serialize the rendering pipeline (Used when exporting)
  144496. * @returns the serialized object
  144497. */
  144498. serialize(): any;
  144499. /**
  144500. * Parse the serialized pipeline
  144501. * @param source Source pipeline.
  144502. * @param scene The scene to load the pipeline to.
  144503. * @param rootUrl The URL of the serialized pipeline.
  144504. * @returns An instantiated pipeline from the serialized object.
  144505. */
  144506. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144507. /**
  144508. * Luminance steps
  144509. */
  144510. static LuminanceSteps: number;
  144511. }
  144512. }
  144513. declare module BABYLON {
  144514. /** @hidden */
  144515. export var stereoscopicInterlacePixelShader: {
  144516. name: string;
  144517. shader: string;
  144518. };
  144519. }
  144520. declare module BABYLON {
  144521. /**
  144522. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144523. */
  144524. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144525. private _stepSize;
  144526. private _passedProcess;
  144527. /**
  144528. * Initializes a StereoscopicInterlacePostProcessI
  144529. * @param name The name of the effect.
  144530. * @param rigCameras The rig cameras to be appled to the post process
  144531. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144532. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144534. * @param engine The engine which the post process will be applied. (default: current engine)
  144535. * @param reusable If the post process can be reused on the same frame. (default: false)
  144536. */
  144537. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144538. }
  144539. /**
  144540. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144541. */
  144542. export class StereoscopicInterlacePostProcess extends PostProcess {
  144543. private _stepSize;
  144544. private _passedProcess;
  144545. /**
  144546. * Initializes a StereoscopicInterlacePostProcess
  144547. * @param name The name of the effect.
  144548. * @param rigCameras The rig cameras to be appled to the post process
  144549. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144551. * @param engine The engine which the post process will be applied. (default: current engine)
  144552. * @param reusable If the post process can be reused on the same frame. (default: false)
  144553. */
  144554. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144555. }
  144556. }
  144557. declare module BABYLON {
  144558. /** @hidden */
  144559. export var tonemapPixelShader: {
  144560. name: string;
  144561. shader: string;
  144562. };
  144563. }
  144564. declare module BABYLON {
  144565. /** Defines operator used for tonemapping */
  144566. export enum TonemappingOperator {
  144567. /** Hable */
  144568. Hable = 0,
  144569. /** Reinhard */
  144570. Reinhard = 1,
  144571. /** HejiDawson */
  144572. HejiDawson = 2,
  144573. /** Photographic */
  144574. Photographic = 3
  144575. }
  144576. /**
  144577. * Defines a post process to apply tone mapping
  144578. */
  144579. export class TonemapPostProcess extends PostProcess {
  144580. private _operator;
  144581. /** Defines the required exposure adjustement */
  144582. exposureAdjustment: number;
  144583. /**
  144584. * Creates a new TonemapPostProcess
  144585. * @param name defines the name of the postprocess
  144586. * @param _operator defines the operator to use
  144587. * @param exposureAdjustment defines the required exposure adjustement
  144588. * @param camera defines the camera to use (can be null)
  144589. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144590. * @param engine defines the hosting engine (can be ignore if camera is set)
  144591. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144592. */
  144593. constructor(name: string, _operator: TonemappingOperator,
  144594. /** Defines the required exposure adjustement */
  144595. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144596. }
  144597. }
  144598. declare module BABYLON {
  144599. /** @hidden */
  144600. export var volumetricLightScatteringPixelShader: {
  144601. name: string;
  144602. shader: string;
  144603. };
  144604. }
  144605. declare module BABYLON {
  144606. /** @hidden */
  144607. export var volumetricLightScatteringPassVertexShader: {
  144608. name: string;
  144609. shader: string;
  144610. };
  144611. }
  144612. declare module BABYLON {
  144613. /** @hidden */
  144614. export var volumetricLightScatteringPassPixelShader: {
  144615. name: string;
  144616. shader: string;
  144617. };
  144618. }
  144619. declare module BABYLON {
  144620. /**
  144621. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144622. */
  144623. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144624. private _volumetricLightScatteringPass;
  144625. private _volumetricLightScatteringRTT;
  144626. private _viewPort;
  144627. private _screenCoordinates;
  144628. private _cachedDefines;
  144629. /**
  144630. * If not undefined, the mesh position is computed from the attached node position
  144631. */
  144632. attachedNode: {
  144633. position: Vector3;
  144634. };
  144635. /**
  144636. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144637. */
  144638. customMeshPosition: Vector3;
  144639. /**
  144640. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144641. */
  144642. useCustomMeshPosition: boolean;
  144643. /**
  144644. * If the post-process should inverse the light scattering direction
  144645. */
  144646. invert: boolean;
  144647. /**
  144648. * The internal mesh used by the post-process
  144649. */
  144650. mesh: Mesh;
  144651. /**
  144652. * @hidden
  144653. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144654. */
  144655. get useDiffuseColor(): boolean;
  144656. set useDiffuseColor(useDiffuseColor: boolean);
  144657. /**
  144658. * Array containing the excluded meshes not rendered in the internal pass
  144659. */
  144660. excludedMeshes: AbstractMesh[];
  144661. /**
  144662. * Controls the overall intensity of the post-process
  144663. */
  144664. exposure: number;
  144665. /**
  144666. * Dissipates each sample's contribution in range [0, 1]
  144667. */
  144668. decay: number;
  144669. /**
  144670. * Controls the overall intensity of each sample
  144671. */
  144672. weight: number;
  144673. /**
  144674. * Controls the density of each sample
  144675. */
  144676. density: number;
  144677. /**
  144678. * @constructor
  144679. * @param name The post-process name
  144680. * @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)
  144681. * @param camera The camera that the post-process will be attached to
  144682. * @param mesh The mesh used to create the light scattering
  144683. * @param samples The post-process quality, default 100
  144684. * @param samplingModeThe post-process filtering mode
  144685. * @param engine The babylon engine
  144686. * @param reusable If the post-process is reusable
  144687. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144688. */
  144689. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144690. /**
  144691. * Returns the string "VolumetricLightScatteringPostProcess"
  144692. * @returns "VolumetricLightScatteringPostProcess"
  144693. */
  144694. getClassName(): string;
  144695. private _isReady;
  144696. /**
  144697. * Sets the new light position for light scattering effect
  144698. * @param position The new custom light position
  144699. */
  144700. setCustomMeshPosition(position: Vector3): void;
  144701. /**
  144702. * Returns the light position for light scattering effect
  144703. * @return Vector3 The custom light position
  144704. */
  144705. getCustomMeshPosition(): Vector3;
  144706. /**
  144707. * Disposes the internal assets and detaches the post-process from the camera
  144708. */
  144709. dispose(camera: Camera): void;
  144710. /**
  144711. * Returns the render target texture used by the post-process
  144712. * @return the render target texture used by the post-process
  144713. */
  144714. getPass(): RenderTargetTexture;
  144715. private _meshExcluded;
  144716. private _createPass;
  144717. private _updateMeshScreenCoordinates;
  144718. /**
  144719. * Creates a default mesh for the Volumeric Light Scattering post-process
  144720. * @param name The mesh name
  144721. * @param scene The scene where to create the mesh
  144722. * @return the default mesh
  144723. */
  144724. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144725. }
  144726. }
  144727. declare module BABYLON {
  144728. interface Scene {
  144729. /** @hidden (Backing field) */
  144730. _boundingBoxRenderer: BoundingBoxRenderer;
  144731. /** @hidden (Backing field) */
  144732. _forceShowBoundingBoxes: boolean;
  144733. /**
  144734. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144735. */
  144736. forceShowBoundingBoxes: boolean;
  144737. /**
  144738. * Gets the bounding box renderer associated with the scene
  144739. * @returns a BoundingBoxRenderer
  144740. */
  144741. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144742. }
  144743. interface AbstractMesh {
  144744. /** @hidden (Backing field) */
  144745. _showBoundingBox: boolean;
  144746. /**
  144747. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144748. */
  144749. showBoundingBox: boolean;
  144750. }
  144751. /**
  144752. * Component responsible of rendering the bounding box of the meshes in a scene.
  144753. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144754. */
  144755. export class BoundingBoxRenderer implements ISceneComponent {
  144756. /**
  144757. * The component name helpfull to identify the component in the list of scene components.
  144758. */
  144759. readonly name: string;
  144760. /**
  144761. * The scene the component belongs to.
  144762. */
  144763. scene: Scene;
  144764. /**
  144765. * Color of the bounding box lines placed in front of an object
  144766. */
  144767. frontColor: Color3;
  144768. /**
  144769. * Color of the bounding box lines placed behind an object
  144770. */
  144771. backColor: Color3;
  144772. /**
  144773. * Defines if the renderer should show the back lines or not
  144774. */
  144775. showBackLines: boolean;
  144776. /**
  144777. * @hidden
  144778. */
  144779. renderList: SmartArray<BoundingBox>;
  144780. private _colorShader;
  144781. private _vertexBuffers;
  144782. private _indexBuffer;
  144783. private _fillIndexBuffer;
  144784. private _fillIndexData;
  144785. /**
  144786. * Instantiates a new bounding box renderer in a scene.
  144787. * @param scene the scene the renderer renders in
  144788. */
  144789. constructor(scene: Scene);
  144790. /**
  144791. * Registers the component in a given scene
  144792. */
  144793. register(): void;
  144794. private _evaluateSubMesh;
  144795. private _activeMesh;
  144796. private _prepareRessources;
  144797. private _createIndexBuffer;
  144798. /**
  144799. * Rebuilds the elements related to this component in case of
  144800. * context lost for instance.
  144801. */
  144802. rebuild(): void;
  144803. /**
  144804. * @hidden
  144805. */
  144806. reset(): void;
  144807. /**
  144808. * Render the bounding boxes of a specific rendering group
  144809. * @param renderingGroupId defines the rendering group to render
  144810. */
  144811. render(renderingGroupId: number): void;
  144812. /**
  144813. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144814. * @param mesh Define the mesh to render the occlusion bounding box for
  144815. */
  144816. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144817. /**
  144818. * Dispose and release the resources attached to this renderer.
  144819. */
  144820. dispose(): void;
  144821. }
  144822. }
  144823. declare module BABYLON {
  144824. interface Scene {
  144825. /** @hidden (Backing field) */
  144826. _depthRenderer: {
  144827. [id: string]: DepthRenderer;
  144828. };
  144829. /**
  144830. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144831. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144832. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144833. * @returns the created depth renderer
  144834. */
  144835. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144836. /**
  144837. * Disables a depth renderer for a given camera
  144838. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144839. */
  144840. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144841. }
  144842. /**
  144843. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144844. * in several rendering techniques.
  144845. */
  144846. export class DepthRendererSceneComponent implements ISceneComponent {
  144847. /**
  144848. * The component name helpfull to identify the component in the list of scene components.
  144849. */
  144850. readonly name: string;
  144851. /**
  144852. * The scene the component belongs to.
  144853. */
  144854. scene: Scene;
  144855. /**
  144856. * Creates a new instance of the component for the given scene
  144857. * @param scene Defines the scene to register the component in
  144858. */
  144859. constructor(scene: Scene);
  144860. /**
  144861. * Registers the component in a given scene
  144862. */
  144863. register(): void;
  144864. /**
  144865. * Rebuilds the elements related to this component in case of
  144866. * context lost for instance.
  144867. */
  144868. rebuild(): void;
  144869. /**
  144870. * Disposes the component and the associated ressources
  144871. */
  144872. dispose(): void;
  144873. private _gatherRenderTargets;
  144874. private _gatherActiveCameraRenderTargets;
  144875. }
  144876. }
  144877. declare module BABYLON {
  144878. /** @hidden */
  144879. export var outlinePixelShader: {
  144880. name: string;
  144881. shader: string;
  144882. };
  144883. }
  144884. declare module BABYLON {
  144885. /** @hidden */
  144886. export var outlineVertexShader: {
  144887. name: string;
  144888. shader: string;
  144889. };
  144890. }
  144891. declare module BABYLON {
  144892. interface Scene {
  144893. /** @hidden */
  144894. _outlineRenderer: OutlineRenderer;
  144895. /**
  144896. * Gets the outline renderer associated with the scene
  144897. * @returns a OutlineRenderer
  144898. */
  144899. getOutlineRenderer(): OutlineRenderer;
  144900. }
  144901. interface AbstractMesh {
  144902. /** @hidden (Backing field) */
  144903. _renderOutline: boolean;
  144904. /**
  144905. * Gets or sets a boolean indicating if the outline must be rendered as well
  144906. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  144907. */
  144908. renderOutline: boolean;
  144909. /** @hidden (Backing field) */
  144910. _renderOverlay: boolean;
  144911. /**
  144912. * Gets or sets a boolean indicating if the overlay must be rendered as well
  144913. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  144914. */
  144915. renderOverlay: boolean;
  144916. }
  144917. /**
  144918. * This class is responsible to draw bothe outline/overlay of meshes.
  144919. * It should not be used directly but through the available method on mesh.
  144920. */
  144921. export class OutlineRenderer implements ISceneComponent {
  144922. /**
  144923. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  144924. */
  144925. private static _StencilReference;
  144926. /**
  144927. * The name of the component. Each component must have a unique name.
  144928. */
  144929. name: string;
  144930. /**
  144931. * The scene the component belongs to.
  144932. */
  144933. scene: Scene;
  144934. /**
  144935. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  144936. */
  144937. zOffset: number;
  144938. private _engine;
  144939. private _effect;
  144940. private _cachedDefines;
  144941. private _savedDepthWrite;
  144942. /**
  144943. * Instantiates a new outline renderer. (There could be only one per scene).
  144944. * @param scene Defines the scene it belongs to
  144945. */
  144946. constructor(scene: Scene);
  144947. /**
  144948. * Register the component to one instance of a scene.
  144949. */
  144950. register(): void;
  144951. /**
  144952. * Rebuilds the elements related to this component in case of
  144953. * context lost for instance.
  144954. */
  144955. rebuild(): void;
  144956. /**
  144957. * Disposes the component and the associated ressources.
  144958. */
  144959. dispose(): void;
  144960. /**
  144961. * Renders the outline in the canvas.
  144962. * @param subMesh Defines the sumesh to render
  144963. * @param batch Defines the batch of meshes in case of instances
  144964. * @param useOverlay Defines if the rendering is for the overlay or the outline
  144965. */
  144966. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  144967. /**
  144968. * Returns whether or not the outline renderer is ready for a given submesh.
  144969. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  144970. * @param subMesh Defines the submesh to check readyness for
  144971. * @param useInstances Defines wheter wee are trying to render instances or not
  144972. * @returns true if ready otherwise false
  144973. */
  144974. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144975. private _beforeRenderingMesh;
  144976. private _afterRenderingMesh;
  144977. }
  144978. }
  144979. declare module BABYLON {
  144980. /**
  144981. * Defines the basic options interface of a Sprite Frame Source Size.
  144982. */
  144983. export interface ISpriteJSONSpriteSourceSize {
  144984. /**
  144985. * number of the original width of the Frame
  144986. */
  144987. w: number;
  144988. /**
  144989. * number of the original height of the Frame
  144990. */
  144991. h: number;
  144992. }
  144993. /**
  144994. * Defines the basic options interface of a Sprite Frame Data.
  144995. */
  144996. export interface ISpriteJSONSpriteFrameData {
  144997. /**
  144998. * number of the x offset of the Frame
  144999. */
  145000. x: number;
  145001. /**
  145002. * number of the y offset of the Frame
  145003. */
  145004. y: number;
  145005. /**
  145006. * number of the width of the Frame
  145007. */
  145008. w: number;
  145009. /**
  145010. * number of the height of the Frame
  145011. */
  145012. h: number;
  145013. }
  145014. /**
  145015. * Defines the basic options interface of a JSON Sprite.
  145016. */
  145017. export interface ISpriteJSONSprite {
  145018. /**
  145019. * string name of the Frame
  145020. */
  145021. filename: string;
  145022. /**
  145023. * ISpriteJSONSpriteFrame basic object of the frame data
  145024. */
  145025. frame: ISpriteJSONSpriteFrameData;
  145026. /**
  145027. * boolean to flag is the frame was rotated.
  145028. */
  145029. rotated: boolean;
  145030. /**
  145031. * boolean to flag is the frame was trimmed.
  145032. */
  145033. trimmed: boolean;
  145034. /**
  145035. * ISpriteJSONSpriteFrame basic object of the source data
  145036. */
  145037. spriteSourceSize: ISpriteJSONSpriteFrameData;
  145038. /**
  145039. * ISpriteJSONSpriteFrame basic object of the source data
  145040. */
  145041. sourceSize: ISpriteJSONSpriteSourceSize;
  145042. }
  145043. /**
  145044. * Defines the basic options interface of a JSON atlas.
  145045. */
  145046. export interface ISpriteJSONAtlas {
  145047. /**
  145048. * Array of objects that contain the frame data.
  145049. */
  145050. frames: Array<ISpriteJSONSprite>;
  145051. /**
  145052. * object basic object containing the sprite meta data.
  145053. */
  145054. meta?: object;
  145055. }
  145056. }
  145057. declare module BABYLON {
  145058. /** @hidden */
  145059. export var spriteMapPixelShader: {
  145060. name: string;
  145061. shader: string;
  145062. };
  145063. }
  145064. declare module BABYLON {
  145065. /** @hidden */
  145066. export var spriteMapVertexShader: {
  145067. name: string;
  145068. shader: string;
  145069. };
  145070. }
  145071. declare module BABYLON {
  145072. /**
  145073. * Defines the basic options interface of a SpriteMap
  145074. */
  145075. export interface ISpriteMapOptions {
  145076. /**
  145077. * Vector2 of the number of cells in the grid.
  145078. */
  145079. stageSize?: Vector2;
  145080. /**
  145081. * Vector2 of the size of the output plane in World Units.
  145082. */
  145083. outputSize?: Vector2;
  145084. /**
  145085. * Vector3 of the position of the output plane in World Units.
  145086. */
  145087. outputPosition?: Vector3;
  145088. /**
  145089. * Vector3 of the rotation of the output plane.
  145090. */
  145091. outputRotation?: Vector3;
  145092. /**
  145093. * number of layers that the system will reserve in resources.
  145094. */
  145095. layerCount?: number;
  145096. /**
  145097. * number of max animation frames a single cell will reserve in resources.
  145098. */
  145099. maxAnimationFrames?: number;
  145100. /**
  145101. * number cell index of the base tile when the system compiles.
  145102. */
  145103. baseTile?: number;
  145104. /**
  145105. * boolean flip the sprite after its been repositioned by the framing data.
  145106. */
  145107. flipU?: boolean;
  145108. /**
  145109. * Vector3 scalar of the global RGB values of the SpriteMap.
  145110. */
  145111. colorMultiply?: Vector3;
  145112. }
  145113. /**
  145114. * Defines the IDisposable interface in order to be cleanable from resources.
  145115. */
  145116. export interface ISpriteMap extends IDisposable {
  145117. /**
  145118. * String name of the SpriteMap.
  145119. */
  145120. name: string;
  145121. /**
  145122. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  145123. */
  145124. atlasJSON: ISpriteJSONAtlas;
  145125. /**
  145126. * Texture of the SpriteMap.
  145127. */
  145128. spriteSheet: Texture;
  145129. /**
  145130. * The parameters to initialize the SpriteMap with.
  145131. */
  145132. options: ISpriteMapOptions;
  145133. }
  145134. /**
  145135. * Class used to manage a grid restricted sprite deployment on an Output plane.
  145136. */
  145137. export class SpriteMap implements ISpriteMap {
  145138. /** The Name of the spriteMap */
  145139. name: string;
  145140. /** The JSON file with the frame and meta data */
  145141. atlasJSON: ISpriteJSONAtlas;
  145142. /** The systems Sprite Sheet Texture */
  145143. spriteSheet: Texture;
  145144. /** Arguments passed with the Constructor */
  145145. options: ISpriteMapOptions;
  145146. /** Public Sprite Storage array, parsed from atlasJSON */
  145147. sprites: Array<ISpriteJSONSprite>;
  145148. /** Returns the Number of Sprites in the System */
  145149. get spriteCount(): number;
  145150. /** Returns the Position of Output Plane*/
  145151. get position(): Vector3;
  145152. /** Returns the Position of Output Plane*/
  145153. set position(v: Vector3);
  145154. /** Returns the Rotation of Output Plane*/
  145155. get rotation(): Vector3;
  145156. /** Returns the Rotation of Output Plane*/
  145157. set rotation(v: Vector3);
  145158. /** Sets the AnimationMap*/
  145159. get animationMap(): RawTexture;
  145160. /** Sets the AnimationMap*/
  145161. set animationMap(v: RawTexture);
  145162. /** Scene that the SpriteMap was created in */
  145163. private _scene;
  145164. /** Texture Buffer of Float32 that holds tile frame data*/
  145165. private _frameMap;
  145166. /** Texture Buffers of Float32 that holds tileMap data*/
  145167. private _tileMaps;
  145168. /** Texture Buffer of Float32 that holds Animation Data*/
  145169. private _animationMap;
  145170. /** Custom ShaderMaterial Central to the System*/
  145171. private _material;
  145172. /** Custom ShaderMaterial Central to the System*/
  145173. private _output;
  145174. /** Systems Time Ticker*/
  145175. private _time;
  145176. /**
  145177. * Creates a new SpriteMap
  145178. * @param name defines the SpriteMaps Name
  145179. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  145180. * @param spriteSheet is the Texture that the Sprites are on.
  145181. * @param options a basic deployment configuration
  145182. * @param scene The Scene that the map is deployed on
  145183. */
  145184. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  145185. /**
  145186. * Returns tileID location
  145187. * @returns Vector2 the cell position ID
  145188. */
  145189. getTileID(): Vector2;
  145190. /**
  145191. * Gets the UV location of the mouse over the SpriteMap.
  145192. * @returns Vector2 the UV position of the mouse interaction
  145193. */
  145194. getMousePosition(): Vector2;
  145195. /**
  145196. * Creates the "frame" texture Buffer
  145197. * -------------------------------------
  145198. * Structure of frames
  145199. * "filename": "Falling-Water-2.png",
  145200. * "frame": {"x":69,"y":103,"w":24,"h":32},
  145201. * "rotated": true,
  145202. * "trimmed": true,
  145203. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  145204. * "sourceSize": {"w":32,"h":32}
  145205. * @returns RawTexture of the frameMap
  145206. */
  145207. private _createFrameBuffer;
  145208. /**
  145209. * Creates the tileMap texture Buffer
  145210. * @param buffer normally and array of numbers, or a false to generate from scratch
  145211. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  145212. * @returns RawTexture of the tileMap
  145213. */
  145214. private _createTileBuffer;
  145215. /**
  145216. * Modifies the data of the tileMaps
  145217. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  145218. * @param pos is the iVector2 Coordinates of the Tile
  145219. * @param tile The SpriteIndex of the new Tile
  145220. */
  145221. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  145222. /**
  145223. * Creates the animationMap texture Buffer
  145224. * @param buffer normally and array of numbers, or a false to generate from scratch
  145225. * @returns RawTexture of the animationMap
  145226. */
  145227. private _createTileAnimationBuffer;
  145228. /**
  145229. * Modifies the data of the animationMap
  145230. * @param cellID is the Index of the Sprite
  145231. * @param _frame is the target Animation frame
  145232. * @param toCell is the Target Index of the next frame of the animation
  145233. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  145234. * @param speed is a global scalar of the time variable on the map.
  145235. */
  145236. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  145237. /**
  145238. * Exports the .tilemaps file
  145239. */
  145240. saveTileMaps(): void;
  145241. /**
  145242. * Imports the .tilemaps file
  145243. * @param url of the .tilemaps file
  145244. */
  145245. loadTileMaps(url: string): void;
  145246. /**
  145247. * Release associated resources
  145248. */
  145249. dispose(): void;
  145250. }
  145251. }
  145252. declare module BABYLON {
  145253. /**
  145254. * Class used to manage multiple sprites of different sizes on the same spritesheet
  145255. * @see http://doc.babylonjs.com/babylon101/sprites
  145256. */
  145257. export class SpritePackedManager extends SpriteManager {
  145258. /** defines the packed manager's name */
  145259. name: string;
  145260. /**
  145261. * Creates a new sprite manager from a packed sprite sheet
  145262. * @param name defines the manager's name
  145263. * @param imgUrl defines the sprite sheet url
  145264. * @param capacity defines the maximum allowed number of sprites
  145265. * @param scene defines the hosting scene
  145266. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  145267. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  145268. * @param samplingMode defines the smapling mode to use with spritesheet
  145269. * @param fromPacked set to true; do not alter
  145270. */
  145271. constructor(
  145272. /** defines the packed manager's name */
  145273. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  145274. }
  145275. }
  145276. declare module BABYLON {
  145277. /**
  145278. * Defines the list of states available for a task inside a AssetsManager
  145279. */
  145280. export enum AssetTaskState {
  145281. /**
  145282. * Initialization
  145283. */
  145284. INIT = 0,
  145285. /**
  145286. * Running
  145287. */
  145288. RUNNING = 1,
  145289. /**
  145290. * Done
  145291. */
  145292. DONE = 2,
  145293. /**
  145294. * Error
  145295. */
  145296. ERROR = 3
  145297. }
  145298. /**
  145299. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  145300. */
  145301. export abstract class AbstractAssetTask {
  145302. /**
  145303. * Task name
  145304. */ name: string;
  145305. /**
  145306. * Callback called when the task is successful
  145307. */
  145308. onSuccess: (task: any) => void;
  145309. /**
  145310. * Callback called when the task is not successful
  145311. */
  145312. onError: (task: any, message?: string, exception?: any) => void;
  145313. /**
  145314. * Creates a new AssetsManager
  145315. * @param name defines the name of the task
  145316. */
  145317. constructor(
  145318. /**
  145319. * Task name
  145320. */ name: string);
  145321. private _isCompleted;
  145322. private _taskState;
  145323. private _errorObject;
  145324. /**
  145325. * Get if the task is completed
  145326. */
  145327. get isCompleted(): boolean;
  145328. /**
  145329. * Gets the current state of the task
  145330. */
  145331. get taskState(): AssetTaskState;
  145332. /**
  145333. * Gets the current error object (if task is in error)
  145334. */
  145335. get errorObject(): {
  145336. message?: string;
  145337. exception?: any;
  145338. };
  145339. /**
  145340. * Internal only
  145341. * @hidden
  145342. */
  145343. _setErrorObject(message?: string, exception?: any): void;
  145344. /**
  145345. * Execute the current task
  145346. * @param scene defines the scene where you want your assets to be loaded
  145347. * @param onSuccess is a callback called when the task is successfully executed
  145348. * @param onError is a callback called if an error occurs
  145349. */
  145350. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145351. /**
  145352. * Execute the current task
  145353. * @param scene defines the scene where you want your assets to be loaded
  145354. * @param onSuccess is a callback called when the task is successfully executed
  145355. * @param onError is a callback called if an error occurs
  145356. */
  145357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145358. /**
  145359. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145360. * This can be used with failed tasks that have the reason for failure fixed.
  145361. */
  145362. reset(): void;
  145363. private onErrorCallback;
  145364. private onDoneCallback;
  145365. }
  145366. /**
  145367. * Define the interface used by progress events raised during assets loading
  145368. */
  145369. export interface IAssetsProgressEvent {
  145370. /**
  145371. * Defines the number of remaining tasks to process
  145372. */
  145373. remainingCount: number;
  145374. /**
  145375. * Defines the total number of tasks
  145376. */
  145377. totalCount: number;
  145378. /**
  145379. * Defines the task that was just processed
  145380. */
  145381. task: AbstractAssetTask;
  145382. }
  145383. /**
  145384. * Class used to share progress information about assets loading
  145385. */
  145386. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145387. /**
  145388. * Defines the number of remaining tasks to process
  145389. */
  145390. remainingCount: number;
  145391. /**
  145392. * Defines the total number of tasks
  145393. */
  145394. totalCount: number;
  145395. /**
  145396. * Defines the task that was just processed
  145397. */
  145398. task: AbstractAssetTask;
  145399. /**
  145400. * Creates a AssetsProgressEvent
  145401. * @param remainingCount defines the number of remaining tasks to process
  145402. * @param totalCount defines the total number of tasks
  145403. * @param task defines the task that was just processed
  145404. */
  145405. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145406. }
  145407. /**
  145408. * Define a task used by AssetsManager to load meshes
  145409. */
  145410. export class MeshAssetTask extends AbstractAssetTask {
  145411. /**
  145412. * Defines the name of the task
  145413. */
  145414. name: string;
  145415. /**
  145416. * Defines the list of mesh's names you want to load
  145417. */
  145418. meshesNames: any;
  145419. /**
  145420. * Defines the root url to use as a base to load your meshes and associated resources
  145421. */
  145422. rootUrl: string;
  145423. /**
  145424. * Defines the filename or File of the scene to load from
  145425. */
  145426. sceneFilename: string | File;
  145427. /**
  145428. * Gets the list of loaded meshes
  145429. */
  145430. loadedMeshes: Array<AbstractMesh>;
  145431. /**
  145432. * Gets the list of loaded particle systems
  145433. */
  145434. loadedParticleSystems: Array<IParticleSystem>;
  145435. /**
  145436. * Gets the list of loaded skeletons
  145437. */
  145438. loadedSkeletons: Array<Skeleton>;
  145439. /**
  145440. * Gets the list of loaded animation groups
  145441. */
  145442. loadedAnimationGroups: Array<AnimationGroup>;
  145443. /**
  145444. * Callback called when the task is successful
  145445. */
  145446. onSuccess: (task: MeshAssetTask) => void;
  145447. /**
  145448. * Callback called when the task is successful
  145449. */
  145450. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145451. /**
  145452. * Creates a new MeshAssetTask
  145453. * @param name defines the name of the task
  145454. * @param meshesNames defines the list of mesh's names you want to load
  145455. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145456. * @param sceneFilename defines the filename or File of the scene to load from
  145457. */
  145458. constructor(
  145459. /**
  145460. * Defines the name of the task
  145461. */
  145462. name: string,
  145463. /**
  145464. * Defines the list of mesh's names you want to load
  145465. */
  145466. meshesNames: any,
  145467. /**
  145468. * Defines the root url to use as a base to load your meshes and associated resources
  145469. */
  145470. rootUrl: string,
  145471. /**
  145472. * Defines the filename or File of the scene to load from
  145473. */
  145474. sceneFilename: string | File);
  145475. /**
  145476. * Execute the current task
  145477. * @param scene defines the scene where you want your assets to be loaded
  145478. * @param onSuccess is a callback called when the task is successfully executed
  145479. * @param onError is a callback called if an error occurs
  145480. */
  145481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145482. }
  145483. /**
  145484. * Define a task used by AssetsManager to load text content
  145485. */
  145486. export class TextFileAssetTask extends AbstractAssetTask {
  145487. /**
  145488. * Defines the name of the task
  145489. */
  145490. name: string;
  145491. /**
  145492. * Defines the location of the file to load
  145493. */
  145494. url: string;
  145495. /**
  145496. * Gets the loaded text string
  145497. */
  145498. text: string;
  145499. /**
  145500. * Callback called when the task is successful
  145501. */
  145502. onSuccess: (task: TextFileAssetTask) => void;
  145503. /**
  145504. * Callback called when the task is successful
  145505. */
  145506. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145507. /**
  145508. * Creates a new TextFileAssetTask object
  145509. * @param name defines the name of the task
  145510. * @param url defines the location of the file to load
  145511. */
  145512. constructor(
  145513. /**
  145514. * Defines the name of the task
  145515. */
  145516. name: string,
  145517. /**
  145518. * Defines the location of the file to load
  145519. */
  145520. url: string);
  145521. /**
  145522. * Execute the current task
  145523. * @param scene defines the scene where you want your assets to be loaded
  145524. * @param onSuccess is a callback called when the task is successfully executed
  145525. * @param onError is a callback called if an error occurs
  145526. */
  145527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145528. }
  145529. /**
  145530. * Define a task used by AssetsManager to load binary data
  145531. */
  145532. export class BinaryFileAssetTask extends AbstractAssetTask {
  145533. /**
  145534. * Defines the name of the task
  145535. */
  145536. name: string;
  145537. /**
  145538. * Defines the location of the file to load
  145539. */
  145540. url: string;
  145541. /**
  145542. * Gets the lodaded data (as an array buffer)
  145543. */
  145544. data: ArrayBuffer;
  145545. /**
  145546. * Callback called when the task is successful
  145547. */
  145548. onSuccess: (task: BinaryFileAssetTask) => void;
  145549. /**
  145550. * Callback called when the task is successful
  145551. */
  145552. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145553. /**
  145554. * Creates a new BinaryFileAssetTask object
  145555. * @param name defines the name of the new task
  145556. * @param url defines the location of the file to load
  145557. */
  145558. constructor(
  145559. /**
  145560. * Defines the name of the task
  145561. */
  145562. name: string,
  145563. /**
  145564. * Defines the location of the file to load
  145565. */
  145566. url: string);
  145567. /**
  145568. * Execute the current task
  145569. * @param scene defines the scene where you want your assets to be loaded
  145570. * @param onSuccess is a callback called when the task is successfully executed
  145571. * @param onError is a callback called if an error occurs
  145572. */
  145573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145574. }
  145575. /**
  145576. * Define a task used by AssetsManager to load images
  145577. */
  145578. export class ImageAssetTask extends AbstractAssetTask {
  145579. /**
  145580. * Defines the name of the task
  145581. */
  145582. name: string;
  145583. /**
  145584. * Defines the location of the image to load
  145585. */
  145586. url: string;
  145587. /**
  145588. * Gets the loaded images
  145589. */
  145590. image: HTMLImageElement;
  145591. /**
  145592. * Callback called when the task is successful
  145593. */
  145594. onSuccess: (task: ImageAssetTask) => void;
  145595. /**
  145596. * Callback called when the task is successful
  145597. */
  145598. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145599. /**
  145600. * Creates a new ImageAssetTask
  145601. * @param name defines the name of the task
  145602. * @param url defines the location of the image to load
  145603. */
  145604. constructor(
  145605. /**
  145606. * Defines the name of the task
  145607. */
  145608. name: string,
  145609. /**
  145610. * Defines the location of the image to load
  145611. */
  145612. url: string);
  145613. /**
  145614. * Execute the current task
  145615. * @param scene defines the scene where you want your assets to be loaded
  145616. * @param onSuccess is a callback called when the task is successfully executed
  145617. * @param onError is a callback called if an error occurs
  145618. */
  145619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145620. }
  145621. /**
  145622. * Defines the interface used by texture loading tasks
  145623. */
  145624. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145625. /**
  145626. * Gets the loaded texture
  145627. */
  145628. texture: TEX;
  145629. }
  145630. /**
  145631. * Define a task used by AssetsManager to load 2D textures
  145632. */
  145633. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145634. /**
  145635. * Defines the name of the task
  145636. */
  145637. name: string;
  145638. /**
  145639. * Defines the location of the file to load
  145640. */
  145641. url: string;
  145642. /**
  145643. * Defines if mipmap should not be generated (default is false)
  145644. */
  145645. noMipmap?: boolean | undefined;
  145646. /**
  145647. * Defines if texture must be inverted on Y axis (default is true)
  145648. */
  145649. invertY: boolean;
  145650. /**
  145651. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145652. */
  145653. samplingMode: number;
  145654. /**
  145655. * Gets the loaded texture
  145656. */
  145657. texture: Texture;
  145658. /**
  145659. * Callback called when the task is successful
  145660. */
  145661. onSuccess: (task: TextureAssetTask) => void;
  145662. /**
  145663. * Callback called when the task is successful
  145664. */
  145665. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145666. /**
  145667. * Creates a new TextureAssetTask object
  145668. * @param name defines the name of the task
  145669. * @param url defines the location of the file to load
  145670. * @param noMipmap defines if mipmap should not be generated (default is false)
  145671. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145672. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145673. */
  145674. constructor(
  145675. /**
  145676. * Defines the name of the task
  145677. */
  145678. name: string,
  145679. /**
  145680. * Defines the location of the file to load
  145681. */
  145682. url: string,
  145683. /**
  145684. * Defines if mipmap should not be generated (default is false)
  145685. */
  145686. noMipmap?: boolean | undefined,
  145687. /**
  145688. * Defines if texture must be inverted on Y axis (default is true)
  145689. */
  145690. invertY?: boolean,
  145691. /**
  145692. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145693. */
  145694. samplingMode?: number);
  145695. /**
  145696. * Execute the current task
  145697. * @param scene defines the scene where you want your assets to be loaded
  145698. * @param onSuccess is a callback called when the task is successfully executed
  145699. * @param onError is a callback called if an error occurs
  145700. */
  145701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145702. }
  145703. /**
  145704. * Define a task used by AssetsManager to load cube textures
  145705. */
  145706. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145707. /**
  145708. * Defines the name of the task
  145709. */
  145710. name: string;
  145711. /**
  145712. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145713. */
  145714. url: string;
  145715. /**
  145716. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145717. */
  145718. extensions?: string[] | undefined;
  145719. /**
  145720. * Defines if mipmaps should not be generated (default is false)
  145721. */
  145722. noMipmap?: boolean | undefined;
  145723. /**
  145724. * Defines the explicit list of files (undefined by default)
  145725. */
  145726. files?: string[] | undefined;
  145727. /**
  145728. * Gets the loaded texture
  145729. */
  145730. texture: CubeTexture;
  145731. /**
  145732. * Callback called when the task is successful
  145733. */
  145734. onSuccess: (task: CubeTextureAssetTask) => void;
  145735. /**
  145736. * Callback called when the task is successful
  145737. */
  145738. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145739. /**
  145740. * Creates a new CubeTextureAssetTask
  145741. * @param name defines the name of the task
  145742. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145743. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145744. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145745. * @param files defines the explicit list of files (undefined by default)
  145746. */
  145747. constructor(
  145748. /**
  145749. * Defines the name of the task
  145750. */
  145751. name: string,
  145752. /**
  145753. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145754. */
  145755. url: string,
  145756. /**
  145757. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145758. */
  145759. extensions?: string[] | undefined,
  145760. /**
  145761. * Defines if mipmaps should not be generated (default is false)
  145762. */
  145763. noMipmap?: boolean | undefined,
  145764. /**
  145765. * Defines the explicit list of files (undefined by default)
  145766. */
  145767. files?: string[] | undefined);
  145768. /**
  145769. * Execute the current task
  145770. * @param scene defines the scene where you want your assets to be loaded
  145771. * @param onSuccess is a callback called when the task is successfully executed
  145772. * @param onError is a callback called if an error occurs
  145773. */
  145774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145775. }
  145776. /**
  145777. * Define a task used by AssetsManager to load HDR cube textures
  145778. */
  145779. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145780. /**
  145781. * Defines the name of the task
  145782. */
  145783. name: string;
  145784. /**
  145785. * Defines the location of the file to load
  145786. */
  145787. url: string;
  145788. /**
  145789. * Defines the desired size (the more it increases the longer the generation will be)
  145790. */
  145791. size: number;
  145792. /**
  145793. * Defines if mipmaps should not be generated (default is false)
  145794. */
  145795. noMipmap: boolean;
  145796. /**
  145797. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145798. */
  145799. generateHarmonics: boolean;
  145800. /**
  145801. * 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)
  145802. */
  145803. gammaSpace: boolean;
  145804. /**
  145805. * Internal Use Only
  145806. */
  145807. reserved: boolean;
  145808. /**
  145809. * Gets the loaded texture
  145810. */
  145811. texture: HDRCubeTexture;
  145812. /**
  145813. * Callback called when the task is successful
  145814. */
  145815. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145816. /**
  145817. * Callback called when the task is successful
  145818. */
  145819. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145820. /**
  145821. * Creates a new HDRCubeTextureAssetTask object
  145822. * @param name defines the name of the task
  145823. * @param url defines the location of the file to load
  145824. * @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.
  145825. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145826. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145827. * @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)
  145828. * @param reserved Internal use only
  145829. */
  145830. constructor(
  145831. /**
  145832. * Defines the name of the task
  145833. */
  145834. name: string,
  145835. /**
  145836. * Defines the location of the file to load
  145837. */
  145838. url: string,
  145839. /**
  145840. * Defines the desired size (the more it increases the longer the generation will be)
  145841. */
  145842. size: number,
  145843. /**
  145844. * Defines if mipmaps should not be generated (default is false)
  145845. */
  145846. noMipmap?: boolean,
  145847. /**
  145848. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145849. */
  145850. generateHarmonics?: boolean,
  145851. /**
  145852. * 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)
  145853. */
  145854. gammaSpace?: boolean,
  145855. /**
  145856. * Internal Use Only
  145857. */
  145858. reserved?: boolean);
  145859. /**
  145860. * Execute the current task
  145861. * @param scene defines the scene where you want your assets to be loaded
  145862. * @param onSuccess is a callback called when the task is successfully executed
  145863. * @param onError is a callback called if an error occurs
  145864. */
  145865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145866. }
  145867. /**
  145868. * Define a task used by AssetsManager to load Equirectangular cube textures
  145869. */
  145870. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  145871. /**
  145872. * Defines the name of the task
  145873. */
  145874. name: string;
  145875. /**
  145876. * Defines the location of the file to load
  145877. */
  145878. url: string;
  145879. /**
  145880. * Defines the desired size (the more it increases the longer the generation will be)
  145881. */
  145882. size: number;
  145883. /**
  145884. * Defines if mipmaps should not be generated (default is false)
  145885. */
  145886. noMipmap: boolean;
  145887. /**
  145888. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145889. * but the standard material would require them in Gamma space) (default is true)
  145890. */
  145891. gammaSpace: boolean;
  145892. /**
  145893. * Gets the loaded texture
  145894. */
  145895. texture: EquiRectangularCubeTexture;
  145896. /**
  145897. * Callback called when the task is successful
  145898. */
  145899. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  145900. /**
  145901. * Callback called when the task is successful
  145902. */
  145903. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  145904. /**
  145905. * Creates a new EquiRectangularCubeTextureAssetTask object
  145906. * @param name defines the name of the task
  145907. * @param url defines the location of the file to load
  145908. * @param size defines the desired size (the more it increases the longer the generation will be)
  145909. * If the size is omitted this implies you are using a preprocessed cubemap.
  145910. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145911. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  145912. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  145913. * (default is true)
  145914. */
  145915. constructor(
  145916. /**
  145917. * Defines the name of the task
  145918. */
  145919. name: string,
  145920. /**
  145921. * Defines the location of the file to load
  145922. */
  145923. url: string,
  145924. /**
  145925. * Defines the desired size (the more it increases the longer the generation will be)
  145926. */
  145927. size: number,
  145928. /**
  145929. * Defines if mipmaps should not be generated (default is false)
  145930. */
  145931. noMipmap?: boolean,
  145932. /**
  145933. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145934. * but the standard material would require them in Gamma space) (default is true)
  145935. */
  145936. gammaSpace?: boolean);
  145937. /**
  145938. * Execute the current task
  145939. * @param scene defines the scene where you want your assets to be loaded
  145940. * @param onSuccess is a callback called when the task is successfully executed
  145941. * @param onError is a callback called if an error occurs
  145942. */
  145943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145944. }
  145945. /**
  145946. * This class can be used to easily import assets into a scene
  145947. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  145948. */
  145949. export class AssetsManager {
  145950. private _scene;
  145951. private _isLoading;
  145952. protected _tasks: AbstractAssetTask[];
  145953. protected _waitingTasksCount: number;
  145954. protected _totalTasksCount: number;
  145955. /**
  145956. * Callback called when all tasks are processed
  145957. */
  145958. onFinish: (tasks: AbstractAssetTask[]) => void;
  145959. /**
  145960. * Callback called when a task is successful
  145961. */
  145962. onTaskSuccess: (task: AbstractAssetTask) => void;
  145963. /**
  145964. * Callback called when a task had an error
  145965. */
  145966. onTaskError: (task: AbstractAssetTask) => void;
  145967. /**
  145968. * Callback called when a task is done (whatever the result is)
  145969. */
  145970. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  145971. /**
  145972. * Observable called when all tasks are processed
  145973. */
  145974. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  145975. /**
  145976. * Observable called when a task had an error
  145977. */
  145978. onTaskErrorObservable: Observable<AbstractAssetTask>;
  145979. /**
  145980. * Observable called when all tasks were executed
  145981. */
  145982. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  145983. /**
  145984. * Observable called when a task is done (whatever the result is)
  145985. */
  145986. onProgressObservable: Observable<IAssetsProgressEvent>;
  145987. /**
  145988. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  145989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  145990. */
  145991. useDefaultLoadingScreen: boolean;
  145992. /**
  145993. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  145994. * when all assets have been downloaded.
  145995. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  145996. */
  145997. autoHideLoadingUI: boolean;
  145998. /**
  145999. * Creates a new AssetsManager
  146000. * @param scene defines the scene to work on
  146001. */
  146002. constructor(scene: Scene);
  146003. /**
  146004. * Add a MeshAssetTask to the list of active tasks
  146005. * @param taskName defines the name of the new task
  146006. * @param meshesNames defines the name of meshes to load
  146007. * @param rootUrl defines the root url to use to locate files
  146008. * @param sceneFilename defines the filename of the scene file
  146009. * @returns a new MeshAssetTask object
  146010. */
  146011. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  146012. /**
  146013. * Add a TextFileAssetTask to the list of active tasks
  146014. * @param taskName defines the name of the new task
  146015. * @param url defines the url of the file to load
  146016. * @returns a new TextFileAssetTask object
  146017. */
  146018. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  146019. /**
  146020. * Add a BinaryFileAssetTask to the list of active tasks
  146021. * @param taskName defines the name of the new task
  146022. * @param url defines the url of the file to load
  146023. * @returns a new BinaryFileAssetTask object
  146024. */
  146025. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  146026. /**
  146027. * Add a ImageAssetTask to the list of active tasks
  146028. * @param taskName defines the name of the new task
  146029. * @param url defines the url of the file to load
  146030. * @returns a new ImageAssetTask object
  146031. */
  146032. addImageTask(taskName: string, url: string): ImageAssetTask;
  146033. /**
  146034. * Add a TextureAssetTask to the list of active tasks
  146035. * @param taskName defines the name of the new task
  146036. * @param url defines the url of the file to load
  146037. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146038. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  146039. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  146040. * @returns a new TextureAssetTask object
  146041. */
  146042. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  146043. /**
  146044. * Add a CubeTextureAssetTask to the list of active tasks
  146045. * @param taskName defines the name of the new task
  146046. * @param url defines the url of the file to load
  146047. * @param extensions defines the extension to use to load the cube map (can be null)
  146048. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146049. * @param files defines the list of files to load (can be null)
  146050. * @returns a new CubeTextureAssetTask object
  146051. */
  146052. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  146053. /**
  146054. *
  146055. * Add a HDRCubeTextureAssetTask to the list of active tasks
  146056. * @param taskName defines the name of the new task
  146057. * @param url defines the url of the file to load
  146058. * @param size defines the size you want for the cubemap (can be null)
  146059. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146060. * @param generateHarmonics defines if you want to automatically generate (true by default)
  146061. * @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)
  146062. * @param reserved Internal use only
  146063. * @returns a new HDRCubeTextureAssetTask object
  146064. */
  146065. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  146066. /**
  146067. *
  146068. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  146069. * @param taskName defines the name of the new task
  146070. * @param url defines the url of the file to load
  146071. * @param size defines the size you want for the cubemap (can be null)
  146072. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  146073. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  146074. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  146075. * @returns a new EquiRectangularCubeTextureAssetTask object
  146076. */
  146077. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  146078. /**
  146079. * Remove a task from the assets manager.
  146080. * @param task the task to remove
  146081. */
  146082. removeTask(task: AbstractAssetTask): void;
  146083. private _decreaseWaitingTasksCount;
  146084. private _runTask;
  146085. /**
  146086. * Reset the AssetsManager and remove all tasks
  146087. * @return the current instance of the AssetsManager
  146088. */
  146089. reset(): AssetsManager;
  146090. /**
  146091. * Start the loading process
  146092. * @return the current instance of the AssetsManager
  146093. */
  146094. load(): AssetsManager;
  146095. /**
  146096. * Start the loading process as an async operation
  146097. * @return a promise returning the list of failed tasks
  146098. */
  146099. loadAsync(): Promise<void>;
  146100. }
  146101. }
  146102. declare module BABYLON {
  146103. /**
  146104. * Wrapper class for promise with external resolve and reject.
  146105. */
  146106. export class Deferred<T> {
  146107. /**
  146108. * The promise associated with this deferred object.
  146109. */
  146110. readonly promise: Promise<T>;
  146111. private _resolve;
  146112. private _reject;
  146113. /**
  146114. * The resolve method of the promise associated with this deferred object.
  146115. */
  146116. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  146117. /**
  146118. * The reject method of the promise associated with this deferred object.
  146119. */
  146120. get reject(): (reason?: any) => void;
  146121. /**
  146122. * Constructor for this deferred object.
  146123. */
  146124. constructor();
  146125. }
  146126. }
  146127. declare module BABYLON {
  146128. /**
  146129. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  146130. */
  146131. export class MeshExploder {
  146132. private _centerMesh;
  146133. private _meshes;
  146134. private _meshesOrigins;
  146135. private _toCenterVectors;
  146136. private _scaledDirection;
  146137. private _newPosition;
  146138. private _centerPosition;
  146139. /**
  146140. * Explodes meshes from a center mesh.
  146141. * @param meshes The meshes to explode.
  146142. * @param centerMesh The mesh to be center of explosion.
  146143. */
  146144. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  146145. private _setCenterMesh;
  146146. /**
  146147. * Get class name
  146148. * @returns "MeshExploder"
  146149. */
  146150. getClassName(): string;
  146151. /**
  146152. * "Exploded meshes"
  146153. * @returns Array of meshes with the centerMesh at index 0.
  146154. */
  146155. getMeshes(): Array<Mesh>;
  146156. /**
  146157. * Explodes meshes giving a specific direction
  146158. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  146159. */
  146160. explode(direction?: number): void;
  146161. }
  146162. }
  146163. declare module BABYLON {
  146164. /**
  146165. * Class used to help managing file picking and drag'n'drop
  146166. */
  146167. export class FilesInput {
  146168. /**
  146169. * List of files ready to be loaded
  146170. */
  146171. static get FilesToLoad(): {
  146172. [key: string]: File;
  146173. };
  146174. /**
  146175. * Callback called when a file is processed
  146176. */
  146177. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  146178. private _engine;
  146179. private _currentScene;
  146180. private _sceneLoadedCallback;
  146181. private _progressCallback;
  146182. private _additionalRenderLoopLogicCallback;
  146183. private _textureLoadingCallback;
  146184. private _startingProcessingFilesCallback;
  146185. private _onReloadCallback;
  146186. private _errorCallback;
  146187. private _elementToMonitor;
  146188. private _sceneFileToLoad;
  146189. private _filesToLoad;
  146190. /**
  146191. * Creates a new FilesInput
  146192. * @param engine defines the rendering engine
  146193. * @param scene defines the hosting scene
  146194. * @param sceneLoadedCallback callback called when scene is loaded
  146195. * @param progressCallback callback called to track progress
  146196. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  146197. * @param textureLoadingCallback callback called when a texture is loading
  146198. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  146199. * @param onReloadCallback callback called when a reload is requested
  146200. * @param errorCallback callback call if an error occurs
  146201. */
  146202. 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);
  146203. private _dragEnterHandler;
  146204. private _dragOverHandler;
  146205. private _dropHandler;
  146206. /**
  146207. * Calls this function to listen to drag'n'drop events on a specific DOM element
  146208. * @param elementToMonitor defines the DOM element to track
  146209. */
  146210. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  146211. /**
  146212. * Release all associated resources
  146213. */
  146214. dispose(): void;
  146215. private renderFunction;
  146216. private drag;
  146217. private drop;
  146218. private _traverseFolder;
  146219. private _processFiles;
  146220. /**
  146221. * Load files from a drop event
  146222. * @param event defines the drop event to use as source
  146223. */
  146224. loadFiles(event: any): void;
  146225. private _processReload;
  146226. /**
  146227. * Reload the current scene from the loaded files
  146228. */
  146229. reload(): void;
  146230. }
  146231. }
  146232. declare module BABYLON {
  146233. /**
  146234. * Defines the root class used to create scene optimization to use with SceneOptimizer
  146235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146236. */
  146237. export class SceneOptimization {
  146238. /**
  146239. * Defines the priority of this optimization (0 by default which means first in the list)
  146240. */
  146241. priority: number;
  146242. /**
  146243. * Gets a string describing the action executed by the current optimization
  146244. * @returns description string
  146245. */
  146246. getDescription(): string;
  146247. /**
  146248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146249. * @param scene defines the current scene where to apply this optimization
  146250. * @param optimizer defines the current optimizer
  146251. * @returns true if everything that can be done was applied
  146252. */
  146253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146254. /**
  146255. * Creates the SceneOptimization object
  146256. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146257. * @param desc defines the description associated with the optimization
  146258. */
  146259. constructor(
  146260. /**
  146261. * Defines the priority of this optimization (0 by default which means first in the list)
  146262. */
  146263. priority?: number);
  146264. }
  146265. /**
  146266. * Defines an optimization used to reduce the size of render target textures
  146267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146268. */
  146269. export class TextureOptimization extends SceneOptimization {
  146270. /**
  146271. * Defines the priority of this optimization (0 by default which means first in the list)
  146272. */
  146273. priority: number;
  146274. /**
  146275. * 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
  146276. */
  146277. maximumSize: number;
  146278. /**
  146279. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146280. */
  146281. step: number;
  146282. /**
  146283. * Gets a string describing the action executed by the current optimization
  146284. * @returns description string
  146285. */
  146286. getDescription(): string;
  146287. /**
  146288. * Creates the TextureOptimization object
  146289. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146290. * @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
  146291. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146292. */
  146293. constructor(
  146294. /**
  146295. * Defines the priority of this optimization (0 by default which means first in the list)
  146296. */
  146297. priority?: number,
  146298. /**
  146299. * 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
  146300. */
  146301. maximumSize?: number,
  146302. /**
  146303. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  146304. */
  146305. step?: number);
  146306. /**
  146307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146308. * @param scene defines the current scene where to apply this optimization
  146309. * @param optimizer defines the current optimizer
  146310. * @returns true if everything that can be done was applied
  146311. */
  146312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146313. }
  146314. /**
  146315. * Defines an optimization used to increase or decrease the rendering resolution
  146316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146317. */
  146318. export class HardwareScalingOptimization extends SceneOptimization {
  146319. /**
  146320. * Defines the priority of this optimization (0 by default which means first in the list)
  146321. */
  146322. priority: number;
  146323. /**
  146324. * Defines the maximum scale to use (2 by default)
  146325. */
  146326. maximumScale: number;
  146327. /**
  146328. * Defines the step to use between two passes (0.5 by default)
  146329. */
  146330. step: number;
  146331. private _currentScale;
  146332. private _directionOffset;
  146333. /**
  146334. * Gets a string describing the action executed by the current optimization
  146335. * @return description string
  146336. */
  146337. getDescription(): string;
  146338. /**
  146339. * Creates the HardwareScalingOptimization object
  146340. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146341. * @param maximumScale defines the maximum scale to use (2 by default)
  146342. * @param step defines the step to use between two passes (0.5 by default)
  146343. */
  146344. constructor(
  146345. /**
  146346. * Defines the priority of this optimization (0 by default which means first in the list)
  146347. */
  146348. priority?: number,
  146349. /**
  146350. * Defines the maximum scale to use (2 by default)
  146351. */
  146352. maximumScale?: number,
  146353. /**
  146354. * Defines the step to use between two passes (0.5 by default)
  146355. */
  146356. step?: number);
  146357. /**
  146358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146359. * @param scene defines the current scene where to apply this optimization
  146360. * @param optimizer defines the current optimizer
  146361. * @returns true if everything that can be done was applied
  146362. */
  146363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146364. }
  146365. /**
  146366. * Defines an optimization used to remove shadows
  146367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146368. */
  146369. export class ShadowsOptimization extends SceneOptimization {
  146370. /**
  146371. * Gets a string describing the action executed by the current optimization
  146372. * @return description string
  146373. */
  146374. getDescription(): string;
  146375. /**
  146376. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146377. * @param scene defines the current scene where to apply this optimization
  146378. * @param optimizer defines the current optimizer
  146379. * @returns true if everything that can be done was applied
  146380. */
  146381. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146382. }
  146383. /**
  146384. * Defines an optimization used to turn post-processes off
  146385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146386. */
  146387. export class PostProcessesOptimization extends SceneOptimization {
  146388. /**
  146389. * Gets a string describing the action executed by the current optimization
  146390. * @return description string
  146391. */
  146392. getDescription(): string;
  146393. /**
  146394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146395. * @param scene defines the current scene where to apply this optimization
  146396. * @param optimizer defines the current optimizer
  146397. * @returns true if everything that can be done was applied
  146398. */
  146399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146400. }
  146401. /**
  146402. * Defines an optimization used to turn lens flares off
  146403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146404. */
  146405. export class LensFlaresOptimization extends SceneOptimization {
  146406. /**
  146407. * Gets a string describing the action executed by the current optimization
  146408. * @return description string
  146409. */
  146410. getDescription(): string;
  146411. /**
  146412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146413. * @param scene defines the current scene where to apply this optimization
  146414. * @param optimizer defines the current optimizer
  146415. * @returns true if everything that can be done was applied
  146416. */
  146417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146418. }
  146419. /**
  146420. * Defines an optimization based on user defined callback.
  146421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146422. */
  146423. export class CustomOptimization extends SceneOptimization {
  146424. /**
  146425. * Callback called to apply the custom optimization.
  146426. */
  146427. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146428. /**
  146429. * Callback called to get custom description
  146430. */
  146431. onGetDescription: () => string;
  146432. /**
  146433. * Gets a string describing the action executed by the current optimization
  146434. * @returns description string
  146435. */
  146436. getDescription(): string;
  146437. /**
  146438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146439. * @param scene defines the current scene where to apply this optimization
  146440. * @param optimizer defines the current optimizer
  146441. * @returns true if everything that can be done was applied
  146442. */
  146443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146444. }
  146445. /**
  146446. * Defines an optimization used to turn particles off
  146447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146448. */
  146449. export class ParticlesOptimization extends SceneOptimization {
  146450. /**
  146451. * Gets a string describing the action executed by the current optimization
  146452. * @return description string
  146453. */
  146454. getDescription(): string;
  146455. /**
  146456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146457. * @param scene defines the current scene where to apply this optimization
  146458. * @param optimizer defines the current optimizer
  146459. * @returns true if everything that can be done was applied
  146460. */
  146461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146462. }
  146463. /**
  146464. * Defines an optimization used to turn render targets off
  146465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146466. */
  146467. export class RenderTargetsOptimization extends SceneOptimization {
  146468. /**
  146469. * Gets a string describing the action executed by the current optimization
  146470. * @return description string
  146471. */
  146472. getDescription(): string;
  146473. /**
  146474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146475. * @param scene defines the current scene where to apply this optimization
  146476. * @param optimizer defines the current optimizer
  146477. * @returns true if everything that can be done was applied
  146478. */
  146479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146480. }
  146481. /**
  146482. * Defines an optimization used to merge meshes with compatible materials
  146483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146484. */
  146485. export class MergeMeshesOptimization extends SceneOptimization {
  146486. private static _UpdateSelectionTree;
  146487. /**
  146488. * Gets or sets a boolean which defines if optimization octree has to be updated
  146489. */
  146490. static get UpdateSelectionTree(): boolean;
  146491. /**
  146492. * Gets or sets a boolean which defines if optimization octree has to be updated
  146493. */
  146494. static set UpdateSelectionTree(value: boolean);
  146495. /**
  146496. * Gets a string describing the action executed by the current optimization
  146497. * @return description string
  146498. */
  146499. getDescription(): string;
  146500. private _canBeMerged;
  146501. /**
  146502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146503. * @param scene defines the current scene where to apply this optimization
  146504. * @param optimizer defines the current optimizer
  146505. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146506. * @returns true if everything that can be done was applied
  146507. */
  146508. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146509. }
  146510. /**
  146511. * Defines a list of options used by SceneOptimizer
  146512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146513. */
  146514. export class SceneOptimizerOptions {
  146515. /**
  146516. * Defines the target frame rate to reach (60 by default)
  146517. */
  146518. targetFrameRate: number;
  146519. /**
  146520. * Defines the interval between two checkes (2000ms by default)
  146521. */
  146522. trackerDuration: number;
  146523. /**
  146524. * Gets the list of optimizations to apply
  146525. */
  146526. optimizations: SceneOptimization[];
  146527. /**
  146528. * Creates a new list of options used by SceneOptimizer
  146529. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146530. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146531. */
  146532. constructor(
  146533. /**
  146534. * Defines the target frame rate to reach (60 by default)
  146535. */
  146536. targetFrameRate?: number,
  146537. /**
  146538. * Defines the interval between two checkes (2000ms by default)
  146539. */
  146540. trackerDuration?: number);
  146541. /**
  146542. * Add a new optimization
  146543. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146544. * @returns the current SceneOptimizerOptions
  146545. */
  146546. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146547. /**
  146548. * Add a new custom optimization
  146549. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146550. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146551. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146552. * @returns the current SceneOptimizerOptions
  146553. */
  146554. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146555. /**
  146556. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146557. * @param targetFrameRate defines the target frame rate (60 by default)
  146558. * @returns a SceneOptimizerOptions object
  146559. */
  146560. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146561. /**
  146562. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146563. * @param targetFrameRate defines the target frame rate (60 by default)
  146564. * @returns a SceneOptimizerOptions object
  146565. */
  146566. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146567. /**
  146568. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146569. * @param targetFrameRate defines the target frame rate (60 by default)
  146570. * @returns a SceneOptimizerOptions object
  146571. */
  146572. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146573. }
  146574. /**
  146575. * Class used to run optimizations in order to reach a target frame rate
  146576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146577. */
  146578. export class SceneOptimizer implements IDisposable {
  146579. private _isRunning;
  146580. private _options;
  146581. private _scene;
  146582. private _currentPriorityLevel;
  146583. private _targetFrameRate;
  146584. private _trackerDuration;
  146585. private _currentFrameRate;
  146586. private _sceneDisposeObserver;
  146587. private _improvementMode;
  146588. /**
  146589. * Defines an observable called when the optimizer reaches the target frame rate
  146590. */
  146591. onSuccessObservable: Observable<SceneOptimizer>;
  146592. /**
  146593. * Defines an observable called when the optimizer enables an optimization
  146594. */
  146595. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146596. /**
  146597. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146598. */
  146599. onFailureObservable: Observable<SceneOptimizer>;
  146600. /**
  146601. * Gets a boolean indicating if the optimizer is in improvement mode
  146602. */
  146603. get isInImprovementMode(): boolean;
  146604. /**
  146605. * Gets the current priority level (0 at start)
  146606. */
  146607. get currentPriorityLevel(): number;
  146608. /**
  146609. * Gets the current frame rate checked by the SceneOptimizer
  146610. */
  146611. get currentFrameRate(): number;
  146612. /**
  146613. * Gets or sets the current target frame rate (60 by default)
  146614. */
  146615. get targetFrameRate(): number;
  146616. /**
  146617. * Gets or sets the current target frame rate (60 by default)
  146618. */
  146619. set targetFrameRate(value: number);
  146620. /**
  146621. * Gets or sets the current interval between two checks (every 2000ms by default)
  146622. */
  146623. get trackerDuration(): number;
  146624. /**
  146625. * Gets or sets the current interval between two checks (every 2000ms by default)
  146626. */
  146627. set trackerDuration(value: number);
  146628. /**
  146629. * Gets the list of active optimizations
  146630. */
  146631. get optimizations(): SceneOptimization[];
  146632. /**
  146633. * Creates a new SceneOptimizer
  146634. * @param scene defines the scene to work on
  146635. * @param options defines the options to use with the SceneOptimizer
  146636. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146637. * @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)
  146638. */
  146639. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146640. /**
  146641. * Stops the current optimizer
  146642. */
  146643. stop(): void;
  146644. /**
  146645. * Reset the optimizer to initial step (current priority level = 0)
  146646. */
  146647. reset(): void;
  146648. /**
  146649. * Start the optimizer. By default it will try to reach a specific framerate
  146650. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146651. */
  146652. start(): void;
  146653. private _checkCurrentState;
  146654. /**
  146655. * Release all resources
  146656. */
  146657. dispose(): void;
  146658. /**
  146659. * Helper function to create a SceneOptimizer with one single line of code
  146660. * @param scene defines the scene to work on
  146661. * @param options defines the options to use with the SceneOptimizer
  146662. * @param onSuccess defines a callback to call on success
  146663. * @param onFailure defines a callback to call on failure
  146664. * @returns the new SceneOptimizer object
  146665. */
  146666. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146667. }
  146668. }
  146669. declare module BABYLON {
  146670. /**
  146671. * Class used to serialize a scene into a string
  146672. */
  146673. export class SceneSerializer {
  146674. /**
  146675. * Clear cache used by a previous serialization
  146676. */
  146677. static ClearCache(): void;
  146678. /**
  146679. * Serialize a scene into a JSON compatible object
  146680. * @param scene defines the scene to serialize
  146681. * @returns a JSON compatible object
  146682. */
  146683. static Serialize(scene: Scene): any;
  146684. /**
  146685. * Serialize a mesh into a JSON compatible object
  146686. * @param toSerialize defines the mesh to serialize
  146687. * @param withParents defines if parents must be serialized as well
  146688. * @param withChildren defines if children must be serialized as well
  146689. * @returns a JSON compatible object
  146690. */
  146691. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146692. }
  146693. }
  146694. declare module BABYLON {
  146695. /**
  146696. * Class used to host texture specific utilities
  146697. */
  146698. export class TextureTools {
  146699. /**
  146700. * Uses the GPU to create a copy texture rescaled at a given size
  146701. * @param texture Texture to copy from
  146702. * @param width defines the desired width
  146703. * @param height defines the desired height
  146704. * @param useBilinearMode defines if bilinear mode has to be used
  146705. * @return the generated texture
  146706. */
  146707. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146708. }
  146709. }
  146710. declare module BABYLON {
  146711. /**
  146712. * This represents the different options available for the video capture.
  146713. */
  146714. export interface VideoRecorderOptions {
  146715. /** Defines the mime type of the video. */
  146716. mimeType: string;
  146717. /** Defines the FPS the video should be recorded at. */
  146718. fps: number;
  146719. /** Defines the chunk size for the recording data. */
  146720. recordChunckSize: number;
  146721. /** The audio tracks to attach to the recording. */
  146722. audioTracks?: MediaStreamTrack[];
  146723. }
  146724. /**
  146725. * This can help with recording videos from BabylonJS.
  146726. * This is based on the available WebRTC functionalities of the browser.
  146727. *
  146728. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146729. */
  146730. export class VideoRecorder {
  146731. private static readonly _defaultOptions;
  146732. /**
  146733. * Returns whether or not the VideoRecorder is available in your browser.
  146734. * @param engine Defines the Babylon Engine.
  146735. * @returns true if supported otherwise false.
  146736. */
  146737. static IsSupported(engine: Engine): boolean;
  146738. private readonly _options;
  146739. private _canvas;
  146740. private _mediaRecorder;
  146741. private _recordedChunks;
  146742. private _fileName;
  146743. private _resolve;
  146744. private _reject;
  146745. /**
  146746. * True when a recording is already in progress.
  146747. */
  146748. get isRecording(): boolean;
  146749. /**
  146750. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146751. * @param engine Defines the BabylonJS Engine you wish to record.
  146752. * @param options Defines options that can be used to customize the capture.
  146753. */
  146754. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146755. /**
  146756. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146757. */
  146758. stopRecording(): void;
  146759. /**
  146760. * Starts recording the canvas for a max duration specified in parameters.
  146761. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146762. * If null no automatic download will start and you can rely on the promise to get the data back.
  146763. * @param maxDuration Defines the maximum recording time in seconds.
  146764. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146765. * @return A promise callback at the end of the recording with the video data in Blob.
  146766. */
  146767. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146768. /**
  146769. * Releases internal resources used during the recording.
  146770. */
  146771. dispose(): void;
  146772. private _handleDataAvailable;
  146773. private _handleError;
  146774. private _handleStop;
  146775. }
  146776. }
  146777. declare module BABYLON {
  146778. /**
  146779. * Class containing a set of static utilities functions for screenshots
  146780. */
  146781. export class ScreenshotTools {
  146782. /**
  146783. * Captures a screenshot of the current rendering
  146784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146785. * @param engine defines the rendering engine
  146786. * @param camera defines the source camera
  146787. * @param size This parameter can be set to a single number or to an object with the
  146788. * following (optional) properties: precision, width, height. If a single number is passed,
  146789. * it will be used for both width and height. If an object is passed, the screenshot size
  146790. * will be derived from the parameters. The precision property is a multiplier allowing
  146791. * rendering at a higher or lower resolution
  146792. * @param successCallback defines the callback receives a single parameter which contains the
  146793. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146794. * src parameter of an <img> to display it
  146795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146796. * Check your browser for supported MIME types
  146797. */
  146798. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146799. /**
  146800. * Captures a screenshot of the current rendering
  146801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146802. * @param engine defines the rendering engine
  146803. * @param camera defines the source camera
  146804. * @param size This parameter can be set to a single number or to an object with the
  146805. * following (optional) properties: precision, width, height. If a single number is passed,
  146806. * it will be used for both width and height. If an object is passed, the screenshot size
  146807. * will be derived from the parameters. The precision property is a multiplier allowing
  146808. * rendering at a higher or lower resolution
  146809. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146810. * Check your browser for supported MIME types
  146811. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146812. * to the src parameter of an <img> to display it
  146813. */
  146814. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146815. /**
  146816. * Generates an image screenshot from the specified camera.
  146817. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146818. * @param engine The engine to use for rendering
  146819. * @param camera The camera to use for rendering
  146820. * @param size This parameter can be set to a single number or to an object with the
  146821. * following (optional) properties: precision, width, height. If a single number is passed,
  146822. * it will be used for both width and height. If an object is passed, the screenshot size
  146823. * will be derived from the parameters. The precision property is a multiplier allowing
  146824. * rendering at a higher or lower resolution
  146825. * @param successCallback The callback receives a single parameter which contains the
  146826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146827. * src parameter of an <img> to display it
  146828. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146829. * Check your browser for supported MIME types
  146830. * @param samples Texture samples (default: 1)
  146831. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146832. * @param fileName A name for for the downloaded file.
  146833. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146834. */
  146835. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146836. /**
  146837. * Generates an image screenshot from the specified camera.
  146838. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146839. * @param engine The engine to use for rendering
  146840. * @param camera The camera to use for rendering
  146841. * @param size This parameter can be set to a single number or to an object with the
  146842. * following (optional) properties: precision, width, height. If a single number is passed,
  146843. * it will be used for both width and height. If an object is passed, the screenshot size
  146844. * will be derived from the parameters. The precision property is a multiplier allowing
  146845. * rendering at a higher or lower resolution
  146846. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146847. * Check your browser for supported MIME types
  146848. * @param samples Texture samples (default: 1)
  146849. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146850. * @param fileName A name for for the downloaded file.
  146851. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146852. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146853. * to the src parameter of an <img> to display it
  146854. */
  146855. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146856. /**
  146857. * Gets height and width for screenshot size
  146858. * @private
  146859. */
  146860. private static _getScreenshotSize;
  146861. }
  146862. }
  146863. declare module BABYLON {
  146864. /**
  146865. * Interface for a data buffer
  146866. */
  146867. export interface IDataBuffer {
  146868. /**
  146869. * Reads bytes from the data buffer.
  146870. * @param byteOffset The byte offset to read
  146871. * @param byteLength The byte length to read
  146872. * @returns A promise that resolves when the bytes are read
  146873. */
  146874. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  146875. /**
  146876. * The byte length of the buffer.
  146877. */
  146878. readonly byteLength: number;
  146879. }
  146880. /**
  146881. * Utility class for reading from a data buffer
  146882. */
  146883. export class DataReader {
  146884. /**
  146885. * The data buffer associated with this data reader.
  146886. */
  146887. readonly buffer: IDataBuffer;
  146888. /**
  146889. * The current byte offset from the beginning of the data buffer.
  146890. */
  146891. byteOffset: number;
  146892. private _dataView;
  146893. private _dataByteOffset;
  146894. /**
  146895. * Constructor
  146896. * @param buffer The buffer to read
  146897. */
  146898. constructor(buffer: IDataBuffer);
  146899. /**
  146900. * Loads the given byte length.
  146901. * @param byteLength The byte length to load
  146902. * @returns A promise that resolves when the load is complete
  146903. */
  146904. loadAsync(byteLength: number): Promise<void>;
  146905. /**
  146906. * Read a unsigned 32-bit integer from the currently loaded data range.
  146907. * @returns The 32-bit integer read
  146908. */
  146909. readUint32(): number;
  146910. /**
  146911. * Read a byte array from the currently loaded data range.
  146912. * @param byteLength The byte length to read
  146913. * @returns The byte array read
  146914. */
  146915. readUint8Array(byteLength: number): Uint8Array;
  146916. /**
  146917. * Read a string from the currently loaded data range.
  146918. * @param byteLength The byte length to read
  146919. * @returns The string read
  146920. */
  146921. readString(byteLength: number): string;
  146922. /**
  146923. * Skips the given byte length the currently loaded data range.
  146924. * @param byteLength The byte length to skip
  146925. */
  146926. skipBytes(byteLength: number): void;
  146927. }
  146928. }
  146929. declare module BABYLON {
  146930. /**
  146931. * Class for storing data to local storage if available or in-memory storage otherwise
  146932. */
  146933. export class DataStorage {
  146934. private static _Storage;
  146935. private static _GetStorage;
  146936. /**
  146937. * Reads a string from the data storage
  146938. * @param key The key to read
  146939. * @param defaultValue The value if the key doesn't exist
  146940. * @returns The string value
  146941. */
  146942. static ReadString(key: string, defaultValue: string): string;
  146943. /**
  146944. * Writes a string to the data storage
  146945. * @param key The key to write
  146946. * @param value The value to write
  146947. */
  146948. static WriteString(key: string, value: string): void;
  146949. /**
  146950. * Reads a boolean from the data storage
  146951. * @param key The key to read
  146952. * @param defaultValue The value if the key doesn't exist
  146953. * @returns The boolean value
  146954. */
  146955. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  146956. /**
  146957. * Writes a boolean to the data storage
  146958. * @param key The key to write
  146959. * @param value The value to write
  146960. */
  146961. static WriteBoolean(key: string, value: boolean): void;
  146962. /**
  146963. * Reads a number from the data storage
  146964. * @param key The key to read
  146965. * @param defaultValue The value if the key doesn't exist
  146966. * @returns The number value
  146967. */
  146968. static ReadNumber(key: string, defaultValue: number): number;
  146969. /**
  146970. * Writes a number to the data storage
  146971. * @param key The key to write
  146972. * @param value The value to write
  146973. */
  146974. static WriteNumber(key: string, value: number): void;
  146975. }
  146976. }
  146977. declare module BABYLON {
  146978. /**
  146979. * Options used for hit testing
  146980. */
  146981. export interface IWebXRLegacyHitTestOptions {
  146982. /**
  146983. * Only test when user interacted with the scene. Default - hit test every frame
  146984. */
  146985. testOnPointerDownOnly?: boolean;
  146986. /**
  146987. * The node to use to transform the local results to world coordinates
  146988. */
  146989. worldParentNode?: TransformNode;
  146990. }
  146991. /**
  146992. * Interface defining the babylon result of raycasting/hit-test
  146993. */
  146994. export interface IWebXRLegacyHitResult {
  146995. /**
  146996. * Transformation matrix that can be applied to a node that will put it in the hit point location
  146997. */
  146998. transformationMatrix: Matrix;
  146999. /**
  147000. * The native hit test result
  147001. */
  147002. xrHitResult: XRHitResult | XRHitTestResult;
  147003. }
  147004. /**
  147005. * The currently-working hit-test module.
  147006. * Hit test (or Ray-casting) is used to interact with the real world.
  147007. * For further information read here - https://github.com/immersive-web/hit-test
  147008. */
  147009. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  147010. /**
  147011. * options to use when constructing this feature
  147012. */
  147013. readonly options: IWebXRLegacyHitTestOptions;
  147014. private _direction;
  147015. private _mat;
  147016. private _onSelectEnabled;
  147017. private _origin;
  147018. /**
  147019. * The module's name
  147020. */
  147021. static readonly Name: string;
  147022. /**
  147023. * The (Babylon) version of this module.
  147024. * This is an integer representing the implementation version.
  147025. * This number does not correspond to the WebXR specs version
  147026. */
  147027. static readonly Version: number;
  147028. /**
  147029. * Populated with the last native XR Hit Results
  147030. */
  147031. lastNativeXRHitResults: XRHitResult[];
  147032. /**
  147033. * Triggered when new babylon (transformed) hit test results are available
  147034. */
  147035. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  147036. /**
  147037. * Creates a new instance of the (legacy version) hit test feature
  147038. * @param _xrSessionManager an instance of WebXRSessionManager
  147039. * @param options options to use when constructing this feature
  147040. */
  147041. constructor(_xrSessionManager: WebXRSessionManager,
  147042. /**
  147043. * options to use when constructing this feature
  147044. */
  147045. options?: IWebXRLegacyHitTestOptions);
  147046. /**
  147047. * execute a hit test with an XR Ray
  147048. *
  147049. * @param xrSession a native xrSession that will execute this hit test
  147050. * @param xrRay the ray (position and direction) to use for ray-casting
  147051. * @param referenceSpace native XR reference space to use for the hit-test
  147052. * @param filter filter function that will filter the results
  147053. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147054. */
  147055. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  147056. /**
  147057. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  147058. * @param event the (select) event to use to select with
  147059. * @param referenceSpace the reference space to use for this hit test
  147060. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  147061. */
  147062. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  147063. /**
  147064. * attach this feature
  147065. * Will usually be called by the features manager
  147066. *
  147067. * @returns true if successful.
  147068. */
  147069. attach(): boolean;
  147070. /**
  147071. * detach this feature.
  147072. * Will usually be called by the features manager
  147073. *
  147074. * @returns true if successful.
  147075. */
  147076. detach(): boolean;
  147077. /**
  147078. * Dispose this feature and all of the resources attached
  147079. */
  147080. dispose(): void;
  147081. protected _onXRFrame(frame: XRFrame): void;
  147082. private _onHitTestResults;
  147083. private _onSelect;
  147084. }
  147085. }
  147086. declare module BABYLON {
  147087. /**
  147088. * Options used in the plane detector module
  147089. */
  147090. export interface IWebXRPlaneDetectorOptions {
  147091. /**
  147092. * The node to use to transform the local results to world coordinates
  147093. */
  147094. worldParentNode?: TransformNode;
  147095. }
  147096. /**
  147097. * A babylon interface for a WebXR plane.
  147098. * A Plane is actually a polygon, built from N points in space
  147099. *
  147100. * Supported in chrome 79, not supported in canary 81 ATM
  147101. */
  147102. export interface IWebXRPlane {
  147103. /**
  147104. * a babylon-assigned ID for this polygon
  147105. */
  147106. id: number;
  147107. /**
  147108. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  147109. */
  147110. polygonDefinition: Array<Vector3>;
  147111. /**
  147112. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  147113. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  147114. */
  147115. transformationMatrix: Matrix;
  147116. /**
  147117. * the native xr-plane object
  147118. */
  147119. xrPlane: XRPlane;
  147120. }
  147121. /**
  147122. * The plane detector is used to detect planes in the real world when in AR
  147123. * For more information see https://github.com/immersive-web/real-world-geometry/
  147124. */
  147125. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  147126. private _options;
  147127. private _detectedPlanes;
  147128. private _enabled;
  147129. private _lastFrameDetected;
  147130. /**
  147131. * The module's name
  147132. */
  147133. static readonly Name: string;
  147134. /**
  147135. * The (Babylon) version of this module.
  147136. * This is an integer representing the implementation version.
  147137. * This number does not correspond to the WebXR specs version
  147138. */
  147139. static readonly Version: number;
  147140. /**
  147141. * Observers registered here will be executed when a new plane was added to the session
  147142. */
  147143. onPlaneAddedObservable: Observable<IWebXRPlane>;
  147144. /**
  147145. * Observers registered here will be executed when a plane is no longer detected in the session
  147146. */
  147147. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  147148. /**
  147149. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  147150. * This can execute N times every frame
  147151. */
  147152. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  147153. /**
  147154. * construct a new Plane Detector
  147155. * @param _xrSessionManager an instance of xr Session manager
  147156. * @param _options configuration to use when constructing this feature
  147157. */
  147158. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  147159. /**
  147160. * Dispose this feature and all of the resources attached
  147161. */
  147162. dispose(): void;
  147163. protected _onXRFrame(frame: XRFrame): void;
  147164. private _init;
  147165. private _updatePlaneWithXRPlane;
  147166. /**
  147167. * avoiding using Array.find for global support.
  147168. * @param xrPlane the plane to find in the array
  147169. */
  147170. private findIndexInPlaneArray;
  147171. }
  147172. }
  147173. declare module BABYLON {
  147174. /**
  147175. * Configuration options of the anchor system
  147176. */
  147177. export interface IWebXRAnchorSystemOptions {
  147178. /**
  147179. * Should a new anchor be added every time a select event is triggered
  147180. */
  147181. addAnchorOnSelect?: boolean;
  147182. /**
  147183. * should the anchor system use plane detection.
  147184. * If set to true, the plane-detection feature should be set using setPlaneDetector
  147185. */
  147186. usePlaneDetection?: boolean;
  147187. /**
  147188. * a node that will be used to convert local to world coordinates
  147189. */
  147190. worldParentNode?: TransformNode;
  147191. }
  147192. /**
  147193. * A babylon container for an XR Anchor
  147194. */
  147195. export interface IWebXRAnchor {
  147196. /**
  147197. * A babylon-assigned ID for this anchor
  147198. */
  147199. id: number;
  147200. /**
  147201. * Transformation matrix to apply to an object attached to this anchor
  147202. */
  147203. transformationMatrix: Matrix;
  147204. /**
  147205. * The native anchor object
  147206. */
  147207. xrAnchor: XRAnchor;
  147208. }
  147209. /**
  147210. * An implementation of the anchor system of WebXR.
  147211. * Note that the current documented implementation is not available in any browser. Future implementations
  147212. * will use the frame to create an anchor and not the session or a detected plane
  147213. * For further information see https://github.com/immersive-web/anchors/
  147214. */
  147215. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  147216. private _options;
  147217. private _enabled;
  147218. private _hitTestModule;
  147219. private _lastFrameDetected;
  147220. private _onSelect;
  147221. private _planeDetector;
  147222. private _trackedAnchors;
  147223. /**
  147224. * The module's name
  147225. */
  147226. static readonly Name: string;
  147227. /**
  147228. * The (Babylon) version of this module.
  147229. * This is an integer representing the implementation version.
  147230. * This number does not correspond to the WebXR specs version
  147231. */
  147232. static readonly Version: number;
  147233. /**
  147234. * Observers registered here will be executed when a new anchor was added to the session
  147235. */
  147236. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  147237. /**
  147238. * Observers registered here will be executed when an anchor was removed from the session
  147239. */
  147240. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  147241. /**
  147242. * Observers registered here will be executed when an existing anchor updates
  147243. * This can execute N times every frame
  147244. */
  147245. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  147246. /**
  147247. * constructs a new anchor system
  147248. * @param _xrSessionManager an instance of WebXRSessionManager
  147249. * @param _options configuration object for this feature
  147250. */
  147251. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  147252. /**
  147253. * Add anchor at a specific XR point.
  147254. *
  147255. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  147256. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  147257. * @returns a promise the fulfills when the anchor was created
  147258. */
  147259. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  147260. /**
  147261. * attach this feature
  147262. * Will usually be called by the features manager
  147263. *
  147264. * @returns true if successful.
  147265. */
  147266. attach(): boolean;
  147267. /**
  147268. * detach this feature.
  147269. * Will usually be called by the features manager
  147270. *
  147271. * @returns true if successful.
  147272. */
  147273. detach(): boolean;
  147274. /**
  147275. * Dispose this feature and all of the resources attached
  147276. */
  147277. dispose(): void;
  147278. /**
  147279. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  147280. * @param hitTestModule the hit-test module to use.
  147281. */
  147282. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  147283. /**
  147284. * set the plane detector to use in order to create anchors from frames
  147285. * @param planeDetector the plane-detector module to use
  147286. * @param enable enable plane-anchors. default is true
  147287. */
  147288. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  147289. protected _onXRFrame(frame: XRFrame): void;
  147290. /**
  147291. * avoiding using Array.find for global support.
  147292. * @param xrAnchor the plane to find in the array
  147293. */
  147294. private _findIndexInAnchorArray;
  147295. private _updateAnchorWithXRFrame;
  147296. }
  147297. }
  147298. declare module BABYLON {
  147299. /**
  147300. * Options interface for the background remover plugin
  147301. */
  147302. export interface IWebXRBackgroundRemoverOptions {
  147303. /**
  147304. * Further background meshes to disable when entering AR
  147305. */
  147306. backgroundMeshes?: AbstractMesh[];
  147307. /**
  147308. * flags to configure the removal of the environment helper.
  147309. * If not set, the entire background will be removed. If set, flags should be set as well.
  147310. */
  147311. environmentHelperRemovalFlags?: {
  147312. /**
  147313. * Should the skybox be removed (default false)
  147314. */
  147315. skyBox?: boolean;
  147316. /**
  147317. * Should the ground be removed (default false)
  147318. */
  147319. ground?: boolean;
  147320. };
  147321. /**
  147322. * don't disable the environment helper
  147323. */
  147324. ignoreEnvironmentHelper?: boolean;
  147325. }
  147326. /**
  147327. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  147328. */
  147329. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  147330. /**
  147331. * read-only options to be used in this module
  147332. */
  147333. readonly options: IWebXRBackgroundRemoverOptions;
  147334. /**
  147335. * The module's name
  147336. */
  147337. static readonly Name: string;
  147338. /**
  147339. * The (Babylon) version of this module.
  147340. * This is an integer representing the implementation version.
  147341. * This number does not correspond to the WebXR specs version
  147342. */
  147343. static readonly Version: number;
  147344. /**
  147345. * registered observers will be triggered when the background state changes
  147346. */
  147347. onBackgroundStateChangedObservable: Observable<boolean>;
  147348. /**
  147349. * constructs a new background remover module
  147350. * @param _xrSessionManager the session manager for this module
  147351. * @param options read-only options to be used in this module
  147352. */
  147353. constructor(_xrSessionManager: WebXRSessionManager,
  147354. /**
  147355. * read-only options to be used in this module
  147356. */
  147357. options?: IWebXRBackgroundRemoverOptions);
  147358. /**
  147359. * attach this feature
  147360. * Will usually be called by the features manager
  147361. *
  147362. * @returns true if successful.
  147363. */
  147364. attach(): boolean;
  147365. /**
  147366. * detach this feature.
  147367. * Will usually be called by the features manager
  147368. *
  147369. * @returns true if successful.
  147370. */
  147371. detach(): boolean;
  147372. /**
  147373. * Dispose this feature and all of the resources attached
  147374. */
  147375. dispose(): void;
  147376. protected _onXRFrame(_xrFrame: XRFrame): void;
  147377. private _setBackgroundState;
  147378. }
  147379. }
  147380. declare module BABYLON {
  147381. /**
  147382. * Options for the controller physics feature
  147383. */
  147384. export class IWebXRControllerPhysicsOptions {
  147385. /**
  147386. * Should the headset get its own impostor
  147387. */
  147388. enableHeadsetImpostor?: boolean;
  147389. /**
  147390. * Optional parameters for the headset impostor
  147391. */
  147392. headsetImpostorParams?: {
  147393. /**
  147394. * The type of impostor to create. Default is sphere
  147395. */
  147396. impostorType: number;
  147397. /**
  147398. * the size of the impostor. Defaults to 10cm
  147399. */
  147400. impostorSize?: number | {
  147401. width: number;
  147402. height: number;
  147403. depth: number;
  147404. };
  147405. /**
  147406. * Friction definitions
  147407. */
  147408. friction?: number;
  147409. /**
  147410. * Restitution
  147411. */
  147412. restitution?: number;
  147413. };
  147414. /**
  147415. * The physics properties of the future impostors
  147416. */
  147417. physicsProperties?: {
  147418. /**
  147419. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147420. * Note that this requires a physics engine that supports mesh impostors!
  147421. */
  147422. useControllerMesh?: boolean;
  147423. /**
  147424. * The type of impostor to create. Default is sphere
  147425. */
  147426. impostorType?: number;
  147427. /**
  147428. * the size of the impostor. Defaults to 10cm
  147429. */
  147430. impostorSize?: number | {
  147431. width: number;
  147432. height: number;
  147433. depth: number;
  147434. };
  147435. /**
  147436. * Friction definitions
  147437. */
  147438. friction?: number;
  147439. /**
  147440. * Restitution
  147441. */
  147442. restitution?: number;
  147443. };
  147444. /**
  147445. * the xr input to use with this pointer selection
  147446. */
  147447. xrInput: WebXRInput;
  147448. }
  147449. /**
  147450. * Add physics impostor to your webxr controllers,
  147451. * including naive calculation of their linear and angular velocity
  147452. */
  147453. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147454. private readonly _options;
  147455. private _attachController;
  147456. private _controllers;
  147457. private _debugMode;
  147458. private _delta;
  147459. private _headsetImpostor?;
  147460. private _headsetMesh?;
  147461. private _lastTimestamp;
  147462. private _tmpQuaternion;
  147463. private _tmpVector;
  147464. /**
  147465. * The module's name
  147466. */
  147467. static readonly Name: string;
  147468. /**
  147469. * The (Babylon) version of this module.
  147470. * This is an integer representing the implementation version.
  147471. * This number does not correspond to the webxr specs version
  147472. */
  147473. static readonly Version: number;
  147474. /**
  147475. * Construct a new Controller Physics Feature
  147476. * @param _xrSessionManager the corresponding xr session manager
  147477. * @param _options options to create this feature with
  147478. */
  147479. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147480. /**
  147481. * @hidden
  147482. * enable debugging - will show console outputs and the impostor mesh
  147483. */
  147484. _enablePhysicsDebug(): void;
  147485. /**
  147486. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147487. * @param xrController the controller to add
  147488. */
  147489. addController(xrController: WebXRInputSource): void;
  147490. /**
  147491. * attach this feature
  147492. * Will usually be called by the features manager
  147493. *
  147494. * @returns true if successful.
  147495. */
  147496. attach(): boolean;
  147497. /**
  147498. * detach this feature.
  147499. * Will usually be called by the features manager
  147500. *
  147501. * @returns true if successful.
  147502. */
  147503. detach(): boolean;
  147504. /**
  147505. * Get the headset impostor, if enabled
  147506. * @returns the impostor
  147507. */
  147508. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147509. /**
  147510. * Get the physics impostor of a specific controller.
  147511. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147512. * @param controller the controller or the controller id of which to get the impostor
  147513. * @returns the impostor or null
  147514. */
  147515. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147516. /**
  147517. * Update the physics properties provided in the constructor
  147518. * @param newProperties the new properties object
  147519. */
  147520. setPhysicsProperties(newProperties: {
  147521. impostorType?: number;
  147522. impostorSize?: number | {
  147523. width: number;
  147524. height: number;
  147525. depth: number;
  147526. };
  147527. friction?: number;
  147528. restitution?: number;
  147529. }): void;
  147530. protected _onXRFrame(_xrFrame: any): void;
  147531. private _detachController;
  147532. }
  147533. }
  147534. declare module BABYLON {
  147535. /**
  147536. * Options used for hit testing (version 2)
  147537. */
  147538. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147539. /**
  147540. * Do not create a permanent hit test. Will usually be used when only
  147541. * transient inputs are needed.
  147542. */
  147543. disablePermanentHitTest?: boolean;
  147544. /**
  147545. * Enable transient (for example touch-based) hit test inspections
  147546. */
  147547. enableTransientHitTest?: boolean;
  147548. /**
  147549. * Offset ray for the permanent hit test
  147550. */
  147551. offsetRay?: Vector3;
  147552. /**
  147553. * Offset ray for the transient hit test
  147554. */
  147555. transientOffsetRay?: Vector3;
  147556. /**
  147557. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147558. */
  147559. useReferenceSpace?: boolean;
  147560. }
  147561. /**
  147562. * Interface defining the babylon result of hit-test
  147563. */
  147564. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147565. /**
  147566. * The input source that generated this hit test (if transient)
  147567. */
  147568. inputSource?: XRInputSource;
  147569. /**
  147570. * Is this a transient hit test
  147571. */
  147572. isTransient?: boolean;
  147573. /**
  147574. * Position of the hit test result
  147575. */
  147576. position: Vector3;
  147577. /**
  147578. * Rotation of the hit test result
  147579. */
  147580. rotationQuaternion: Quaternion;
  147581. }
  147582. /**
  147583. * The currently-working hit-test module.
  147584. * Hit test (or Ray-casting) is used to interact with the real world.
  147585. * For further information read here - https://github.com/immersive-web/hit-test
  147586. *
  147587. * Tested on chrome (mobile) 80.
  147588. */
  147589. export class WebXRHitTest extends WebXRAbstractFeature {
  147590. /**
  147591. * options to use when constructing this feature
  147592. */
  147593. readonly options: IWebXRHitTestOptions;
  147594. private _tmpMat;
  147595. private _tmpPos;
  147596. private _tmpQuat;
  147597. private _transientXrHitTestSource;
  147598. private _xrHitTestSource;
  147599. private initHitTestSource;
  147600. /**
  147601. * The module's name
  147602. */
  147603. static readonly Name: string;
  147604. /**
  147605. * The (Babylon) version of this module.
  147606. * This is an integer representing the implementation version.
  147607. * This number does not correspond to the WebXR specs version
  147608. */
  147609. static readonly Version: number;
  147610. /**
  147611. * When set to true, each hit test will have its own position/rotation objects
  147612. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147613. * the developers will clone them or copy them as they see fit.
  147614. */
  147615. autoCloneTransformation: boolean;
  147616. /**
  147617. * Populated with the last native XR Hit Results
  147618. */
  147619. lastNativeXRHitResults: XRHitResult[];
  147620. /**
  147621. * Triggered when new babylon (transformed) hit test results are available
  147622. */
  147623. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147624. /**
  147625. * Use this to temporarily pause hit test checks.
  147626. */
  147627. paused: boolean;
  147628. /**
  147629. * Creates a new instance of the hit test feature
  147630. * @param _xrSessionManager an instance of WebXRSessionManager
  147631. * @param options options to use when constructing this feature
  147632. */
  147633. constructor(_xrSessionManager: WebXRSessionManager,
  147634. /**
  147635. * options to use when constructing this feature
  147636. */
  147637. options?: IWebXRHitTestOptions);
  147638. /**
  147639. * attach this feature
  147640. * Will usually be called by the features manager
  147641. *
  147642. * @returns true if successful.
  147643. */
  147644. attach(): boolean;
  147645. /**
  147646. * detach this feature.
  147647. * Will usually be called by the features manager
  147648. *
  147649. * @returns true if successful.
  147650. */
  147651. detach(): boolean;
  147652. /**
  147653. * Dispose this feature and all of the resources attached
  147654. */
  147655. dispose(): void;
  147656. protected _onXRFrame(frame: XRFrame): void;
  147657. private _processWebXRHitTestResult;
  147658. }
  147659. }
  147660. declare module BABYLON {
  147661. /**
  147662. * The motion controller class for all microsoft mixed reality controllers
  147663. */
  147664. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147665. protected readonly _mapping: {
  147666. defaultButton: {
  147667. valueNodeName: string;
  147668. unpressedNodeName: string;
  147669. pressedNodeName: string;
  147670. };
  147671. defaultAxis: {
  147672. valueNodeName: string;
  147673. minNodeName: string;
  147674. maxNodeName: string;
  147675. };
  147676. buttons: {
  147677. "xr-standard-trigger": {
  147678. rootNodeName: string;
  147679. componentProperty: string;
  147680. states: string[];
  147681. };
  147682. "xr-standard-squeeze": {
  147683. rootNodeName: string;
  147684. componentProperty: string;
  147685. states: string[];
  147686. };
  147687. "xr-standard-touchpad": {
  147688. rootNodeName: string;
  147689. labelAnchorNodeName: string;
  147690. touchPointNodeName: string;
  147691. };
  147692. "xr-standard-thumbstick": {
  147693. rootNodeName: string;
  147694. componentProperty: string;
  147695. states: string[];
  147696. };
  147697. };
  147698. axes: {
  147699. "xr-standard-touchpad": {
  147700. "x-axis": {
  147701. rootNodeName: string;
  147702. };
  147703. "y-axis": {
  147704. rootNodeName: string;
  147705. };
  147706. };
  147707. "xr-standard-thumbstick": {
  147708. "x-axis": {
  147709. rootNodeName: string;
  147710. };
  147711. "y-axis": {
  147712. rootNodeName: string;
  147713. };
  147714. };
  147715. };
  147716. };
  147717. /**
  147718. * The base url used to load the left and right controller models
  147719. */
  147720. static MODEL_BASE_URL: string;
  147721. /**
  147722. * The name of the left controller model file
  147723. */
  147724. static MODEL_LEFT_FILENAME: string;
  147725. /**
  147726. * The name of the right controller model file
  147727. */
  147728. static MODEL_RIGHT_FILENAME: string;
  147729. profileId: string;
  147730. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147731. protected _getFilenameAndPath(): {
  147732. filename: string;
  147733. path: string;
  147734. };
  147735. protected _getModelLoadingConstraints(): boolean;
  147736. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147737. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147738. protected _updateModel(): void;
  147739. }
  147740. }
  147741. declare module BABYLON {
  147742. /**
  147743. * The motion controller class for oculus touch (quest, rift).
  147744. * This class supports legacy mapping as well the standard xr mapping
  147745. */
  147746. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147747. private _forceLegacyControllers;
  147748. private _modelRootNode;
  147749. /**
  147750. * The base url used to load the left and right controller models
  147751. */
  147752. static MODEL_BASE_URL: string;
  147753. /**
  147754. * The name of the left controller model file
  147755. */
  147756. static MODEL_LEFT_FILENAME: string;
  147757. /**
  147758. * The name of the right controller model file
  147759. */
  147760. static MODEL_RIGHT_FILENAME: string;
  147761. /**
  147762. * Base Url for the Quest controller model.
  147763. */
  147764. static QUEST_MODEL_BASE_URL: string;
  147765. profileId: string;
  147766. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147767. protected _getFilenameAndPath(): {
  147768. filename: string;
  147769. path: string;
  147770. };
  147771. protected _getModelLoadingConstraints(): boolean;
  147772. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147773. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147774. protected _updateModel(): void;
  147775. /**
  147776. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147777. * between the touch and touch 2.
  147778. */
  147779. private _isQuest;
  147780. }
  147781. }
  147782. declare module BABYLON {
  147783. /**
  147784. * The motion controller class for the standard HTC-Vive controllers
  147785. */
  147786. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147787. private _modelRootNode;
  147788. /**
  147789. * The base url used to load the left and right controller models
  147790. */
  147791. static MODEL_BASE_URL: string;
  147792. /**
  147793. * File name for the controller model.
  147794. */
  147795. static MODEL_FILENAME: string;
  147796. profileId: string;
  147797. /**
  147798. * Create a new Vive motion controller object
  147799. * @param scene the scene to use to create this controller
  147800. * @param gamepadObject the corresponding gamepad object
  147801. * @param handedness the handedness of the controller
  147802. */
  147803. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147804. protected _getFilenameAndPath(): {
  147805. filename: string;
  147806. path: string;
  147807. };
  147808. protected _getModelLoadingConstraints(): boolean;
  147809. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147810. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147811. protected _updateModel(): void;
  147812. }
  147813. }
  147814. declare module BABYLON {
  147815. /**
  147816. * A cursor which tracks a point on a path
  147817. */
  147818. export class PathCursor {
  147819. private path;
  147820. /**
  147821. * Stores path cursor callbacks for when an onchange event is triggered
  147822. */
  147823. private _onchange;
  147824. /**
  147825. * The value of the path cursor
  147826. */
  147827. value: number;
  147828. /**
  147829. * The animation array of the path cursor
  147830. */
  147831. animations: Animation[];
  147832. /**
  147833. * Initializes the path cursor
  147834. * @param path The path to track
  147835. */
  147836. constructor(path: Path2);
  147837. /**
  147838. * Gets the cursor point on the path
  147839. * @returns A point on the path cursor at the cursor location
  147840. */
  147841. getPoint(): Vector3;
  147842. /**
  147843. * Moves the cursor ahead by the step amount
  147844. * @param step The amount to move the cursor forward
  147845. * @returns This path cursor
  147846. */
  147847. moveAhead(step?: number): PathCursor;
  147848. /**
  147849. * Moves the cursor behind by the step amount
  147850. * @param step The amount to move the cursor back
  147851. * @returns This path cursor
  147852. */
  147853. moveBack(step?: number): PathCursor;
  147854. /**
  147855. * Moves the cursor by the step amount
  147856. * If the step amount is greater than one, an exception is thrown
  147857. * @param step The amount to move the cursor
  147858. * @returns This path cursor
  147859. */
  147860. move(step: number): PathCursor;
  147861. /**
  147862. * Ensures that the value is limited between zero and one
  147863. * @returns This path cursor
  147864. */
  147865. private ensureLimits;
  147866. /**
  147867. * Runs onchange callbacks on change (used by the animation engine)
  147868. * @returns This path cursor
  147869. */
  147870. private raiseOnChange;
  147871. /**
  147872. * Executes a function on change
  147873. * @param f A path cursor onchange callback
  147874. * @returns This path cursor
  147875. */
  147876. onchange(f: (cursor: PathCursor) => void): PathCursor;
  147877. }
  147878. }
  147879. declare module BABYLON {
  147880. /** @hidden */
  147881. export var blurPixelShader: {
  147882. name: string;
  147883. shader: string;
  147884. };
  147885. }
  147886. declare module BABYLON {
  147887. /** @hidden */
  147888. export var pointCloudVertexDeclaration: {
  147889. name: string;
  147890. shader: string;
  147891. };
  147892. }
  147893. // Mixins
  147894. interface Window {
  147895. mozIndexedDB: IDBFactory;
  147896. webkitIndexedDB: IDBFactory;
  147897. msIndexedDB: IDBFactory;
  147898. webkitURL: typeof URL;
  147899. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  147900. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  147901. WebGLRenderingContext: WebGLRenderingContext;
  147902. MSGesture: MSGesture;
  147903. CANNON: any;
  147904. AudioContext: AudioContext;
  147905. webkitAudioContext: AudioContext;
  147906. PointerEvent: any;
  147907. Math: Math;
  147908. Uint8Array: Uint8ArrayConstructor;
  147909. Float32Array: Float32ArrayConstructor;
  147910. mozURL: typeof URL;
  147911. msURL: typeof URL;
  147912. VRFrameData: any; // WebVR, from specs 1.1
  147913. DracoDecoderModule: any;
  147914. setImmediate(handler: (...args: any[]) => void): number;
  147915. }
  147916. interface HTMLCanvasElement {
  147917. requestPointerLock(): void;
  147918. msRequestPointerLock?(): void;
  147919. mozRequestPointerLock?(): void;
  147920. webkitRequestPointerLock?(): void;
  147921. /** Track wether a record is in progress */
  147922. isRecording: boolean;
  147923. /** Capture Stream method defined by some browsers */
  147924. captureStream(fps?: number): MediaStream;
  147925. }
  147926. interface CanvasRenderingContext2D {
  147927. msImageSmoothingEnabled: boolean;
  147928. }
  147929. interface MouseEvent {
  147930. mozMovementX: number;
  147931. mozMovementY: number;
  147932. webkitMovementX: number;
  147933. webkitMovementY: number;
  147934. msMovementX: number;
  147935. msMovementY: number;
  147936. }
  147937. interface Navigator {
  147938. mozGetVRDevices: (any: any) => any;
  147939. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147940. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147941. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147942. webkitGetGamepads(): Gamepad[];
  147943. msGetGamepads(): Gamepad[];
  147944. webkitGamepads(): Gamepad[];
  147945. }
  147946. interface HTMLVideoElement {
  147947. mozSrcObject: any;
  147948. }
  147949. interface Math {
  147950. fround(x: number): number;
  147951. imul(a: number, b: number): number;
  147952. }
  147953. interface WebGLRenderingContext {
  147954. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  147955. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  147956. vertexAttribDivisor(index: number, divisor: number): void;
  147957. createVertexArray(): any;
  147958. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  147959. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  147960. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  147961. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  147962. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  147963. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  147964. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  147965. // Queries
  147966. createQuery(): WebGLQuery;
  147967. deleteQuery(query: WebGLQuery): void;
  147968. beginQuery(target: number, query: WebGLQuery): void;
  147969. endQuery(target: number): void;
  147970. getQueryParameter(query: WebGLQuery, pname: number): any;
  147971. getQuery(target: number, pname: number): any;
  147972. MAX_SAMPLES: number;
  147973. RGBA8: number;
  147974. READ_FRAMEBUFFER: number;
  147975. DRAW_FRAMEBUFFER: number;
  147976. UNIFORM_BUFFER: number;
  147977. HALF_FLOAT_OES: number;
  147978. RGBA16F: number;
  147979. RGBA32F: number;
  147980. R32F: number;
  147981. RG32F: number;
  147982. RGB32F: number;
  147983. R16F: number;
  147984. RG16F: number;
  147985. RGB16F: number;
  147986. RED: number;
  147987. RG: number;
  147988. R8: number;
  147989. RG8: number;
  147990. UNSIGNED_INT_24_8: number;
  147991. DEPTH24_STENCIL8: number;
  147992. MIN: number;
  147993. MAX: number;
  147994. /* Multiple Render Targets */
  147995. drawBuffers(buffers: number[]): void;
  147996. readBuffer(src: number): void;
  147997. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  147998. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  147999. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  148000. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  148001. // Occlusion Query
  148002. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  148003. ANY_SAMPLES_PASSED: number;
  148004. QUERY_RESULT_AVAILABLE: number;
  148005. QUERY_RESULT: number;
  148006. }
  148007. interface WebGLProgram {
  148008. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  148009. }
  148010. interface EXT_disjoint_timer_query {
  148011. QUERY_COUNTER_BITS_EXT: number;
  148012. TIME_ELAPSED_EXT: number;
  148013. TIMESTAMP_EXT: number;
  148014. GPU_DISJOINT_EXT: number;
  148015. QUERY_RESULT_EXT: number;
  148016. QUERY_RESULT_AVAILABLE_EXT: number;
  148017. queryCounterEXT(query: WebGLQuery, target: number): void;
  148018. createQueryEXT(): WebGLQuery;
  148019. beginQueryEXT(target: number, query: WebGLQuery): void;
  148020. endQueryEXT(target: number): void;
  148021. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  148022. deleteQueryEXT(query: WebGLQuery): void;
  148023. }
  148024. interface WebGLUniformLocation {
  148025. _currentState: any;
  148026. }
  148027. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  148028. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  148029. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  148030. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148031. interface WebGLRenderingContext {
  148032. readonly RASTERIZER_DISCARD: number;
  148033. readonly DEPTH_COMPONENT24: number;
  148034. readonly TEXTURE_3D: number;
  148035. readonly TEXTURE_2D_ARRAY: number;
  148036. readonly TEXTURE_COMPARE_FUNC: number;
  148037. readonly TEXTURE_COMPARE_MODE: number;
  148038. readonly COMPARE_REF_TO_TEXTURE: number;
  148039. readonly TEXTURE_WRAP_R: number;
  148040. readonly HALF_FLOAT: number;
  148041. readonly RGB8: number;
  148042. readonly RED_INTEGER: number;
  148043. readonly RG_INTEGER: number;
  148044. readonly RGB_INTEGER: number;
  148045. readonly RGBA_INTEGER: number;
  148046. readonly R8_SNORM: number;
  148047. readonly RG8_SNORM: number;
  148048. readonly RGB8_SNORM: number;
  148049. readonly RGBA8_SNORM: number;
  148050. readonly R8I: number;
  148051. readonly RG8I: number;
  148052. readonly RGB8I: number;
  148053. readonly RGBA8I: number;
  148054. readonly R8UI: number;
  148055. readonly RG8UI: number;
  148056. readonly RGB8UI: number;
  148057. readonly RGBA8UI: number;
  148058. readonly R16I: number;
  148059. readonly RG16I: number;
  148060. readonly RGB16I: number;
  148061. readonly RGBA16I: number;
  148062. readonly R16UI: number;
  148063. readonly RG16UI: number;
  148064. readonly RGB16UI: number;
  148065. readonly RGBA16UI: number;
  148066. readonly R32I: number;
  148067. readonly RG32I: number;
  148068. readonly RGB32I: number;
  148069. readonly RGBA32I: number;
  148070. readonly R32UI: number;
  148071. readonly RG32UI: number;
  148072. readonly RGB32UI: number;
  148073. readonly RGBA32UI: number;
  148074. readonly RGB10_A2UI: number;
  148075. readonly R11F_G11F_B10F: number;
  148076. readonly RGB9_E5: number;
  148077. readonly RGB10_A2: number;
  148078. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  148079. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  148080. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  148081. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  148082. readonly DEPTH_COMPONENT32F: number;
  148083. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  148084. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  148085. 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;
  148086. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  148087. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  148088. readonly TRANSFORM_FEEDBACK: number;
  148089. readonly INTERLEAVED_ATTRIBS: number;
  148090. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  148091. createTransformFeedback(): WebGLTransformFeedback;
  148092. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  148093. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  148094. beginTransformFeedback(primitiveMode: number): void;
  148095. endTransformFeedback(): void;
  148096. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  148097. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148098. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148099. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  148100. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  148101. }
  148102. interface ImageBitmap {
  148103. readonly width: number;
  148104. readonly height: number;
  148105. close(): void;
  148106. }
  148107. interface WebGLQuery extends WebGLObject {
  148108. }
  148109. declare var WebGLQuery: {
  148110. prototype: WebGLQuery;
  148111. new(): WebGLQuery;
  148112. };
  148113. interface WebGLSampler extends WebGLObject {
  148114. }
  148115. declare var WebGLSampler: {
  148116. prototype: WebGLSampler;
  148117. new(): WebGLSampler;
  148118. };
  148119. interface WebGLSync extends WebGLObject {
  148120. }
  148121. declare var WebGLSync: {
  148122. prototype: WebGLSync;
  148123. new(): WebGLSync;
  148124. };
  148125. interface WebGLTransformFeedback extends WebGLObject {
  148126. }
  148127. declare var WebGLTransformFeedback: {
  148128. prototype: WebGLTransformFeedback;
  148129. new(): WebGLTransformFeedback;
  148130. };
  148131. interface WebGLVertexArrayObject extends WebGLObject {
  148132. }
  148133. declare var WebGLVertexArrayObject: {
  148134. prototype: WebGLVertexArrayObject;
  148135. new(): WebGLVertexArrayObject;
  148136. };
  148137. // Type definitions for WebVR API
  148138. // Project: https://w3c.github.io/webvr/
  148139. // Definitions by: six a <https://github.com/lostfictions>
  148140. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  148141. interface VRDisplay extends EventTarget {
  148142. /**
  148143. * Dictionary of capabilities describing the VRDisplay.
  148144. */
  148145. readonly capabilities: VRDisplayCapabilities;
  148146. /**
  148147. * z-depth defining the far plane of the eye view frustum
  148148. * enables mapping of values in the render target depth
  148149. * attachment to scene coordinates. Initially set to 10000.0.
  148150. */
  148151. depthFar: number;
  148152. /**
  148153. * z-depth defining the near plane of the eye view frustum
  148154. * enables mapping of values in the render target depth
  148155. * attachment to scene coordinates. Initially set to 0.01.
  148156. */
  148157. depthNear: number;
  148158. /**
  148159. * An identifier for this distinct VRDisplay. Used as an
  148160. * association point in the Gamepad API.
  148161. */
  148162. readonly displayId: number;
  148163. /**
  148164. * A display name, a user-readable name identifying it.
  148165. */
  148166. readonly displayName: string;
  148167. readonly isConnected: boolean;
  148168. readonly isPresenting: boolean;
  148169. /**
  148170. * If this VRDisplay supports room-scale experiences, the optional
  148171. * stage attribute contains details on the room-scale parameters.
  148172. */
  148173. readonly stageParameters: VRStageParameters | null;
  148174. /**
  148175. * Passing the value returned by `requestAnimationFrame` to
  148176. * `cancelAnimationFrame` will unregister the callback.
  148177. * @param handle Define the hanle of the request to cancel
  148178. */
  148179. cancelAnimationFrame(handle: number): void;
  148180. /**
  148181. * Stops presenting to the VRDisplay.
  148182. * @returns a promise to know when it stopped
  148183. */
  148184. exitPresent(): Promise<void>;
  148185. /**
  148186. * Return the current VREyeParameters for the given eye.
  148187. * @param whichEye Define the eye we want the parameter for
  148188. * @returns the eye parameters
  148189. */
  148190. getEyeParameters(whichEye: string): VREyeParameters;
  148191. /**
  148192. * Populates the passed VRFrameData with the information required to render
  148193. * the current frame.
  148194. * @param frameData Define the data structure to populate
  148195. * @returns true if ok otherwise false
  148196. */
  148197. getFrameData(frameData: VRFrameData): boolean;
  148198. /**
  148199. * Get the layers currently being presented.
  148200. * @returns the list of VR layers
  148201. */
  148202. getLayers(): VRLayer[];
  148203. /**
  148204. * Return a VRPose containing the future predicted pose of the VRDisplay
  148205. * when the current frame will be presented. The value returned will not
  148206. * change until JavaScript has returned control to the browser.
  148207. *
  148208. * The VRPose will contain the position, orientation, velocity,
  148209. * and acceleration of each of these properties.
  148210. * @returns the pose object
  148211. */
  148212. getPose(): VRPose;
  148213. /**
  148214. * Return the current instantaneous pose of the VRDisplay, with no
  148215. * prediction applied.
  148216. * @returns the current instantaneous pose
  148217. */
  148218. getImmediatePose(): VRPose;
  148219. /**
  148220. * The callback passed to `requestAnimationFrame` will be called
  148221. * any time a new frame should be rendered. When the VRDisplay is
  148222. * presenting the callback will be called at the native refresh
  148223. * rate of the HMD. When not presenting this function acts
  148224. * identically to how window.requestAnimationFrame acts. Content should
  148225. * make no assumptions of frame rate or vsync behavior as the HMD runs
  148226. * asynchronously from other displays and at differing refresh rates.
  148227. * @param callback Define the eaction to run next frame
  148228. * @returns the request handle it
  148229. */
  148230. requestAnimationFrame(callback: FrameRequestCallback): number;
  148231. /**
  148232. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  148233. * Repeat calls while already presenting will update the VRLayers being displayed.
  148234. * @param layers Define the list of layer to present
  148235. * @returns a promise to know when the request has been fulfilled
  148236. */
  148237. requestPresent(layers: VRLayer[]): Promise<void>;
  148238. /**
  148239. * Reset the pose for this display, treating its current position and
  148240. * orientation as the "origin/zero" values. VRPose.position,
  148241. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  148242. * updated when calling resetPose(). This should be called in only
  148243. * sitting-space experiences.
  148244. */
  148245. resetPose(): void;
  148246. /**
  148247. * The VRLayer provided to the VRDisplay will be captured and presented
  148248. * in the HMD. Calling this function has the same effect on the source
  148249. * canvas as any other operation that uses its source image, and canvases
  148250. * created without preserveDrawingBuffer set to true will be cleared.
  148251. * @param pose Define the pose to submit
  148252. */
  148253. submitFrame(pose?: VRPose): void;
  148254. }
  148255. declare var VRDisplay: {
  148256. prototype: VRDisplay;
  148257. new(): VRDisplay;
  148258. };
  148259. interface VRLayer {
  148260. leftBounds?: number[] | Float32Array | null;
  148261. rightBounds?: number[] | Float32Array | null;
  148262. source?: HTMLCanvasElement | null;
  148263. }
  148264. interface VRDisplayCapabilities {
  148265. readonly canPresent: boolean;
  148266. readonly hasExternalDisplay: boolean;
  148267. readonly hasOrientation: boolean;
  148268. readonly hasPosition: boolean;
  148269. readonly maxLayers: number;
  148270. }
  148271. interface VREyeParameters {
  148272. /** @deprecated */
  148273. readonly fieldOfView: VRFieldOfView;
  148274. readonly offset: Float32Array;
  148275. readonly renderHeight: number;
  148276. readonly renderWidth: number;
  148277. }
  148278. interface VRFieldOfView {
  148279. readonly downDegrees: number;
  148280. readonly leftDegrees: number;
  148281. readonly rightDegrees: number;
  148282. readonly upDegrees: number;
  148283. }
  148284. interface VRFrameData {
  148285. readonly leftProjectionMatrix: Float32Array;
  148286. readonly leftViewMatrix: Float32Array;
  148287. readonly pose: VRPose;
  148288. readonly rightProjectionMatrix: Float32Array;
  148289. readonly rightViewMatrix: Float32Array;
  148290. readonly timestamp: number;
  148291. }
  148292. interface VRPose {
  148293. readonly angularAcceleration: Float32Array | null;
  148294. readonly angularVelocity: Float32Array | null;
  148295. readonly linearAcceleration: Float32Array | null;
  148296. readonly linearVelocity: Float32Array | null;
  148297. readonly orientation: Float32Array | null;
  148298. readonly position: Float32Array | null;
  148299. readonly timestamp: number;
  148300. }
  148301. interface VRStageParameters {
  148302. sittingToStandingTransform?: Float32Array;
  148303. sizeX?: number;
  148304. sizeY?: number;
  148305. }
  148306. interface Navigator {
  148307. getVRDisplays(): Promise<VRDisplay[]>;
  148308. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  148309. }
  148310. interface Window {
  148311. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  148312. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  148313. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  148314. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148315. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  148316. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  148317. }
  148318. interface Gamepad {
  148319. readonly displayId: number;
  148320. }
  148321. type XRSessionMode =
  148322. | "inline"
  148323. | "immersive-vr"
  148324. | "immersive-ar";
  148325. type XRReferenceSpaceType =
  148326. | "viewer"
  148327. | "local"
  148328. | "local-floor"
  148329. | "bounded-floor"
  148330. | "unbounded";
  148331. type XREnvironmentBlendMode =
  148332. | "opaque"
  148333. | "additive"
  148334. | "alpha-blend";
  148335. type XRVisibilityState =
  148336. | "visible"
  148337. | "visible-blurred"
  148338. | "hidden";
  148339. type XRHandedness =
  148340. | "none"
  148341. | "left"
  148342. | "right";
  148343. type XRTargetRayMode =
  148344. | "gaze"
  148345. | "tracked-pointer"
  148346. | "screen";
  148347. type XREye =
  148348. | "none"
  148349. | "left"
  148350. | "right";
  148351. type XREventType =
  148352. | "devicechange"
  148353. | "visibilitychange"
  148354. | "end"
  148355. | "inputsourceschange"
  148356. | "select"
  148357. | "selectstart"
  148358. | "selectend"
  148359. | "squeeze"
  148360. | "squeezestart"
  148361. | "squeezeend"
  148362. | "reset";
  148363. interface XRSpace extends EventTarget {
  148364. }
  148365. interface XRRenderState {
  148366. depthNear?: number;
  148367. depthFar?: number;
  148368. inlineVerticalFieldOfView?: number;
  148369. baseLayer?: XRWebGLLayer;
  148370. }
  148371. interface XRInputSource {
  148372. handedness: XRHandedness;
  148373. targetRayMode: XRTargetRayMode;
  148374. targetRaySpace: XRSpace;
  148375. gripSpace: XRSpace | undefined;
  148376. gamepad: Gamepad | undefined;
  148377. profiles: Array<string>;
  148378. }
  148379. interface XRSessionInit {
  148380. optionalFeatures?: string[];
  148381. requiredFeatures?: string[];
  148382. }
  148383. interface XRSession extends XRAnchorCreator {
  148384. addEventListener: Function;
  148385. removeEventListener: Function;
  148386. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148387. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148388. requestAnimationFrame: Function;
  148389. end(): Promise<void>;
  148390. renderState: XRRenderState;
  148391. inputSources: Array<XRInputSource>;
  148392. // hit test
  148393. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148394. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148395. // legacy AR hit test
  148396. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148397. // legacy plane detection
  148398. updateWorldTrackingState(options: {
  148399. planeDetectionState?: { enabled: boolean; }
  148400. }): void;
  148401. }
  148402. interface XRReferenceSpace extends XRSpace {
  148403. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148404. onreset: any;
  148405. }
  148406. type XRPlaneSet = Set<XRPlane>;
  148407. type XRAnchorSet = Set<XRAnchor>;
  148408. interface XRFrame {
  148409. session: XRSession;
  148410. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148411. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148412. // AR
  148413. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148414. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148415. // Anchors
  148416. trackedAnchors?: XRAnchorSet;
  148417. // Planes
  148418. worldInformation: {
  148419. detectedPlanes?: XRPlaneSet;
  148420. };
  148421. }
  148422. interface XRViewerPose extends XRPose {
  148423. views: Array<XRView>;
  148424. }
  148425. interface XRPose {
  148426. transform: XRRigidTransform;
  148427. emulatedPosition: boolean;
  148428. }
  148429. interface XRWebGLLayerOptions {
  148430. antialias?: boolean;
  148431. depth?: boolean;
  148432. stencil?: boolean;
  148433. alpha?: boolean;
  148434. multiview?: boolean;
  148435. framebufferScaleFactor?: number;
  148436. }
  148437. declare var XRWebGLLayer: {
  148438. prototype: XRWebGLLayer;
  148439. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148440. };
  148441. interface XRWebGLLayer {
  148442. framebuffer: WebGLFramebuffer;
  148443. framebufferWidth: number;
  148444. framebufferHeight: number;
  148445. getViewport: Function;
  148446. }
  148447. declare class XRRigidTransform {
  148448. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148449. position: DOMPointReadOnly;
  148450. orientation: DOMPointReadOnly;
  148451. matrix: Float32Array;
  148452. inverse: XRRigidTransform;
  148453. }
  148454. interface XRView {
  148455. eye: XREye;
  148456. projectionMatrix: Float32Array;
  148457. transform: XRRigidTransform;
  148458. }
  148459. interface XRInputSourceChangeEvent {
  148460. session: XRSession;
  148461. removed: Array<XRInputSource>;
  148462. added: Array<XRInputSource>;
  148463. }
  148464. interface XRInputSourceEvent extends Event {
  148465. readonly frame: XRFrame;
  148466. readonly inputSource: XRInputSource;
  148467. }
  148468. // Experimental(er) features
  148469. declare class XRRay {
  148470. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148471. origin: DOMPointReadOnly;
  148472. direction: DOMPointReadOnly;
  148473. matrix: Float32Array;
  148474. }
  148475. declare enum XRHitTestTrackableType {
  148476. "point",
  148477. "plane"
  148478. }
  148479. interface XRHitResult {
  148480. hitMatrix: Float32Array;
  148481. }
  148482. interface XRTransientInputHitTestResult {
  148483. readonly inputSource: XRInputSource;
  148484. readonly results: Array<XRHitTestResult>;
  148485. }
  148486. interface XRHitTestResult {
  148487. getPose(baseSpace: XRSpace): XRPose | undefined;
  148488. }
  148489. interface XRHitTestSource {
  148490. cancel(): void;
  148491. }
  148492. interface XRTransientInputHitTestSource {
  148493. cancel(): void;
  148494. }
  148495. interface XRHitTestOptionsInit {
  148496. space: XRSpace;
  148497. entityTypes?: Array<XRHitTestTrackableType>;
  148498. offsetRay?: XRRay;
  148499. }
  148500. interface XRTransientInputHitTestOptionsInit {
  148501. profile: string;
  148502. entityTypes?: Array<XRHitTestTrackableType>;
  148503. offsetRay?: XRRay;
  148504. }
  148505. interface XRAnchor {
  148506. // remove?
  148507. id?: string;
  148508. anchorSpace: XRSpace;
  148509. lastChangedTime: number;
  148510. detach(): void;
  148511. }
  148512. interface XRPlane extends XRAnchorCreator {
  148513. orientation: "Horizontal" | "Vertical";
  148514. planeSpace: XRSpace;
  148515. polygon: Array<DOMPointReadOnly>;
  148516. lastChangedTime: number;
  148517. }
  148518. interface XRAnchorCreator {
  148519. // AR Anchors
  148520. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148521. }